[gtk+/gtk-style-context: 157/260] GtkStyleContext: Add gtk_style_context_lookup_color().
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 157/260] GtkStyleContext: Add gtk_style_context_lookup_color().
- Date: Wed, 20 Oct 2010 10:34:38 +0000 (UTC)
commit dde8ab32da59fb9b568b14239201d0f6787ae3a3
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Aug 3 20:30:26 2010 +0200
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 9a9ccb5..ef6fe30 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 (mapping)
- {
- color->red = mapping->red;
- color->green = mapping->green;
- color->blue = mapping->blue;
- return TRUE;
- }
- }
+ if (!priv->context)
+ return FALSE;
- return FALSE;
+ return gtk_style_context_lookup_color (priv->context, color_name, color);
}
/**
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 0e7cedb..591094b 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 c3a4516..133f357 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]