Re: GtkRadioMenuItem, GSList
- From: Daniel Pekelharing <legendstar gmail com>
- To: Gtk-App-Devel-List <gtk-app-devel-list gnome org>
- Subject: Re: GtkRadioMenuItem, GSList
- Date: Mon, 07 Nov 2005 16:22:44 +0200
On Sat, 2005-11-05 at 14:13 +0200, Daniel Pekelharing wrote:
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!
In case anyone else ever has this problem.. I have now solved it,
my error was actually in correctly determining if a menu item was the
last in the list...
When destroying "menu_item" :
if (list != NULL) {
if (list->data == (gpointer)menu_item)
list = list->next;
}
gtk_widget_destroy(menu_item);
This works fine.
--
Daniel Pekelharing
<legendstar gmail com>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]