Re: GtkBuilder and callbacks.



Hello.

> I'm usong GtkBuilder, to set up my interface. My callbacks are all take
> the GtkBuilder as argument. This way, I can access all elements inside
> the callback, with gtk_builder_get_object.
>
> What do you think about this? Is this a good design? Or do you see any
> problems? And if so, what do you do?

I usually define one large global data storage (usually struct) that
is passed as a data parameter to signal connection. This structure
holds information that needs to accessed from callbacks. Part of this
data are also widget pointers that are retrieved from builder at init
phase of application.

This way, builder is not needed anymore, so I usually destroy it after
all the pointers I need were retrieved and signals connected.

> And is it possible to add/remove objects to/from a gtkBuilder directly?

Object can be added to builder only by passing it XML with UI
description (XML can come from file or from string). You cannot "push"
one of your manually constructed widgets onto builder. What you can do
is to add widgets to the GUI that builder created (for example, you
can pack more widgets into vertical box, created by builder). This is
useful if you want to pack pack a custom widget inside your GUI but
don't have Glade catalog for it.

Tadej

-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeboro gmail com
tadej borovsak gmail com


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]