added new function gimp_get_mod_string() which takes a GdkModifierType and

2004-06-29  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpwidgets-utils.[ch]: added new function
	gimp_get_mod_string() which takes a GdkModifierType and returns
	correctly formated strings for all shift,control,alt combinations.

	* app/tools/gimpbucketfilloptions.c
	* app/tools/gimpcolorpickeroptions.c
	* app/tools/gimpconvolvetool.c
	* app/tools/gimpcropoptions.c
	* app/tools/gimpdodgeburntool.c
	* app/tools/gimperasertool.c
	* app/tools/gimpflipoptions.c
	* app/tools/gimpmagnifyoptions.c
	* app/tools/gimpmoveoptions.c
	* app/tools/gimptransformoptions.c
	* app/tools/gimpvectoroptions.c
	* app/widgets/gimpchanneltreeview.c
	* app/widgets/gimpcolormapeditor.c
	* app/widgets/gimpdocumentview.c
	* app/widgets/gimperrorconsole.c
	* app/widgets/gimpgradienteditor.c
	* app/widgets/gimpitemtreeview.c
	* app/widgets/gimppaletteeditor.c
	* app/widgets/gimpselectioneditor.c
	* app/widgets/gimpthumbbox.c
	* app/widgets/gimptooloptionseditor.c
	* app/widgets/gimpvectorstreeview.c: use the new function instead
	of gimp_get_mod_name_shift(),control(),alt(),separator(). This
	kindof addresses the issue of configurable modifier keys but is
	actually indended to ease translation of format strings ("%s" is
	easier to get right than "%s%s%s").
This commit is contained in:
Michael Natterer 2004-06-28 23:30:57 +00:00 committed by Michael Natterer
parent 6a5e68c9e2
commit 6cd5737257
25 changed files with 170 additions and 64 deletions

View file

@ -1,3 +1,36 @@
2004-06-29 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpwidgets-utils.[ch]: added new function
gimp_get_mod_string() which takes a GdkModifierType and returns
correctly formated strings for all shift,control,alt combinations.
* app/tools/gimpbucketfilloptions.c
* app/tools/gimpcolorpickeroptions.c
* app/tools/gimpconvolvetool.c
* app/tools/gimpcropoptions.c
* app/tools/gimpdodgeburntool.c
* app/tools/gimperasertool.c
* app/tools/gimpflipoptions.c
* app/tools/gimpmagnifyoptions.c
* app/tools/gimpmoveoptions.c
* app/tools/gimptransformoptions.c
* app/tools/gimpvectoroptions.c
* app/widgets/gimpchanneltreeview.c
* app/widgets/gimpcolormapeditor.c
* app/widgets/gimpdocumentview.c
* app/widgets/gimperrorconsole.c
* app/widgets/gimpgradienteditor.c
* app/widgets/gimpitemtreeview.c
* app/widgets/gimppaletteeditor.c
* app/widgets/gimpselectioneditor.c
* app/widgets/gimpthumbbox.c
* app/widgets/gimptooloptionseditor.c
* app/widgets/gimpvectorstreeview.c: use the new function instead
of gimp_get_mod_name_shift(),control(),alt(),separator(). This
kindof addresses the issue of configurable modifier keys but is
actually indended to ease translation of format strings ("%s" is
easier to get right than "%s%s%s").
2004-06-28 Michael Natterer <mitch@gimp.org>
Allow all sorts of things to be dropped on or in between the

View file

@ -255,7 +255,8 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
vbox = gimp_paint_options_gui (tool_options);
/* fill type */
str = g_strdup_printf (_("Fill Type %s"), gimp_get_mod_name_control ());
str = g_strdup_printf (_("Fill Type %s"),
gimp_get_mod_string (GDK_CONTROL_MASK)),
frame = gimp_prop_enum_radio_frame_new (config, "fill-mode", str, 0, 0);
g_free (str);
@ -263,7 +264,8 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
gtk_widget_show (frame);
/* fill selection */
str = g_strdup_printf (_("Affected Area %s"), gimp_get_mod_name_shift ());
str = g_strdup_printf (_("Affected Area %s"),
gimp_get_mod_string (GDK_SHIFT_MASK));
frame = gimp_prop_boolean_radio_frame_new (config, "fill-selection",
str,
_("Fill whole selection"),

View file

@ -172,7 +172,8 @@ gimp_color_picker_options_gui (GimpToolOptions *tool_options)
gtk_widget_show (button);
/* the pick FG/BG frame */
str = g_strdup_printf (_("Pick Mode %s"), gimp_get_mod_name_control ());
str = g_strdup_printf (_("Pick Mode %s"),
gimp_get_mod_string (GDK_CONTROL_MASK));
frame = gimp_prop_enum_radio_frame_new (config, "pick-mode", str, -1, -1);
g_free (str);

View file

@ -191,7 +191,7 @@ gimp_convolve_options_gui (GimpToolOptions *tool_options)
/* the type radio box */
str = g_strdup_printf (_("Convolve Type %s"),
gimp_get_mod_name_control ());
gimp_get_mod_string (GDK_CONTROL_MASK));
frame = gimp_prop_enum_radio_frame_new (config, "type",
str, 0, 0);

View file

@ -195,7 +195,8 @@ gimp_crop_options_gui (GimpToolOptions *tool_options)
vbox = gimp_tool_options_gui (tool_options);
/* tool toggle */
str = g_strdup_printf (_("Tool Toggle %s"), gimp_get_mod_name_control ());
str = g_strdup_printf (_("Tool Toggle %s"),
gimp_get_mod_string (GDK_CONTROL_MASK));
frame = gimp_prop_enum_radio_frame_new (config, "crop-mode",
str, 0, 0);
@ -211,7 +212,8 @@ gimp_crop_options_gui (GimpToolOptions *tool_options)
gtk_widget_show (button);
/* enlarge toggle */
str = g_strdup_printf (_("Allow enlarging %s"), gimp_get_mod_name_alt ());
str = g_strdup_printf (_("Allow enlarging %s"),
gimp_get_mod_string (GDK_MOD1_MASK));
button = gimp_prop_check_button_new (config, "allow-enlarge", str);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
@ -220,7 +222,8 @@ gimp_crop_options_gui (GimpToolOptions *tool_options)
g_free (str);
/* layer toggle */
str = g_strdup_printf (_("Keep aspect ratio %s"), gimp_get_mod_name_shift());
str = g_strdup_printf (_("Keep aspect ratio %s"),
gimp_get_mod_string (GDK_SHIFT_MASK));
button = gimp_prop_check_button_new (config, "keep-aspect", str);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);

View file

@ -189,7 +189,8 @@ gimp_dodge_burn_options_gui (GimpToolOptions *tool_options)
vbox = gimp_paint_options_gui (tool_options);
/* the type (dodge or burn) */
str = g_strdup_printf (_("Type %s"), gimp_get_mod_name_control ());
str = g_strdup_printf (_("Type %s"),
gimp_get_mod_string (GDK_CONTROL_MASK));
frame = gimp_prop_enum_radio_frame_new (config, "type",
str, 0, 0);

View file

@ -182,7 +182,8 @@ gimp_eraser_options_gui (GimpToolOptions *tool_options)
vbox = gimp_paint_options_gui (tool_options);
/* the anti_erase toggle */
str = g_strdup_printf (_("Anti erase %s"), gimp_get_mod_name_alt ());
str = g_strdup_printf (_("Anti erase %s"),
gimp_get_mod_string (GDK_MOD1_MASK));
button = gimp_prop_check_button_new (config, "anti-erase", str);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

View file

@ -178,7 +178,8 @@ gimp_flip_options_gui (GimpToolOptions *tool_options)
gtk_widget_show (label);
/* tool toggle */
str = g_strdup_printf (_("Flip Type %s"), gimp_get_mod_name_control ());
str = g_strdup_printf (_("Flip Type %s"),
gimp_get_mod_string (GDK_CONTROL_MASK));
frame = gimp_prop_enum_radio_frame_new (config, "flip-type",
str,

View file

@ -227,7 +227,8 @@ gimp_magnify_options_gui (GimpToolOptions *tool_options)
gtk_widget_show (button);
/* tool toggle */
str = g_strdup_printf (_("Tool Toggle %s"), gimp_get_mod_name_control ());
str = g_strdup_printf (_("Tool Toggle %s"),
gimp_get_mod_string (GDK_CONTROL_MASK));
frame = gimp_prop_enum_radio_frame_new (config, "zoom-type",
str, 0, 0);

View file

@ -225,7 +225,8 @@ gimp_move_options_gui (GimpToolOptions *tool_options)
gtk_widget_show (label);
/* tool toggle */
title = g_strdup_printf (_("Tool Toggle %s"), gimp_get_mod_name_shift ());
title = g_strdup_printf (_("Tool Toggle %s"),
gimp_get_mod_string (GDK_SHIFT_MASK));
frame = gimp_prop_boolean_radio_frame_new (config, "move-current",
title, "true", "false");

View file

@ -324,14 +324,14 @@ gimp_scale_constraints_callback (GtkWidget *widget,
value = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
"gimp-item-data"));
c0 = c1 = FALSE;
if (value == 1 || value == 3)
c0 = TRUE;
if (value == 2 || value == 3)
c1 = TRUE;
g_object_set (config,
"constrain-1", c0,
"constrain-2", c1,
@ -398,7 +398,7 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
button = gimp_prop_check_button_new (config, "show-preview", _("Preview"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* the grid frame */
frame = gimp_frame_new (NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
@ -431,10 +431,6 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
{
GtkWidget *vbox2;
GtkWidget *vbox3;
gchar *str;
gchar *str1;
gchar *str2;
gchar *str3;
/* the constraints frame */
frame = gimp_frame_new (_("Constraints"));
@ -448,8 +444,10 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
if (tool_options->tool_info->tool_type == GIMP_TYPE_ROTATE_TOOL)
{
gchar *str;
str = g_strdup_printf (_("15 degrees %s"),
gimp_get_mod_name_control ());
gimp_get_mod_string (GDK_CONTROL_MASK));
button = gimp_prop_check_button_new (config, "constrain-1", str);
gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
@ -459,17 +457,22 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
}
else if (tool_options->tool_info->tool_type == GIMP_TYPE_SCALE_TOOL)
{
g_object_set (config,
gchar *str1;
gchar *str2;
gchar *str3;
g_object_set (config,
"constrain-1", FALSE,
"constrain-2", FALSE,
NULL);
str1 = g_strdup_printf (_("Keep height %s"),
gimp_get_mod_name_control ());
gimp_get_mod_string (GDK_SHIFT_MASK));
str2 = g_strdup_printf (_("Keep width %s"),
gimp_get_mod_name_alt ());
str3 = g_strdup_printf (_("Keep aspect %s-%s"),
gimp_get_mod_name_control (), gimp_get_mod_name_alt ());
gimp_get_mod_string (GDK_MOD1_MASK));
str3 = g_strdup_printf (_("Keep aspect %s"),
gimp_get_mod_string (GDK_CONTROL_MASK |
GDK_MOD1_MASK));
vbox3 = gimp_int_radio_group_new (FALSE, NULL,
G_CALLBACK (gimp_scale_constraints_callback),
@ -481,7 +484,7 @@ gimp_transform_options_gui (GimpToolOptions *tool_options)
str3, 3, NULL,
NULL);
gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
gtk_widget_show (vbox3);

View file

@ -197,12 +197,11 @@ gimp_vector_options_gui (GimpToolOptions *tool_options)
str = g_strdup_printf (_("Path to Selection\n"
"%s Add\n"
"%s Subtract\n"
"%s%s%s Intersect"),
gimp_get_mod_name_shift (),
gimp_get_mod_name_control (),
gimp_get_mod_name_shift (),
gimp_get_mod_separator (),
gimp_get_mod_name_control ());
"%s Intersect"),
gimp_get_mod_string (GDK_SHIFT_MASK),
gimp_get_mod_string (GDK_CONTROL_MASK),
gimp_get_mod_string (GDK_SHIFT_MASK |
GDK_CONTROL_MASK));
button = gimp_button_new ();
gtk_button_set_label (GTK_BUTTON (button), _("Create selection from path"));

View file

@ -166,12 +166,11 @@ gimp_channel_tree_view_constructor (GType type,
str = g_strdup_printf (_("Channel to selection\n"
"%s Add\n"
"%s Subtract\n"
"%s%s%s Intersect"),
gimp_get_mod_name_shift (),
gimp_get_mod_name_control (),
gimp_get_mod_name_shift (),
gimp_get_mod_separator (),
gimp_get_mod_name_control ());
"%s Intersect"),
gimp_get_mod_string (GDK_SHIFT_MASK),
gimp_get_mod_string (GDK_CONTROL_MASK),
gimp_get_mod_string (GDK_SHIFT_MASK |
GDK_CONTROL_MASK));
view->toselection_button =
gimp_editor_add_action_button (GIMP_EDITOR (view), "channels",

View file

@ -239,7 +239,7 @@ gimp_colormap_editor_constructor (GType type,
editor);
str = g_strdup_printf (_("Add color from FG\n%s from BG"),
gimp_get_mod_name_control ());
gimp_get_mod_string (GDK_CONTROL_MASK));
editor->add_button =
gimp_editor_add_action_button (GIMP_EDITOR (editor), "colormap-editor",
"colormap-editor-add-color-from-fg",

View file

@ -130,8 +130,8 @@ gimp_document_view_new (GimpViewType view_type,
str = g_strdup_printf (_("Open the selected entry\n"
"%s Raise window if already open\n"
"%s Open image dialog"),
gimp_get_mod_name_shift (),
gimp_get_mod_name_control ());
gimp_get_mod_string (GDK_SHIFT_MASK),
gimp_get_mod_string (GDK_CONTROL_MASK));
document_view->open_button =
gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "documents",
@ -159,8 +159,8 @@ gimp_document_view_new (GimpViewType view_type,
str = g_strdup_printf (_("Recreate preview\n"
"%s Reload all previews\n"
"%s Remove Dangling Entries"),
gimp_get_mod_name_shift (),
gimp_get_mod_name_control ());
gimp_get_mod_string (GDK_SHIFT_MASK),
gimp_get_mod_string (GDK_CONTROL_MASK));
document_view->refresh_button =
gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "documents",

View file

@ -180,7 +180,7 @@ gimp_error_console_init (GimpErrorConsole *console)
str = g_strdup_printf (_("Save all errors\n"
"%s Save selection"),
gimp_get_mod_name_shift ());
gimp_get_mod_string (GDK_SHIFT_MASK));
console->save_button =
gimp_editor_add_button (GIMP_EDITOR (console),

View file

@ -1123,7 +1123,7 @@ control_do_hint (GimpGradientEditor *editor,
if (seg->prev != NULL)
{
str = g_strdup_printf (_("%s%sDrag: move & compress"),
gimp_get_mod_name_shift (),
gimp_get_mod_string (GDK_SHIFT_MASK),
gimp_get_mod_separator ());
gradient_editor_set_hint (editor,
@ -1136,7 +1136,7 @@ control_do_hint (GimpGradientEditor *editor,
else
{
str = g_strdup_printf (_("%s%sClick: extend selection"),
gimp_get_mod_name_shift (),
gimp_get_mod_string (GDK_SHIFT_MASK),
gimp_get_mod_separator ());
gradient_editor_set_hint (editor,
@ -1150,7 +1150,7 @@ control_do_hint (GimpGradientEditor *editor,
else
{
str = g_strdup_printf (_("%s%sClick: extend selection"),
gimp_get_mod_name_shift (),
gimp_get_mod_string (GDK_SHIFT_MASK),
gimp_get_mod_separator ());
gradient_editor_set_hint (editor,
@ -1164,7 +1164,7 @@ control_do_hint (GimpGradientEditor *editor,
case GRAD_DRAG_MIDDLE:
str = g_strdup_printf (_("%s%sClick: extend selection"),
gimp_get_mod_name_shift (),
gimp_get_mod_string (GDK_SHIFT_MASK),
gimp_get_mod_separator ());
gradient_editor_set_hint (editor,
@ -1186,10 +1186,10 @@ control_do_hint (GimpGradientEditor *editor,
gchar *str2;
str = g_strdup_printf (_("%s%sClick: extend selection"),
gimp_get_mod_name_shift (),
gimp_get_mod_string (GDK_SHIFT_MASK),
gimp_get_mod_separator ());
str2 = g_strdup_printf (_("%s%sDrag: move & compress"),
gimp_get_mod_name_shift (),
gimp_get_mod_string (GDK_SHIFT_MASK),
gimp_get_mod_separator ());
gradient_editor_set_hint (editor,

View file

@ -348,7 +348,7 @@ gimp_item_tree_view_init (GimpItemTreeView *view,
view);
str = g_strdup_printf (view_class->new_desc,
gimp_get_mod_name_shift ());
gimp_get_mod_string (GDK_SHIFT_MASK));
view->new_button =
gimp_editor_add_button (editor,
@ -362,7 +362,7 @@ gimp_item_tree_view_init (GimpItemTreeView *view,
str = g_strdup_printf (_("%s\n"
"%s To Top"),
view_class->raise_desc,
gimp_get_mod_name_shift ());
gimp_get_mod_string (GDK_SHIFT_MASK));
view->raise_button =
gimp_editor_add_button (editor,
@ -376,7 +376,7 @@ gimp_item_tree_view_init (GimpItemTreeView *view,
str = g_strdup_printf (_("%s\n"
"%s To Bottom"),
view_class->lower_desc,
gimp_get_mod_name_shift ());
gimp_get_mod_string (GDK_SHIFT_MASK));
view->lower_button =
gimp_editor_add_button (editor,

View file

@ -308,7 +308,7 @@ gimp_palette_editor_init (GimpPaletteEditor *editor)
editor);
str = g_strdup_printf (_("New color from FG\n%s from BG"),
gimp_get_mod_name_control ());
gimp_get_mod_string (GDK_CONTROL_MASK));
editor->new_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
GTK_STOCK_NEW, str,

View file

@ -182,7 +182,7 @@ gimp_selection_editor_constructor (GType type,
str = g_strdup_printf (_("Selection to path\n"
"%s Advanced options"),
gimp_get_mod_name_shift ());
gimp_get_mod_string (GDK_SHIFT_MASK));
editor->path_button =
gimp_editor_add_action_button (GIMP_EDITOR (editor), "vectors",

View file

@ -189,7 +189,7 @@ gimp_thumb_box_new (Gimp *gimp)
str = g_strdup_printf (_("Click to update preview\n"
"%s Click to force update even "
"if preview is up-to-date"),
gimp_get_mod_name_control ());
gimp_get_mod_string (GDK_CONTROL_MASK));
gimp_help_set_help_data (ebox, str, NULL);

View file

@ -207,7 +207,7 @@ gimp_tool_options_editor_constructor (GType type,
str = g_strdup_printf (_("Reset to default values\n"
"%s Reset all Tool Options"),
gimp_get_mod_name_shift ());
gimp_get_mod_string (GDK_SHIFT_MASK));
editor->reset_button =
gimp_editor_add_action_button (GIMP_EDITOR (editor), "tool-options",
"tool-options-reset",

View file

@ -145,12 +145,11 @@ gimp_vectors_tree_view_constructor (GType type,
str = g_strdup_printf (_("Path to Selection\n"
"%s Add\n"
"%s Subtract\n"
"%s%s%s Intersect"),
gimp_get_mod_name_shift (),
gimp_get_mod_name_control (),
gimp_get_mod_name_shift (),
gimp_get_mod_separator (),
gimp_get_mod_name_control ());
"%s Intersect"),
gimp_get_mod_string (GDK_SHIFT_MASK),
gimp_get_mod_string (GDK_CONTROL_MASK),
gimp_get_mod_string (GDK_SHIFT_MASK |
GDK_CONTROL_MASK));
view->toselection_button =
gimp_editor_add_action_button (editor, "vectors",
@ -170,7 +169,7 @@ gimp_vectors_tree_view_constructor (GType type,
str = g_strdup_printf (_("Selection to Path\n"
"%s Advanced Options"),
gimp_get_mod_name_shift ());
gimp_get_mod_string (GDK_SHIFT_MASK));
view->tovectors_button =
gimp_editor_add_action_button (editor, "vectors",

View file

@ -600,6 +600,67 @@ gimp_get_mod_separator (void)
return (const gchar *) mod_separator;
}
const gchar *
gimp_get_mod_string (GdkModifierType modifiers)
{
static struct
{
GdkModifierType modifiers;
gchar *name;
}
modifier_strings[] =
{
{ GDK_SHIFT_MASK, NULL },
{ GDK_CONTROL_MASK, NULL },
{ GDK_MOD1_MASK, NULL },
{ GDK_SHIFT_MASK | GDK_CONTROL_MASK, NULL },
{ GDK_SHIFT_MASK | GDK_MOD1_MASK, NULL },
{ GDK_CONTROL_MASK | GDK_MOD1_MASK, NULL },
{ GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK, NULL }
};
gint i;
for (i = 0; i < G_N_ELEMENTS (modifier_strings); i++)
{
if (modifiers == modifier_strings[i].modifiers)
{
if (! modifier_strings[i].name)
{
GString *str = g_string_new ("");
if (modifiers & GDK_SHIFT_MASK)
{
g_string_append (str, gimp_get_mod_name_shift ());
}
if (modifiers & GDK_CONTROL_MASK)
{
if (str->len)
g_string_append (str, gimp_get_mod_separator ());
g_string_append (str, gimp_get_mod_name_control ());
}
if (modifiers & GDK_MOD1_MASK)
{
if (str->len)
g_string_append (str, gimp_get_mod_separator ());
g_string_append (str, gimp_get_mod_name_alt ());
}
modifier_strings[i].name = g_string_free (str, FALSE);
}
return modifier_strings[i].name;
}
}
return "<BUG: unsupported modifiers>";
}
/**
* gimp_get_screen_resolution:
* @screen: a #GdkScreen or %NULL

View file

@ -56,6 +56,7 @@ const gchar * gimp_get_mod_name_shift (void);
const gchar * gimp_get_mod_name_control (void);
const gchar * gimp_get_mod_name_alt (void);
const gchar * gimp_get_mod_separator (void);
const gchar * gimp_get_mod_string (GdkModifierType modifiers);
void gimp_get_screen_resolution (GdkScreen *screen,
gdouble *xres,