GtkStyleContext: Add gtk_style_context_lookup_color().
gtk_style_lookup_color() now uses this function internally.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user