⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menu.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 4 页
字号:
     * We have to release the lock since input_ToggleES needs it */    if( p_item_active != NULL )    {        gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_active ),                                        TRUE );    }    /* be sure that menu is sensitive if non empty */    if( i_item > 0 )    {        gtk_widget_set_sensitive( p_root, TRUE );    }    return TRUE;}/***************************************************************************** * GtkTitleMenu: sets menus for titles and chapters selection ***************************************************************************** * Generates two types of menus: *  -simple list of titles *  -cascaded lists of chapters for each title *****************************************************************************/static gint GtkTitleMenu( gpointer       p_data,                          GtkWidget *    p_navigation,                          void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) ){    intf_thread_t *     p_intf;    char                psz_name[ GTK_MENU_LABEL_SIZE ];    GtkWidget *         p_title_menu;    GtkWidget *         p_title_submenu;    GtkWidget *         p_title_item;    GtkWidget *         p_item_active;    GtkWidget *         p_chapter_menu;    GtkWidget *         p_chapter_submenu;    GtkWidget *         p_title_menu_item;    GtkWidget *         p_chapter_menu_item;    GtkWidget *         p_item;    GSList *            p_title_group;    GSList *            p_chapter_group;    guint               i_title;    guint               i_chapter;    guint               i_title_nb;    guint               i_chapter_nb;    /* cast */    p_intf = (intf_thread_t*)p_data;    /* temporary hack to avoid blank menu when an open menu is removed */    if( GTK_MENU_ITEM(p_navigation)->submenu != NULL )    {        gtk_menu_popdown( GTK_MENU( GTK_MENU_ITEM(p_navigation)->submenu ) );    }    /* removes previous menu */    gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_navigation ) );    gtk_widget_set_sensitive( p_navigation, FALSE );    p_title_menu = gtk_menu_new();    p_title_group = NULL;    p_title_submenu = NULL;    p_title_menu_item = NULL;    p_chapter_group = NULL;    p_chapter_submenu = NULL;    p_chapter_menu_item = NULL;    p_item_active = NULL;    i_title_nb = p_intf->p_sys->p_input->stream.i_area_nb - 1;    gtk_object_set_data( GTK_OBJECT( p_title_menu ), "p_intf", p_intf );    /* loop on titles */    for( i_title = 1 ; i_title <= i_title_nb ; i_title++ )    {        /* we group titles in packets of ten for small screens */        if( ( i_title % 10 == 1 ) && ( i_title_nb > 20 ) )        {            if( i_title != 1 )            {                gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_menu_item ),                                           p_title_submenu );                gtk_menu_append( GTK_MENU( p_title_menu ), p_title_menu_item );            }            snprintf( psz_name, GTK_MENU_LABEL_SIZE,                      "%d - %d", i_title, i_title + 9 );            psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';            p_title_menu_item = gtk_menu_item_new_with_label( psz_name );            gtk_widget_show( p_title_menu_item );            p_title_submenu = gtk_menu_new();            gtk_object_set_data( GTK_OBJECT( p_title_submenu ),                                 "p_intf", p_intf );        }        snprintf( psz_name, GTK_MENU_LABEL_SIZE, _("Title %d (%d)"), i_title,                  p_intf->p_sys->p_input->stream.pp_areas[i_title]->i_part_nb - 1);        psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';#if 0        if( pf_toggle == on_menubar_title_toggle )        {            p_title_item = gtk_radio_menu_item_new_with_label( p_title_group,                                                           psz_name );            p_title_group =              gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_title_item ) );            if( p_intf->p_sys->p_input->stream.pp_areas[i_title] ==                         p_intf->p_sys->p_input->stream.p_selected_area )            {                p_item_active = p_title_item;            }            /* setup signal hanling */            gtk_signal_connect( GTK_OBJECT( p_title_item ),                     "toggled",                     GTK_SIGNAL_FUNC( pf_toggle ),                     (gpointer)(p_intf->p_sys->p_input->stream.pp_areas[i_title]) );            if( p_intf->p_sys->p_input->stream.i_area_nb > 1 )            {                /* be sure that menu is sensitive */                gtk_widget_set_sensitive( p_navigation, TRUE );            }        }        else#endif        {            p_title_item = gtk_menu_item_new_with_label( psz_name );#if 1            p_chapter_menu = gtk_menu_new();            gtk_object_set_data( GTK_OBJECT( p_chapter_menu ),                                 "p_intf", p_intf );            i_chapter_nb =               p_intf->p_sys->p_input->stream.pp_areas[i_title]->i_part_nb - 1;            for( i_chapter = 1 ; i_chapter <= i_chapter_nb ; i_chapter++ )            {                /* we group chapters in packets of ten for small screens */                if( ( i_chapter % 10 == 1 ) && ( i_chapter_nb > 20 ) )                {                    if( i_chapter != 1 )                    {                        gtk_menu_item_set_submenu(                                    GTK_MENU_ITEM( p_chapter_menu_item ),                                    p_chapter_submenu );                        gtk_menu_append( GTK_MENU( p_chapter_menu ),                                         p_chapter_menu_item );                    }                    snprintf( psz_name, GTK_MENU_LABEL_SIZE,                              "%d - %d", i_chapter, i_chapter + 9 );                    psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';                    p_chapter_menu_item =                            gtk_menu_item_new_with_label( psz_name );                    gtk_widget_show( p_chapter_menu_item );                    p_chapter_submenu = gtk_menu_new();                    gtk_object_set_data( GTK_OBJECT( p_chapter_submenu ),                                         "p_intf", p_intf );                }                snprintf( psz_name, GTK_MENU_LABEL_SIZE,                          _("Chapter %d"), i_chapter );                psz_name[ GTK_MENU_LABEL_SIZE - 1 ] = '\0';                p_item = gtk_radio_menu_item_new_with_label(                                                p_chapter_group, psz_name );                p_chapter_group = gtk_radio_menu_item_group(                                                GTK_RADIO_MENU_ITEM( p_item ) );                gtk_widget_show( p_item );#define p_area p_intf->p_sys->p_input->stream.pp_areas[i_title]                if( ( p_area ==                        p_intf->p_sys->p_input->stream.p_selected_area ) &&                    ( p_area->i_part == i_chapter ) )                {                    p_item_active = p_item;                }#undef p_area                /* setup signal hanling */                gtk_signal_connect( GTK_OBJECT( p_item ),                           "toggled",                           GTK_SIGNAL_FUNC( pf_toggle ),                           (gpointer)POS2DATA( i_title, i_chapter ) );                if( i_chapter_nb > 20 )                {                    gtk_menu_append( GTK_MENU( p_chapter_submenu ), p_item );                }                else                {                    gtk_menu_append( GTK_MENU( p_chapter_menu ), p_item );                }            }            if( i_chapter_nb > 20 )            {                gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_chapter_menu_item ),                                           p_chapter_submenu );                gtk_menu_append( GTK_MENU( p_chapter_menu ),                                 p_chapter_menu_item );            }            /* link the new menu to the title menu item */            gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_item ),                                       p_chapter_menu );            if( p_intf->p_sys->p_input->stream.pp_areas[i_title]->i_part_nb > 1 )            {                /* be sure that menu is sensitive */                gtk_widget_set_sensitive( p_navigation, TRUE );            }#else            GtkRadioMenu( p_intf, p_title_item, p_chapter_group, _("Chapter"),                p_intf->p_sys->p_input->stream.pp_areas[i_title]->i_part_nb - 1,                1, i_title * 100,                p_intf->p_sys->p_input->stream.p_selected_area->i_part +                p_intf->p_sys->p_input->stream.p_selected_area->i_id *100,                pf_toggle );#endif        }        gtk_widget_show( p_title_item );        if( i_title_nb > 20 )        {            gtk_menu_append( GTK_MENU( p_title_submenu ), p_title_item );        }        else        {            gtk_menu_append( GTK_MENU( p_title_menu ), p_title_item );        }    }    if( i_title_nb > 20 )    {        gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_menu_item ),                                   p_title_submenu );        gtk_menu_append( GTK_MENU( p_title_menu ), p_title_menu_item );    }    /* be sure that menu is sensitive */    gtk_widget_set_sensitive( p_title_menu, TRUE );    /* link the new menu to the menubar item */    gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_navigation ), p_title_menu );    /* Default selected chapter     * We have to release the lock since input_ToggleES needs it */    if( p_item_active != NULL )    {        gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_active ),                                        TRUE );    }#if 0    if( p_intf->p_sys->p_input->stream.i_area_nb > 1 )    {        /* be sure that menu is sensitive */        gtk_widget_set_sensitive( p_navigation, TRUE );    }#endif    return TRUE;}/***************************************************************************** * GtkSetupVarMenu : ***************************************************************************** * *****************************************************************************/static gint GtkSetupVarMenu( intf_thread_t * p_intf,                             vlc_object_t * p_object,                             GtkWidget *p_root,                             char * psz_variable,                             void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) ){    vlc_value_t         val, text, val_list, text_list;    GtkWidget *         p_menu;    GSList *            p_group = NULL;    GtkWidget *         p_item;    GtkWidget *         p_item_active = NULL;    int                 i_item, i_type;     /* temporary hack to avoid blank menu when an open menu is removed */    if( GTK_MENU_ITEM(p_root)->submenu != NULL )    {        gtk_menu_popdown( GTK_MENU( GTK_MENU_ITEM(p_root)->submenu ) );    }    /* removes previous menu */    gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_root ) );    gtk_widget_set_sensitive( p_root, FALSE );    /* Check the type of the object variable */    i_type = var_Type( p_object, psz_variable );    /* Make sure we want to display the variable */    if( i_type & VLC_VAR_HASCHOICE )    {        var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );        if( val.i_int == 0 ) return FALSE;    }    /* Get the descriptive name of the variable */    var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL );    /* get the current value */    if( var_Get( p_object, psz_variable, &val ) < 0 )    {        return FALSE;    }    if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST,                    &val_list, &text_list ) < 0 )    {        if( i_type == VLC_VAR_STRING ) free( val.psz_string );        return FALSE;    }    /* menu container */    p_menu = gtk_menu_new();    gtk_object_set_data( GTK_OBJECT( p_menu ), "p_intf", p_intf );    for( i_item = 0; i_item < val_list.p_list->i_count; i_item++ )    {        switch( i_type & VLC_VAR_TYPE )        {        case VLC_VAR_STRING:            p_item = gtk_radio_menu_item_new_with_label( p_group,                     text_list.p_list->p_values[i_item].psz_string ?                     text_list.p_list->p_values[i_item].psz_string :                     val_list.p_list->p_values[i_item].psz_string );            /* signal hanling for off */            gtk_signal_connect( GTK_OBJECT( p_item ), "toggled",                GTK_SIGNAL_FUNC ( pf_toggle ),                /* FIXME memory leak */                strdup(val_list.p_list->p_values[i_item].psz_string) );            if( !strcmp( val.psz_string,                         val_list.p_list->p_values[i_item].psz_string ) )            {                p_item_active = p_item;            }            break;        case VLC_VAR_INTEGER:            p_item = gtk_radio_menu_item_new_with_label( p_group,                     text_list.p_list->p_values[i_item].psz_string ?                     text_list.p_list->p_values[i_item].psz_string :                     NULL /* FIXME */ );            /* signal hanling for off */            gtk_signal_connect( GTK_OBJECT( p_item ), "toggled",                GTK_SIGNAL_FUNC ( pf_toggle ),                (gpointer)val_list.p_list->p_values[i_item].i_int );            if( val.i_int == val_list.p_list->p_values[i_item].i_int )            {                p_item_active = p_item;            }            break;        default:            /* FIXME */            return FALSE;        }        p_group = gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) );        gtk_widget_show( p_item );        gtk_menu_append( GTK_MENU( p_menu ), p_item );    }    /* link the new menu to the menubar item */    gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );    if( p_item_active )    {        gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(p_item_active),                                        TRUE );    }    if( val_list.p_list->i_count > 0 )    {        gtk_widget_set_sensitive( p_root, TRUE );    }    /* clean up everything */    if( i_type == VLC_VAR_STRING ) free( val.psz_string );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -