[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Set up callbacks for dynamically created buttons
- From: "David Necas (Yeti)" <yeti physics muni cz>
- To: 3saul <saul_lethbridge hotmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Set up callbacks for dynamically created buttons
- Date: Sat, 22 Apr 2006 10:33:44 +0200
On Sat, Apr 22, 2006 at 09:22:44AM +0200, Daniel Pekelharing wrote:
>
> gint button_callback(GtkWidget *button, gint i)
> {
> printf("Button %d was clicked\n", i);
> }
>
> and connect to it like:
>
> g_signal_connect(G_OBJECT(buttons[i]), "clicked", G_CALLBACK(button_callback), (gpointer)i)
Please do not do this. Perhaps it works on your i386 box,
but the macros GINT_TO_POINTER() and GPOINTER_TO_INT() exist
for a good reason.
> Alternatively if you want to pass some other data to the callback you
> could determine which button was pressed by calling
> gtk_button_get_label(GTK_BUTTON(button)
> from withing the callback to determine the label of the button.
Alternatively (and better), you can use g_object_set_data()
to attach arbitrary data to each button.
Yeti
--
That's enough.
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]