static void preferences_themes_setup (EmpathyPreferences *preferences) { GtkComboBox *combo; GtkListStore *model; GtkTreeIter iter; const gchar **themes; gint i; combo = GTK_COMBO_BOX (preferences->combobox_chat_theme); model = gtk_list_store_new (COL_COMBO_COUNT, G_TYPE_STRING, G_TYPE_STRING); themes = empathy_theme_manager_get_themes (); for (i = 0; themes[i]; i += 2) { gtk_list_store_append (model, &iter); gtk_list_store_set (model, &iter, COL_COMBO_VISIBLE_NAME, _(themes[i + 1]), COL_COMBO_NAME, themes[i], -1); } gtk_combo_box_set_model (combo, GTK_TREE_MODEL (model)); g_object_unref (model); }
static void preferences_themes_setup (EmpathyPreferences *preferences) { EmpathyPreferencesPriv *priv = GET_PRIV (preferences); GtkComboBox *combo; GtkCellLayout *cell_layout; GtkCellRenderer *renderer; GtkListStore *store; const gchar **themes; GList *adium_themes; gint i; preferences_theme_variants_setup (preferences); combo = GTK_COMBO_BOX (priv->combobox_chat_theme); cell_layout = GTK_CELL_LAYOUT (combo); /* Create the model */ store = gtk_list_store_new (COL_THEME_COUNT, G_TYPE_STRING, /* Display name */ G_TYPE_STRING, /* Theme name */ G_TYPE_BOOLEAN, /* Is an Adium theme */ G_TYPE_STRING, /* Adium theme path */ G_TYPE_HASH_TABLE); /* Adium theme info */ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), COL_THEME_VISIBLE_NAME, GTK_SORT_ASCENDING); /* Fill the model */ themes = empathy_theme_manager_get_themes (); for (i = 0; themes[i]; i += 2) { gtk_list_store_insert_with_values (store, NULL, -1, COL_THEME_VISIBLE_NAME, _(themes[i + 1]), COL_THEME_NAME, themes[i], COL_THEME_IS_ADIUM, FALSE, -1); } adium_themes = empathy_theme_manager_get_adium_themes (); while (adium_themes != NULL) { GHashTable *info; const gchar *name; const gchar *path; info = adium_themes->data; name = tp_asv_get_string (info, "CFBundleName"); path = tp_asv_get_string (info, "path"); if (name != NULL && path != NULL) { gtk_list_store_insert_with_values (store, NULL, -1, COL_THEME_VISIBLE_NAME, name, COL_THEME_NAME, "adium", COL_THEME_IS_ADIUM, TRUE, COL_THEME_ADIUM_PATH, path, COL_THEME_ADIUM_INFO, info, -1); } g_hash_table_unref (info); adium_themes = g_list_delete_link (adium_themes, adium_themes); } /* Add cell renderer */ renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (cell_layout, renderer, TRUE); gtk_cell_layout_set_attributes (cell_layout, renderer, "text", COL_THEME_VISIBLE_NAME, NULL); gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store)); g_object_unref (store); g_signal_connect (combo, "changed", G_CALLBACK (preferences_theme_changed_cb), preferences); /* Select the theme from the GSetting key and track changes */ preferences_theme_notify_cb (priv->gsettings_chat, EMPATHY_PREFS_CHAT_THEME, preferences); g_signal_connect (priv->gsettings_chat, "changed::" EMPATHY_PREFS_CHAT_THEME, G_CALLBACK (preferences_theme_notify_cb), preferences); g_signal_connect (priv->gsettings_chat, "changed::" EMPATHY_PREFS_CHAT_ADIUM_PATH, G_CALLBACK (preferences_theme_notify_cb), preferences); }