style: Add _gtk_style_provider_private_get_settings()

This gives a GtkSettings object for resolving system-dependant things -
like the default font family and font size.
No code does this yet, but we have an API.

Only GtkSettings implements this.
This commit is contained in:
Benjamin Otte 2012-12-01 01:24:12 +01:00
parent 41f8ba3c35
commit 3ff7f1fd43
4 changed files with 48 additions and 0 deletions

View File

@ -1454,6 +1454,12 @@ gtk_settings_provider_iface_init (GtkStyleProviderIface *iface)
{
}
static GtkSettings *
gtk_settings_style_provider_get_settings (GtkStyleProviderPrivate *provider)
{
return GTK_SETTINGS (provider);
}
static void
gtk_settings_style_provider_lookup (GtkStyleProviderPrivate *provider,
const GtkCssMatcher *matcher,
@ -1472,6 +1478,7 @@ gtk_settings_style_provider_lookup (GtkStyleProviderPrivate *provider,
static void
gtk_settings_provider_private_init (GtkStyleProviderPrivateInterface *iface)
{
iface->get_settings = gtk_settings_style_provider_get_settings;
iface->lookup = gtk_settings_style_provider_lookup;
}

View File

@ -123,6 +123,29 @@ gtk_style_cascade_provider_iface_init (GtkStyleProviderIface *iface)
iface->get_style_property = gtk_style_cascade_get_style_property;
}
static GtkSettings *
gtk_style_cascade_get_settings (GtkStyleProviderPrivate *provider)
{
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
GtkStyleCascadeIter iter;
GtkSettings *settings;
GtkStyleProvider *item;
for (item = gtk_style_cascade_iter_init (cascade, &iter);
item;
item = gtk_style_cascade_iter_next (cascade, &iter))
{
if (!GTK_IS_STYLE_PROVIDER_PRIVATE (item))
continue;
settings = _gtk_style_provider_private_get_settings (GTK_STYLE_PROVIDER_PRIVATE (item));
if (settings)
return settings;
}
return NULL;
}
static GtkCssValue *
gtk_style_cascade_get_color (GtkStyleProviderPrivate *provider,
const char *name)
@ -233,6 +256,7 @@ static void
gtk_style_cascade_provider_private_iface_init (GtkStyleProviderPrivateInterface *iface)
{
iface->get_color = gtk_style_cascade_get_color;
iface->get_settings = gtk_style_cascade_get_settings;
iface->get_keyframes = gtk_style_cascade_get_keyframes;
iface->lookup = gtk_style_cascade_lookup;
iface->get_change = gtk_style_cascade_get_change;

View File

@ -125,3 +125,18 @@ _gtk_style_provider_private_changed (GtkStyleProviderPrivate *provider)
g_signal_emit (provider, signals[CHANGED], 0);
}
GtkSettings *
_gtk_style_provider_private_get_settings (GtkStyleProviderPrivate *provider)
{
GtkStyleProviderPrivateInterface *iface;
g_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), NULL);
iface = GTK_STYLE_PROVIDER_PRIVATE_GET_INTERFACE (provider);
if (!iface->get_settings)
return NULL;
return iface->get_settings (provider);
}

View File

@ -41,6 +41,7 @@ struct _GtkStyleProviderPrivateInterface
GtkCssValue * (* get_color) (GtkStyleProviderPrivate *provider,
const char *name);
GtkSettings * (* get_settings) (GtkStyleProviderPrivate *provider);
GtkCssKeyframes * (* get_keyframes) (GtkStyleProviderPrivate *provider,
const char *name);
void (* lookup) (GtkStyleProviderPrivate *provider,
@ -55,6 +56,7 @@ struct _GtkStyleProviderPrivateInterface
GType _gtk_style_provider_private_get_type (void) G_GNUC_CONST;
GtkSettings * _gtk_style_provider_private_get_settings (GtkStyleProviderPrivate *provider);
GtkCssValue * _gtk_style_provider_private_get_color (GtkStyleProviderPrivate *provider,
const char *name);
GtkCssKeyframes * _gtk_style_provider_private_get_keyframes(GtkStyleProviderPrivate *provider,