app/widgets/gimpwidgets-utils.h New utility function to build status bar

2006-08-02  Raphael Quinet  <raphael@gimp.org>

	* app/widgets/gimpwidgets-utils.h
	* app/widgets/gimpwidgets-utils.c (gimp_suggest_modifiers):
	New utility function to build status bar messages while allowing
	dynamic names for the modifiers.

	* app/tools/gimppainttool.h
	* app/tools/gimppainttool.c: Added new members to the class in
	order to allow paint tools to set different status messages for
	the normal case or when drawing a line.

	* app/tools/gimpclonetool.c
	* app/tools/gimpconvolvetool.c
	* app/tools/gimpdodgeburntool.c
	* app/tools/gimperasertool.c
	* app/tools/gimpsmudgetool.c: Use the new functions to set
	appropriate messages in the status bar.  Still work in progress,
	partial fix for bug #124040.

	* app/tools/gimpvectortool.c: Use gimp_suggest_modifiers().
This commit is contained in:
Raphael Quinet 2006-08-01 23:42:12 +00:00 committed by Raphaël Quinet
parent 90c342cc67
commit a54a6b162c
14 changed files with 473 additions and 78 deletions

View File

@ -1,3 +1,25 @@
2006-08-02 Raphaël Quinet <raphael@gimp.org>
* app/widgets/gimpwidgets-utils.h
* app/widgets/gimpwidgets-utils.c (gimp_suggest_modifiers):
New utility function to build status bar messages while allowing
dynamic names for the modifiers.
* app/tools/gimppainttool.h
* app/tools/gimppainttool.c: Added new members to the class in
order to allow paint tools to set different status messages for
the normal case or when drawing a line.
* app/tools/gimpclonetool.c
* app/tools/gimpconvolvetool.c
* app/tools/gimpdodgeburntool.c
* app/tools/gimperasertool.c
* app/tools/gimpsmudgetool.c: Use the new functions to set
appropriate messages in the status bar. Still work in progress,
partial fix for bug #124040.
* app/tools/gimpvectortool.c: Use gimp_suggest_modifiers().
2006-07-31 Karine Delvare <edhel@gimp.org>
* app/tools/gimprectangletool.c: Applied patch from Karl Günter

View File

@ -44,6 +44,7 @@
#include "paint/gimppaintoptions.h"
#include "widgets/gimpdevices.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
@ -162,6 +163,10 @@ gimp_paint_tool_init (GimpPaintTool *paint_tool)
paint_tool->pick_colors = FALSE;
paint_tool->draw_line = FALSE;
paint_tool->status = _("Click to paint.");
paint_tool->status_line = _("Click to draw the line.");
paint_tool->status_ctrl = _("%s to pick a color");
paint_tool->show_cursor = TRUE;
paint_tool->draw_brush = TRUE;
paint_tool->brush_x = 0.0;
@ -542,9 +547,23 @@ gimp_paint_tool_modifier_key (GimpTool *tool,
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
GIMP_COLOR_OPTIONS (info->tool_options));
gimp_tool_push_status (tool, display,
_("Click in any image to pick the "
"foreground color."));
switch (GIMP_COLOR_TOOL (tool)->pick_mode)
{
case GIMP_COLOR_PICK_MODE_FOREGROUND:
gimp_tool_push_status (tool, display,
_("Click in any image to pick the "
"foreground color."));
break;
case GIMP_COLOR_PICK_MODE_BACKGROUND:
gimp_tool_push_status (tool, display,
_("Click in any image to pick the "
"background color."));
break;
default:
break;
}
}
}
else
@ -615,7 +634,7 @@ gimp_paint_tool_oper_update (GimpTool *tool,
gdouble dx, dy, dist;
gchar status_str[STATUSBAR_SIZE];
const gchar *status_help;
gchar *status_help;
gint off_x, off_y;
gboolean hard;
@ -633,11 +652,11 @@ gimp_paint_tool_oper_update (GimpTool *tool,
dx = core->cur_coords.x - core->last_coords.x;
dy = core->cur_coords.y - core->last_coords.y;
if ((state & GDK_CONTROL_MASK))
status_help = _("Click to draw the line.");
else
status_help = _("Click to draw the line."
" (try Ctrl for constrained angles)");
status_help = gimp_suggest_modifiers (paint_tool->status_line,
GDK_CONTROL_MASK & ~state,
NULL,
_("%s for constrained angles"),
NULL);
/* show distance in statusbar */
if (shell->unit == GIMP_UNIT_PIXEL)
@ -663,22 +682,30 @@ gimp_paint_tool_oper_update (GimpTool *tool,
g_snprintf (status_str, sizeof (status_str), format_str, dist,
status_help);
}
g_free (status_help);
gimp_tool_push_status (tool, display, status_str);
paint_tool->draw_line = TRUE;
}
else
{
gchar *status;
if (display == tool->display)
gimp_tool_push_status (tool, display,
_("Click to paint. (try "
"Shift for a straight line, "
"Ctrl to pick a color)"));
status = gimp_suggest_modifiers (paint_tool->status,
(GDK_SHIFT_MASK
| GDK_CONTROL_MASK) & ~state,
_("%s for a straight line"),
paint_tool->status_ctrl,
NULL);
else
gimp_tool_push_status (tool, display,
_("Click to paint. (try "
"Ctrl to pick a color)"));
status = gimp_suggest_modifiers (paint_tool->status,
GDK_CONTROL_MASK & ~state,
NULL,
paint_tool->status_ctrl,
NULL);
gimp_tool_push_status (tool, display, status);
g_free (status);
paint_tool->draw_line = FALSE;
}

View File

@ -45,6 +45,10 @@ struct _GimpPaintTool
gdouble brush_x;
gdouble brush_y;
const gchar *status; /* status message */
const gchar *status_line; /* status message when drawing a line */
const gchar *status_ctrl; /* additional message for the ctrl modifier */
GimpPaintCore *core;
};

View File

@ -70,6 +70,11 @@ static void gimp_clone_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_clone_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_clone_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
@ -115,8 +120,9 @@ gimp_clone_tool_class_init (GimpCloneToolClass *klass)
tool_class->control = gimp_clone_tool_control;
tool_class->button_press = gimp_clone_tool_button_press;
tool_class->motion = gimp_clone_tool_motion;
tool_class->cursor_update = gimp_clone_tool_cursor_update;
tool_class->modifier_key = gimp_clone_tool_modifier_key;
tool_class->oper_update = gimp_clone_tool_oper_update;
tool_class->cursor_update = gimp_clone_tool_cursor_update;
draw_tool_class->draw = gimp_clone_tool_draw;
}
@ -124,12 +130,16 @@ gimp_clone_tool_class_init (GimpCloneToolClass *klass)
static void
gimp_clone_tool_init (GimpCloneTool *clone)
{
GimpTool *tool = GIMP_TOOL (clone);
GimpTool *tool = GIMP_TOOL (clone);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_CLONE);
gimp_tool_control_set_action_object_2 (tool->control,
"context/context-pattern-select-set");
paint_tool->status = _("Click to clone.");
paint_tool->status_ctrl = _("%s to set a new clone source");
}
static gboolean
@ -259,6 +269,31 @@ gimp_clone_tool_motion (GimpTool *tool,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
static void
gimp_clone_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display)
{
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpCloneOptions *options;
options = GIMP_CLONE_OPTIONS (tool->tool_info->tool_options);
if (options->clone_type == GIMP_IMAGE_CLONE && key == GDK_CONTROL_MASK)
{
if (press)
paint_tool->status = _("Click to set the clone source.");
else
paint_tool->status = _("Click to clone.");
}
GIMP_TOOL_CLASS (parent_class)->modifier_key (tool, key, press, state,
display);
}
static void
gimp_clone_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
@ -316,8 +351,18 @@ gimp_clone_tool_oper_update (GimpTool *tool,
if (clone->src_drawable == NULL)
{
gimp_tool_replace_status (tool, display,
_("Ctrl-Click to set a clone source."));
if (state & GDK_CONTROL_MASK)
gimp_tool_replace_status (tool, display,
_("Click to set the clone source."));
else
{
gchar *status;
status = g_strdup_printf (_("%s%sClick to set a clone source."),
gimp_get_mod_name_control (),
gimp_get_mod_separator ());
gimp_tool_replace_status (tool, display, status);
g_free (status);
}
}
else
{

View File

@ -38,17 +38,24 @@
#include "gimp-intl.h"
static void gimp_convolve_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_convolve_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_convolve_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_convolve_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_convolve_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display);
static void gimp_convolve_tool_status_update (GimpTool *tool,
GimpConvolveType type);
static GtkWidget * gimp_convolve_options_gui (GimpToolOptions *options);
static GtkWidget * gimp_convolve_options_gui (GimpToolOptions *options);
G_DEFINE_TYPE (GimpConvolveTool, gimp_convolve_tool, GIMP_TYPE_PAINT_TOOL)
@ -80,6 +87,7 @@ gimp_convolve_tool_class_init (GimpConvolveToolClass *klass)
tool_class->modifier_key = gimp_convolve_tool_modifier_key;
tool_class->cursor_update = gimp_convolve_tool_cursor_update;
tool_class->oper_update = gimp_convolve_tool_oper_update;
}
static void
@ -91,6 +99,8 @@ gimp_convolve_tool_init (GimpConvolveTool *convolve)
GIMP_TOOL_CURSOR_BLUR);
gimp_tool_control_set_toggle_cursor_modifier (tool->control,
GIMP_CURSOR_MODIFIER_MINUS);
gimp_convolve_tool_status_update (tool, GIMP_BLUR_CONVOLVE);
}
static void
@ -139,6 +149,46 @@ gimp_convolve_tool_cursor_update (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
}
static void
gimp_convolve_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display)
{
GimpConvolveOptions *options;
options = GIMP_CONVOLVE_OPTIONS (tool->tool_info->tool_options);
gimp_convolve_tool_status_update (tool, options->type);
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity,
display);
}
static void
gimp_convolve_tool_status_update (GimpTool *tool,
GimpConvolveType type)
{
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
switch (type)
{
case GIMP_BLUR_CONVOLVE:
paint_tool->status = _("Click to blur.");
paint_tool->status_line = _("Click to blur the line.");
paint_tool->status_ctrl = _("%s to sharpen");
break;
case GIMP_SHARPEN_CONVOLVE:
paint_tool->status = _("Click to sharpen.");
paint_tool->status_line = _("Click to sharpen the line.");
paint_tool->status_ctrl = _("%s to blur");
break;
default:
break;
}
}
/* tool options stuff */

View File

@ -38,17 +38,24 @@
#include "gimp-intl.h"
static void gimp_dodge_burn_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_dodge_burn_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_dodge_burn_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_dodge_burn_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_dodge_burn_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display);
static void gimp_dodge_burn_tool_status_update (GimpTool *tool,
GimpDodgeBurnType type);
static GtkWidget * gimp_dodge_burn_options_gui (GimpToolOptions *tool_options);
static GtkWidget * gimp_dodge_burn_options_gui (GimpToolOptions *tool_options);
G_DEFINE_TYPE (GimpDodgeBurnTool, gimp_dodge_burn_tool, GIMP_TYPE_PAINT_TOOL)
@ -80,6 +87,7 @@ gimp_dodge_burn_tool_class_init (GimpDodgeBurnToolClass *klass)
tool_class->modifier_key = gimp_dodge_burn_tool_modifier_key;
tool_class->cursor_update = gimp_dodge_burn_tool_cursor_update;
tool_class->oper_update = gimp_dodge_burn_tool_oper_update;
}
static void
@ -91,6 +99,8 @@ gimp_dodge_burn_tool_init (GimpDodgeBurnTool *dodgeburn)
GIMP_TOOL_CURSOR_DODGE);
gimp_tool_control_set_toggle_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_BURN);
gimp_dodge_burn_tool_status_update (tool, GIMP_BURN);
}
static void
@ -140,6 +150,47 @@ gimp_dodge_burn_tool_cursor_update (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
}
static void
gimp_dodge_burn_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display)
{
GimpDodgeBurnOptions *options;
options = GIMP_DODGE_BURN_OPTIONS (tool->tool_info->tool_options);
gimp_dodge_burn_tool_status_update (tool, options->type);
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity,
display);
}
static void
gimp_dodge_burn_tool_status_update (GimpTool *tool,
GimpDodgeBurnType type)
{
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
switch (type)
{
case GIMP_DODGE:
paint_tool->status = _("Click to dodge.");
paint_tool->status_line = _("Click to dodge the line.");
paint_tool->status_ctrl = _("%s to burn");
break;
case GIMP_BURN:
paint_tool->status = _("Click to burn.");
paint_tool->status_line = _("Click to burn the line.");
paint_tool->status_ctrl = _("%s to dodge");
break;
default:
break;
}
}
/* tool options stuff */

View File

@ -85,15 +85,20 @@ gimp_eraser_tool_class_init (GimpEraserToolClass *klass)
static void
gimp_eraser_tool_init (GimpEraserTool *eraser)
{
GimpTool *tool = GIMP_TOOL (eraser);
GimpTool *tool = GIMP_TOOL (eraser);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (eraser);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_ERASER);
gimp_tool_control_set_toggle_cursor_modifier (tool->control,
GIMP_CURSOR_MODIFIER_MINUS);
gimp_paint_tool_enable_color_picker (GIMP_PAINT_TOOL (eraser),
gimp_paint_tool_enable_color_picker (paint_tool,
GIMP_COLOR_PICK_MODE_BACKGROUND);
paint_tool->status = _("Click to erase.");
paint_tool->status_line = _("Click to erase the line.");
paint_tool->status_ctrl = _("%s to pick a background color");
}
static void

View File

@ -44,6 +44,7 @@
#include "paint/gimppaintoptions.h"
#include "widgets/gimpdevices.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
@ -162,6 +163,10 @@ gimp_paint_tool_init (GimpPaintTool *paint_tool)
paint_tool->pick_colors = FALSE;
paint_tool->draw_line = FALSE;
paint_tool->status = _("Click to paint.");
paint_tool->status_line = _("Click to draw the line.");
paint_tool->status_ctrl = _("%s to pick a color");
paint_tool->show_cursor = TRUE;
paint_tool->draw_brush = TRUE;
paint_tool->brush_x = 0.0;
@ -542,9 +547,23 @@ gimp_paint_tool_modifier_key (GimpTool *tool,
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
GIMP_COLOR_OPTIONS (info->tool_options));
gimp_tool_push_status (tool, display,
_("Click in any image to pick the "
"foreground color."));
switch (GIMP_COLOR_TOOL (tool)->pick_mode)
{
case GIMP_COLOR_PICK_MODE_FOREGROUND:
gimp_tool_push_status (tool, display,
_("Click in any image to pick the "
"foreground color."));
break;
case GIMP_COLOR_PICK_MODE_BACKGROUND:
gimp_tool_push_status (tool, display,
_("Click in any image to pick the "
"background color."));
break;
default:
break;
}
}
}
else
@ -615,7 +634,7 @@ gimp_paint_tool_oper_update (GimpTool *tool,
gdouble dx, dy, dist;
gchar status_str[STATUSBAR_SIZE];
const gchar *status_help;
gchar *status_help;
gint off_x, off_y;
gboolean hard;
@ -633,11 +652,11 @@ gimp_paint_tool_oper_update (GimpTool *tool,
dx = core->cur_coords.x - core->last_coords.x;
dy = core->cur_coords.y - core->last_coords.y;
if ((state & GDK_CONTROL_MASK))
status_help = _("Click to draw the line.");
else
status_help = _("Click to draw the line."
" (try Ctrl for constrained angles)");
status_help = gimp_suggest_modifiers (paint_tool->status_line,
GDK_CONTROL_MASK & ~state,
NULL,
_("%s for constrained angles"),
NULL);
/* show distance in statusbar */
if (shell->unit == GIMP_UNIT_PIXEL)
@ -663,22 +682,30 @@ gimp_paint_tool_oper_update (GimpTool *tool,
g_snprintf (status_str, sizeof (status_str), format_str, dist,
status_help);
}
g_free (status_help);
gimp_tool_push_status (tool, display, status_str);
paint_tool->draw_line = TRUE;
}
else
{
gchar *status;
if (display == tool->display)
gimp_tool_push_status (tool, display,
_("Click to paint. (try "
"Shift for a straight line, "
"Ctrl to pick a color)"));
status = gimp_suggest_modifiers (paint_tool->status,
(GDK_SHIFT_MASK
| GDK_CONTROL_MASK) & ~state,
_("%s for a straight line"),
paint_tool->status_ctrl,
NULL);
else
gimp_tool_push_status (tool, display,
_("Click to paint. (try "
"Ctrl to pick a color)"));
status = gimp_suggest_modifiers (paint_tool->status,
GDK_CONTROL_MASK & ~state,
NULL,
paint_tool->status_ctrl,
NULL);
gimp_tool_push_status (tool, display, status);
g_free (status);
paint_tool->draw_line = FALSE;
}

View File

@ -45,6 +45,10 @@ struct _GimpPaintTool
gdouble brush_x;
gdouble brush_y;
const gchar *status; /* status message */
const gchar *status_line; /* status message when drawing a line */
const gchar *status_ctrl; /* additional message for the ctrl modifier */
GimpPaintCore *core;
};

View File

@ -29,6 +29,7 @@
#include "paint/gimpsmudgeoptions.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimpsmudgetool.h"
#include "gimppaintoptions-gui.h"
@ -68,12 +69,16 @@ gimp_smudge_tool_class_init (GimpSmudgeToolClass *klass)
static void
gimp_smudge_tool_init (GimpSmudgeTool *smudge)
{
GimpTool *tool = GIMP_TOOL (smudge);
GimpTool *tool = GIMP_TOOL (smudge);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (smudge);
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_SMUDGE);
gimp_paint_tool_enable_color_picker (GIMP_PAINT_TOOL (smudge),
GIMP_COLOR_PICK_MODE_FOREGROUND);
paint_tool->status = _("Click to smudge.");
paint_tool->status_line = _("Click to smudge the line.");
}

View File

@ -70,6 +70,11 @@ static void gimp_clone_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_clone_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_clone_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
@ -115,8 +120,9 @@ gimp_clone_tool_class_init (GimpCloneToolClass *klass)
tool_class->control = gimp_clone_tool_control;
tool_class->button_press = gimp_clone_tool_button_press;
tool_class->motion = gimp_clone_tool_motion;
tool_class->cursor_update = gimp_clone_tool_cursor_update;
tool_class->modifier_key = gimp_clone_tool_modifier_key;
tool_class->oper_update = gimp_clone_tool_oper_update;
tool_class->cursor_update = gimp_clone_tool_cursor_update;
draw_tool_class->draw = gimp_clone_tool_draw;
}
@ -124,12 +130,16 @@ gimp_clone_tool_class_init (GimpCloneToolClass *klass)
static void
gimp_clone_tool_init (GimpCloneTool *clone)
{
GimpTool *tool = GIMP_TOOL (clone);
GimpTool *tool = GIMP_TOOL (clone);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_CLONE);
gimp_tool_control_set_action_object_2 (tool->control,
"context/context-pattern-select-set");
paint_tool->status = _("Click to clone.");
paint_tool->status_ctrl = _("%s to set a new clone source");
}
static gboolean
@ -259,6 +269,31 @@ gimp_clone_tool_motion (GimpTool *tool,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
static void
gimp_clone_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display)
{
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpCloneOptions *options;
options = GIMP_CLONE_OPTIONS (tool->tool_info->tool_options);
if (options->clone_type == GIMP_IMAGE_CLONE && key == GDK_CONTROL_MASK)
{
if (press)
paint_tool->status = _("Click to set the clone source.");
else
paint_tool->status = _("Click to clone.");
}
GIMP_TOOL_CLASS (parent_class)->modifier_key (tool, key, press, state,
display);
}
static void
gimp_clone_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
@ -316,8 +351,18 @@ gimp_clone_tool_oper_update (GimpTool *tool,
if (clone->src_drawable == NULL)
{
gimp_tool_replace_status (tool, display,
_("Ctrl-Click to set a clone source."));
if (state & GDK_CONTROL_MASK)
gimp_tool_replace_status (tool, display,
_("Click to set the clone source."));
else
{
gchar *status;
status = g_strdup_printf (_("%s%sClick to set a clone source."),
gimp_get_mod_name_control (),
gimp_get_mod_separator ());
gimp_tool_replace_status (tool, display, status);
g_free (status);
}
}
else
{

View File

@ -45,6 +45,7 @@
#include "vectors/gimpbezierstroke.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
@ -101,6 +102,7 @@ static void gimp_vector_tool_oper_update (GimpTool *tool,
GimpDisplay *display);
static void gimp_vector_tool_status_update (GimpTool *tool,
GimpDisplay *display,
GdkModifierType state,
gboolean proximity);
static void gimp_vector_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
@ -1125,14 +1127,15 @@ gimp_vector_tool_oper_update (GimpTool *tool,
break;
}
gimp_vector_tool_status_update (tool, display, proximity);
gimp_vector_tool_status_update (tool, display, state, proximity);
}
static void
gimp_vector_tool_status_update (GimpTool *tool,
GimpDisplay *display,
gboolean proximity)
gimp_vector_tool_status_update (GimpTool *tool,
GimpDisplay *display,
GdkModifierType state,
gboolean proximity)
{
GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (tool);
@ -1140,7 +1143,7 @@ gimp_vector_tool_status_update (GimpTool *tool,
if (proximity)
{
const gchar *status = NULL;
gchar *status = NULL;
switch (vector_tool->function)
{
@ -1154,7 +1157,9 @@ gimp_vector_tool_status_update (GimpTool *tool,
status = _("Click to create a new component of the path.");
break;
case VECTORS_ADD_ANCHOR:
status = _("Click to create a new anchor. (try Shift)");
status = gimp_suggest_modifiers (_("Click to create a new anchor."),
GDK_SHIFT_MASK & ~state,
NULL, NULL, NULL);
break;
case VECTORS_MOVE_ANCHOR:
status = _("Click-Drag to move the anchor around.");
@ -1163,24 +1168,37 @@ gimp_vector_tool_status_update (GimpTool *tool,
status = _("Click-Drag to move the anchors around.");
break;
case VECTORS_MOVE_HANDLE:
status = _("Click-Drag to move the handle around. (try Shift)");
status = gimp_suggest_modifiers (_("Click-Drag to move the handle "
"around."),
GDK_SHIFT_MASK & ~state,
NULL, NULL, NULL);
break;
case VECTORS_MOVE_CURVE:
if (GIMP_VECTOR_OPTIONS (tool->tool_info->tool_options)->polygonal)
status = _("Click-Drag to move the anchors around.");
status = gimp_suggest_modifiers (_("Click-Drag to move the "
"anchors around."),
GDK_SHIFT_MASK & ~state,
NULL, NULL, NULL);
else
status = _("Click-Drag to change the shape of the curve. "
"(Shift: symmetrical)");
status = gimp_suggest_modifiers (_("Click-Drag to change the "
"shape of the curve."),
GDK_SHIFT_MASK & ~state,
_("%s: symmetrical"), NULL, NULL);
break;
case VECTORS_MOVE_STROKE:
status = _("Click-Drag to move the component around. "
"(try Shift)");
status = gimp_suggest_modifiers (_("Click-Drag to move the "
"component around."),
GDK_SHIFT_MASK & ~state,
NULL, NULL, NULL);
break;
case VECTORS_MOVE_VECTORS:
status = _("Click-Drag to move the path around.");
break;
case VECTORS_INSERT_ANCHOR:
status = _("Click to insert an anchor on the path. (try Shift)");
status = gimp_suggest_modifiers (_("Click-Drag to insert an anchor "
"on the path."),
GDK_SHIFT_MASK & ~state,
NULL, NULL, NULL);
break;
case VECTORS_DELETE_ANCHOR:
status = _("Click to delete this anchor.");
@ -1202,6 +1220,20 @@ gimp_vector_tool_status_update (GimpTool *tool,
if (status)
gimp_tool_push_status (tool, display, status);
/* not very elegant */
switch (vector_tool->function)
{
case VECTORS_ADD_ANCHOR:
case VECTORS_MOVE_HANDLE:
case VECTORS_MOVE_CURVE:
case VECTORS_MOVE_STROKE:
case VECTORS_INSERT_ANCHOR:
g_free (status);
break;
default:
break;
}
}
}

View File

@ -569,6 +569,79 @@ gimp_get_accel_string (guint key,
return g_string_free (gstring, FALSE);
}
#define BUF_SIZE 100
/**
* gimp_suggest_modifiers:
* @message: initial text for the message
* @modifiers: bit mask of modifiers that should be suggested
* @shift_format: optional format string for the Shift modifier
* @control_format: optional format string for the Ctrl modifier
* @alt_format: optional format string for the Alt modifier
*
* Utility function to build a message suggesting to use some
* modifiers for performing different actions (only Shift, Ctrl and
* Alt are currently supported). If some of these modifiers are
* already active, they will not be suggested. The optional format
* strings #shift_format, #control_format and #alt_format may be used
* to describe what the modifier will do. They must contain a single
* '%%s' which will be replaced by the name of the modifier. They
* can also be %NULL if the modifier name should be left alone.
*
* Return value: a newly allocated string containing the message.
**/
gchar *
gimp_suggest_modifiers (const gchar *message,
GdkModifierType modifiers,
const gchar *shift_format,
const gchar *control_format,
const gchar *alt_format)
{
gchar msg_buf[3][BUF_SIZE];
gint num_msgs = 0;
if (modifiers & GDK_SHIFT_MASK)
{
if (shift_format && *shift_format)
g_snprintf (msg_buf[num_msgs], BUF_SIZE, shift_format,
gimp_get_mod_name_shift ());
else
g_strlcpy (msg_buf[num_msgs], gimp_get_mod_name_shift (), BUF_SIZE);
num_msgs++;
}
if (modifiers & GDK_CONTROL_MASK)
{
if (control_format && *control_format)
g_snprintf (msg_buf[num_msgs], BUF_SIZE, control_format,
gimp_get_mod_name_control ());
else
g_strlcpy (msg_buf[num_msgs], gimp_get_mod_name_control (), BUF_SIZE);
num_msgs++;
}
if (modifiers & GDK_MOD1_MASK)
{
if (alt_format && *alt_format)
g_snprintf (msg_buf[num_msgs], BUF_SIZE, alt_format,
gimp_get_mod_name_alt ());
else
g_strlcpy (msg_buf[num_msgs], gimp_get_mod_name_alt (), BUF_SIZE);
num_msgs++;
}
/* This convoluted way to build the message using multiple format strings
* tries to make the messages easier to translate to other languages.
*/
if (num_msgs == 1)
return g_strdup_printf (_("%s (try %s)"), message,
msg_buf[0]);
else if (num_msgs == 2)
return g_strdup_printf (_("%s (try %s, %s)"), message,
msg_buf[0], msg_buf[1]);
else if (num_msgs == 3)
return g_strdup_printf (_("%s (try %s, %s, %s)"), message,
msg_buf[0], msg_buf[1], msg_buf[2]);
else
return g_strdup (message);
}
#undef BUF_SIZE
/**
* gimp_get_screen_resolution:

View File

@ -55,6 +55,11 @@ const gchar * gimp_get_mod_separator (void);
const gchar * gimp_get_mod_string (GdkModifierType modifiers);
gchar * gimp_get_accel_string (guint key,
GdkModifierType modifiers);
gchar * gimp_suggest_modifiers (const gchar *message,
GdkModifierType modifiers,
const gchar *shift_format,
const gchar *control_format,
const gchar *alt_format);
void gimp_get_screen_resolution (GdkScreen *screen,
gdouble *xres,