Fixes https://github.com/geany/geany-plugins/issues/462 You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1396
-- Commit Summary --
* Fix setting menu item labels dynamically
-- File Changes --
M src/build.c (15)
-- Patch Links --
https://github.com/geany/geany/pull/1396.patch https://github.com/geany/geany/pull/1396.diff
elextr requested changes on this pull request.
Needs to set use_underline so the mnemonics work, thats the reason for the workaround in the first place.
@elextr Are you sure that’s necessary? The items [are created](https://github.com/vfaronov/geany/blob/73476315635faab9a30102956362dce19a39b...) using [`gtk_image_menu_item_new_with_mnemonic`](https://developer.gnome.org/gtk3/stable/GtkImageMenuItem.html#gtk-image-menu...), and the mnemonics work for me under both GTK+ 2.24 and 3.18.
@elextr Are you sure that’s necessary?
No. But but it certainly didn't work at some point in the past, hence the workaround in the first place :)
But maybe GTK has "standardised" on an undocumented behaviour of [gtk_menu_item_set_label()](https://developer.gnome.org/gtk3/stable/GtkMenuItem.html#gtk-menu-item-set-l...) not changing the mnemonic setting on the underlying label despite normal [gtk_label_set_text()](https://developer.gnome.org/gtk3/stable/GtkLabel.html#gtk-label-set-text) explicitly clearing the flag.
GTK experts shall have to pronounce.
@elextr Well, explicitly setting `use-underline` doesn’t seem to do any harm, so I added it. See the updated PR.
@elextr
Needs to set use_underline so the mnemonics work, thats the reason for the workaround in the first place.
No, as @vfaronov mentioned there's no need as the item is crated with `gtk_image_menu_item_new_with_mnemonic()`, changing the label will keep the mnemonic choice. No it's not properly documented, but it always worked (AFAIK) and works.
So IMO the best fix would be to get rid of this obsolete compatibility function and call `gtk_menu_item_set_label()` directly.
[…] despite normal [gtk_label_set_text()](https://developer.gnome.org/gtk3/stable/GtkLabel.html#gtk-label-set-text) explicitly clearing the flag.
But [`gtk_label_set_label()`](https://developer.gnome.org/gtk3/stable/GtkLabel.html#gtk-label-set-label) explicitly does *not* reset that flag.
@vfaronov sorry if it was your original fix, I didn't see it before :S
@b4n No problem, I kept it in a branch :) See the updated PR.
Merged #1396.
Merged, thanks!
github-comments@lists.geany.org