Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Tue, 21 Nov 2023 23:34:26 UTC Commit: fc54c5700fe86ffb13fa254096a163efbc479728 https://github.com/geany/geany-plugins/commit/fc54c5700fe86ffb13fa254096a163...
Log Message: ----------- webhelper: Show accelerator in context menu
This looks pretty and helps a bit with discovery... although this item currently has no default binding so the user has to have set one, meaning they already probably know about it. But it looks nice and consistent.
Modified Paths: -------------- webhelper/src/gwh-browser.c
Modified: webhelper/src/gwh-browser.c 22 lines changed, 22 insertions(+), 0 deletions(-) =================================================================== @@ -225,6 +225,27 @@ on_item_bookmark_toggled (GtkCheckMenuItem *item, } }
+static void +item_show_accelerator (GtkWidget *item, + gsize key_id) +{ + GeanyKeyBinding *binding = keybindings_get_item (gwh_keybindings_get_group (), + key_id); + + if (binding->key) { + /* we need an accel group for setting the accelerator, but we can't get + * Geany's. It doesn't matter though, as this is only for showing the + * accelarator, not actually for tiggering the item. */ + GtkAccelGroup *dummy_accel_group = gtk_accel_group_new (); + + gtk_widget_add_accelerator (item, "activate", dummy_accel_group, + binding->key, binding->mods, + GTK_ACCEL_VISIBLE); + g_object_set_data_full (G_OBJECT (item), "dummy_accel_group", + dummy_accel_group, g_object_unref); + } +} + static void on_url_entry_icon_press (GtkEntry *entry, GtkEntryIconPosition icon_pos, @@ -243,6 +264,7 @@ on_url_entry_icon_press (GtkEntry *entry, G_CALLBACK (on_item_bookmark_toggled), self); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); + item_show_accelerator (item, GWH_KB_TOGGLE_BOOKMARK);
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org