Multiple menubars and linked radio buttons?



I have been beating my head against the wall for a while on this.  I am
writing a GTK program with two top-level windows, each with its own menu
bar. Each menu bar contains an "Options" menu with an identical set of
radio buttons, because the same options apply to both windows.

So if the user clicks a radio button in the Options menu in window #1, it
should cause the identical radio button in the menu of window #2 to also
be selected (and of course vice versa).  Is there any easy way to do this?
I tried putting the same radio buttons (i.e. the same GtkWidget pointers)
into both menus, but then I get errors at run time. (no compile errors)


Example code:

(in the code for menubar for first window, after using an itemfactory: )

menu_thingy = gtk_item_factory_get_widget (item_factory,
					   "/Options/Toggle Legend");	     

(in the code for menubar for second window: )

gtk_menu_append (GTK_MENU (menu2), menu_thingy);


The run-time error is:
Gtk-CRITICAL **: file gtkwidget.c: line 3353 (gtk_widget_set_parent):
assertion `widget->parent == NULL' failed.

Then after this error, the menu item in question disappears from one of
the windows' menubars.  Is it the case that GTK doesn't like for a widget
to be displayed in more than one place at a time?  Can anyone give me a
better idea for how to "link" two identical groups of radio buttons
together so they always have the same state?

Please cc: email to me as well as the list since I'm not subscribed.
Thanks,
Kevin McCarty





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