Commit 13352755 authored by Matthias Clasen's avatar Matthias Clasen

Add a way to set symbolic colors per-widget

The new function, gtk_widget_modify_symbolic_color() is similar
in spirit to the other gtk_widget_modify_ functions.
parent be3a1abc
......@@ -5661,6 +5661,7 @@ gtk_widget_modify_text
gtk_widget_modify_base
gtk_widget_modify_font
gtk_widget_modify_cursor
gtk_widget_modify_symbolic_color
gtk_widget_create_pango_context
gtk_widget_get_pango_context
gtk_widget_create_pango_layout
......
......@@ -5170,6 +5170,7 @@ gtk_widget_modify_cursor
gtk_widget_modify_font
gtk_widget_modify_style
gtk_widget_modify_text
gtk_widget_modify_symbolic_color
gtk_widget_new
gtk_widget_path
gtk_widget_pop_colormap
......
......@@ -1334,6 +1334,34 @@ _gtk_rc_style_get_color_hashes (GtkRcStyle *rc_style)
return priv->color_hashes;
}
static void gtk_rc_style_prepend_empty_color_hash (GtkRcStyle *rc_style);
void
_gtk_rc_style_set_symbolic_color (GtkRcStyle *rc_style,
const gchar *name,
const GdkColor *color)
{
GtkRcStylePrivate *priv = GTK_RC_STYLE_GET_PRIVATE (rc_style);
GHashTable *our_hash = NULL;
if (priv->color_hashes)
our_hash = priv->color_hashes->data;
if (our_hash == NULL)
{
if (color == NULL)
return;
gtk_rc_style_prepend_empty_color_hash (rc_style);
our_hash = priv->color_hashes->data;
}
if (color)
g_hash_table_insert (our_hash, g_strdup (name), gdk_color_copy (color));
else
g_hash_table_remove (our_hash, name);
}
static gint
gtk_rc_properties_cmp (gconstpointer bsearch_node1,
gconstpointer bsearch_node2)
......
......@@ -263,6 +263,10 @@ void _gtk_rc_style_unset_rc_property (GtkRcStyle *rc_style,
GSList * _gtk_rc_style_get_color_hashes (GtkRcStyle *rc_style);
void _gtk_rc_style_set_symbolic_color (GtkRcStyle *rc_style,
const gchar *name,
const GdkColor *color);
const gchar* _gtk_rc_context_get_default_font_name (GtkSettings *settings);
void _gtk_rc_context_destroy (GtkSettings *settings);
......
......@@ -6683,6 +6683,32 @@ gtk_widget_modify_color_component (GtkWidget *widget,
gtk_widget_modify_style (widget, rc_style);
}
/**
* gtk_widget_modify_symbolic_color:
* @widget: a #GtkWidget
* @name: the name of the symbolic color to modify
* @color: (allow-none): the color to assign (does not need to be allocated),
* or %NULL to undo the effect of previous calls to
* of gtk_widget_modify_symbolic_color().
*
* Sets a symbolic color for a widget.
* All other style values are left untouched. See also
* gtk_widget_modify_style().
*
* Since: 2.22
**/
void
gtk_widget_modify_symbolic_color (GtkWidget *widget,
const gchar *name,
const GdkColor *color)
{
GtkRcStyle *rc_style = gtk_widget_get_modifier_style (widget);
_gtk_rc_style_set_symbolic_color (rc_style, name, color);
gtk_widget_modify_style (widget, rc_style);
}
/**
* gtk_widget_modify_fg:
* @widget: a #GtkWidget
......
......@@ -1156,6 +1156,9 @@ void gtk_widget_modify_cursor (GtkWidget *widget,
const GdkColor *secondary);
void gtk_widget_modify_font (GtkWidget *widget,
PangoFontDescription *font_desc);
void gtk_widget_modify_symbolic_color (GtkWidget *widget,
const gchar *name,
const GdkColor *color);
#ifndef GTK_DISABLE_DEPRECATED
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment