[gtk+/wip/baedert/children: 31/46] Move child widget snapshotting into GtkWidget



commit 352060c7a13d4d909f2d85250eeef0e202e4e9d5
Author: Timm Bäder <mail baedert org>
Date:   Wed Nov 30 11:18:50 2016 +0100

    Move child widget snapshotting into GtkWidget

 gtk/gtkcontainer.c |   35 -----------------------------------
 gtk/gtkwidget.c    |   23 ++++++++++++++++++++++-
 2 files changed, 22 insertions(+), 36 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index a289ce5..3b05b8f 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -42,7 +42,6 @@
 #include "gtkmarshalers.h"
 #include "gtksizerequest.h"
 #include "gtksizerequestcacheprivate.h"
-#include "gtksnapshotprivate.h"
 #include "gtkwidgetprivate.h"
 #include "gtkwindow.h"
 #include "gtkassistant.h"
@@ -322,8 +321,6 @@ static void     gtk_container_children_callback    (GtkWidget         *widget,
                                                     gpointer           client_data);
 static gint     gtk_container_draw                 (GtkWidget         *widget,
                                                     cairo_t           *cr);
-static void     gtk_container_snapshot             (GtkWidget         *widget,
-                                                    GtkSnapshot       *snapshot);
 static GtkSizeRequestMode gtk_container_get_request_mode (GtkWidget   *widget);
 
 static GtkWidgetPath * gtk_container_real_get_path_for_child (GtkContainer *container,
@@ -458,7 +455,6 @@ gtk_container_class_init (GtkContainerClass *class)
 
   widget_class->destroy = gtk_container_destroy;
   widget_class->compute_expand = gtk_container_compute_expand;
-  widget_class->snapshot = gtk_container_snapshot;
   widget_class->draw = gtk_container_draw;
   widget_class->focus = gtk_container_focus;
   widget_class->get_request_mode = gtk_container_get_request_mode;
@@ -3044,37 +3040,6 @@ gtk_container_draw (GtkWidget *widget,
   return FALSE;
 }
 
-static void
-gtk_container_snapshot_forall (GtkWidget *child,
-                               gpointer   snapshot)
-{
-  gtk_widget_snapshot_child (_gtk_widget_get_parent (child),
-                             child,
-                             snapshot);
-}
-
-static void
-gtk_container_snapshot (GtkWidget   *widget,
-                        GtkSnapshot *snapshot)
-{
-  GtkContainer *container = GTK_CONTAINER (widget);
-  GtkAllocation allocation, clip;
-  graphene_rect_t bounds;
-
-  gtk_widget_get_clip (widget, &clip);
-  gtk_widget_get_allocation (widget, &allocation);
-  graphene_rect_init (&bounds,
-                      clip.x - allocation.x, clip.y - allocation.y,
-                      clip.width, clip.height);
-  gtk_snapshot_push (snapshot, &bounds, "Children<%s>", G_OBJECT_TYPE_NAME (container));
-
-  gtk_container_forall (container,
-                        gtk_container_snapshot_forall,
-                        snapshot);
-
-  gtk_snapshot_pop (snapshot);
-}
-
 static gboolean
 gtk_container_should_propagate_draw (GtkContainer   *container,
                                      GtkWidget      *child,
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b55d150..c5e9d1f 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -940,7 +940,28 @@ static void
 gtk_widget_real_snapshot (GtkWidget   *widget,
                           GtkSnapshot *snapshot)
 {
-  /* nothing to do here */
+  GtkAllocation allocation, clip;
+  GtkWidget *child;
+  graphene_rect_t bounds;
+
+  gtk_widget_get_clip (widget, &clip);
+  gtk_widget_get_allocation (widget, &allocation);
+  graphene_rect_init (&bounds,
+                      clip.x - allocation.x, clip.y - allocation.y,
+                      clip.width, clip.height);
+  gtk_snapshot_push (snapshot, &bounds, "Children<%s>", G_OBJECT_TYPE_NAME (widget));
+
+  for (child = _gtk_widget_get_first_child (widget);
+       child != NULL;
+       child = _gtk_widget_get_next_sibling (child))
+    {
+      gtk_widget_snapshot_child (widget,
+                                 child,
+                                 snapshot);
+
+    }
+
+  gtk_snapshot_pop (snapshot);
 }
 
 static void


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