Option Menu
- From: Ignacio Nodal <inodal teleline es>
- To: GTK-List <gtk-list gnome org>
- Subject: Option Menu
- Date: Wed, 04 Jul 2001 11:32:15 +0200
Hi again,
When creating a menu using radio items and showing all toggles with
"gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM
(menu_item),TRUE)", how can I force a different menu item specified by
index to be selected?
I've used gtk_option_menu_set_history(). The value is shown correctly,
but then when I press on the OptionMenu for the first time, it always
show "pressed" the first menu item, not according to what I've passed
using gtk_option_menu_set_history().
How can I make this two values (showed and "programmactly" selected) to
work together?
Here's what I've tried without succeess:
/* *parameter points into a gint, being the index of the menu item I
want to be selected/active */
/* _enum_option is the option menu */
[...]
menu = gtk_menu_new();
/* Creating 3 menu items */
menu_item = gtk_radio_menu_item_new_with_label(group,"Option 1");
group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM(menu_item));
gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM
(menu_item),TRUE);
gtk_menu_append(GTK_MENU (menu), menu_item);
gtk_widget_show(menu_item);
menu_item = gtk_radio_menu_item_new_with_label(group,"Option 2");
gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM
(menu_item),TRUE);
gtk_menu_append(GTK_MENU (menu), menu_item);
gtk_widget_show(menu_item);
menu_item = gtk_radio_menu_item_new_with_label(group,"Option 3");
gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM
(menu_item),TRUE);
gtk_menu_append(GTK_MENU (menu), menu_item);
gtk_widget_show(menu_item);
/* Creating option menu and adding it the previous created menu */
_enum_option = gtk_option_menu_new();
gtk_option_menu_set_menu(GTK_OPTION_MENU(_enum_option), menu);
/* Default menu item = "Option 2" */
*parameter = 1;
[...]
switch(_type){
case EnumOptionMenu:
if (*parameter <= _last_enum){
GtkWidget* menu;
g_print("*parameter %d\n",*parameter);
menu =
gtk_option_menu_get_menu(GTK_OPTION_MENU(_enum_option));
gtk_menu_set_active(GTK_MENU(menu),*parameter);
gtk_option_menu_set_history(GTK_OPTION_MENU(_enum_option),*parameter);
}
break;
}
[...]
When I launch the program "Option 2" is shown correctly. But if I click
the option menu, the menu item which is shown "pressed" is still "Option
1" and not "Option 2". If I set the menu item clicking with the mouse
all works fine..
Can anybody help me with this?
Thanks in advance,
Ignacio Nodal
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]