styleprovider: Change function prototype
Make _gtk_style_provider_private_get_color() return a GtkCssValue (a GtkCssColorValue to be exact) instead of GtkSymbolicColor. With this, the symbolic color usage inside GTK is minimized.
This commit is contained in:
parent
08ac1504d2
commit
42dc0ea0fd
@ -161,14 +161,13 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
|
||||
return _gtk_css_value_ref (color->last_value);
|
||||
case COLOR_TYPE_NAME:
|
||||
{
|
||||
GtkSymbolicColor *symbolic;
|
||||
GtkCssValue *named;
|
||||
|
||||
symbolic = _gtk_style_provider_private_get_color (provider, color->sym_col.name);
|
||||
|
||||
if (!symbolic)
|
||||
named = _gtk_style_provider_private_get_color (provider, color->sym_col.name);
|
||||
if (named == NULL)
|
||||
return NULL;
|
||||
|
||||
value = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (symbolic), provider, current, current_deps, dependencies);
|
||||
value = _gtk_css_color_value_resolve (named, provider, current, current_deps, dependencies);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -27,13 +27,13 @@
|
||||
|
||||
#include "gtkbitmaskprivate.h"
|
||||
#include "gtkcssarrayvalueprivate.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtkcsskeyframesprivate.h"
|
||||
#include "gtkcssparserprivate.h"
|
||||
#include "gtkcsssectionprivate.h"
|
||||
#include "gtkcssselectorprivate.h"
|
||||
#include "gtkcssshorthandpropertyprivate.h"
|
||||
#include "gtkcssstylefuncsprivate.h"
|
||||
#include "gtksymboliccolor.h"
|
||||
#include "gtkstyleprovider.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkstylepropertiesprivate.h"
|
||||
@ -1403,7 +1403,7 @@ gtk_css_provider_init (GtkCssProvider *css_provider)
|
||||
|
||||
priv->symbolic_colors = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
(GDestroyNotify) g_free,
|
||||
(GDestroyNotify) gtk_symbolic_color_unref);
|
||||
(GDestroyNotify) _gtk_css_value_unref);
|
||||
priv->keyframes = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
(GDestroyNotify) g_free,
|
||||
(GDestroyNotify) _gtk_css_value_unref);
|
||||
@ -1479,7 +1479,7 @@ gtk_css_style_provider_iface_init (GtkStyleProviderIface *iface)
|
||||
iface->get_style_property = gtk_css_provider_get_style_property;
|
||||
}
|
||||
|
||||
static GtkSymbolicColor *
|
||||
static GtkCssValue *
|
||||
gtk_css_style_provider_get_color (GtkStyleProviderPrivate *provider,
|
||||
const char *name)
|
||||
{
|
||||
@ -1838,7 +1838,7 @@ parse_import (GtkCssScanner *scanner)
|
||||
static gboolean
|
||||
parse_color_definition (GtkCssScanner *scanner)
|
||||
{
|
||||
GtkSymbolicColor *symbolic;
|
||||
GtkCssValue *color;
|
||||
char *name;
|
||||
|
||||
gtk_css_scanner_push_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
|
||||
@ -1862,8 +1862,8 @@ parse_color_definition (GtkCssScanner *scanner)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
symbolic = _gtk_css_symbolic_value_new (scanner->parser);
|
||||
if (symbolic == NULL)
|
||||
color = _gtk_css_color_value_parse (scanner->parser);
|
||||
if (color == NULL)
|
||||
{
|
||||
g_free (name);
|
||||
_gtk_css_parser_resync (scanner->parser, TRUE, 0);
|
||||
@ -1874,7 +1874,7 @@ parse_color_definition (GtkCssScanner *scanner)
|
||||
if (!_gtk_css_parser_try (scanner->parser, ";", TRUE))
|
||||
{
|
||||
g_free (name);
|
||||
gtk_symbolic_color_unref (symbolic);
|
||||
_gtk_css_value_unref (color);
|
||||
gtk_css_provider_error_literal (scanner->provider,
|
||||
scanner,
|
||||
GTK_CSS_PROVIDER_ERROR,
|
||||
@ -1886,7 +1886,7 @@ parse_color_definition (GtkCssScanner *scanner)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
g_hash_table_insert (scanner->provider->priv->symbolic_colors, name, symbolic);
|
||||
g_hash_table_insert (scanner->provider->priv->symbolic_colors, name, color);
|
||||
|
||||
gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_COLOR_DEFINITION);
|
||||
return TRUE;
|
||||
@ -2878,7 +2878,6 @@ gtk_css_provider_print_colors (GHashTable *colors,
|
||||
GString *str)
|
||||
{
|
||||
GList *keys, *walk;
|
||||
char *s;
|
||||
|
||||
keys = g_hash_table_get_keys (colors);
|
||||
/* so the output is identical for identical styles */
|
||||
@ -2887,14 +2886,12 @@ gtk_css_provider_print_colors (GHashTable *colors,
|
||||
for (walk = keys; walk; walk = walk->next)
|
||||
{
|
||||
const char *name = walk->data;
|
||||
GtkSymbolicColor *symbolic = g_hash_table_lookup (colors, (gpointer) name);
|
||||
GtkCssValue *color = g_hash_table_lookup (colors, (gpointer) name);
|
||||
|
||||
g_string_append (str, "@define-color ");
|
||||
g_string_append (str, name);
|
||||
g_string_append (str, " ");
|
||||
s = gtk_symbolic_color_to_string (symbolic);
|
||||
g_string_append (str, s);
|
||||
g_free (s);
|
||||
_gtk_css_value_print (color, str);
|
||||
g_string_append (str, ";\n");
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ gtk_modifier_style_provider_init (GtkStyleProviderIface *iface)
|
||||
iface->get_style_property = gtk_modifier_style_get_style_property;
|
||||
}
|
||||
|
||||
static GtkSymbolicColor *
|
||||
static GtkCssValue *
|
||||
gtk_modifier_style_provider_get_color (GtkStyleProviderPrivate *provider,
|
||||
const char *name)
|
||||
{
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkcssproviderprivate.h"
|
||||
#include "gtkstyleproviderprivate.h"
|
||||
#include "gtksymboliccolor.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkversion.h"
|
||||
|
||||
@ -1460,7 +1459,7 @@ gtk_settings_provider_iface_init (GtkStyleProviderIface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
static GtkSymbolicColor *
|
||||
static GtkCssValue *
|
||||
gtk_settings_style_provider_get_color (GtkStyleProviderPrivate *provider,
|
||||
const char *name)
|
||||
{
|
||||
|
@ -123,13 +123,13 @@ gtk_style_cascade_provider_iface_init (GtkStyleProviderIface *iface)
|
||||
iface->get_style_property = gtk_style_cascade_get_style_property;
|
||||
}
|
||||
|
||||
static GtkSymbolicColor *
|
||||
static GtkCssValue *
|
||||
gtk_style_cascade_get_color (GtkStyleProviderPrivate *provider,
|
||||
const char *name)
|
||||
{
|
||||
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
|
||||
GtkStyleCascadeIter iter;
|
||||
GtkSymbolicColor *symbolic;
|
||||
GtkCssValue *color;
|
||||
GtkStyleProvider *item;
|
||||
|
||||
for (item = gtk_style_cascade_iter_init (cascade, &iter);
|
||||
@ -138,9 +138,9 @@ gtk_style_cascade_get_color (GtkStyleProviderPrivate *provider,
|
||||
{
|
||||
if (GTK_IS_STYLE_PROVIDER_PRIVATE (item))
|
||||
{
|
||||
symbolic = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (item), name);
|
||||
if (symbolic)
|
||||
return symbolic;
|
||||
color = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (item), name);
|
||||
if (color)
|
||||
return color;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2298,7 +2298,7 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context,
|
||||
else
|
||||
g_value_init (&pcache->value, GDK_TYPE_COLOR);
|
||||
|
||||
if (_gtk_style_context_resolve_color (context, color, &rgba, NULL))
|
||||
if (_gtk_style_context_resolve_color (context, _gtk_symbolic_color_get_css_value (color), &rgba, NULL))
|
||||
{
|
||||
if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_RGBA)
|
||||
g_value_set_boxed (&pcache->value, &rgba);
|
||||
@ -2704,7 +2704,7 @@ gtk_style_context_get_junction_sides (GtkStyleContext *context)
|
||||
|
||||
gboolean
|
||||
_gtk_style_context_resolve_color (GtkStyleContext *context,
|
||||
GtkSymbolicColor *color,
|
||||
GtkCssValue *color,
|
||||
GdkRGBA *result,
|
||||
GtkCssDependencies *dependencies)
|
||||
{
|
||||
@ -2714,7 +2714,7 @@ _gtk_style_context_resolve_color (GtkStyleContext *context,
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
g_return_val_if_fail (result != NULL, FALSE);
|
||||
|
||||
val = _gtk_css_color_value_resolve (_gtk_symbolic_color_get_css_value (color),
|
||||
val = _gtk_css_color_value_resolve (color,
|
||||
GTK_STYLE_PROVIDER_PRIVATE (context->priv->cascade),
|
||||
_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR),
|
||||
GTK_CSS_DEPENDS_ON_COLOR,
|
||||
@ -2742,17 +2742,17 @@ gtk_style_context_lookup_color (GtkStyleContext *context,
|
||||
const gchar *color_name,
|
||||
GdkRGBA *color)
|
||||
{
|
||||
GtkSymbolicColor *sym_color;
|
||||
GtkCssValue *value;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE);
|
||||
g_return_val_if_fail (color_name != NULL, FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
sym_color = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (context->priv->cascade), color_name);
|
||||
if (sym_color == NULL)
|
||||
value = _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (context->priv->cascade), color_name);
|
||||
if (value == NULL)
|
||||
return FALSE;
|
||||
|
||||
return _gtk_style_context_resolve_color (context, sym_color, color, NULL);
|
||||
return _gtk_style_context_resolve_color (context, value, color, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtkstyleproviderprivate.h"
|
||||
#include "gtksymboliccolor.h"
|
||||
#include "gtkbitmaskprivate.h"
|
||||
#include "gtkcssvalueprivate.h"
|
||||
|
||||
@ -46,7 +45,7 @@ void _gtk_style_context_queue_invalidate (GtkStyleContext *c
|
||||
gboolean _gtk_style_context_check_region_name (const gchar *str);
|
||||
|
||||
gboolean _gtk_style_context_resolve_color (GtkStyleContext *context,
|
||||
GtkSymbolicColor *color,
|
||||
GtkCssValue *color,
|
||||
GdkRGBA *result,
|
||||
GtkCssDependencies *dependencies);
|
||||
void _gtk_style_context_get_cursor_color (GtkStyleContext *context,
|
||||
|
@ -284,11 +284,11 @@ gtk_style_properties_provider_init (GtkStyleProviderIface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
static GtkSymbolicColor *
|
||||
static GtkCssValue *
|
||||
gtk_style_properties_provider_get_color (GtkStyleProviderPrivate *provider,
|
||||
const char *name)
|
||||
{
|
||||
return gtk_style_properties_lookup_color (GTK_STYLE_PROPERTIES (provider), name);
|
||||
return _gtk_symbolic_color_get_css_value (gtk_style_properties_lookup_color (GTK_STYLE_PROPERTIES (provider), name));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -44,7 +44,7 @@ _gtk_style_provider_private_default_init (GtkStyleProviderPrivateInterface *ifac
|
||||
|
||||
}
|
||||
|
||||
GtkSymbolicColor *
|
||||
GtkCssValue *
|
||||
_gtk_style_provider_private_get_color (GtkStyleProviderPrivate *provider,
|
||||
const char *name)
|
||||
{
|
||||
|
@ -22,8 +22,7 @@
|
||||
#include "gtk/gtkcsskeyframesprivate.h"
|
||||
#include "gtk/gtkcsslookupprivate.h"
|
||||
#include "gtk/gtkcssmatcherprivate.h"
|
||||
#include <gtk/gtkenums.h>
|
||||
#include <gtk/gtksymboliccolor.h>
|
||||
#include "gtk/gtkcssvalueprivate.h"
|
||||
#include <gtk/gtktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
@ -40,7 +39,7 @@ struct _GtkStyleProviderPrivateInterface
|
||||
{
|
||||
GTypeInterface g_iface;
|
||||
|
||||
GtkSymbolicColor * (* get_color) (GtkStyleProviderPrivate *provider,
|
||||
GtkCssValue * (* get_color) (GtkStyleProviderPrivate *provider,
|
||||
const char *name);
|
||||
GtkCssKeyframes * (* get_keyframes) (GtkStyleProviderPrivate *provider,
|
||||
const char *name);
|
||||
@ -56,7 +55,7 @@ struct _GtkStyleProviderPrivateInterface
|
||||
|
||||
GType _gtk_style_provider_private_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkSymbolicColor * _gtk_style_provider_private_get_color (GtkStyleProviderPrivate *provider,
|
||||
GtkCssValue * _gtk_style_provider_private_get_color (GtkStyleProviderPrivate *provider,
|
||||
const char *name);
|
||||
GtkCssKeyframes * _gtk_style_provider_private_get_keyframes(GtkStyleProviderPrivate *provider,
|
||||
const char *name);
|
||||
|
Loading…
Reference in New Issue
Block a user