Re: [gtk-list] gtk_signal_connect() w/key_press_event



>  Using gtk_signal_connect() for a key_press_event in a GtkText widget causes
>  the callback routine to be passed the widget id of the GtkText widget and
>  the GdkEventKey structure.  However, there doesn't appear to be any way to
>  pass in user data to this callback.  How can you pass in the user data (arg
>  4 of gtk_signal_connect()) to the callback?  I need to pass in a data
>  structure of information to this callback.  Is that what the "string"
>  element of the GdkEventKey structure is for?  If so, should that be an
>  opaque gpointer instead of a gchar type?

GtkText *my_text;

...
gtk_signal_connect (GTK_OBJECT (my_text), "key_press_event",
		    (GtkSignalFunc) my_callback,
		    0xdeadbeef);


static gint
my_callback (GtkText *text, GdkEventKey *event, gpointer data)
{
	printf ("Got %p\n", data);
}

  Federico



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