[gimp] app: get rid of hardcoding GDK_SHIFT_MASK in tools/
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: get rid of hardcoding GDK_SHIFT_MASK in tools/
- Date: Sat, 17 Oct 2015 13:34:58 +0000 (UTC)
commit 7ec04e4afecbf72ca49ee97251eda970c08e78f6
Author: Michael Natterer <mitch gimp org>
Date: Sat Oct 17 15:31:08 2015 +0200
app: get rid of hardcoding GDK_SHIFT_MASK in tools/
gimp_suggest_modifiers(): change "shift_format" and "control_format"
parameters to "extend_selection_format" and "toggle_behavior_format",
which fixes the longstanding problem that the function did the right
thing only by accident.
tools: use gimp_get_extend_selection_mask() instead of GDK_SHIFT_MASK
which is not 100% semantically correct in all cases, but at least a
step in the right direction to make the tool modifiers easier to
improve.
app/tools/gimpbucketfilloptions.c | 7 ++--
app/tools/gimpbucketfilltool.c | 2 +-
app/tools/gimpcagetool.c | 9 +++--
app/tools/gimpcolorpickeroptions.c | 7 ++--
app/tools/gimpcolorpickertool.c | 20 ++++++------
app/tools/gimpconvolvetool.c | 19 +++++------
app/tools/gimpcurvestool.c | 22 +++++++++----
app/tools/gimpdodgeburntool.c | 19 +++++------
app/tools/gimpeditselectiontool.c | 47 +++++++++++++++-----------
app/tools/gimpfreeselecttool.c | 3 +-
app/tools/gimpiscissorstool.c | 12 ++++---
app/tools/gimpmeasuretool.c | 15 +++++---
app/tools/gimpmoveoptions.c | 5 ++-
app/tools/gimpmovetool.c | 2 +-
app/tools/gimpnpointdeformationtool.c | 6 ++--
app/tools/gimppainttool.c | 4 +-
app/tools/gimppainttool.h | 3 ++
app/tools/gimpperspectiveclonetool.c | 6 ++-
app/tools/gimprectangletool.c | 4 +-
app/tools/gimpsourcetool.c | 6 ++-
app/tools/gimpvectortool.c | 26 +++++++-------
app/widgets/gimpwidgets-utils.c | 57 +++++++++++++++++----------------
app/widgets/gimpwidgets-utils.h | 4 +-
23 files changed, 166 insertions(+), 139 deletions(-)
---
diff --git a/app/tools/gimpbucketfilloptions.c b/app/tools/gimpbucketfilloptions.c
index ccef99a..1ecc477 100644
--- a/app/tools/gimpbucketfilloptions.c
+++ b/app/tools/gimpbucketfilloptions.c
@@ -221,9 +221,8 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
GtkWidget *scale;
GtkWidget *combo;
gchar *str;
- GdkModifierType toggle_mask;
-
- toggle_mask = gimp_get_toggle_behavior_mask ();
+ GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
+ GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
/* fill type */
str = g_strdup_printf (_("Fill Type (%s)"),
@@ -242,7 +241,7 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
/* fill selection */
str = g_strdup_printf (_("Affected Area (%s)"),
- gimp_get_mod_string (GDK_SHIFT_MASK));
+ gimp_get_mod_string (extend_mask));
frame = gimp_prop_boolean_radio_frame_new (config, "fill-selection",
str,
_("Fill whole selection"),
diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c
index 206c213..2a9be16 100644
--- a/app/tools/gimpbucketfilltool.c
+++ b/app/tools/gimpbucketfilltool.c
@@ -268,7 +268,7 @@ gimp_bucket_fill_tool_modifier_key (GimpTool *tool,
break;
}
}
- else if (key == GDK_SHIFT_MASK)
+ else if (key == gimp_get_extend_selection_mask ())
{
g_object_set (options, "fill-selection", ! options->fill_selection, NULL);
}
diff --git a/app/tools/gimpcagetool.c b/app/tools/gimpcagetool.c
index 41359cf..ddb96a7 100644
--- a/app/tools/gimpcagetool.c
+++ b/app/tools/gimpcagetool.c
@@ -46,6 +46,7 @@
#include "core/gimpprojection.h"
#include "widgets/gimphelp-ids.h"
+#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
@@ -551,7 +552,7 @@ gimp_cage_tool_button_press (GimpTool *tool,
{
/* User clicked on a handle, so we move it */
- if (state & GDK_SHIFT_MASK)
+ if (state & gimp_get_extend_selection_mask ())
{
/* Multiple selection */
@@ -595,7 +596,7 @@ gimp_cage_tool_button_press (GimpTool *tool,
{
/* User clicked on a handle, so we move it */
- if (state & GDK_SHIFT_MASK)
+ if (state & gimp_get_extend_selection_mask ())
{
/* Multiple selection */
@@ -690,7 +691,7 @@ gimp_cage_tool_button_release (GimpTool *tool,
abs (ct->selection_start_x - coords->x),
abs (ct->selection_start_y - coords->y) };
- if (state & GDK_SHIFT_MASK)
+ if (state & gimp_get_extend_selection_mask ())
{
gimp_cage_config_select_add_area (ct->config,
GIMP_CAGE_MODE_CAGE_CHANGE,
@@ -720,7 +721,7 @@ gimp_cage_tool_button_release (GimpTool *tool,
abs (ct->selection_start_x - coords->x),
abs (ct->selection_start_y - coords->y) };
- if (state & GDK_SHIFT_MASK)
+ if (state & gimp_get_extend_selection_mask ())
{
gimp_cage_config_select_add_area (ct->config,
GIMP_CAGE_MODE_DEFORM, area);
diff --git a/app/tools/gimpcolorpickeroptions.c b/app/tools/gimpcolorpickeroptions.c
index 42944d4..e653cbb 100644
--- a/app/tools/gimpcolorpickeroptions.c
+++ b/app/tools/gimpcolorpickeroptions.c
@@ -150,9 +150,8 @@ gimp_color_picker_options_gui (GimpToolOptions *tool_options)
GtkWidget *button;
GtkWidget *frame;
gchar *str;
- GdkModifierType toggle_mask;
-
- toggle_mask = gimp_get_toggle_behavior_mask ();
+ GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
+ GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
/* the sample merged toggle button */
button = gimp_prop_check_button_new (config, "sample-merged",
@@ -171,7 +170,7 @@ gimp_color_picker_options_gui (GimpToolOptions *tool_options)
/* the use_info_window toggle button */
str = g_strdup_printf (_("Use info window (%s)"),
- gimp_get_mod_string (GDK_SHIFT_MASK));
+ gimp_get_mod_string (extend_mask));
button = gimp_prop_check_button_new (config, "use-info-window", str);
g_free (str);
diff --git a/app/tools/gimpcolorpickertool.c b/app/tools/gimpcolorpickertool.c
index 2f3b792..021575d 100644
--- a/app/tools/gimpcolorpickertool.c
+++ b/app/tools/gimpcolorpickertool.c
@@ -191,7 +191,7 @@ gimp_color_picker_tool_modifier_key (GimpTool *tool,
{
GimpColorPickerOptions *options = GIMP_COLOR_PICKER_TOOL_GET_OPTIONS (tool);
- if (key == GDK_SHIFT_MASK)
+ if (key == gimp_get_extend_selection_mask ())
{
g_object_set (options, "use-info-window", ! options->use_info_window,
NULL);
@@ -226,9 +226,6 @@ gimp_color_picker_tool_oper_update (GimpTool *tool,
{
GimpColorPickerTool *picker_tool = GIMP_COLOR_PICKER_TOOL (tool);
GimpColorPickerOptions *options = GIMP_COLOR_PICKER_TOOL_GET_OPTIONS (tool);
- GdkModifierType toggle_mask;
-
- toggle_mask = gimp_get_toggle_behavior_mask ();
GIMP_COLOR_TOOL (tool)->pick_mode = options->pick_mode;
@@ -237,24 +234,27 @@ gimp_color_picker_tool_oper_update (GimpTool *tool,
if (proximity)
{
gchar *status_help = NULL;
- GdkModifierType shift_mod = 0;
+ GdkModifierType extend_mask = 0;
+ GdkModifierType toggle_mask;
if (! picker_tool->gui)
- shift_mod = GDK_SHIFT_MASK;
+ extend_mask = gimp_get_extend_selection_mask ();
+
+ toggle_mask = gimp_get_toggle_behavior_mask ();
switch (options->pick_mode)
{
case GIMP_COLOR_PICK_MODE_NONE:
status_help = gimp_suggest_modifiers (_("Click in any image to view"
" its color"),
- shift_mod & ~state,
+ extend_mask & ~state,
NULL, NULL, NULL);
break;
case GIMP_COLOR_PICK_MODE_FOREGROUND:
status_help = gimp_suggest_modifiers (_("Click in any image to pick"
" the foreground color"),
- (shift_mod | toggle_mask) &
+ (extend_mask | toggle_mask) &
~state,
NULL, NULL, NULL);
break;
@@ -262,7 +262,7 @@ gimp_color_picker_tool_oper_update (GimpTool *tool,
case GIMP_COLOR_PICK_MODE_BACKGROUND:
status_help = gimp_suggest_modifiers (_("Click in any image to pick"
" the background color"),
- (shift_mod | toggle_mask) &
+ (extend_mask | toggle_mask) &
~state,
NULL, NULL, NULL);
break;
@@ -270,7 +270,7 @@ gimp_color_picker_tool_oper_update (GimpTool *tool,
case GIMP_COLOR_PICK_MODE_PALETTE:
status_help = gimp_suggest_modifiers (_("Click in any image to add"
" the color to the palette"),
- shift_mod & ~state,
+ extend_mask & ~state,
NULL, NULL, NULL);
break;
}
diff --git a/app/tools/gimpconvolvetool.c b/app/tools/gimpconvolvetool.c
index 352f634..0c3bdd2 100644
--- a/app/tools/gimpconvolvetool.c
+++ b/app/tools/gimpconvolvetool.c
@@ -109,21 +109,20 @@ gimp_convolve_tool_modifier_key (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
- GimpConvolveTool *convolve = GIMP_CONVOLVE_TOOL (tool);
- GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
- GdkModifierType toggle_mask;
+ GimpConvolveTool *convolve = GIMP_CONVOLVE_TOOL (tool);
+ GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
+ GdkModifierType line_mask = GIMP_PAINT_TOOL_LINE_MASK;
+ GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
- toggle_mask = gimp_get_toggle_behavior_mask ();
-
- if (((key == toggle_mask) &&
- ! (state & GDK_SHIFT_MASK) && /* leave stuff untouched in line draw mode */
+ if (((key == toggle_mask) &&
+ ! (state & line_mask) && /* leave stuff untouched in line draw mode */
press != convolve->toggled)
||
- (key == GDK_SHIFT_MASK && /* toggle back after keypresses CTRL(hold)-> */
- ! press && /* SHIFT(hold)->CTRL(release)->SHIFT(release) */
- convolve->toggled &&
+ (key == line_mask && /* toggle back after keypresses CTRL(hold)-> */
+ ! press && /* SHIFT(hold)->CTRL(release)->SHIFT(release) */
+ convolve->toggled &&
! (state & toggle_mask)))
{
convolve->toggled = press;
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index a92a8dc..b42e033 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -237,7 +237,7 @@ gimp_curves_tool_button_release (GimpTool *tool,
GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool);
GimpCurvesConfig *config = c_tool->config;
- if (state & GDK_SHIFT_MASK)
+ if (state & gimp_get_extend_selection_mask ())
{
GimpCurve *curve = config->curve[config->channel];
gdouble value = c_tool->picked_color[config->channel];
@@ -300,33 +300,41 @@ gimp_curves_tool_oper_update (GimpTool *tool,
GimpDisplay *display)
{
GimpColorPickMode mode;
- const gchar *status;
+ gchar *status = NULL;
+ GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
+ GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity,
display);
gimp_tool_pop_status (tool, display);
- if (state & GDK_SHIFT_MASK)
+ if (state & extend_mask)
{
mode = GIMP_COLOR_PICK_MODE_PALETTE;
- status = _("Click to add a control point");
+ status = g_strdup (_("Click to add a control point"));
}
- else if (state & gimp_get_toggle_behavior_mask ())
+ else if (state & toggle_mask)
{
mode = GIMP_COLOR_PICK_MODE_PALETTE;
- status = _("Click to add control points to all channels");
+ status = g_strdup (_("Click to add control points to all channels"));
}
else
{
mode = GIMP_COLOR_PICK_MODE_NONE;
- status = _("Click to locate on curve (try Shift, Ctrl)");
+ status = gimp_suggest_modifiers (_("Click to locate on curve"),
+ (extend_mask | toggle_mask) & ~state,
+ _("%s: add control point"),
+ _("%s: add control points to all channels"),
+ NULL);
}
GIMP_COLOR_TOOL (tool)->pick_mode = mode;
if (proximity)
gimp_tool_push_status (tool, display, "%s", status);
+
+ g_free (status);
}
static void
diff --git a/app/tools/gimpdodgeburntool.c b/app/tools/gimpdodgeburntool.c
index 99cdbcc..1b4825b 100644
--- a/app/tools/gimpdodgeburntool.c
+++ b/app/tools/gimpdodgeburntool.c
@@ -109,21 +109,20 @@ gimp_dodge_burn_tool_modifier_key (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
- GimpDodgeBurnTool *dodgeburn = GIMP_DODGE_BURN_TOOL (tool);
- GimpDodgeBurnOptions *options = GIMP_DODGE_BURN_TOOL_GET_OPTIONS (tool);
- GdkModifierType toggle_mask;
+ GimpDodgeBurnTool *dodgeburn = GIMP_DODGE_BURN_TOOL (tool);
+ GimpDodgeBurnOptions *options = GIMP_DODGE_BURN_TOOL_GET_OPTIONS (tool);
+ GdkModifierType line_mask = GIMP_PAINT_TOOL_LINE_MASK;
+ GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
- toggle_mask = gimp_get_toggle_behavior_mask ();
-
- if ((key == toggle_mask &&
- ! (state & GDK_SHIFT_MASK) && /* leave stuff untouched in line draw mode */
+ if ((key == toggle_mask &&
+ ! (state & line_mask) && /* leave stuff untouched in line draw mode */
press != dodgeburn->toggled)
||
- (key == GDK_SHIFT_MASK && /* toggle back after keypresses CTRL(hold)-> */
- ! press && /* SHIFT(hold)->CTRL(release)->SHIFT(release) */
- dodgeburn->toggled &&
+ (key == line_mask && /* toggle back after keypresses CTRL(hold)-> */
+ ! press && /* SHIFT(hold)->CTRL(release)->SHIFT(release) */
+ dodgeburn->toggled &&
! (state & toggle_mask)))
{
dodgeburn->toggled = press;
diff --git a/app/tools/gimpeditselectiontool.c b/app/tools/gimpeditselectiontool.c
index ffd3cfd..aa0f8bb 100644
--- a/app/tools/gimpeditselectiontool.c
+++ b/app/tools/gimpeditselectiontool.c
@@ -964,11 +964,17 @@ gimp_edit_selection_tool_key_press (GimpTool *tool,
GimpTransformType translate_type;
if (kevent->state & GDK_MOD1_MASK)
- translate_type = GIMP_TRANSFORM_TYPE_SELECTION;
+ {
+ translate_type = GIMP_TRANSFORM_TYPE_SELECTION;
+ }
else if (kevent->state & gimp_get_toggle_behavior_mask ())
- translate_type = GIMP_TRANSFORM_TYPE_PATH;
+ {
+ translate_type = GIMP_TRANSFORM_TYPE_PATH;
+ }
else
- translate_type = GIMP_TRANSFORM_TYPE_LAYER;
+ {
+ translate_type = GIMP_TRANSFORM_TYPE_LAYER;
+ }
return gimp_edit_selection_tool_translate (tool, kevent, translate_type,
display);
@@ -980,15 +986,16 @@ gimp_edit_selection_tool_translate (GimpTool *tool,
GimpTransformType translate_type,
GimpDisplay *display)
{
- gint inc_x = 0;
- gint inc_y = 0;
+ gint inc_x = 0;
+ gint inc_y = 0;
GimpUndo *undo;
- gboolean push_undo = TRUE;
- GimpImage *image = gimp_display_get_image (display);
- GimpItem *item = NULL;
- GimpTranslateMode edit_mode = GIMP_TRANSLATE_MODE_MASK;
- GimpUndoType undo_type = GIMP_UNDO_GROUP_MASK;
- const gchar *undo_desc = NULL;
+ gboolean push_undo = TRUE;
+ GimpImage *image = gimp_display_get_image (display);
+ GimpItem *item = NULL;
+ GimpTranslateMode edit_mode = GIMP_TRANSLATE_MODE_MASK;
+ GimpUndoType undo_type = GIMP_UNDO_GROUP_MASK;
+ const gchar *undo_desc = NULL;
+ GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
gint velocity;
/* bail out early if it is not an arrow key event */
@@ -1005,43 +1012,43 @@ gimp_edit_selection_tool_translate (GimpTool *tool,
velocity = MAX (1.0, velocity);
/* check the event queue for key events with the same modifier mask
- * as the current event, allowing only GDK_SHIFT_MASK to vary between
+ * as the current event, allowing only extend_mask to vary between
* them.
*/
inc_x = process_event_queue_keys (kevent,
GDK_KEY_Left,
- kevent->state | GDK_SHIFT_MASK,
+ kevent->state | extend_mask,
-1 * velocity,
GDK_KEY_Left,
- kevent->state & ~GDK_SHIFT_MASK,
+ kevent->state & ~extend_mask,
-1,
GDK_KEY_Right,
- kevent->state | GDK_SHIFT_MASK,
+ kevent->state | extend_mask,
1 * velocity,
GDK_KEY_Right,
- kevent->state & ~GDK_SHIFT_MASK,
+ kevent->state & ~extend_mask,
1,
0);
inc_y = process_event_queue_keys (kevent,
GDK_KEY_Up,
- kevent->state | GDK_SHIFT_MASK,
+ kevent->state | extend_mask,
-1 * velocity,
GDK_KEY_Up,
- kevent->state & ~GDK_SHIFT_MASK,
+ kevent->state & ~extend_mask,
-1,
GDK_KEY_Down,
- kevent->state | GDK_SHIFT_MASK,
+ kevent->state | extend_mask,
1 * velocity,
GDK_KEY_Down,
- kevent->state & ~GDK_SHIFT_MASK,
+ kevent->state & ~extend_mask,
1,
0);
diff --git a/app/tools/gimpfreeselecttool.c b/app/tools/gimpfreeselecttool.c
index 678e666..5c961d0 100644
--- a/app/tools/gimpfreeselecttool.c
+++ b/app/tools/gimpfreeselecttool.c
@@ -1393,7 +1393,8 @@ gimp_free_select_tool_modifier_key (GimpTool *tool,
priv->constrain_angle = ((state & gimp_get_constrain_behavior_mask ()) ?
TRUE : FALSE);
- priv->supress_handles = state & GDK_SHIFT_MASK ? TRUE : FALSE;
+ priv->supress_handles = ((state & gimp_get_extend_selection_mask ()) ?
+ TRUE : FALSE);
gimp_draw_tool_resume (draw_tool);
}
diff --git a/app/tools/gimpiscissorstool.c b/app/tools/gimpiscissorstool.c
index 4884204..dc11a6c 100644
--- a/app/tools/gimpiscissorstool.c
+++ b/app/tools/gimpiscissorstool.c
@@ -417,7 +417,7 @@ gimp_iscissors_tool_button_press (GimpTool *tool,
case NO_ACTION:
iscissors->state = SEED_PLACEMENT;
- if (! (state & GDK_SHIFT_MASK))
+ if (! (state & gimp_get_extend_selection_mask ()))
find_max_gradient (iscissors, image,
&iscissors->x, &iscissors->y);
@@ -742,7 +742,7 @@ gimp_iscissors_tool_motion (GimpTool *tool,
iscissors->y = RINT (coords->y);
/* Hold the shift key down to disable the auto-edge snap feature */
- if (! (state & GDK_SHIFT_MASK))
+ if (! (state & gimp_get_extend_selection_mask ()))
find_max_gradient (iscissors, image,
&iscissors->x, &iscissors->y);
@@ -927,6 +927,7 @@ gimp_iscissors_tool_oper_update (GimpTool *tool,
if (mouse_over_vertex (iscissors, coords->x, coords->y) > 1)
{
+ GdkModifierType snap_mask = gimp_get_extend_selection_mask ();
GdkModifierType remove_mask = gimp_get_modify_selection_mask ();
if (state & remove_mask)
@@ -939,7 +940,7 @@ gimp_iscissors_tool_oper_update (GimpTool *tool,
{
gchar *status =
gimp_suggest_modifiers (_("Click-Drag to move this point"),
- (GDK_SHIFT_MASK | remove_mask) & ~state,
+ (snap_mask | remove_mask) & ~state,
_("%s: disable auto-snap"),
_("%s: remove this point"),
NULL);
@@ -1003,11 +1004,12 @@ gimp_iscissors_tool_oper_update (GimpTool *tool,
case WAITING:
if (proximity)
{
- gchar *status;
+ GdkModifierType snap_mask = gimp_get_extend_selection_mask ();
+ gchar *status;
status = gimp_suggest_modifiers (_("Click or Click-Drag to add a"
" point"),
- GDK_SHIFT_MASK & ~state,
+ snap_mask & ~state,
_("%s: disable auto-snap"),
NULL, NULL);
gimp_tool_replace_status (tool, display, "%s", status);
diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c
index abd7977..a58f6eb 100644
--- a/app/tools/gimpmeasuretool.c
+++ b/app/tools/gimpmeasuretool.c
@@ -223,6 +223,7 @@ gimp_measure_tool_button_press (GimpTool *tool,
*/
if (measure->point != -1)
{
+ GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
if (state & (toggle_mask | GDK_MOD1_MASK))
@@ -267,7 +268,7 @@ gimp_measure_tool_button_press (GimpTool *tool,
}
else
{
- if (state & GDK_SHIFT_MASK)
+ if (state & extend_mask)
measure->function = ADDING;
else
measure->function = MOVING;
@@ -550,6 +551,7 @@ gimp_measure_tool_oper_update (GimpTool *tool,
if (gimp_canvas_item_hit (measure->handles[i],
coords->x, coords->y))
{
+ GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
point = i;
@@ -590,7 +592,7 @@ gimp_measure_tool_oper_update (GimpTool *tool,
break;
}
- if ((state & GDK_SHIFT_MASK)
+ if ((state & extend_mask)
&& ! ((i == 0) && (measure->num_points == 3)))
{
status = gimp_suggest_modifiers (_("Click-Drag to add a "
@@ -602,11 +604,11 @@ gimp_measure_tool_oper_update (GimpTool *tool,
else
{
if ((i == 0) && (measure->num_points == 3))
- state |= GDK_SHIFT_MASK;
+ state |= extend_mask;
status = gimp_suggest_modifiers (_("Click-Drag to move this "
"point"),
- (GDK_SHIFT_MASK |
- toggle_mask |
+ (extend_mask |
+ toggle_mask |
GDK_MOD1_MASK) & ~state,
NULL, NULL, NULL);
}
@@ -673,6 +675,7 @@ gimp_measure_tool_cursor_update (GimpTool *tool,
{
if (measure->point != -1)
{
+ GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
if (state & toggle_mask)
@@ -686,7 +689,7 @@ gimp_measure_tool_cursor_update (GimpTool *tool,
{
cursor = GIMP_CURSOR_SIDE_RIGHT;
}
- else if ((state & GDK_SHIFT_MASK) &&
+ else if ((state & extend_mask) &&
! ((measure->point == 0) &&
(measure->num_points == 3)))
{
diff --git a/app/tools/gimpmoveoptions.c b/app/tools/gimpmoveoptions.c
index 496a94b..b0f64b2 100644
--- a/app/tools/gimpmoveoptions.c
+++ b/app/tools/gimpmoveoptions.c
@@ -185,8 +185,9 @@ gimp_move_options_gui (GimpToolOptions *tool_options)
gtk_widget_show (box);
/* tool toggle */
- title = g_strdup_printf (_("Tool Toggle (%s)"),
- gimp_get_mod_string (GDK_SHIFT_MASK));
+ title =
+ g_strdup_printf (_("Tool Toggle (%s)"),
+ gimp_get_mod_string (gimp_get_extend_selection_mask ()));
frame = gimp_prop_boolean_radio_frame_new (config, "move-current",
title, "true", "false");
diff --git a/app/tools/gimpmovetool.c b/app/tools/gimpmovetool.c
index 6acce25..6e89f6c 100644
--- a/app/tools/gimpmovetool.c
+++ b/app/tools/gimpmovetool.c
@@ -635,7 +635,7 @@ gimp_move_tool_modifier_key (GimpTool *tool,
GimpMoveTool *move = GIMP_MOVE_TOOL (tool);
GimpMoveOptions *options = GIMP_MOVE_TOOL_GET_OPTIONS (tool);
- if (key == GDK_SHIFT_MASK)
+ if (key == gimp_get_extend_selection_mask ())
{
g_object_set (options, "move-current", ! options->move_current, NULL);
}
diff --git a/app/tools/gimpnpointdeformationtool.c b/app/tools/gimpnpointdeformationtool.c
index 039d3a2..8c35534 100644
--- a/app/tools/gimpnpointdeformationtool.c
+++ b/app/tools/gimpnpointdeformationtool.c
@@ -578,7 +578,7 @@ gimp_n_point_deformation_tool_button_press (GimpTool *tool,
* list of selected control points
*/
- if (! (state & GDK_SHIFT_MASK))
+ if (! (state & gimp_get_extend_selection_mask ()))
{
/* <SHIFT> isn't pressed, so this isn't a
* multiselection - clear the list of selected
@@ -589,7 +589,7 @@ gimp_n_point_deformation_tool_button_press (GimpTool *tool,
gimp_n_point_deformation_tool_add_cp_to_selection (npd_tool, cp);
}
- else if (state & GDK_SHIFT_MASK)
+ else if (state & gimp_get_extend_selection_mask ())
{
/* control point is selected and <SHIFT> is pressed -
* remove control point from selected points
@@ -666,7 +666,7 @@ gimp_n_point_deformation_tool_button_release (GimpTool *tool,
gint y1 = MAX (npd_tool->start_y, npd_tool->cursor_y);
gint i;
- if (! (state & GDK_SHIFT_MASK))
+ if (! (state & gimp_get_extend_selection_mask ()))
{
/* <SHIFT> isn't pressed, so we want a clear selection */
gimp_n_point_deformation_tool_clear_selected_points_list (npd_tool);
diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c
index b85e198..f80af50 100644
--- a/app/tools/gimppainttool.c
+++ b/app/tools/gimppainttool.c
@@ -634,7 +634,7 @@ gimp_paint_tool_oper_update (GimpTool *tool,
core->cur_coords.x -= off_x;
core->cur_coords.y -= off_y;
- if (display == tool->display && (state & GDK_SHIFT_MASK))
+ if (display == tool->display && (state & GIMP_PAINT_TOOL_LINE_MASK))
{
/* If shift is down and this is not the first paint stroke,
* draw a line.
@@ -703,7 +703,7 @@ gimp_paint_tool_oper_update (GimpTool *tool,
/* suggest drawing lines only after the first point is set
*/
if (display == tool->display)
- modifiers |= GDK_SHIFT_MASK;
+ modifiers |= GIMP_PAINT_TOOL_LINE_MASK;
status = gimp_suggest_modifiers (paint_tool->status,
modifiers & ~state,
diff --git a/app/tools/gimppainttool.h b/app/tools/gimppainttool.h
index 01d0068..9841771 100644
--- a/app/tools/gimppainttool.h
+++ b/app/tools/gimppainttool.h
@@ -22,6 +22,9 @@
#include "gimpcolortool.h"
+#define GIMP_PAINT_TOOL_LINE_MASK (gimp_get_extend_selection_mask ())
+
+
#define GIMP_TYPE_PAINT_TOOL (gimp_paint_tool_get_type ())
#define GIMP_PAINT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PAINT_TOOL,
GimpPaintTool))
#define GIMP_PAINT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PAINT_TOOL,
GimpPaintToolClass))
diff --git a/app/tools/gimpperspectiveclonetool.c b/app/tools/gimpperspectiveclonetool.c
index b6ff187..de39015 100644
--- a/app/tools/gimpperspectiveclonetool.c
+++ b/app/tools/gimpperspectiveclonetool.c
@@ -342,12 +342,13 @@ gimp_perspective_clone_tool_button_press (GimpTool *tool,
case GIMP_PERSPECTIVE_CLONE_MODE_PAINT:
{
+ GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
gdouble nnx, nny;
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
- if ((state & (toggle_mask | GDK_SHIFT_MASK)) == toggle_mask)
+ if ((state & (toggle_mask | extend_mask)) == toggle_mask)
{
source_core->set_source = TRUE;
@@ -569,9 +570,10 @@ gimp_perspective_clone_tool_cursor_update (GimpTool *tool,
}
else
{
+ GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
- if ((state & (toggle_mask | GDK_SHIFT_MASK)) == toggle_mask)
+ if ((state & (toggle_mask | extend_mask)) == toggle_mask)
{
cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
}
diff --git a/app/tools/gimprectangletool.c b/app/tools/gimprectangletool.c
index 99d26e1..0465314 100644
--- a/app/tools/gimprectangletool.c
+++ b/app/tools/gimprectangletool.c
@@ -1242,7 +1242,7 @@ gimp_rectangle_tool_active_modifier_key (GimpTool *tool,
gimp_draw_tool_pause (draw_tool);
- if (key == GDK_SHIFT_MASK)
+ if (key == gimp_get_extend_selection_mask ())
{
/* Here we want to handle manualy when to update the rectangle, so we
* don't want gimp_rectangle_tool_options_notify to do anything.
@@ -1462,7 +1462,7 @@ gimp_rectangle_tool_key_press (GimpTool *tool,
}
/* If the shift key is down, move by an accelerated increment */
- if (kevent->state & GDK_SHIFT_MASK)
+ if (kevent->state & gimp_get_extend_selection_mask ())
{
dx *= ARROW_VELOCITY;
dy *= ARROW_VELOCITY;
diff --git a/app/tools/gimpsourcetool.c b/app/tools/gimpsourcetool.c
index da25c92..7fdc60f 100644
--- a/app/tools/gimpsourcetool.c
+++ b/app/tools/gimpsourcetool.c
@@ -179,11 +179,12 @@ gimp_source_tool_button_press (GimpTool *tool,
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (tool);
GimpSourceCore *source = GIMP_SOURCE_CORE (paint_tool->core);
+ GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
- if ((state & (toggle_mask | GDK_SHIFT_MASK)) == toggle_mask)
+ if ((state & (toggle_mask | extend_mask)) == toggle_mask)
{
source->set_source = TRUE;
@@ -275,9 +276,10 @@ gimp_source_tool_cursor_update (GimpTool *tool,
if (gimp_source_core_use_source (GIMP_SOURCE_CORE (paint_tool->core),
options))
{
+ GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
- if ((state & (toggle_mask | GDK_SHIFT_MASK)) == toggle_mask)
+ if ((state & (toggle_mask | extend_mask)) == toggle_mask)
{
cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
}
diff --git a/app/tools/gimpvectortool.c b/app/tools/gimpvectortool.c
index 19cf519..93d13cc 100644
--- a/app/tools/gimpvectortool.c
+++ b/app/tools/gimpvectortool.c
@@ -61,7 +61,7 @@
#include "gimp-intl.h"
-#define TOGGLE_MASK GDK_SHIFT_MASK
+#define TOGGLE_MASK gimp_get_extend_selection_mask ()
#define MOVE_MASK GDK_MOD1_MASK
#define INSDEL_MASK gimp_get_toggle_behavior_mask ()
@@ -815,7 +815,7 @@ gimp_vector_tool_key_press (GimpTool *tool,
shell = gimp_display_get_shell (draw_tool->display);
- if (kevent->state & GDK_SHIFT_MASK)
+ if (kevent->state & gimp_get_extend_selection_mask ())
pixels = 10.0;
if (kevent->state & gimp_get_toggle_behavior_mask ())
@@ -1198,8 +1198,10 @@ gimp_vector_tool_status_update (GimpTool *tool,
if (proximity)
{
- const gchar *status = NULL;
- gboolean free_status = FALSE;
+ GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
+ GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
+ const gchar *status = NULL;
+ gboolean free_status = FALSE;
switch (vector_tool->function)
{
@@ -1218,7 +1220,7 @@ gimp_vector_tool_status_update (GimpTool *tool,
case VECTORS_ADD_ANCHOR:
status = gimp_suggest_modifiers (_("Click or Click-Drag to create "
"a new anchor"),
- GDK_SHIFT_MASK & ~state,
+ extend_mask & ~state,
NULL, NULL, NULL);
free_status = TRUE;
break;
@@ -1226,8 +1228,6 @@ gimp_vector_tool_status_update (GimpTool *tool,
case VECTORS_MOVE_ANCHOR:
if (options->edit_mode != GIMP_VECTOR_MODE_EDIT)
{
- GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
-
status = gimp_suggest_modifiers (_("Click-Drag to move the "
"anchor around"),
toggle_mask & ~state,
@@ -1247,14 +1247,14 @@ gimp_vector_tool_status_update (GimpTool *tool,
{
status = gimp_suggest_modifiers (_("Click-Drag to move the "
"handle around"),
- GDK_SHIFT_MASK & ~state,
+ extend_mask & ~state,
NULL, NULL, NULL);
}
else
{
status = gimp_suggest_modifiers (_("Click-Drag to move the "
"handles around symmetrically"),
- GDK_SHIFT_MASK & ~state,
+ extend_mask & ~state,
NULL, NULL, NULL);
}
free_status = TRUE;
@@ -1264,12 +1264,12 @@ gimp_vector_tool_status_update (GimpTool *tool,
if (GIMP_VECTOR_TOOL_GET_OPTIONS (tool)->polygonal)
status = gimp_suggest_modifiers (_("Click-Drag to move the "
"anchors around"),
- GDK_SHIFT_MASK & ~state,
+ extend_mask & ~state,
NULL, NULL, NULL);
else
status = gimp_suggest_modifiers (_("Click-Drag to change the "
"shape of the curve"),
- GDK_SHIFT_MASK & ~state,
+ extend_mask & ~state,
_("%s: symmetrical"), NULL, NULL);
free_status = TRUE;
break;
@@ -1277,7 +1277,7 @@ gimp_vector_tool_status_update (GimpTool *tool,
case VECTORS_MOVE_STROKE:
status = gimp_suggest_modifiers (_("Click-Drag to move the "
"component around"),
- GDK_SHIFT_MASK & ~state,
+ extend_mask & ~state,
NULL, NULL, NULL);
free_status = TRUE;
break;
@@ -1289,7 +1289,7 @@ gimp_vector_tool_status_update (GimpTool *tool,
case VECTORS_INSERT_ANCHOR:
status = gimp_suggest_modifiers (_("Click-Drag to insert an anchor "
"on the path"),
- GDK_SHIFT_MASK & ~state,
+ extend_mask & ~state,
NULL, NULL, NULL);
free_status = TRUE;
break;
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index 93837e6..d28ede1 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -552,66 +552,67 @@ gimp_get_mod_string (GdkModifierType modifiers)
#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
+ * @message: initial text for the message
+ * @modifiers: bit mask of modifiers that should be suggested
+ * @extend_selection_format: optional format string for the
+ * "Extend selection" modifier
+ * @toggle_behavior_format: optional format string for the
+ * "Toggle behavior" 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.
+ * strings #extend_selection_format, #toggle_behavior_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 *extend_selection_format,
+ const gchar *toggle_behavior_format,
const gchar *alt_format)
{
- gchar msg_buf[3][BUF_SIZE];
- gint num_msgs = 0;
- gboolean try = FALSE;
+ GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
+ GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
+ gchar msg_buf[3][BUF_SIZE];
+ gint num_msgs = 0;
+ gboolean try = FALSE;
- if (modifiers & GDK_SHIFT_MASK)
+ if (modifiers & extend_mask)
{
- if (shift_format && *shift_format)
+ if (extend_selection_format && *extend_selection_format)
{
- g_snprintf (msg_buf[num_msgs], BUF_SIZE, shift_format,
- gimp_get_mod_string (GDK_SHIFT_MASK));
+ g_snprintf (msg_buf[num_msgs], BUF_SIZE, extend_selection_format,
+ gimp_get_mod_string (extend_mask));
}
else
{
g_strlcpy (msg_buf[num_msgs],
- gimp_get_mod_string (GDK_SHIFT_MASK), BUF_SIZE);
+ gimp_get_mod_string (extend_mask), BUF_SIZE);
try = TRUE;
}
num_msgs++;
}
- /* FIXME: using toggle_behavior_mask is such a hack. The fact that
- * it happens to do the right thing on all platforms doesn't make it
- * any better.
- */
- if (modifiers & gimp_get_toggle_behavior_mask ())
+ if (modifiers & toggle_mask)
{
- if (control_format && *control_format)
+ if (toggle_behavior_format && *toggle_behavior_format)
{
- g_snprintf (msg_buf[num_msgs], BUF_SIZE, control_format,
- gimp_get_mod_string (gimp_get_toggle_behavior_mask ()));
+ g_snprintf (msg_buf[num_msgs], BUF_SIZE, toggle_behavior_format,
+ gimp_get_mod_string (toggle_mask));
}
else
{
g_strlcpy (msg_buf[num_msgs],
- gimp_get_mod_string (gimp_get_toggle_behavior_mask ()), BUF_SIZE);
+ gimp_get_mod_string (toggle_mask), BUF_SIZE);
try = TRUE;
}
diff --git a/app/widgets/gimpwidgets-utils.h b/app/widgets/gimpwidgets-utils.h
index 5a4d11c..3bed890 100644
--- a/app/widgets/gimpwidgets-utils.h
+++ b/app/widgets/gimpwidgets-utils.h
@@ -57,8 +57,8 @@ GimpTabStyle gimp_preview_tab_style_to_icon (GimpTabStyle tab_st
const gchar * gimp_get_mod_string (GdkModifierType modifiers);
gchar * gimp_suggest_modifiers (const gchar *message,
GdkModifierType modifiers,
- const gchar *shift_format,
- const gchar *control_format,
+ const gchar *extend_selection_format,
+ const gchar *toggle_behavior_format,
const gchar *alt_format);
GimpChannelOps gimp_modifiers_to_channel_op (GdkModifierType modifiers);
GdkModifierType gimp_replace_virtual_modifiers (GdkModifierType modifiers);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]