GNOME Bugzilla – Bug 770385
ShortcutsWindow: show_all() doesn't, must manually show 1 Section before add(), else opens locked on Search Results
Last modified: 2018-04-15 00:00:04 UTC
Created attachment 334130 [details] MCVE / example of how to create Shortcuts in-code I've been through a process of filling out the large gaps in the docs in order to determine how to use the GtkShortcuts* widgets from within code, rather than by the "recommended" method of using a .ui file, as I brought up here: > https://bugzilla.gnome.org/show_bug.cgi?id=770377 Having gotten the required tricks under my belt, along with the new appreciation of GObject that was required - I came across another oddity, which meant another N hours of puzzling. Specifically, ShortcutsWindow and ShortcutsSection have some very unintuitive behaviour with their show_all() and show() properties respectively. The Window opens locked on the "Search Results" page unless both of the following are true: * the user has manually run gtk_widget_show(shortcutsSection) because ShortcutsWindow's show_all() somehow excludes its child Sections * said manual show() is done BEFORE adding it to its parent ShortcutsWindow If both of these conditions are not met, no ShortcutsSections can be accessed using the ShortcutsWindow: the user is locked on the Search Results page and can only search for shortcuts. This is not very intuitive at all - costing me an hour or 2 of confusion and random trial-and-error - and so I'm wondering whether it's really necessary or whether it can be improved to work without manual intervention - or at least documented what users must do, to spare others the hassle I've had. I can't figure out the exact cause, but the fact that the ShortcutsSection's internal GtkStackSwitcher has "no-show-all" set to TRUE is probably relevant: > https://github.com/GNOME/gtk/blob/master/gtk/gtkshortcutssection.c#L441 Please see the attached C file for a demo of this (and the raw GObject API required) - and please feel free to use this as a demo to save other users reinventing the wheel figuring out how to create Shortcuts programmatically. Run the program as follows, with and without a single argument of Y: * ./a.out => does not manually show() Section, ShortcutsWindow locked on Search * ./a.out Y => manually show()s Section before add() and hence works properly HTH and thanks.
Fwiw, a GNU C (I think) version of the MCVE, but without the test argument/logic, is uploaded at the other ticket: https://bugzilla.gnome.org/show_bug.cgi?id=770377
I don't think this is a bug. GtkShortcutsWindow takes over visibility management, but it respects the initial visibility setting you have on the items that get added. So making them visible before adding is correct and expected. The reason we can't let show_all just show everything is that then ltr- and rtl-variants would be shown at the same time.
Thanks. That's a good example of why you can't include Sections in show_all() If API/docs get added to these widgets, maybe there could be a small note added about such reasons and requirement to manually show Sections, to prevent anyone else getting as confused as me... or at least, I hope I'm not the only user who would ever get confused by this :D
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla. If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab: https://gitlab.gnome.org/GNOME/gtk/issues/new