[gtk+] Add a way to set symbolic colors per-widget
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add a way to set symbolic colors per-widget
- Date: Thu, 29 Apr 2010 21:03:22 +0000 (UTC)
commit 13352755481200ae784b3d3cf6f9151cc36f2bbe
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Apr 28 22:59:03 2010 -0400
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.
docs/reference/gtk/gtk-sections.txt | 1 +
gtk/gtk.symbols | 1 +
gtk/gtkrc.c | 28 ++++++++++++++++++++++++++++
gtk/gtkrc.h | 4 ++++
gtk/gtkwidget.c | 26 ++++++++++++++++++++++++++
gtk/gtkwidget.h | 3 +++
6 files changed, 63 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt
index bf9c664..3ffd3a6 100644
--- a/docs/reference/gtk/gtk-sections.txt
+++ b/docs/reference/gtk/gtk-sections.txt
@@ -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
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index ff85c8c..08f1ae0 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -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
diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c
index 2e94cdf..556e92b 100644
--- a/gtk/gtkrc.c
+++ b/gtk/gtkrc.c
@@ -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)
diff --git a/gtk/gtkrc.h b/gtk/gtkrc.h
index 1ca2d33..0d5e0ce 100644
--- a/gtk/gtkrc.h
+++ b/gtk/gtkrc.h
@@ -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);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 06bfe04..9935874 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -6684,6 +6684,32 @@ gtk_widget_modify_color_component (GtkWidget *widget,
}
/**
+ * 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
* @state: the state for which to set the foreground color
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 0b2d84b..8e12ce8 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]