[gtk+/wip/baedert/children: 5/13] widget: Implement map/unmap with child widgets



commit c64627802bb8d535d36262089e326063e4ac16a2
Author: Timm Bäder <mail baedert org>
Date:   Fri Nov 18 09:50:52 2016 +0100

    widget: Implement map/unmap with child widgets
    
    Once again, do what GtkContainer did before.

 gtk/gtkcontainer.c |   34 ----------------------------------
 gtk/gtkwidget.c    |   17 +++++++++++++++--
 2 files changed, 15 insertions(+), 36 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 66983bc..4fcaf57 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -326,8 +326,6 @@ static gint     gtk_container_draw                 (GtkWidget         *widget,
                                                     cairo_t           *cr);
 static void     gtk_container_snapshot             (GtkWidget         *widget,
                                                     GtkSnapshot       *snapshot);
-static void     gtk_container_map                  (GtkWidget         *widget);
-static void     gtk_container_unmap                (GtkWidget         *widget);
 static GtkSizeRequestMode gtk_container_get_request_mode (GtkWidget   *widget);
 
 static GtkWidgetPath * gtk_container_real_get_path_for_child (GtkContainer *container,
@@ -464,8 +462,6 @@ gtk_container_class_init (GtkContainerClass *class)
   widget_class->compute_expand = gtk_container_compute_expand;
   widget_class->snapshot = gtk_container_snapshot;
   widget_class->draw = gtk_container_draw;
-  widget_class->map = gtk_container_map;
-  widget_class->unmap = gtk_container_unmap;
   widget_class->focus = gtk_container_focus;
   widget_class->get_request_mode = gtk_container_get_request_mode;
 
@@ -3098,36 +3094,6 @@ gtk_container_snapshot (GtkWidget   *widget,
   gtk_snapshot_pop (snapshot);
 }
 
-static void
-gtk_container_map_child (GtkWidget *child,
-                         gpointer   client_data)
-{
-  if (_gtk_widget_get_visible (child) &&
-      _gtk_widget_get_child_visible (child) &&
-      !_gtk_widget_get_mapped (child))
-    gtk_widget_map (child);
-}
-
-static void
-gtk_container_map (GtkWidget *widget)
-{
-  GTK_WIDGET_CLASS (parent_class)->map (widget);
-
-  gtk_container_forall (GTK_CONTAINER (widget),
-                        gtk_container_map_child,
-                        NULL);
-}
-
-static void
-gtk_container_unmap (GtkWidget *widget)
-{
-  GTK_WIDGET_CLASS (parent_class)->unmap (widget);
-
-  gtk_container_forall (GTK_CONTAINER (widget),
-                        (GtkCallback)gtk_widget_unmap,
-                        NULL);
-}
-
 static gboolean
 gtk_container_should_propagate_draw (GtkContainer   *container,
                                      GtkWidget      *child,
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 5dfbad5..d9b77bf 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -10742,10 +10742,21 @@ gtk_widget_real_map (GtkWidget *widget)
 
   if (!_gtk_widget_get_mapped (widget))
     {
+      GtkWidget *p;
       priv->mapped = TRUE;
 
       if (_gtk_widget_get_has_window (widget))
-       gdk_window_show (priv->window);
+        gdk_window_show (priv->window);
+
+      for (p = gtk_widget_get_first_child (widget);
+           p != NULL;
+           p = gtk_widget_get_next_sibling (p))
+        {
+          if (_gtk_widget_get_visible (p) &&
+              _gtk_widget_get_child_visible (p) &&
+              !_gtk_widget_get_mapped (p))
+            gtk_widget_map (p);
+        }
     }
 }
 
@@ -10767,7 +10778,9 @@ gtk_widget_real_unmap (GtkWidget *widget)
       priv->mapped = FALSE;
 
       if (_gtk_widget_get_has_window (widget))
-       gdk_window_hide (priv->window);
+        gdk_window_hide (priv->window);
+
+      gtk_widget_forall (widget, (GtkCallback) gtk_widget_unmap, NULL);
     }
 }
 


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