[Glade-users] [glade-users] Using a global variable for GladeXML object?



On Sat, 2007-01-20 at 09:12 +0530, Sudharshan S wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, 2007-01-19 at 00:33 -0800, Micah Carrick wrote:
When I create my applications using glade, I create and use the
gladeXML object in an initialize function and store all references
to widgets I will need later in a structure declared in main(). I
pass the necessary widgets to callbacks, and then I call
g_object_unref() on the gladeXML object and return. I do this
mainly because I try to avoid global variables because that's what
I learn
Just curious, can you point me to the code that does this..what
happens when the number of widgets becomes large

    I'd suggest you look at the devhelp code, it makes sane
usage of libglade and is very simple code so you wont get lost
in irrelevent stuff (look at dh-prefs.[ch] preferences dialog
for example).

Note how each source file is a GObject, that instance might
control a portion of the UI, if widgets need to be set sensitive
etc that are relevent to that code portion, those widget pointers
should be stored on the instance of the appropriate object.

Note also that even if your glade file contains lots of widgets,
usually even in large UIs only a few widgets need to be accessed
explicitly (usually you receive the widget pointers in callbacks
anyway, and probably your object instance as user data).

Cheers,
                 -Tristan






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