Revision: 4389 http://geany.svn.sourceforge.net/geany/?rev=4389&view=rev Author: ntrel Date: 2009-10-29 11:59:55 +0000 (Thu, 29 Oct 2009)
Log Message: ----------- Allow GeanyKeyBinding label field to contain underscores, which won't be displayed by Geany. This saves adding near-duplicate translation strings. Add mnemonics for 3 Edit->Format menu items. Add keybindings_get_label().
Modified Paths: -------------- trunk/ChangeLog trunk/geany.glade trunk/plugins/splitwindow.c trunk/src/interface.c trunk/src/keybindings.c trunk/src/keybindings.h trunk/src/prefs.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-10-29 11:31:48 UTC (rev 4388) +++ trunk/ChangeLog 2009-10-29 11:59:55 UTC (rev 4389) @@ -3,6 +3,13 @@ * src/pluginutils.c: Don't expand Plugin Preferences page spacing vertically to fill the height of the dialog. + * src/interface.c, src/keybindings.c, src/keybindings.h, src/prefs.c, + geany.glade, plugins/splitwindow.c: + Allow GeanyKeyBinding label field to contain underscores, which won't + be displayed by Geany. This saves adding near-duplicate translation + strings. + Add mnemonics for 3 Edit->Format menu items. + Add keybindings_get_label().
2009-10-28 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/geany.glade =================================================================== --- trunk/geany.glade 2009-10-29 11:31:48 UTC (rev 4388) +++ trunk/geany.glade 2009-10-29 11:59:55 UTC (rev 4389) @@ -428,7 +428,7 @@ <child> <widget class="GtkMenuItem" id="reflow_lines/block1"> <property name="visible">True</property> - <property name="label" translatable="yes">Reflow Lines/Block</property> + <property name="label" translatable="yes">_Reflow Lines/Block</property> <property name="use_underline">True</property> <signal name="activate" handler="on_reflow_lines/block1_activate" last_modification_time="Wed, 28 Oct 2009 11:13:48 GMT"/> </widget> @@ -446,7 +446,7 @@ <child> <widget class="GtkMenuItem" id="transpose_current_line1"> <property name="visible">True</property> - <property name="label" translatable="yes">Transpose Current Line</property> + <property name="label" translatable="yes">_Transpose Current Line</property> <property name="use_underline">True</property> <signal name="activate" handler="on_transpose_current_line1_activate" last_modification_time="Wed, 28 Oct 2009 11:13:48 GMT"/> </widget> @@ -536,7 +536,7 @@ <child> <widget class="GtkMenuItem" id="smart_line_indent1"> <property name="visible">True</property> - <property name="label" translatable="yes">Smart Line Indent</property> + <property name="label" translatable="yes">_Smart Line Indent</property> <property name="use_underline">True</property> <signal name="activate" handler="on_smart_line_indent1_activate" last_modification_time="Wed, 28 Oct 2009 11:13:48 GMT"/> </widget>
Modified: trunk/plugins/splitwindow.c =================================================================== --- trunk/plugins/splitwindow.c 2009-10-29 11:31:48 UTC (rev 4388) +++ trunk/plugins/splitwindow.c 2009-10-29 11:59:55 UTC (rev 4389) @@ -401,7 +401,7 @@ keybindings_set_item(key_group, KB_SPLIT_VERTICAL, kb_activate, 0, 0, "split_vertical", _("Split Vertically"), menu_items.vertical); keybindings_set_item(key_group, KB_SPLIT_UNSPLIT, kb_activate, - 0, 0, "split_unsplit", _("Unsplit"), menu_items.unsplit); + 0, 0, "split_unsplit", _("_Unsplit"), menu_items.unsplit); }
Modified: trunk/src/interface.c =================================================================== --- trunk/src/interface.c 2009-10-29 11:31:48 UTC (rev 4388) +++ trunk/src/interface.c 2009-10-29 11:59:55 UTC (rev 4389) @@ -483,7 +483,7 @@ menu_format1_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_format1), menu_format1_menu);
- reflow_lines_block1 = gtk_menu_item_new_with_mnemonic (_("Reflow Lines/Block")); + reflow_lines_block1 = gtk_menu_item_new_with_mnemonic (_("_Reflow Lines/Block")); gtk_widget_show (reflow_lines_block1); gtk_container_add (GTK_CONTAINER (menu_format1_menu), reflow_lines_block1);
@@ -491,7 +491,7 @@ gtk_widget_show (menu_toggle_case2); gtk_container_add (GTK_CONTAINER (menu_format1_menu), menu_toggle_case2);
- transpose_current_line1 = gtk_menu_item_new_with_mnemonic (_("Transpose Current Line")); + transpose_current_line1 = gtk_menu_item_new_with_mnemonic (_("_Transpose Current Line")); gtk_widget_show (transpose_current_line1); gtk_container_add (GTK_CONTAINER (menu_format1_menu), transpose_current_line1);
@@ -533,7 +533,7 @@ gtk_widget_show (image3148); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_decrease_indent1), image3148);
- smart_line_indent1 = gtk_menu_item_new_with_mnemonic (_("Smart Line Indent")); + smart_line_indent1 = gtk_menu_item_new_with_mnemonic (_("_Smart Line Indent")); gtk_widget_show (smart_line_indent1); gtk_container_add (GTK_CONTAINER (menu_format1_menu), smart_line_indent1);
Modified: trunk/src/keybindings.c =================================================================== --- trunk/src/keybindings.c 2009-10-29 11:31:48 UTC (rev 4388) +++ trunk/src/keybindings.c 2009-10-29 11:59:55 UTC (rev 4389) @@ -134,7 +134,8 @@ * @param key (Lower case) default key, e.g. @c GDK_j, but usually 0 for unset. * @param mod Default modifier, e.g. @c GDK_CONTROL_MASK, but usually 0 for unset. * @param kf_name Key name for the configuration file, such as @c "menu_new". - * @param label Label used in the preferences dialog keybindings tab. + * @param label Label used in the preferences dialog keybindings tab. May contain + * underscores - these won't be displayed. * @param menu_item Optional widget to set an accelerator for, or @c NULL. * @return The keybinding - normally this is ignored. */ GeanyKeyBinding *keybindings_set_item(GeanyKeyGroup *group, gsize key_id, @@ -266,7 +267,7 @@ _("Delete to line end"), NULL); /* transpose may fit better in format group */ keybindings_set_item(group, GEANY_KEYS_EDITOR_TRANSPOSELINE, NULL, - GDK_t, GDK_CONTROL_MASK, "edit_transposeline", _("Transpose Current Line"), + GDK_t, GDK_CONTROL_MASK, "edit_transposeline", _("_Transpose Current Line"), LW(transpose_current_line1)); keybindings_set_item(group, GEANY_KEYS_EDITOR_SCROLLTOLINE, NULL, GDK_l, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "edit_scrolltoline", _("Scroll to current line"), NULL); @@ -350,7 +351,7 @@ keybindings_set_item(group, GEANY_KEYS_FORMAT_DECREASEINDENTBYSPACE, NULL, 0, 0, "edit_decreaseindentbyspace", _("Decrease indent by one space"), NULL); keybindings_set_item(group, GEANY_KEYS_FORMAT_AUTOINDENT, NULL, - 0, 0, "edit_autoindent", _("Smart Line Indent"), LW(smart_line_indent1)); + 0, 0, "edit_autoindent", _("_Smart Line Indent"), LW(smart_line_indent1)); keybindings_set_item(group, GEANY_KEYS_FORMAT_SENDTOCMD1, NULL, GDK_1, GDK_CONTROL_MASK, "edit_sendtocmd1", _("Send to Custom Command 1"), NULL); keybindings_set_item(group, GEANY_KEYS_FORMAT_SENDTOCMD2, NULL, @@ -360,7 +361,7 @@ keybindings_set_item(group, GEANY_KEYS_FORMAT_SENDTOVTE, NULL, 0, 0, "edit_sendtovte", _("Send Selection to Terminal"), LW(send_selection_to_vte1)); keybindings_set_item(group, GEANY_KEYS_FORMAT_REFLOWPARAGRAPH, NULL, - GDK_j, GDK_CONTROL_MASK, "format_reflowparagraph", _("Reflow Lines/Block"), + GDK_j, GDK_CONTROL_MASK, "format_reflowparagraph", _("_Reflow Lines/Block"), LW(reflow_lines_block1));
group = ADD_KB_GROUP(INSERT, _("Insert"), cb_func_insert_action); @@ -776,10 +777,15 @@ }
+gchar *keybindings_get_label(GeanyKeyBinding *kb) +{ + return utils_str_remove_chars(g_strdup(kb->label), "_"); +} + + static void fill_shortcut_labels_treeview(GtkWidget *tree) { gsize g, i; - gchar *shortcut; GeanyKeyBinding *kb; GeanyKeyGroup *group; GtkListStore *store; @@ -802,13 +808,17 @@
for (i = 0; i < group->count; i++) { + gchar *shortcut, *label; + kb = &group->keys[i]; + label = keybindings_get_label(kb); shortcut = gtk_accelerator_get_label(kb->key, kb->mods);
gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, 0, kb->label, 1, shortcut, 2, PANGO_WEIGHT_NORMAL, -1); + gtk_list_store_set(store, &iter, 0, label, 1, shortcut, 2, PANGO_WEIGHT_NORMAL, -1);
g_free(shortcut); + g_free(label); } }
Modified: trunk/src/keybindings.h =================================================================== --- trunk/src/keybindings.h 2009-10-29 11:31:48 UTC (rev 4388) +++ trunk/src/keybindings.h 2009-10-29 11:59:55 UTC (rev 4389) @@ -41,7 +41,9 @@ guint key; /**< Key value in lower-case, such as @c GDK_a or 0 */ GdkModifierType mods; /**< Modifier keys, such as @c GDK_CONTROL_MASK or 0 */ gchar *name; /**< Key name for the configuration file, such as @c "menu_new" */ - gchar *label; /**< Label used in the preferences dialog keybindings tab */ + /** Label used in the preferences dialog keybindings tab. + * May contain underscores - these won't be displayed. */ + gchar *label; /** Function called when the key combination is pressed, or @c NULL to use the group callback * (preferred). @see plugin_set_key_group(). */ GeanyKeyCallback callback; @@ -351,6 +353,8 @@
GeanyKeyBinding *keybindings_get_item(GeanyKeyGroup *group, gsize key_id);
+gchar *keybindings_get_label(GeanyKeyBinding *kb); + void keybindings_update_combo(GeanyKeyBinding *kb, guint key, GdkModifierType mods);
void keybindings_send_command(guint group_id, guint key_id);
Modified: trunk/src/prefs.c =================================================================== --- trunk/src/prefs.c 2009-10-29 11:31:48 UTC (rev 4388) +++ trunk/src/prefs.c 2009-10-29 11:59:55 UTC (rev 4389) @@ -297,7 +297,7 @@ { GtkTreeIter parent, iter; gsize g, i; - gchar *key_string; + gchar *key_string, *label; GeanyKeyGroup *group; GeanyKeyBinding *kb;
@@ -316,11 +316,13 @@ { kb = &group->keys[i];
+ label = keybindings_get_label(kb); key_string = gtk_accelerator_name(kb->key, kb->mods); gtk_tree_store_append(store, &iter, &parent); - gtk_tree_store_set(store, &iter, KB_TREE_ACTION, kb->label, + gtk_tree_store_set(store, &iter, KB_TREE_ACTION, label, KB_TREE_SHORTCUT, key_string, KB_TREE_INDEX, i, -1); g_free(key_string); + g_free(label); } } gtk_tree_view_expand_all(GTK_TREE_VIEW(tree)); @@ -1400,12 +1402,15 @@ if (kb->key == key && kb->mods == mods && ! (kb->key == search_kb->key && kb->mods == search_kb->mods)) { + gchar *label = keybindings_get_label(kb); gint ret = dialogs_show_prompt(main_widgets.window, _("_Override"), GTK_STOCK_CANCEL, _("_Allow"), _("Override that keybinding?"), _("The combination '%s' is already used for "%s"."), - action, kb->label); + action, label);
+ g_free(label); + if (ret == GTK_RESPONSE_YES) { keybindings_update_combo(kb, 0, 0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.