GtkRadioMenuItem, GSList



Hi all,

I have a function for creating and adding GtkRadioMenuItems into a menu,
something like this:

/* Global vars */
static GtkWidget *menu;
static GSList *list = NULL;

void add_item(myobj *obj, GCallback callback)
{
        GtkWidget *menu_item;

        menu_item = gtk_radio_menu_item_new_with_label(list, obj->name);
        list = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menu_item));

        gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
        g_signal_connect(G_OBJECT(menu_item), "activate", callback, obj);
        gtk_widget_show(menu_item);
}


This works fine, adding an item to the menu each time its called.

The problem comes, if I destroy the most recently created menu item
then the radio-group "list" variable becomes invalid.

The question I have is where should I point "list" to on destroying the
most recent item?

I did try setting it to: list = list->next
before destroying the menu item, but it just spits out error messages.

Thanks!
-- 
Daniel Pekelharing
<legendstar gmail com>




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