Re: using multiple widgets in a callback
- From: TP Muller <tpm01 aber ac uk>
- To: moosewood mooseroot org, "GTK Developement List" <gtk-app-devel-list gnome org>
- Subject: Re: using multiple widgets in a callback
- Date: Fri, 26 Jul 2002 22:50:55 +0100
On Friday 26 July 2002 21:21, Jeffrey Goddard wrote:
I've seen, somewhere, a method for passing more than two widgets to a
callback routine, but I can't seem to find it anywhere in my office. Could
someone please give me a clue?
Pass a pointer to a structure or to an array containing the widgets, e.g.
typedef struct
{
GtkWidget *widget1, *widget2, *widget3;
} threeWidgetsStructure;
and then in your code ...
threeWidgetStucture *tws = g_new0 (threeWidgetStructure, 1);
if (tws)
{
tws->widget1 = somewidget;
tws->widget2 = anotherwidget;
tws->widget3 = yetanotherwidget;
gtk_signal_connect (GTK_OBJECT (some_object), "some-signal",
GTK_SIGNAL_FUNC(some_signal_function), (gpointer)tws);
} else g_printerr ("mem alloc failed in %s!\n", __FUNCTION__);
alternatively:
GtkWidget **threeWidgets = g_new( (GtkWidget*), 3);
threeWidgets[0]=somewidget;
threeWidgets[1]=anotherwidget;
threeWidgets[2]=yetanotherwidget;
gtk_signal_connect (GTK_OBJECT(some_object), "some-signal",
GTK_SIGNAL_FUNC(some_signal_function), (gpointer) threeWidgets);
then in some_signal_function(), (for example);
GtkWidget **threeWidgets = (GtkWidget**)user_data;
....
gtk_widget_hide (threeWidgets[0]);
gtk_widget_hide (threeWidgets[1]);
gtk_widget_hide (threeWidgets[2]);
Dunno if those are good methods or not.
Cheers
-Tim
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]