[Glade-users] newbie question: accessing multiple widgets from the callback function of another widget
- From: tristan.van.berkom at gmail.com (Tristan Van Berkom)
- Subject: [Glade-users] newbie question: accessing multiple widgets from the callback function of another widget
- Date: Tue, 31 May 2011 11:10:58 +0900
On Tue, May 31, 2011 at 10:52 AM, Benton Greene <beezum88 at gmail.com> wrote:
I'm sure this is a simple thing, but I'm at a loss. I have a button
that needs to call a function that has access to the values of six
spin buttons, as well as to a drawing area. I have only written one
program using GTK+ before, and that was by hand. In that one, I
collected the pointers to each of the widgets I needed access to and
put them all in an array that I then passed using the "gpointer
user-data" field of g_signal_connect. I found it inelegant and a pain
in the butt, but it worked. I have no idea, however, how to do a
similar thing in the context of glade.
I guess in general, I can't figure out how to pass arguments, or even
gather the arguments I need to pass, using Glade. The whole xml ui
file and gtk_builder function don't make any sense to me.
A common practice is:
o Create an object that is in charge of a said component (a
preferences dialog or such)
o Create the dialog/interface when the object initializes using
gtk_builder_add_from_file/data()
o Collect the pointers that the object might need using
gtk_builder_get_object() and store
them as data of the instance (probably private data when using C)
o Pass the said object as the data for all signal callbacks
(gtk_builder_connect_signals()
or another variation lets you assign a single pointer as the user
data for all callbacks).
Cheers,
-Tristan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]