Confused about radio menu items and signals



Hi,

Still learning with gtk2. I have a menu with a submenu. That submenu 
contains items for three mutually exclusive states in my program: A, B, and C. 
Each menu item is created with code like:
     A_menu_item = gtk_radio_menu_item_new_with_mnemonic(group, "label")

In the constructor, my program does
     gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (A_menu_item), 
true); // default
to set the checkmark next to A to start things.

Then if the user clicks on Menu | Submenu | B, it was my understanding 
that B would get the checkmark/true, and A's checkmark would be auto
erased/false and I could process what is necessary when B becomes true.

I have a shared handler for activate signal on these menu items, and 
when B is clicked, I see a situation where both A and B are true. What 
am I missing?

I thought OK, maybe gtk leaves it to me to figure out which radio item 
needs to be turned on, and turn the rest off. But this has me call
     gtk_check_menu_item_set_active(menuitem, false);
for each of the menuitems that shouldn't be on. This generates more 
signals to my signal handler, and I end up with a mess of nested calls 
to the signal handler and my program gets totally confused, not to 
mention its author.

Thanks for any guidance. You all have been helpful to me before :-)

Matt



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