Re: Option Menu



Ignacio Nodal wrote:
> 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?

Hi Ignacio, I'm not sure you should be using radio items with an option
menu. Here's what I do:

-- 
	optionview->options = gtk_option_menu_new();
        gtk_box_pack_start( GTK_BOX( hb ), 
                optionview->options, FALSE, FALSE, 2 );
        pane = gtk_menu_new();
        for( p = option->labels, i = 0; p; p = p->next, i++ ) {
                item = gtk_menu_item_new_with_label( (char *) p->data );
                gtk_signal_connect( GTK_OBJECT( item ), "activate", 
                        GTK_SIGNAL_FUNC( optionview_change_cb ),
optionview );
                gtk_menu_append( GTK_MENU( pane ), item );
        }
        nitems = i;
        gtk_widget_show_all( GTK_WIDGET( pane ) );
        gtk_option_menu_set_menu( 
                GTK_OPTION_MENU( optionview->options ), pane );
        i = CLIP( 0, option->value, nitems - 1 );
        gtk_option_menu_set_history( GTK_OPTION_MENU( widget ), i );
-- 

Works for me.

HTH, John




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