diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-01-10 21:42:57 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-01-10 21:42:57 -0500 |
commit | 592794b3090f9cd02aa3a84c8dfcda8d68ff5e64 (patch) | |
tree | d9e34ce0beb9e43b85f0caa5e4a6328309214d9a | |
parent | 0691f8f011efebbc1c3a9e7ca76a65d23f58c1e2 (diff) | |
download | gtk+-592794b3090f9cd02aa3a84c8dfcda8d68ff5e64.tar.gz |
inspector: Don't use GSettings directly
It is not necessary here, and using GtkSettings gives us
a greater chance to not fail e.g. on Windows.
https://bugzilla.gnome.org/show_bug.cgi?id=742664
-rw-r--r-- | gtk/inspector/visual.c | 65 | ||||
-rw-r--r-- | gtk/inspector/visual.ui | 2 |
2 files changed, 13 insertions, 54 deletions
diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c index b2f2c42801..ee4ee3f28e 100644 --- a/gtk/inspector/visual.c +++ b/gtk/inspector/visual.c @@ -203,9 +203,7 @@ init_theme (GtkInspectorVisual *vis) { GHashTable *t; GHashTableIter iter; - gchar *theme, *current_theme, *path; - gint i, pos; - GSettings *settings; + gchar *theme, *path; t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); g_hash_table_add (t, g_strdup ("Adwaita")); @@ -223,22 +221,16 @@ init_theme (GtkInspectorVisual *vis) fill_gtk (path, t); g_free (path); - settings = g_settings_new ("org.gnome.desktop.interface"); - current_theme = g_settings_get_string (settings, "gtk-theme"); - g_object_unref (settings); - g_hash_table_iter_init (&iter, t); - pos = i = 0; while (g_hash_table_iter_next (&iter, (gpointer *)&theme, NULL)) { - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (vis->priv->theme_combo), theme); - if (g_strcmp0 (theme, current_theme) == 0) - pos = i; - i++; + gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (vis->priv->theme_combo), theme, theme); } g_hash_table_destroy (t); - gtk_combo_box_set_active (GTK_COMBO_BOX (vis->priv->theme_combo), pos); + g_object_bind_property (gtk_settings_get_default (), "gtk-theme-name", + vis->priv->theme_combo, "active-id", + G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); if (g_getenv ("GTK_THEME") != NULL) { @@ -249,17 +241,6 @@ init_theme (GtkInspectorVisual *vis) } static void -theme_changed (GtkComboBox *c, - GtkInspectorVisual *vis) -{ - gchar *theme; - - theme = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (c)); - g_object_set (gtk_settings_get_default (), "gtk-theme-name", theme, NULL); - g_free (theme); -} - -static void init_dark (GtkInspectorVisual *vis) { g_object_bind_property (gtk_settings_get_default (), "gtk-application-prefer-dark-theme", @@ -303,46 +284,28 @@ init_icons (GtkInspectorVisual *vis) { GHashTable *t; GHashTableIter iter; - gchar *theme, *current_theme, *path; - gint i, pos; - GSettings *settings; - gchar *iconsdir = get_data_path ("icons"); + gchar *theme, *path; t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - fill_icons (iconsdir, t); - - g_free (iconsdir); + path = get_data_path ("icons"); + fill_icons (path, t); + g_free (path); path = g_build_filename (g_get_user_data_dir (), "icons", NULL); fill_icons (path, t); g_free (path); - settings = g_settings_new ("org.gnome.desktop.interface"); - current_theme = g_settings_get_string (settings, "icon-theme"); - g_object_unref (settings); - g_hash_table_iter_init (&iter, t); - pos = i = 0; while (g_hash_table_iter_next (&iter, (gpointer *)&theme, NULL)) { - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (vis->priv->icon_combo), theme); - if (g_strcmp0 (theme, current_theme) == 0) - pos = i; - i++; + gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (vis->priv->icon_combo), theme, theme); } g_hash_table_destroy (t); - gtk_combo_box_set_active (GTK_COMBO_BOX (vis->priv->icon_combo), pos); -} - -static void -icons_changed (GtkComboBox *c, - GtkInspectorVisual *vis) -{ - gchar *theme = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (c)); - g_object_set (gtk_settings_get_default (), "gtk-icon-theme-name", theme, NULL); - g_free (theme); + g_object_bind_property (gtk_settings_get_default (), "gtk-icon-theme-name", + vis->priv->icon_combo, "active-id", + G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); } static void @@ -529,8 +492,6 @@ gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass) gtk_widget_class_bind_template_callback (widget_class, direction_changed); gtk_widget_class_bind_template_callback (widget_class, baselines_activate); gtk_widget_class_bind_template_callback (widget_class, pixelcache_activate); - gtk_widget_class_bind_template_callback (widget_class, theme_changed); - gtk_widget_class_bind_template_callback (widget_class, icons_changed); } // vim: set et sw=2 ts=2: diff --git a/gtk/inspector/visual.ui b/gtk/inspector/visual.ui index 5d49c60583..8890a8255b 100644 --- a/gtk/inspector/visual.ui +++ b/gtk/inspector/visual.ui @@ -50,7 +50,6 @@ <property name="visible">True</property> <property name="halign">end</property> <property name="valign">baseline</property> - <signal name="changed" handler="theme_changed"/> </object> <packing> <property name="expand">True</property> @@ -117,7 +116,6 @@ <property name="visible">True</property> <property name="halign">end</property> <property name="valign">baseline</property> - <signal name="changed" handler="icons_changed"/> </object> <packing> <property name="expand">True</property> |