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

📄 gtk.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 2 页
字号:
    gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_adj),                         "p_intf", p_intf );    gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_sout ),                         "p_intf", p_intf );    psz_sout = config_GetPsz( p_intf, "sout" );    p_target = g_string_new( psz_sout ? psz_sout : "" );    if( psz_sout ) free( psz_sout );    gtk_entry_set_text( gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_sout ), "sout_entry_target" ), p_target->str );    g_string_free( p_target, TRUE );    /* FIXME it's to be sure that only file entry is selected */    gtk_toggle_button_set_active(  gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_sout ),                                   "sout_access_udp" ), TRUE );    gtk_toggle_button_set_active(  gtk_object_get_data( GTK_OBJECT( p_intf->p_sys->p_sout ),                                   "sout_access_file" ), TRUE );    /* Show the control window */    gtk_widget_show( p_intf->p_sys->p_window );#ifdef NEED_GTK_MAIN    while( !p_intf->b_die )    {        Manage( p_intf );        /* Sleep to avoid using all CPU - since some interfaces need to         * access keyboard events, a 100ms delay is a good compromise */        gdk_threads_leave();        msleep( INTF_IDLE_SLEEP );        gdk_threads_enter();    }#else    /* Sleep to avoid using all CPU - since some interfaces needs to access     * keyboard events, a 100ms delay is a good compromise */    i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, (GtkFunction)Manage,                               p_intf );    /* Enter Gtk mode */    gtk_main();    /* Remove the timeout */    gtk_timeout_remove( i_dummy );#endif    /* Destroy the Tooltips structure */    gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_tooltips) );    gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_messages) );    gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_playwin) );    gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_popup) );    gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_window) );#ifdef NEED_GTK_MAIN    gdk_threads_leave();#endif}/* following functions are local *//***************************************************************************** * Manage: manage main thread messages ***************************************************************************** * In this function, called approx. 10 times a second, we check what the * main program wanted to tell us. *****************************************************************************/static int Manage( intf_thread_t *p_intf ){    int i_start, i_stop;    vlc_mutex_lock( &p_intf->change_lock );    /* If the "display popup" flag has changed */    if( p_intf->b_menu_change )    {        if( !GTK_IS_WIDGET( p_intf->p_sys->p_popup ) )        {            p_intf->p_sys->p_popup = create_intf_popup();            gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_popup ),                                 "p_intf", p_intf );        }        gtk_menu_popup( GTK_MENU( p_intf->p_sys->p_popup ),                        NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME );        p_intf->b_menu_change = 0;    }    /* Update the log window */    vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );    i_stop = *p_intf->p_sys->p_sub->pi_stop;    vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );    if( p_intf->p_sys->p_sub->i_start != i_stop )    {        static GdkColor white  = { 0, 0xffff, 0xffff, 0xffff };        static GdkColor gray   = { 0, 0xaaaa, 0xaaaa, 0xaaaa };        static GdkColor yellow = { 0, 0xffff, 0xffff, 0x6666 };        static GdkColor red    = { 0, 0xffff, 0x6666, 0x6666 };        static const char * ppsz_type[4] = { ": ", " error: ", " warning: ",                                             " debug: " };        static GdkColor *   pp_color[4] = { &white, &red, &yellow, &gray };        for( i_start = p_intf->p_sys->p_sub->i_start;             i_start != i_stop;             i_start = (i_start+1) % VLC_MSG_QSIZE )        {            /* Append all messages to log window */            gtk_text_insert( p_intf->p_sys->p_messages_text, NULL, &gray,             NULL, p_intf->p_sys->p_sub->p_msg[i_start].psz_module, -1 );            gtk_text_insert( p_intf->p_sys->p_messages_text, NULL, &gray,                NULL, ppsz_type[p_intf->p_sys->p_sub->p_msg[i_start].i_type],                -1 );            gtk_text_insert( p_intf->p_sys->p_messages_text, NULL,                pp_color[p_intf->p_sys->p_sub->p_msg[i_start].i_type], NULL,                p_intf->p_sys->p_sub->p_msg[i_start].psz_msg, -1 );            gtk_text_insert( p_intf->p_sys->p_messages_text, NULL, &gray,                NULL, "\n", -1 );        }        vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );        p_intf->p_sys->p_sub->i_start = i_start;        vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );        /* If the messages list becomes too big, just clean half of it. */        if( gtk_text_get_length( p_intf->p_sys->p_messages_text ) >            VLC_MSG_QSIZE * 1000 )        {            gtk_text_set_point( p_intf->p_sys->p_messages_text, 0 );            gtk_text_forward_delete( p_intf->p_sys->p_messages_text,                gtk_text_get_length( p_intf->p_sys->p_messages_text ) / 2 );        }        gtk_text_set_point( p_intf->p_sys->p_messages_text,                    gtk_text_get_length( p_intf->p_sys->p_messages_text ) );    }    /* Update the playlist */    GtkPlayListManage( p_intf );    /* Update the input */    if( p_intf->p_sys->p_input == NULL )    {        p_intf->p_sys->p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,                                                          FIND_ANYWHERE );    }    else if( p_intf->p_sys->p_input->b_dead )    {        vlc_object_release( p_intf->p_sys->p_input );        p_intf->p_sys->p_input = NULL;    }    if( p_intf->p_sys->p_input )    {        input_thread_t  *p_input = p_intf->p_sys->p_input;        aout_instance_t *p_aout  = NULL;        vout_thread_t   *p_vout  = NULL;        vlc_bool_t      b_need_menus = VLC_FALSE;        vlc_mutex_lock( &p_input->stream.stream_lock );        if( !p_input->b_die )        {            /* New input or stream map change */            if( p_input->stream.b_changed )            {                E_(GtkModeManage)( p_intf );                GtkSetupMenus( p_intf );                p_intf->p_sys->b_playing = 1;            }            /* Manage the slider */            if( p_input->stream.b_seekable && p_intf->p_sys->b_playing )            {                float newvalue = p_intf->p_sys->p_adj->value;#define p_area p_input->stream.p_selected_area                /* If the user hasn't touched the slider since the last time,                 * then the input can safely change it */                if( newvalue == p_intf->p_sys->f_adj_oldvalue )                {                    /* Update the value */                    p_intf->p_sys->p_adj->value =                    p_intf->p_sys->f_adj_oldvalue =                        ( 100. * p_area->i_tell ) / p_area->i_size;                    gtk_signal_emit_by_name( GTK_OBJECT( p_intf->p_sys->p_adj ),                                             "value_changed" );                }                /* Otherwise, send message to the input if the user has                 * finished dragging the slider.                 * Beware, the hack below is needed by the dvdplay plugin! */                else if( p_intf->p_sys->b_slider_free                /* hack -> */ && (p_intf->p_sys->f_adj_oldvalue < 100.) )                {                    if( newvalue >= 0. && newvalue < 100. )                    {                        double f_fpos = (double)newvalue / 100.0;                        /* release the lock to be able to seek */                        vlc_mutex_unlock( &p_input->stream.stream_lock );                        var_SetFloat( p_input, "position", f_fpos );                        vlc_mutex_lock( &p_input->stream.stream_lock );                    }                    /* Update the old value */                    p_intf->p_sys->f_adj_oldvalue = newvalue;                }#undef p_area            }            if( p_intf->p_sys->i_part !=                p_input->stream.p_selected_area->i_part )            {                p_intf->p_sys->b_chapter_update = 1;                b_need_menus = VLC_TRUE;            }            /* Does the audio output require to update the menus ? */            p_aout = (aout_instance_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,                                                         FIND_ANYWHERE );            if( p_aout != NULL )            {                vlc_value_t val;                if( var_Get( (vlc_object_t *)p_aout, "intf-change", &val ) >= 0                    && val.b_bool )                {                    p_intf->p_sys->b_aout_update = 1;                    b_need_menus = 1;                }                vlc_object_release( (vlc_object_t *)p_aout );            }            /* Does the video output require to update the menus ? */            p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,                                                       FIND_ANYWHERE );            if( p_vout != NULL )             {                vlc_value_t val;                if( var_Get( (vlc_object_t *)p_vout, "intf-change", &val ) >= 0                    && val.b_bool )                {                    p_intf->p_sys->b_vout_update = 1;                    b_need_menus = 1;                }                vlc_object_release( (vlc_object_t *)p_vout );            }            if( b_need_menus )            {                GtkSetupMenus( p_intf );            }        }        vlc_mutex_unlock( &p_input->stream.stream_lock );    }    else if( p_intf->p_sys->b_playing && !p_intf->b_die )    {        E_(GtkModeManage)( p_intf );        p_intf->p_sys->b_playing = 0;    }#ifndef NEED_GTK_MAIN    if( p_intf->b_die )    {        vlc_mutex_unlock( &p_intf->change_lock );        /* Prepare to die, young Skywalker */        gtk_main_quit();        return FALSE;    }#endif    vlc_mutex_unlock( &p_intf->change_lock );    return TRUE;}

⌨️ 快捷键说明

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