Reputation: 715
I have a toplevel window that contains a lot of spinbuttons.
Actually user selects how many objects he needs and after pressing a button the application provides some action.
Usually I'm using a struct
typedef struct
{
.......
GtkWidget *widget;
.......
} _GUI;
that conatains widgets initialized by means of gtk_builder_get_object(). After it I can get info from them.
But here I need to cover a lot (>50) of spinbuttons and also I need to set their properties (for example set sensitive option etc).
So the question is it possible to list all widgets of a toplevel window (there are boxes and expanders also) and somehow sort them by their type (GtkSpinButton, GtkWidget etc)?
I want to avoid direct pointing to specific spinbuttons.
Upvotes: 0
Views: 848
Reputation: 399833
Since the top-level window (a GtkWindow) is a subclass of GtkContainer, you can use gtk_container_forall()
, for instance, to iterate over the windows' children.
Then for each child, you can use GObject's API:s (for instance the G_OBJECT_TYPE()
macro macro) to figure out the type of each child. You might need to recurse, if you have your spin buttons in nested containers within the window.
Upvotes: 2