Re: The widget that called



If you dont' want to use global vars to check for the widget pointer you
can use the following method.

Every callback can pass data. If you don't already use the data field
simply use GINT_TO_POINTER and GPOINTER_TO_INT e.g.:

funtion void my_callback( GtkWidget *w, gpointer data )
{
        switch( GPOINTER_TO_INT( data ) ) {
        ...
        }
}

// 1. Widget
g_signal_connect(w, "callback", G_CALLBBACK( my_callback ),
        GINT_TO_POINTER( 1 ) );

// 2. Widget
g_signal_connect(w, "callback", G_CALLBBACK( my_callback ),
        GINT_TO_POINTER( 2 ) );

An other alternative is g_object_set_data / g_object_get_data - used just
like the above example

HTH

Jan-Marek



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