From 3d83d3a0a20438f921fa19cd193e145de36515f1 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Sat, 7 May 2005 10:16:01 +0000 Subject: [PATCH] added modifier keys to the tooltips of the selection mode buttons. 2005-05-07 Sven Neumann * app/tools/gimpselectionoptions.c: added modifier keys to the tooltips of the selection mode buttons. --- ChangeLog | 3 ++ app/tools/gimpselectionoptions.c | 63 ++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index f32cb20389..39f0aaa255 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2005-05-07 Sven Neumann + * app/tools/gimpselectionoptions.c: added modifier keys to the + tooltips of the selection mode buttons. + * app/dialogs/preferences-dialog.c: removed the GUI for the "default-threshold" preference. diff --git a/app/tools/gimpselectionoptions.c b/app/tools/gimpselectionoptions.c index 93699199ac..cfac5bdf45 100644 --- a/app/tools/gimpselectionoptions.c +++ b/app/tools/gimpselectionoptions.c @@ -345,6 +345,33 @@ gimp_selection_options_reset (GimpToolOptions *tool_options) GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options); } +static const gchar * +gimp_selection_options_get_modifier (GimpChannelOps operation) +{ + GdkModifierType mod = 0; + + switch (operation) + { + case GIMP_CHANNEL_OP_ADD: + mod = GDK_SHIFT_MASK; + break; + + case GIMP_CHANNEL_OP_SUBTRACT: + mod = GDK_CONTROL_MASK; + break; + + case GIMP_CHANNEL_OP_REPLACE: + mod = 0; + break; + + case GIMP_CHANNEL_OP_INTERSECT: + mod = GDK_CONTROL_MASK | GDK_SHIFT_MASK; + break; + } + + return gimp_get_mod_string (mod); +} + GtkWidget * gimp_selection_options_gui (GimpToolOptions *tool_options) { @@ -359,17 +386,45 @@ gimp_selection_options_gui (GimpToolOptions *tool_options) { GtkWidget *hbox; GtkWidget *label; + GList *children; GList *list; + gint i; hbox = gimp_prop_enum_stock_box_new (config, "operation", "gimp-selection", 0, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); - list = gtk_container_get_children (GTK_CONTAINER (hbox)); - gtk_box_reorder_child (GTK_BOX (hbox), GTK_WIDGET (list->next->next->data), - 0); - g_list_free (list); + children = gtk_container_get_children (GTK_CONTAINER (hbox)); + + /* add modifier keys to the tooltips */ + for (list = children, i = 0; list; list = list->next, i++) + { + GtkWidget *button = list->data; + GtkTooltipsData *data = gtk_tooltips_data_get (button); + const gchar *modifier = gimp_selection_options_get_modifier (i); + + if (! modifier) + continue; + + if (data && data->tip_text) + { + gchar *tip = g_strdup_printf ("%s %s", data->tip_text, modifier); + + gimp_help_set_help_data (button, tip, NULL); + g_free (tip); + } + else + { + gimp_help_set_help_data (button, modifier, NULL); + } + } + + /* move GIMP_CHANNEL_OP_REPLACE to the front */ + gtk_box_reorder_child (GTK_BOX (hbox), + GTK_WIDGET (children->next->next->data), 0); + + g_list_free (children); label = gtk_label_new (_("Mode:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);