Re: Internal Data



On Thu, 2003-07-10 at 19:52, Gortari Nicholas-p56512 wrote:
> Is there any way to add a widget or some sort of object to a window that will hold internal/hidden data?  I am writing a dialog that receives an integer value on creation and then passes that same value to a on_button_clicked callback.  Ideas?

You have at least three options:
(i) Set the data as the user_data when you connect to the signal; it
will get passed as a parameter to the callback - though only to that
callback.
(ii) If the data is shared between multiple callbacks, you can attach it
as generic data to the dialog.  Under GTK 2.* , look at
g_object_set_data and g_object_get_data; under GTK 1.*, look at
gtk_object_set_data, gtk_object_get_data (IIRC).   This is good if
you've got data shared between several callbacks.
(iii) Create a custom dialog subclass.  Do this if you've got lots of
data, with complicated semantics.  But it can be pain.

I tend to go for method (ii)

Good luck!


Dave Malcolm




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