After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 770385 - ShortcutsWindow: show_all() doesn't, must manually show 1 Section before add(), else opens locked on Search Results
ShortcutsWindow: show_all() doesn't, must manually show 1 Section before add(...
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: Other
3.20.x
Other Windows
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-08-25 12:12 UTC by Daniel Boles
Modified: 2018-04-15 00:00 UTC
See Also:
GNOME target: ---
GNOME version: 3.19/3.20


Attachments
MCVE / example of how to create Shortcuts in-code (1.42 KB, text/plain)
2016-08-25 12:12 UTC, Daniel Boles
Details

Description Daniel Boles 2016-08-25 12:12:33 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.
Comment 1 Daniel Boles 2016-08-25 12:52:17 UTC
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
Comment 2 Matthias Clasen 2016-09-10 12:57:16 UTC
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.
Comment 3 Daniel Boles 2016-09-10 13:04:41 UTC
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
Comment 4 Matthias Clasen 2018-02-10 04:55:55 UTC
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.
Comment 5 Matthias Clasen 2018-04-15 00:00:04 UTC
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