MenuItem callback weirdness



Hi all,

I'm developping with Gtk 1.2.x.  I connect a callback function to each
menu item of an option menu. The function extracts the label of the last
selected menu item.

The function looks like this:

void omenu_callb(GtkWidget *wdg, gpointer data) {
 gchar *label;
my_struct *str;
 str = (my_struct *) data;
 if (!GTK_CHECK_MENU_ITEM(wdg)->active)
  return;
 gtk_label_get(GTK_LABEL(GTK_BIN(wdg)->child), &label);
 strcpy(str->some_allocated_string,label);
}

It works the first time the callback is executed, when I set the default
option.  But at each subsequent call, GTK_BIN(wdg)->child is NULL.

GTK_IS_MENU_ITEM(wdg) is always TRUE, though, and "wdg" is the right
MenuItem (the widget address is the same for the same choice).

GTK_BIN(wdg)->children is a 1 element list for the first call, an empty
list after.

Menu items where created with gtk_radio_menu_item_new_with_label (group,
label_string);

Does somebody have any hint about where my label has disappeared?

Sure, I can create one callback structure for each menu item (instead of
one for the whole option menu), and embed the label string in it, but
what a burden!

Thanks!

Patrice St-Gelais






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