Commit 18931cf0 authored by Matthias Clasen's avatar Matthias Clasen

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
parent 5c95a2fc
......@@ -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;
}
......@@ -40,6 +40,16 @@ gboolean _gtk_settings_parse_convert (GtkRcPropertyParse
GdkScreen *_gtk_settings_get_screen (GtkSettings *settings);
GtkStyleCascade *_gtk_settings_get_style_cascade (GtkSettings *settings);
typedef enum
{
GTK_SETTINGS_SOURCE_DEFAULT,
GTK_SETTINGS_SOURCE_THEME,
GTK_SETTINGS_SOURCE_XSETTING,
GTK_SETTINGS_SOURCE_APPLICATION
} GtkSettingsSource;
GtkSettingsSource _gtk_settings_get_setting_source (GtkSettings *settings,
const gchar *name);
G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment