Merge lp://qastaging/~attente/unity-gtk-module/gtk-enable-mnemonics into lp://qastaging/unity-gtk-module/14.04

Proposed by William Hua
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 322
Merged at revision: 315
Proposed branch: lp://qastaging/~attente/unity-gtk-module/gtk-enable-mnemonics
Merge into: lp://qastaging/unity-gtk-module/14.04
Diff against target: 403 lines (+190/-48)
5 files modified
lib/unity-gtk-menu-item-private.h (+1/-0)
lib/unity-gtk-menu-item.c (+92/-19)
lib/unity-gtk-menu-shell-private.h (+20/-18)
lib/unity-gtk-menu-shell.c (+76/-11)
lib/unity-gtk-menu-shell.h (+1/-0)
To merge this branch: bzr merge lp://qastaging/~attente/unity-gtk-module/gtk-enable-mnemonics
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
PS Jenkins bot (community) continuous-integration Approve
desrt (community) Needs Fixing
Review via email: mp+207752@code.qastaging.launchpad.net

Commit message

Filter out mnemonics when the gtk-enable-mnemonics setting is cleared. Workaround for LP: #1282782.

Description of the change

Filter out mnemonics when the gtk-enable-mnemonics setting is cleared. Workaround for LP: #1282782.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
desrt (desrt) wrote :

trying to dynamically handle the settings changing at runtime is maybe a bit insane.... but assuming that indeed you do want to do this:

unity_gtk_menu_shell_handle_item_notify() only uses the pspec to get the name -- why not just modify this function to take the name directly, removing the need to lookup the pspec...

keeping a gtksettings per menuitem is definitely overkill -- it's exceptionally unlikely that we will ever see more than one gtksettings per program. just use the global one. cache it in a static if you really don't trust that it will never change...

since you will just use the global gtksettings, no need to remove/readd the signal handler every time. also: don't bother with handler ids: they don't really make much of an improvement in performance. just disconnect by funcs/data.

finally: you shouldn't try to do this for every single menu item: only for toplevel ones in menubars.

one unrelated note: your underscore removal algorithm's attempt to be correct on non-ascii utf8 strings is not really necessary. all non-ascii utf8 sequences are composed entirely of non-ascii characters (ie: every byte is > 0x80). it is therefore impossible for '_' to appear in the middle of the sequence. just do the naive thing here and it will be correct.

review: Needs Fixing
Revision history for this message
desrt (desrt) wrote :

about the strdup: the strlen() + 1 on sized new is not necessary with gstring -- it adds the nul internally. maybe skip GString here entirely since you know that the result string will definitely be smaller than the input.

also: with respect to my previous comments, strchr() is your friend.

316. By William Hua

Pass property name directly.

317. By William Hua

Simplify mnemonic removal.

318. By William Hua

Only honour gtk-enable-mnemonics on top-level shells.

Revision history for this message
William Hua (attente) wrote :

I added the signal handler connection/disconnection in the unity_gtk_menu_shell_set_menu_shell () function because sometimes the GtkMenuShell can be set to NULL, and it makes sense to no longer watch once that happens. If you're worried about it being connected/disconnected more than once, in practice that function is never called with a non-NULL GtkMenuShell except at initialization.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
desrt (desrt) wrote :

This is better, but still not exactly what I had in mind. I wouldn't block on further review bickering at this point, though.

What I was thinking of (and did a relative poor job of explaining) is one global default GtkSettings watch (using gtk_settings_get_default) for the entire thing. When it fires, then you can iterate the toplevel items and make the tweak.

319. By William Hua

Use only one signal handler for notify::gtk-enable-mnemonics.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
320. By William Hua

Reset the label in the label handler.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
desrt (desrt) wrote :

Keeping the global list is really strange -- particularly considering that in practice there will only ever be exactly one menubar. It would have been better to just hook directly up to each (of the one and only) toplevel shell instead of bothering with all of this register stuff...

This is totally fine as-is, though...

321. By William Hua

Don't use a global linked list.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
desrt (desrt) wrote :

Just one more nag: this check will never fail:

+ if (gtk_enable_mnemonics_name == NULL)
282 + gtk_enable_mnemonics_name = g_intern_static_string ("gtk-enable-mnemonics");
283 +
284 + if (g_param_spec_get_name (pspec) == gtk_enable_mnemonics_name)
285 + {

because you already have a detailed signal connection.

322. By William Hua

Don't check pspec name in detailed signal handler.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

Seems like that's ready to land, thanks guys for the review/iterations!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches