Question

Is there any global top level windows pointer in GTK ?

I know in wxWidgets, there are. And we can get them by :

import wx
wx.GetTopLevelWindows()

Is there any method in similar way with wxWidgets in GTK ?

Was it helpful?

Solution

liberforce's advice is good: keep your lower level components modular.

However, if you really want to do it the same way as wxWidgets, use gtk_window_list_toplevels().

OTHER TIPS

The most similar will be using gtk_builder_get_object on the toplever identifier. Otherwise, just keep the pointer to the window around if you create it manually instead of using GtkBuilder. I prefer that, because this kind of "my lower level component can depend on calls to the implementation above it" often leads to ugly spaghetti code and circular dependencies in the code.

So I usually just declare a struct on the stack in the main(), so the struct will exist for the whole app life cycle, and pass a pointer to this struct in the gpointer user_data argument of callbacks. And in that structure, I may store my widgets, or other data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top