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 722588 - GtkStack: add gtk_stack_get_child_by_name()
GtkStack: add gtk_stack_get_child_by_name()
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-01-20 08:38 UTC by Steve Frécinaux
Modified: 2014-01-21 08:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GtkStack: add gtk_stack_get_child_by_name() (2.59 KB, patch)
2014-01-20 08:38 UTC, Steve Frécinaux
accepted-commit_now Details | Review
GtkStack: add gtk_stack_get_child_by_name() (2.66 KB, patch)
2014-01-20 10:46 UTC, Steve Frécinaux
committed Details | Review
GtkContainer: add gtk_container_get_n_children() (2.16 KB, patch)
2014-01-20 11:04 UTC, Steve Frécinaux
none Details | Review

Description Steve Frécinaux 2014-01-20 08:38:45 UTC
In gedit, in the context of upgrading the UI to match the GNOME 3 style, we are looking at replacing our GtkNotebook usage in the side and bottom panels with GtkStacks. But in those panels the pages are added and removed dynamically.

The currently visible panel is stored in GSettings. In some case it is possible that no panel has a name equal to the value in GSettings (plugin removed, etc). In this case we'd like to be able to check if the stack has a child with the name before acting on it.

This current method, gtk_stack_get_child_by_name(), will do just that, in a generic fashion.
Comment 1 Steve Frécinaux 2014-01-20 08:38:47 UTC
Created attachment 266705 [details] [review]
GtkStack: add gtk_stack_get_child_by_name()

This new method allows getting a widget from a GtkStack when we know its
name, and will also return NULL if there is no widget going by that
name.

Usage example would be to check if a child with a given name exists
before calling gtk_stack_set_visible_child_name().
Comment 2 Alexander Larsson 2014-01-20 10:41:48 UTC
Review of attachment 266705 [details] [review]:

looks good to me
Comment 3 Steve Frécinaux 2014-01-20 10:46:21 UTC
Created attachment 266713 [details] [review]
GtkStack: add gtk_stack_get_child_by_name()

This new method allows getting a widget from a GtkStack when we know its
name, and will also return NULL if there is no widget going by that
name.

Usage example would be to check if a child with a given name exists
before calling gtk_stack_set_visible_child_name().
Comment 4 Steve Frécinaux 2014-01-20 11:04:58 UTC
Created attachment 266717 [details] [review]
GtkContainer: add gtk_container_get_n_children()

This is a generalization over gtk_notebook_get_n_pages(), to get the
amount of non-internal children for any container.