gtk_menu: update the menu



Hi GTK list,

I have a question about the gtk_menu wigdet.

Application:
My GTK 2.2 application build a menu from a sting, in the string every item is separated by "\t".
So the string can look like: "item 1\titem 2\titem3\n".
This string can change when I am running the app, and that must be made visual in the menu.

Problem: If the string changes (it contains other items) I can not see it in the menu.

Question:
What is the best way to make new string entrys visual in the menu?
I this possible anyway?, Or must I use an other widget (like gtk_list).
Or perhaps there I must use an Update-function in my code to update the menu.

Solutions for my problem are more then welcome! :-)
Regards
Maarten.

This is how I am creating the menu from the string: 'strings':

GtkWidget * create_option_menu (gchar * strings)
{
   GtkWidget *menu;
   GtkWidget *option_menu;
   GtkWidget *menu_item;
   gchar *p;

   menu = gtk_menu_new ();
p = strtok (strings, "\t"); while (p != NULL) {
           menu_item = gtk_menu_item_new_with_label (p);
           gtk_widget_show (menu_item);
           gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
g_signal_connect_swapped (G_OBJECT (menu_item), "activate", G_CALLBACK (menu_item_select), (gpointer) g_strdup (p)); p = strtok (NULL, "\t"); } option_menu = gtk_option_menu_new ();
   gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
return option_menu;
}


I use strtok to separate the entrys from the string.




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