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
This commit is contained in:
Matthias Clasen 2014-09-19 08:41:06 -04:00
parent 5c95a2fc12
commit 18931cf0db
2 changed files with 39 additions and 8 deletions

View File

@ -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;
}

View File

@ -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