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

📄 preferences.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 4 页
字号:
/***************************************************************************** * gtk_preferences.c: functions to handle the preferences dialog box. ***************************************************************************** * Copyright (C) 2001-2004 VideoLAN * $Id: preferences.c 10101 2005-03-02 16:47:31Z robux4 $ * * Authors: Gildas Bazin <gbazin@netcourrier.com> *          Lo颿 Minier <lool@via.ecp.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *  * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. *****************************************************************************//***************************************************************************** * Preamble: Our main job is to build a nice interface from the modules config *   structure. Once this is done, we need to track each change made by the *   user to the data contained in this interface so that when/if he decides to *   apply his changes we can quickly commit them into the modules config *   structure. (for this last task we use a GHashTable to accumulate the *   changes. To commit them, we then just have to circle through it ) * *****************************************************************************/#include <sys/types.h>                                              /* off_t */#include <stdlib.h>#include <vlc/vlc.h>#include <vlc/intf.h>#ifdef MODULE_NAME_IS_gnome#   include <gnome.h>#else#   include <gtk/gtk.h>#endif#include <string.h>#include "gtk_support.h"#include "common.h"#include "preferences.h"/* local functions */static void GtkCreateConfigDialog( char *, intf_thread_t * );static void GtkConfigOk          ( GtkButton *, gpointer );static void GtkConfigApply       ( GtkButton *, gpointer );static void GtkConfigCancel      ( GtkButton *, gpointer );static void GtkConfigSave        ( GtkButton *, gpointer );static void GtkConfigDialogDestroyed ( GtkObject *, gpointer );static void GtkStringChanged     ( GtkEditable *, gpointer );static void GtkIntChanged        ( GtkEditable *, gpointer );static void GtkIntRangedChanged  ( GtkEditable *, gpointer );static void GtkFloatChanged      ( GtkEditable *, gpointer );static void GtkFloatRangedChanged      ( GtkEditable *, gpointer );static void GtkBoolChanged       ( GtkToggleButton *, gpointer );static void GtkFreeHashTable     ( GtkObject *object );static void GtkFreeHashValue     ( gpointer, gpointer, gpointer );static gboolean GtkSaveHashValue ( gpointer, gpointer, gpointer );static void GtkModuleConfigure   ( GtkButton *, gpointer );static void GtkModuleSelected    ( GtkButton *, gpointer );static void GtkModuleHighlighted ( GtkCList *, int, int, GdkEventButton *,                                   gpointer );/**************************************************************************** * Callback for menuitems: display configuration interface window ****************************************************************************/void GtkPreferencesShow( GtkMenuItem * menuitem, gpointer user_data ){    intf_thread_t * p_intf;    p_intf = GtkGetIntf( menuitem );    GtkCreateConfigDialog( "main", p_intf );}/**************************************************************************** * GtkCreateConfigDialog: dynamically creates the configuration dialog * box from all the configuration data provided by the selected module. ****************************************************************************//* create a new tooltipped area */#define TOOLTIP( text )                                                   \    /* create an event box to catch some events */                        \    item_event_box = gtk_event_box_new();                                 \    /* add a tooltip on mouseover */                                      \    gtk_tooltips_set_tip( p_intf->p_sys->p_tooltips,                      \                          item_event_box, text, "" );                     \    gtk_container_set_border_width( GTK_CONTAINER(item_event_box), 4 );/* draws a right aligned label in side of a widget */#define LABEL_AND_WIDGET( label_text, widget, tooltip )                   \    gtk_table_resize( GTK_TABLE(category_table), ++rows, 2 );             \    item_align = gtk_alignment_new( 1, .5, 0, 0 );                        \    item_label = gtk_label_new( label_text );                             \    gtk_container_add( GTK_CONTAINER(item_align), item_label );           \    gtk_table_attach_defaults( GTK_TABLE(category_table), item_align,     \                               0, 1, rows - 1, rows );                    \    item_align = gtk_alignment_new( 0, .5, .5, 0 );                       \    gtk_container_add( GTK_CONTAINER(item_align), widget );               \    TOOLTIP(tooltip)                                                      \    gtk_container_add( GTK_CONTAINER(item_event_box), item_align );       \    gtk_table_attach_defaults( GTK_TABLE(category_table), item_event_box, \                               1, 2, rows - 1, rows );static void GtkCreateConfigDialog( char *psz_module_name,                                   intf_thread_t *p_intf ){    module_t *p_parser = NULL;    vlc_list_t *p_list;    module_config_t *p_item;    vlc_bool_t b_advanced = config_GetInt( p_intf, "advanced" );    int i_index;    guint rows = 0;    GHashTable *config_hash_table;    GtkWidget *item_event_box;    GtkWidget *config_dialog;    GtkWidget *config_dialog_vbox;    GtkWidget *config_notebook;    GtkWidget *category_table = NULL;    GtkWidget *category_label = NULL;#ifndef MODULE_NAME_IS_gnome    GtkWidget *dialog_action_area;#endif    GtkWidget *ok_button;    GtkWidget *apply_button;    GtkWidget *save_button;    GtkWidget *cancel_button;    GtkWidget *item_align;    GtkWidget *item_frame;    GtkWidget *item_hbox;    GtkWidget *item_label;    GtkWidget *item_vbox;    GtkWidget *item_combo;    GtkWidget *string_entry;    GtkWidget *integer_spinbutton;    GtkWidget *integer_slider;    GtkWidget *float_spinbutton;    GtkWidget *float_slider;    GtkObject *item_adj;    GtkWidget *bool_checkbutton;    GtkWidget *module_clist;    GtkWidget *module_config_button;    GtkWidget *module_select_button;    gint category_max_height;    /* Check if the dialog box is already opened because we don't want to     * duplicate identical dialog windows. */    config_dialog = (GtkWidget *)gtk_object_get_data(                    GTK_OBJECT(p_intf->p_sys->p_window), psz_module_name );    if( config_dialog )    {        /* Yeah it was open */        gtk_widget_grab_focus( config_dialog );        return;    }    /* Look for the selected module */    p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );    for( i_index = 0; i_index < p_list->i_count; i_index++ )    {        p_parser = (module_t *)p_list->p_values[i_index].p_object ;        if( psz_module_name             && !strcmp( psz_module_name, p_parser->psz_object_name ) )        {            break;        }    }    if( !p_parser || i_index == p_list->i_count )    {        vlc_list_release( p_list );        return;    }    /* We found it, now we can start building its configuration interface */    /* Create the configuration dialog box */#ifdef MODULE_NAME_IS_gnome    config_dialog = gnome_dialog_new( p_parser->psz_longname, NULL );    config_dialog_vbox = GNOME_DIALOG(config_dialog)->vbox;#else    config_dialog = gtk_dialog_new();    gtk_window_set_title( GTK_WINDOW(config_dialog),                          p_parser->psz_longname );    config_dialog_vbox = GTK_DIALOG(config_dialog)->vbox;#endif    gtk_object_set_data( GTK_OBJECT(config_dialog), "p_intf", p_intf );    category_max_height = config_GetInt( p_intf, MODULE_STRING "-prefs-maxh" );    gtk_window_set_policy( GTK_WINDOW(config_dialog), TRUE, TRUE, FALSE );    gtk_container_set_border_width( GTK_CONTAINER(config_dialog_vbox), 0 );    /* Create our config hash table and associate it with the dialog box */    config_hash_table = g_hash_table_new( NULL, NULL );    gtk_object_set_data( GTK_OBJECT(config_dialog),                         "config_hash_table", config_hash_table );    /* Create notebook */    config_notebook = gtk_notebook_new();    gtk_notebook_set_scrollable( GTK_NOTEBOOK(config_notebook), TRUE );    gtk_container_add( GTK_CONTAINER(config_dialog_vbox), config_notebook );    /* Enumerate config options and add corresponding config boxes */    p_item = p_parser->p_config;    if( p_item ) do    {        if( p_item->b_advanced && !b_advanced ) continue;        if( p_item->i_type == CONFIG_HINT_CATEGORY ||            p_item->i_type == CONFIG_HINT_END ||            !category_table )        {            /*             * Before we start building the interface for the new category, we             * must close/finish the previous one we were generating.             */            if( category_table )            {                GtkWidget *_scrolled_window;                GtkWidget *_viewport;                GtkWidget *_vbox;                GtkRequisition _requisition;                /* create a vbox to deal with EXPAND/FILL issues in the                 * notebook page, and pack it with the previously generated                 * category_table */                _vbox = gtk_vbox_new( FALSE, 0 );                gtk_container_set_border_width( GTK_CONTAINER(_vbox), 4 );                gtk_box_pack_start( GTK_BOX(_vbox), category_table,                                    FALSE, FALSE, 0 );                /* create a new scrolled window that will contain all of the                 * above. */                _scrolled_window = gtk_scrolled_window_new( NULL, NULL );                gtk_scrolled_window_set_policy(                    GTK_SCROLLED_WINDOW(_scrolled_window), GTK_POLICY_NEVER,                    GTK_POLICY_AUTOMATIC );                /* add scrolled window as a notebook page */                gtk_notebook_append_page( GTK_NOTEBOOK(config_notebook),                                          _scrolled_window, category_label );                /* pack the vbox into the scrolled window */                _viewport = gtk_viewport_new( NULL, NULL );

⌨️ 快捷键说明

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