summaryrefslogtreecommitdiff
path: root/gtk/gtksettings.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2014-09-19 08:41:06 -0400
committerMatthias Clasen <mclasen@redhat.com>2014-09-22 19:40:49 -0400
commit18931cf0dbd52f1c96d6f89011aaf7b613e66267 (patch)
tree3e7e97cb67fcd959d9aeacdd55c9171eb92123a4 /gtk/gtksettings.c
parent5c95a2fc12db6a67192f5e4679cb1719cbb64e93 (diff)
downloadgtk+-18931cf0dbd52f1c96d6f89011aaf7b613e66267.tar.gz
GtkSettings: Add a private getter for the source
Settings have a little more metadata than plain properties. They can come from different sources. Make this information available so we can show it in the inspector. https://bugzilla.gnome.org/show_bug.cgi?id=736971
Diffstat (limited to 'gtk/gtksettings.c')
-rw-r--r--gtk/gtksettings.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index d35c1811c3..6f69576c42 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -120,14 +120,6 @@ struct _GtkSettingsPrivate
GtkCssProvider *key_theme_provider;
};
-typedef enum
-{
- GTK_SETTINGS_SOURCE_DEFAULT,
- GTK_SETTINGS_SOURCE_THEME,
- GTK_SETTINGS_SOURCE_XSETTING,
- GTK_SETTINGS_SOURCE_APPLICATION
-} GtkSettingsSource;
-
struct _GtkSettingsValuePrivate
{
GtkSettingsValue public;
@@ -3213,3 +3205,32 @@ gtk_settings_load_from_key_file (GtkSettings *settings,
g_strfreev (keys);
g_key_file_free (keyfile);
}
+
+GtkSettingsSource
+_gtk_settings_get_setting_source (GtkSettings *settings,
+ const gchar *name)
+{
+ GtkSettingsPrivate *priv = settings->priv;
+ GParamSpec *pspec;
+ GValue val = G_VALUE_INIT;
+
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (settings), name);
+ if (!pspec)
+ return GTK_SETTINGS_SOURCE_DEFAULT;
+
+ if (priv->property_values[pspec->param_id - 1].source == GTK_SETTINGS_SOURCE_APPLICATION)
+ return GTK_SETTINGS_SOURCE_APPLICATION;
+
+ /* We never actually store GTK_SETTINGS_SOURCE_XSETTING as a source
+ * value in the property_values array - we just try to load the xsetting,
+ * and use it when available. Do the same here.
+ */
+ g_value_init (&val, G_TYPE_STRING);
+ if (gdk_screen_get_setting (priv->screen, pspec->name, &val))
+ {
+ g_value_unset (&val);
+ return GTK_SETTINGS_SOURCE_XSETTING;
+ }
+
+ return priv->property_values[pspec->param_id - 1].source;
+}