[gtk+] inspector: Don't use GSettings directly
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Don't use GSettings directly
- Date: Fri, 9 Jan 2015 20:30:34 +0000 (UTC)
commit 6384167054307ce7af249e40e47973d4761d97ab
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jan 9 15:28:53 2015 -0500
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
gtk/inspector/visual.c | 101 ++++++++++-------------------------------------
gtk/inspector/visual.ui | 3 -
2 files changed, 21 insertions(+), 83 deletions(-)
---
diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c
index dec6e74..3bde0aa 100644
--- a/gtk/inspector/visual.c
+++ b/gtk/inspector/visual.c
@@ -227,9 +227,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);
/* Builtin themes */
@@ -249,22 +247,14 @@ 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)
{
@@ -275,17 +265,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",
@@ -329,46 +308,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
@@ -401,44 +362,27 @@ init_cursors (GtkInspectorVisual *vis)
GHashTableIter iter;
gchar *theme, *current_theme, *path;
gint i, pos;
- GSettings *settings;
- gchar *cursordir;
t = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- cursordir = get_data_path ("icons");
- fill_cursors (cursordir, t);
- g_free (cursordir);
+ path = get_data_path ("icons");
+ fill_cursors (path, t);
+ g_free (path);
path = g_build_filename (g_get_user_data_dir (), "icons", NULL);
fill_cursors (path, t);
g_free (path);
- settings = g_settings_new ("org.gnome.desktop.interface");
- current_theme = g_settings_get_string (settings, "cursor-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->cursor_combo), theme);
- if (g_strcmp0 (theme, current_theme) == 0)
- pos = i;
- i++;
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (vis->priv->cursor_combo), theme, theme);
}
g_hash_table_destroy (t);
- gtk_combo_box_set_active (GTK_COMBO_BOX (vis->priv->cursor_combo), pos);
-}
-
-static void
-cursors_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-cursor-theme-name", theme, NULL);
- g_free (theme);
+ g_object_bind_property (gtk_settings_get_default (), "gtk-cursor-theme-name",
+ vis->priv->cursor_combo, "active-id",
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
}
static void
@@ -568,7 +512,7 @@ keynav_failed (GtkWidget *widget, GtkDirectionType direction, GtkInspectorVisual
else if (direction == GTK_DIR_UP &&
widget == vis->priv->gl_box)
next = vis->priv->debug_box;
- else
+ else
next = NULL;
if (next)
@@ -758,9 +702,6 @@ gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
gtk_widget_class_bind_template_callback (widget_class, rendering_mode_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);
- gtk_widget_class_bind_template_callback (widget_class, cursors_changed);
gtk_widget_class_bind_template_callback (widget_class, software_gl_activate);
gtk_widget_class_bind_template_callback (widget_class, software_surface_activate);
gtk_widget_class_bind_template_callback (widget_class, texture_rectangle_activate);
diff --git a/gtk/inspector/visual.ui b/gtk/inspector/visual.ui
index abbfb2b..adb7cf2 100644
--- a/gtk/inspector/visual.ui
+++ b/gtk/inspector/visual.ui
@@ -57,7 +57,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>
@@ -124,7 +123,6 @@
<property name="visible">True</property>
<property name="halign">end</property>
<property name="valign">baseline</property>
- <signal name="changed" handler="cursors_changed"/>
</object>
<packing>
<property name="expand">True</property>
@@ -193,7 +191,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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]