Re: Help with retreiving children?

On Mon, 21 Aug 2000 wrote:

> Hi there... 
> I am creating an app using GTK+... I don't like global variables, or
> exporting large numbers of variables to implement functionality.
> I have a form with multiple entries and combos and spin-buttons and I
> would like to be able to access those widgets without having a global
> variable for each.
> I'm thinking something along the line of using a function on the top-level
> widget to return a pointer to the requested child-widget (requested by
> name, since I did name all my widgets, and whats the point of names if
> this isn't it?)
> So if there's any functionality like this, or other suggestions, it would
> be greatly appreciated.  I've been through the docs, unfortunately they're
> a bit sketchy on the more complex topics.

    I would recomend you to (ab)use gtk_object_set_data/gtk_object_get_data,
in the toplevel widget, e.g.
and then, when ptr is needed, extract it like this:
	GtkWidget* total_button =

in order to save typing, I always use the following macros:
GOSD(obj,name,data) gtk_object_set_data(GTK_OBJECT(obj),name,(gpointer)data)
GOGD(obj,name) gtk_object_get_data(GTK_OBJECT(obj),name)
GOSI(obj,name,val) GOSD(obj,name,GINT_TO_POINTER(val))
GOGI(obj,name) GPOINTER_TO_INT(GOGD(obj,name))
GOGW(obj,name) (GtkWidget*)(GOGD(obj,name))

> Thanks loads,
> Leeman 
> _______________________________________________
> gtk-list mailing list

 Best regards,

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