dynamic menus

Hi all,

I'm trying to figure smth. out on the usage of optionmenus ... perhaps I'm
missing smth. obvious.

I have this dialog where I can set an optionmenu sensitive or insensitive
based on a checkbutton. If the checkbutton is checked the user wants the
value usually picked from the optionmenu to be auto-detected based on
some other user input.

This all works fine ... however, I can't seem to think of a way of how to set
the menu selection based on the other user input because I don't retain
the menuitems added to the menu.

The options available from the menu are dependant on the ways the application
has been built, so I build them on the fly:

   sf_format_optionmenu = gtk_option_menu_new ();
   gtk_widget_show (sf_format_optionmenu);
   gtk_table_attach (GTK_TABLE (table8), sf_format_optionmenu, 2, 3, 1, 2,
       (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
gtk_tooltips_set_tip (tooltips, sf_format_optionmenu, _ ("Click and pick a file format from the list of available formats."), NULL); menu1 = gtk_menu_new ();

       int a = 1;
       char form_name[256];
       while (a < NUMCAPS) {
           if ( tFFormats[a].ffmpeg_name == NULL ) {
sprintf(form_name, "%s (%s)", tFFormats[a].longname, xv_next_element (tFFormats[a].extensions)); sf_format_item1 = gtk_menu_item_new_with_mnemonic (_ (form_name));
               gtk_widget_show (sf_format_item1);
               gtk_container_add (GTK_CONTAINER (menu1), sf_format_item1);
gtk_option_menu_set_menu (GTK_OPTION_MENU (sf_format_optionmenu), menu1);

I wasn't sure this was going to work, but this far it does. Now, if I want to programatically select one of the entries, I don't know which entry has which index. So I need to look at
each item, check the label, get the index if the label text matches.

However, I can't find a way to enumerate across all the menuitems.

Or are there better ways to do it?


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