diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2010-11-09 21:24:41 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2010-12-04 15:38:54 +0100 |
commit | 3f12fc2bd87209b366e806c01859279830b350de (patch) | |
tree | d4db3b018ee9e481a791ebe44e37f81af3957d3e /gtk/gtkstylecontext.c | |
parent | d9664021cc4917b93ac9a1aa0183e30226f61c7c (diff) | |
download | gtk+-3f12fc2bd87209b366e806c01859279830b350de.tar.gz |
GtkStyleContext: Add gtk_style_context_set_background().
This function replaces gtk_style_set_background().
Diffstat (limited to 'gtk/gtkstylecontext.c')
-rw-r--r-- | gtk/gtkstylecontext.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index cadd28e684..7554322848 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -2743,6 +2743,48 @@ gtk_style_context_invalidate (GtkStyleContext *context) priv->invalidating_context = FALSE; } +/** + * gtk_style_context_set_background: + * @context: a #GtkStyleContext + * @window: a #GdkWindow + * + * Sets the background of @window to the background pattern or + * color specified in @context for its current state. + * + * Since: 3.0 + **/ +void +gtk_style_context_set_background (GtkStyleContext *context, + GdkWindow *window) +{ + GtkStateFlags state; + cairo_pattern_t *pattern; + GdkRGBA *color; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (GDK_IS_WINDOW (window)); + + state = gtk_style_context_get_state (context); + gtk_style_context_get (context, state, + "background-image", &pattern, + NULL); + if (pattern) + { + gdk_window_set_background_pattern (window, pattern); + cairo_pattern_destroy (pattern); + return; + } + + gtk_style_context_get (context, state, + "background-color", &color, + NULL); + if (color) + { + gdk_window_set_background_rgba (window, color); + gdk_rgba_free (color); + } +} + /* Paint methods */ /** |