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

📄 preferences.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 4 页
字号:
                                                    "apply_button" );    gtk_widget_set_sensitive( apply_button, TRUE );}/**************************************************************************** * GtkIntChanged: signal called when the user changes an integer value. ****************************************************************************/static void GtkIntChanged( GtkEditable *editable, gpointer user_data ){    intf_thread_t *p_intf;    module_config_t *p_config;    GHashTable *hash_table;    GtkWidget *apply_button;    p_intf = (intf_thread_t *)gtk_object_get_data( GTK_OBJECT(editable),                                                   "p_intf" );    gtk_spin_button_update( GTK_SPIN_BUTTON(editable) );    hash_table = (GHashTable *)gtk_object_get_data( GTK_OBJECT(user_data),                                                    "config_hash_table" );    /* free old p_config */    p_config = (module_config_t *)g_hash_table_lookup( hash_table,                                                       (gpointer)editable );    if( p_config ) GtkFreeHashValue( NULL, (gpointer)p_config, (void *)p_intf );    p_config = malloc( sizeof(module_config_t) );    p_config->i_type = CONFIG_ITEM_INTEGER;    p_config->i_value = gtk_spin_button_get_value_as_int(                            GTK_SPIN_BUTTON(editable) );    p_config->psz_name = (char *)gtk_object_get_data( GTK_OBJECT(editable),                                                      "config_option" );    g_hash_table_insert( hash_table, (gpointer)editable,                         (gpointer)p_config );    /* change the highlight status of the Apply button */    apply_button = (GtkWidget *)gtk_object_get_data( GTK_OBJECT(user_data),                                                    "apply_button" );    gtk_widget_set_sensitive( apply_button, TRUE );}/*************************************************************************************** * GtkIntRangedChanged: signal called when the user changes an integer with range value. **************************************************************************************/static void GtkIntRangedChanged( GtkEditable *editable, gpointer user_data ){    intf_thread_t *p_intf;    module_config_t *p_config;    GHashTable *hash_table;    GtkWidget *apply_button;    p_intf = (intf_thread_t *)gtk_object_get_data( GTK_OBJECT(editable),                                                   "p_intf" );    hash_table = (GHashTable *)gtk_object_get_data( GTK_OBJECT(user_data),                                                    "config_hash_table" );    /* free old p_config */    p_config = (module_config_t *)g_hash_table_lookup( hash_table,                                                       (gpointer)editable );    if( p_config ) GtkFreeHashValue( NULL, (gpointer)p_config, (void *)p_intf );    p_config = malloc( sizeof(module_config_t) );    p_config->i_type = CONFIG_ITEM_INTEGER;    p_config->i_value = ((GTK_ADJUSTMENT(editable))->value);    p_config->psz_name = (char *)gtk_object_get_data( GTK_OBJECT(editable),                                                      "config_option" );    g_hash_table_insert( hash_table, (gpointer)editable,                         (gpointer)p_config );    /* change the highlight status of the Apply button */    apply_button = (GtkWidget *)gtk_object_get_data( GTK_OBJECT(user_data),                                                    "apply_button" );    gtk_widget_set_sensitive( apply_button, TRUE );}/**************************************************************************** * GtkFloatChanged: signal called when the user changes a float value. ****************************************************************************/static void GtkFloatChanged( GtkEditable *editable, gpointer user_data ){    intf_thread_t *p_intf;    module_config_t *p_config;    GHashTable *hash_table;    GtkWidget *apply_button;    p_intf = (intf_thread_t *)gtk_object_get_data( GTK_OBJECT(editable),                                                   "p_intf" );    gtk_spin_button_update( GTK_SPIN_BUTTON(editable) );    hash_table = (GHashTable *)gtk_object_get_data( GTK_OBJECT(user_data),                                                    "config_hash_table" );    /* free old p_config */    p_config = (module_config_t *)g_hash_table_lookup( hash_table,                                                       (gpointer)editable );    if( p_config ) GtkFreeHashValue( NULL, (gpointer)p_config, (void *)p_intf );    p_config = malloc( sizeof(module_config_t) );    p_config->i_type = CONFIG_ITEM_FLOAT;    p_config->f_value = gtk_spin_button_get_value_as_float(                           GTK_SPIN_BUTTON(editable) );    p_config->psz_name = (char *)gtk_object_get_data( GTK_OBJECT(editable),                                                      "config_option" );    g_hash_table_insert( hash_table, (gpointer)editable,                         (gpointer)p_config );    /* change the highlight status of the Apply button */    apply_button = (GtkWidget *)gtk_object_get_data( GTK_OBJECT(user_data),                                                    "apply_button" );    gtk_widget_set_sensitive( apply_button, TRUE );}/*************************************************************************************** * GtkIntRangedChanged: signal called when the user changes an integer with range value. **************************************************************************************/static void GtkFloatRangedChanged( GtkEditable *editable, gpointer user_data ){    intf_thread_t *p_intf;    module_config_t *p_config;    GHashTable *hash_table;    GtkWidget *apply_button;    p_intf = (intf_thread_t *)gtk_object_get_data( GTK_OBJECT(editable),                                                   "p_intf" );    hash_table = (GHashTable *)gtk_object_get_data( GTK_OBJECT(user_data),                                                    "config_hash_table" );    /* free old p_config */    p_config = (module_config_t *)g_hash_table_lookup( hash_table,                                                       (gpointer)editable );    if( p_config ) GtkFreeHashValue( NULL, (gpointer)p_config, (void *)p_intf );    p_config = malloc( sizeof(module_config_t) );    p_config->i_type = CONFIG_ITEM_FLOAT;    p_config->f_value = ((GTK_ADJUSTMENT(editable))->value);    p_config->psz_name = (char *)gtk_object_get_data( GTK_OBJECT(editable),                                                      "config_option" );    g_hash_table_insert( hash_table, (gpointer)editable,                         (gpointer)p_config );    /* change the highlight status of the Apply button */    apply_button = (GtkWidget *)gtk_object_get_data( GTK_OBJECT(user_data),                                                    "apply_button" );    gtk_widget_set_sensitive( apply_button, TRUE );}/**************************************************************************** * GtkBoolChanged: signal called when the user changes a bool value. ****************************************************************************/static void GtkBoolChanged( GtkToggleButton *button, gpointer user_data ){    intf_thread_t *p_intf;    module_config_t *p_config;    GHashTable *hash_table;    GtkWidget *apply_button;    p_intf = (intf_thread_t *)gtk_object_get_data( GTK_OBJECT(button),                                                   "p_intf" );    hash_table = (GHashTable *)gtk_object_get_data( GTK_OBJECT(user_data),                                                    "config_hash_table" );    /* free old p_config */    p_config = (module_config_t *)g_hash_table_lookup( hash_table,                                                       (gpointer)button );    if( p_config ) GtkFreeHashValue( NULL, (gpointer)p_config, (void *)p_intf );    p_config = malloc( sizeof(module_config_t) );    p_config->i_type = CONFIG_ITEM_BOOL;    p_config->i_value = gtk_toggle_button_get_active( button );    p_config->psz_name = (char *)gtk_object_get_data( GTK_OBJECT(button),                                                      "config_option" );    g_hash_table_insert( hash_table, (gpointer)button,                         (gpointer)p_config );    /* change the highlight status of the Apply button */    apply_button = (GtkWidget *)gtk_object_get_data( GTK_OBJECT(user_data),                                                     "apply_button" );    gtk_widget_set_sensitive( apply_button, TRUE );}/**************************************************************************** * GtkFreeHashTable: signal called when the config hash table is destroyed. ****************************************************************************/static void GtkFreeHashTable( GtkObject *object ){    GHashTable *hash_table = (GHashTable *)gtk_object_get_data( object,                                                         "config_hash_table" );    intf_thread_t *p_intf = (intf_thread_t *)gtk_object_get_data( object,                                                                  "p_intf" );    g_hash_table_foreach( hash_table, GtkFreeHashValue, (void *)p_intf );    g_hash_table_destroy( hash_table );}/**************************************************************************** * GtkFreeHashValue: signal called when an element of the config hash table * is destroyed. ****************************************************************************/static void GtkFreeHashValue( gpointer key, gpointer value, gpointer user_data){    module_config_t * p_config = (module_config_t *)value;    if( p_config->i_type == CONFIG_ITEM_STRING )        if( p_config->psz_value ) g_free( p_config->psz_value );    free( p_config );}/**************************************************************************** * GtkSaveHashValue: callback used when enumerating the hash table in * GtkConfigApply(). ****************************************************************************/static gboolean GtkSaveHashValue( gpointer key, gpointer value,                                  gpointer user_data ){    intf_thread_t *   p_intf   = (intf_thread_t *)user_data;    module_config_t * p_config = (module_config_t *)value;    switch( p_config->i_type )    {    case CONFIG_ITEM_STRING:    case CONFIG_ITEM_FILE:    case CONFIG_ITEM_DIRECTORY:    case CONFIG_ITEM_MODULE:        config_PutPsz( p_intf, p_config->psz_name,                       *p_config->psz_value ? p_config->psz_value : NULL );        break;    case CONFIG_ITEM_INTEGER:    case CONFIG_ITEM_BOOL:        config_PutInt( p_intf, p_config->psz_name, p_config->i_value );        break;    case CONFIG_ITEM_FLOAT:        config_PutFloat( p_intf, p_config->psz_name, p_config->f_value );        break;    }    /* free the hash value we allocated */    if( p_config->i_type == CONFIG_ITEM_STRING )        g_free( p_config->psz_value );    free( p_config );    /* return TRUE so glib will free the hash entry */    return TRUE;}/**************************************************************************** * GtkConfigDialogDestroyed: callback triggered when the config dialog box is * destroyed. ****************************************************************************/static void GtkConfigDialogDestroyed( GtkObject *object, gpointer user_data ){    intf_thread_t *p_intf = (intf_thread_t *)user_data;    char *psz_module_name;    psz_module_name = gtk_object_get_data( object, "psz_module_name" );    /* remove the ref to the dialog box */    gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_window),                         psz_module_name, NULL );    GtkFreeHashTable( object );}

⌨️ 快捷键说明

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