forked from AuroraMiddleware/gtk
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
This commit is contained in:
parent
c2ff89bbe3
commit
6384167054
@ -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)
|
||||
{
|
||||
@ -274,17 +264,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)
|
||||
{
|
||||
@ -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);
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user