I'm into a problem with a GTK+ C application. I have a container that, contains a item text. During the running an user interation must cause this widget to contain more or less of them.
I need to write a function that removes all the "old" inner item, less last four witch is application command, then adds all the ones from a list and finally refresh the view.
I have create a panel menu which display a menu like in screenshot. First part of the menu, to the first line separator, displays the names of TV channels whose number is updated. After first separator (in screensot after "WHITE", I have same control of application that I would like to be fixed in menu.
I want to remove all item least last 6.
Code:
void create_panel_menu(GtkWidget *app) {
GList *node = settings.channels;
int i;
panel_menu = gtk_menu_new();
for (i = 0; node; i++, node = node->next)
{
channel *ch = (channel*)node->data;
GtkWidget *menuitem = gtk_menu_item_new_with_label(ch->name);
gtk_menu_shell_insert(GTK_MENU_SHELL(panel_menu), menuitem, i);
g_signal_connect(G_OBJECT(menuitem), "activate", (GCallback)channel_menuitem_activate_cb, GINT_TO_POINTER (i));
gtk_widget_show(menuitem);
}
gtk_menu_shell_append(GTK_MENU_SHELL(panel_menu), gtk_separator_menu_item_new());
mute_menuitem = gtk_check_menu_item_new_with_label(_("Muted"));
gtk_menu_shell_append(GTK_MENU_SHELL(panel_menu), mute_menuitem);
record_menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_MEDIA_RECORD, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(panel_menu), record_menuitem);
gtk_menu_shell_append(GTK_MENU_SHELL(panel_menu), gtk_separator_menu_item_new());
showwindow_menuitem = gtk_check_menu_item_new_with_label(_("Show Window"));
gtk_menu_shell_append(GTK_MENU_SHELL(panel_menu), showwindow_menuitem);
quit_menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(panel_menu), quit_menuitem);
gtk_widget_show_all(panel_menu);
}
Code:
GList* menuitems = gtk_container_get_children(GTK_CONTAINER(panel_menu));
The first entry is channel name witch is added by the users in list of presets and they appear here in panel menu even if they were deleted afterwards in the list store. I want to remove them when list store is empty.
Thanks