[gtk+/gtk-style-context: 344/490] GtkStyleContext: Add gtk_style_context_set_background().



commit 87b8baaef9ba05c7cb06d73a4013943409387af8
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Nov 9 21:24:41 2010 +0100

    GtkStyleContext: Add gtk_style_context_set_background().
    
    This function replaces gtk_style_set_background().

 docs/reference/gtk/gtk3-sections.txt |    1 +
 gtk/gtkstylecontext.c                |   42 ++++++++++++++++++++++++++++++++++
 gtk/gtkstylecontext.h                |    3 ++
 3 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 1f67689..da2a56a 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -5466,6 +5466,7 @@ gtk_style_context_push_animatable_region
 gtk_style_context_remove_provider
 gtk_style_context_remove_provider_for_screen
 gtk_style_context_reset_widgets
+gtk_style_context_set_background
 gtk_style_context_restore
 gtk_style_context_save
 gtk_style_context_set_direction
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index cadd28e..7554322 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 */
 
 /**
diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h
index 7b335da..cc83bad 100644
--- a/gtk/gtkstylecontext.h
+++ b/gtk/gtkstylecontext.h
@@ -362,6 +362,9 @@ void gtk_style_context_state_transition_stop   (GtkStyleContext *context,
 void gtk_style_context_invalidate (GtkStyleContext *context);
 void gtk_style_context_reset_widgets (GdkScreen *screen);
 
+void gtk_style_context_set_background (GtkStyleContext *context,
+                                       GdkWindow       *window);
+
 /* Paint methods */
 void gtk_render_check (GtkStyleContext *context,
                        cairo_t         *cr,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]