From 143c4b3b60014891ff43ef00e781bd90b4b19b47 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 3 Aug 2010 20:30:26 +0200 Subject: [PATCH] GtkStyleContext: Add gtk_style_context_lookup_color(). gtk_style_lookup_color() now uses this function internally. --- gtk/gtkstyle.c | 18 +++--------------- gtk/gtkstylecontext.c | 21 +++++++++++++++++++++ gtk/gtkstylecontext.h | 3 +++ 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 9a9ccb55b7..ef6fe3031e 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -958,7 +958,6 @@ gtk_style_lookup_color (GtkStyle *style, GdkColor *color) { GtkStylePrivate *priv; - GSList *iter; g_return_val_if_fail (GTK_IS_STYLE (style), FALSE); g_return_val_if_fail (color_name != NULL, FALSE); @@ -966,21 +965,10 @@ gtk_style_lookup_color (GtkStyle *style, priv = GTK_STYLE_GET_PRIVATE (style); - for (iter = priv->color_hashes; iter != NULL; iter = iter->next) - { - GHashTable *hash = iter->data; - GdkColor *mapping = g_hash_table_lookup (hash, color_name); + if (!priv->context) + return FALSE; - if (mapping) - { - color->red = mapping->red; - color->green = mapping->green; - color->blue = mapping->blue; - return TRUE; - } - } - - return FALSE; + return gtk_style_context_lookup_color (priv->context, color_name, color); } /** diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 0e7cedb476..591094b304 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -1255,6 +1255,27 @@ gtk_style_context_get_direction (GtkStyleContext *context) return priv->direction; } +gboolean +gtk_style_context_lookup_color (GtkStyleContext *context, + const gchar *color_name, + GdkColor *color) +{ + GtkStyleContextPrivate *priv; + GtkSymbolicColor *sym_color; + + 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); + + priv = context->priv; + sym_color = gtk_style_set_lookup_color (priv->store, color_name); + + if (!sym_color) + return FALSE; + + return gtk_symbolic_color_resolve (sym_color, priv->store, color); +} + /* Paint methods */ void gtk_render_check (GtkStyleContext *context, diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index c3a4516225..133f357397 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -118,6 +118,9 @@ void gtk_style_context_set_direction (GtkStyleContext *context, GtkTextDirection direction); GtkTextDirection gtk_style_context_get_direction (GtkStyleContext *context); +gboolean gtk_style_context_lookup_color (GtkStyleContext *context, + const gchar *color_name, + GdkColor *color); /* Semi-private API */ const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,