Re: Passing data to menu callback



Peter Hawkins wrote,

>>Can I suggest what you really want to do is:
>>licq_plugin_mode_status_menu_callback( (gpointer) ICQ_STATUS_ONLINE );
>>ie. cut the "&"? Pass the VALUE in the pointer, don't use the pointer as a
>>pointer:-)
>>
>>And this function becomes:
>>void licq_plugin_mode_status_menu_callback( gpointer user_data )
>>{
>> unsigned short int NewStatus = ( short unsigned int ) user_data;
>>  licq_plugin_mode_status_set( NewStatus );
>>}

After doing this NewStatus always becomes 0.  =(

Erik B. Andersen wrote,
>>Your callback is getting a pointer to a widget... In
>>gnomehack, I do the following to pass an int through a menu
>>(nethack/win/gnome/GnomeHackMainWindow.c if you want to look
>>at the code in CVS):
>>
>>GnomeUIInfo edit_menu[] = {
>>          {
>>               GNOME_APP_UI_ITEM, N_("Inventory"),
>>               N_("Edit/View your Inventory"), ghack_accelerator_selected,
>>               GINT_TO_POINTER('i'), NULL, GNOME_APP_PIXMAP_NONE, NULL, 'i', 0

>>           },
>>           etc....
>>}
>>
>>static void
>>ghack_accelerator_selected (GtkWidget *widget, gpointer data)
>>{
>>    GdkEventKey event;
>>    int key = GPOINTER_TO_INT( data);
>>    /* Do stuff with the key value */
>>}

Same problem here, NewStatus always becomes 0. =(

Does anyone know why?

BTW. The Constants are declared:
const unsigned short ICQ_STATUS_OFFLINE            = 0xFFFF;
const unsigned short ICQ_STATUS_ONLINE             = 0x0000;
const unsigned short ICQ_STATUS_AWAY               = 0x0001;
const unsigned short ICQ_STATUS_DND                = 0x0002;
const unsigned short ICQ_STATUS_NA                 = 0x0004;
const unsigned short ICQ_STATUS_OCCUPIED           = 0x0010;
const unsigned short ICQ_STATUS_FREEFORCHAT        = 0x0020;

Thx

--Halfline



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