A partial fix for #1368, #1286, #998. It doesn't add support for the hotkeys that are not bound to menu items, but fixes the most annoying and confusing part of the mentioned reports - about cut and copy that sometimes work, sometimes not. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1386
-- Commit Summary --
* Fix Ctrl+X and Ctrl+C in non-Latin keyboard layouts by restoring accelerators sensitive state on menu deactivate
-- File Changes --
M data/geany.glade (1) M src/callbacks.c (6) M src/ui_utils.c (20) M src/ui_utils.h (2)
-- Patch Links --
https://github.com/geany/geany/pull/1386.patch https://github.com/geany/geany/pull/1386.diff
b4n commented on this pull request.
I propose a few small fixes in 148fa9f59e70ce1e691fa7d008cb7fc9b798f481. If you're OK with them (as I just amended the commit they are in your name), I'll merge that.
A better solution would be to update the items sensitivity in reaction to selection changes (e.g. enable them whenever they can work, disable them when they can't). That could also fix the statusbar items sensitivity. But unfortunately it's tricky because those need to work on a wide range of widgets, not only the main editing area, but also all entry and text fields. So your proposal looks reasonable enough to me.
@@ -6321,6 +6321,7 @@
<object class="GtkMenuBar" id="menubar1"> <property name="visible">True</property> <property name="can_focus">False</property> + <signal name="deactivate" handler="on_menubar1_deactivate" after="yes" swapped="no"/>
Sad we can't really connect something on the menu item next to the "activate" signal. We could use "deselect", but I'm not sure is really correct.
@@ -299,6 +299,8 @@ void ui_update_popup_goto_items(gboolean enable);
void ui_update_menu_copy_items(GeanyDocument *doc);
+void ui_restore_menu_copy_items();
argument list should be `(void)` for a proper prototype
@@ -533,9 +541,13 @@ void ui_update_menu_copy_items(GeanyDocument *doc)
enable = gtk_text_buffer_get_selection_bounds(buffer, NULL, NULL); }
- len = G_N_ELEMENTS(widgets.menu_copy_items); - for (i = 0; i < len; i++) - ui_widget_set_sensitive(widgets.menu_copy_items[i], enable); + set_menu_copy_items_sensitive(enable); +} + + +void ui_restore_menu_copy_items()
This function indirection doesn't add clarity to me, so I'd rather expose the `set_sensitive()` part directly.
I'm absolutely OK with the fixes. Thank you for the effort.
Forkest commented on this pull request.
@@ -6321,6 +6321,7 @@
<object class="GtkMenuBar" id="menubar1"> <property name="visible">True</property> <property name="can_focus">False</property> + <signal name="deactivate" handler="on_menubar1_deactivate" after="yes" swapped="no"/>
I'm not sure about "deselect" too. Probably yes, but it feels not safe to rely on "activate"-"deselect". But if we change "activate" to "select", then it'll be OK, IMHO.
Forkest commented on this pull request.
@@ -6321,6 +6321,7 @@
<object class="GtkMenuBar" id="menubar1"> <property name="visible">True</property> <property name="can_focus">False</property> + <signal name="deactivate" handler="on_menubar1_deactivate" after="yes" swapped="no"/>
I've experimented a bit, but can't find the difference between `activate` and `select`. GTK docs aren't clear about this too.
b4n commented on this pull request.
@@ -6321,6 +6321,7 @@
<object class="GtkMenuBar" id="menubar1"> <property name="visible">True</property> <property name="can_focus">False</property> + <signal name="deactivate" handler="on_menubar1_deactivate" after="yes" swapped="no"/>
https://developer.gnome.org/gtk3/stable/GtkMenuShell.html#id-1.3.20.5.10.4 suggests using select/deselect is just fine. And in practice it does seem to work great. But agreed the docs are not very clear.
See the last commit on https://github.com/b4n/geany/commits/Forkest/copy-items-nonlatin
Works perfectly.
Closed #1386 via b0f71a166651b65a0a6184b02d90327d696cfea2.
@b4n: Thanks!
github-comments@lists.geany.org