GtkOptionMenu weirdness



Hello all,
        Searching around the net I was unable to find a solution to this problem.

I have a GtkOptionMenu that i'm using to display a list of strings (simple enough).
When my application is initialized, it pulls the strings from a file, and loads the strings in no hassle.

The problem I'm getting is when I need to add a new GtkMenuItem to the underlying GtkMenu. The add executes 
without warning or error, but I can't see the newly added item in my GtkOptionMenu. Here's the code:

GtkWidget *string_menu, *string_select;
GtkWidget *add_button;

gint add_clicked(GtkWidget *wid, gpointer data)
{
  ....
  item = gtk_menu_item_new_with_label("Label");
  gtk_menu_shell_append(GTK_MENU_SHELL(string_menu), item);
  gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(update), NULL);
 
  gtk_menu_shell_activate_item(GTK_MENU_SHELL(string_menu), item, TRUE);
  gtk_widget_queue_draw(string_menu);
  gtk_widget_queue_draw(string_select);
 
  return TRUE;
}

int main()
{
  ...
  add_button = gtk_button_new_with_label("Add");
  string_menu = gtk_menu_new();
  string_select = gtk_option_menu_new();
        
  gtk_option_menu_set_menu(GTK_OPTION_MENU(string_select), string_menu);
  gtk_signal_connect(GTK_OBJECT(add_button), "clicked", GTK_SIGNAL_FUNC(add_clicked), NULL);
  ...
}

I'm using gtk1.2.10 under redhat 7.2 beta
Thanks!

~Marshall




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