[gtk+] API: Add gtk_container_propagate_draw()



commit 0cbe62f943c5bd0fc71824b2415d7ee330ff815e
Author: Benjamin Otte <otte redhat com>
Date:   Mon Sep 6 11:34:07 2010 +0200

    API: Add gtk_container_propagate_draw()
    
    Equivalent to gtk_container_propagate_expose(), just for the draw event.
    Also port GtkContainer to the draw vfunc

 gtk/gtk.symbols    |    1 +
 gtk/gtkcontainer.c |   68 +++++++++++++++++++++++++++++++++------------------
 gtk/gtkcontainer.h |    3 ++
 3 files changed, 48 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 30923d3..671cdd4 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -880,6 +880,7 @@ gtk_container_get_focus_hadjustment
 gtk_container_get_focus_vadjustment
 gtk_container_get_resize_mode
 gtk_container_get_type G_GNUC_CONST
+gtk_container_propagate_draw
 gtk_container_propagate_expose
 gtk_container_remove
 gtk_container_resize_children
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 78299be..8800ecb 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -106,8 +106,8 @@ static void     gtk_container_children_callback    (GtkWidget         *widget,
 						    gpointer           client_data);
 static void     gtk_container_show_all             (GtkWidget         *widget);
 static void     gtk_container_hide_all             (GtkWidget         *widget);
-static gint     gtk_container_expose               (GtkWidget         *widget,
-						    GdkEventExpose    *event);
+static gint     gtk_container_draw                 (GtkWidget         *widget,
+                                                    cairo_t           *cr);
 static void     gtk_container_map                  (GtkWidget         *widget);
 static void     gtk_container_unmap                (GtkWidget         *widget);
 static void     gtk_container_adjust_size_request  (GtkWidget         *widget,
@@ -239,7 +239,7 @@ gtk_container_class_init (GtkContainerClass *class)
 
   widget_class->show_all = gtk_container_show_all;
   widget_class->hide_all = gtk_container_hide_all;
-  widget_class->expose_event = gtk_container_expose;
+  widget_class->draw = gtk_container_draw;
   widget_class->map = gtk_container_map;
   widget_class->unmap = gtk_container_unmap;
   widget_class->focus = gtk_container_focus;
@@ -2757,41 +2757,34 @@ gtk_container_hide_all (GtkWidget *widget)
 
 
 static void
-gtk_container_expose_child (GtkWidget *child,
-			    gpointer   client_data)
+gtk_container_draw_child (GtkWidget *child,
+			  gpointer   client_data)
 {
   struct {
     GtkWidget *container;
-    GdkEventExpose *event;
+    cairo_t *cr;
   } *data = client_data;
   
-  gtk_container_propagate_expose (GTK_CONTAINER (data->container),
-				  child,
-				  data->event);
+  gtk_container_propagate_draw (GTK_CONTAINER (data->container),
+				child,
+				data->cr);
 }
 
 static gint 
-gtk_container_expose (GtkWidget      *widget,
-		      GdkEventExpose *event)
+gtk_container_draw (GtkWidget *widget,
+                    cairo_t   *cr)
 {
   struct {
     GtkWidget *container;
-    GdkEventExpose *event;
+    cairo_t *cr;
   } data;
 
-  g_return_val_if_fail (GTK_IS_CONTAINER (widget), FALSE);
-  g_return_val_if_fail (event != NULL, FALSE);
-
+  data.container = widget;
+  data.cr = cr;
   
-  if (gtk_widget_is_drawable (widget))
-    {
-      data.container = widget;
-      data.event = event;
-      
-      gtk_container_forall (GTK_CONTAINER (widget),
-			    gtk_container_expose_child,
-			    &data);
-    }   
+  gtk_container_forall (GTK_CONTAINER (widget),
+                        gtk_container_draw_child,
+			&data);
   
   return FALSE;
 }
@@ -2832,6 +2825,33 @@ gtk_container_unmap (GtkWidget *widget)
 			  NULL);
 }
 
+void
+gtk_container_propagate_draw (GtkContainer   *container,
+                              GtkWidget      *child,
+                              cairo_t        *cr)
+{
+  GdkEventExpose *event;
+
+  g_return_if_fail (GTK_IS_CONTAINER (container));
+  g_return_if_fail (GTK_IS_WIDGET (child));
+  g_return_if_fail (cr != NULL);
+
+  g_assert (gtk_widget_get_parent (child) == GTK_WIDGET (container));
+
+  event = _gtk_cairo_get_event (cr);
+  if (event)
+    {
+      gtk_container_propagate_expose (container, child, event);
+    }
+  else
+    {
+      /* XXX: Needs gtk_widget_draw(), but can only happen once
+       * that function exists */
+      g_assert_not_reached ();
+    }
+
+}
+
 /**
  * gtk_container_propagate_expose:
  * @container: a #GtkContainer
diff --git a/gtk/gtkcontainer.h b/gtk/gtkcontainer.h
index f437675..cabe547 100644
--- a/gtk/gtkcontainer.h
+++ b/gtk/gtkcontainer.h
@@ -119,6 +119,9 @@ void     gtk_container_foreach      (GtkContainer       *container,
 				     gpointer            callback_data);
 GList*   gtk_container_get_children     (GtkContainer       *container);
 
+void     gtk_container_propagate_draw   (GtkContainer   *container,
+					 GtkWidget      *child,
+					 cairo_t        *cr);
 void     gtk_container_propagate_expose (GtkContainer   *container,
 					 GtkWidget      *child,
 					 GdkEventExpose *event);



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