Widget/child constraint maintainence



The attached patch deals with:

 http://bugzilla.gnome.org/show_bug.cgi?id=56834

By making gtk_widget_set_parent() enforce the mapping and
realization constraints itself. It follows my proposal in:

 http://mail.gnome.org/archives/gtk-devel-list/2000-October/msg00277.html

By adding a function (private flag) gtk_widget_set_child_visibible()
to deal with the GtkNoteBook case where a widget wants to keeped
VISIBLE children not mapped.

The patch also adds gtk_container_map() and gtk_container_unmap()
implementations that should work for nearly all containers,
and deletes most of the map()/unmap() implementations from
GTK+.

There is one incompatibility in this change -- containers must call
gtk_widget_set_parent_window() before gtk_widget_set_parent()
when adding a child to a realized window, since gtk_widget_set_parent()
will realize.the child widget in this case.

Even with added docs and a ChangeLog entry, it reduces GTK+
by about 700 lines, which is a tidy simplification.

Regards,
                                        Owen

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.2112
diff -u -r1.2112 ChangeLog
--- ChangeLog	2001/07/06 19:40:58	1.2112
+++ ChangeLog	2001/07/07 06:59:02
@@ -1,3 +1,26 @@
+Sat Jul  7 02:50:14 2001  Owen Taylor  <otaylor redhat com>
+
+	* gtk/gtkwidget.c (gtk_widget_set_parent): Enforce
+	the widget/child realization/mapping invariants.
+
+	* gtk/gtkwidget.[ch] gtk/gtkprivate.h: Add functions 
+	gtk_widget_[get/set]_child_visible() to control
+	whether visible children of a mapped window are
+	mapped.
+
+	* docs/widget_system.txt: Updated for changes in
+	container contract, and addition of GTK_CHILD_VISIBLE.
+
+	* gtk/gtkcontainer.c: Add generic map()/unmap()
+	functions that work for almost all containers.
+
+	* gtk/gtknotebook.c gtk/gtkpacker.c: Use 
+	gtk_widget_set_child_visible() where necessary.
+
+	* gtk/*.c: Remove excess map(), unmap(), and 
+	realization/mapping invariant enforcing code
+	from many containers.
+
 Fri Jul  6 15:38:33 2001  Owen Taylor  <otaylor redhat com>
 
 	* gtk/gtkwidget.c (gtk_widget_class_init):
Index: docs/Changes-2.0.txt
===================================================================
RCS file: /cvs/gnome/gtk+/docs/Changes-2.0.txt,v
retrieving revision 1.24
diff -u -r1.24 Changes-2.0.txt
--- docs/Changes-2.0.txt	2001/06/30 16:08:18	1.24
+++ docs/Changes-2.0.txt	2001/07/07 06:59:03
@@ -396,3 +396,33 @@
   undefined contents for the offscreen areas. In most cases, code
   using gdk_image_get() should really be ported to
   gdk_pixbuf_get_from_drawable().
+
+* The core GTK+ now takes care of handling mapping, unmapping and
+  realizing the child widgets of containers in
+  gtk_widget_set_parent(). In most cases, this allows container
+  implementations to be simplifid by removing the code in add()
+  methods to map and realize children. However, there are 
+  a couple of things to watch out for here:
+
+   - If the parent is realized before the add() happens, 
+     gtk_widget_set_parent_window() must be called before
+     gtk_widget_set_parent(), since gtk_widget_set_parent()
+     will realize the child.
+
+   - If a container depended on its children not being mapped
+     unless it did so itself (for example, GtkNotebook only
+     mapped the current page), then the new function
+     gtk_widget_set_child_visible() must be called to keep
+     widgets that should not be mapped not mapped.
+
+  As part of this change, most containers also will no longer need
+  custom implementations of the map() and unmap() virtual
+  functions. The only cases where this is necessary are:
+
+   - For !NO_WINDOW widgets, if you create children of widget->window 
+     and don't map them in realize() then you must map them
+     in map(). [ In almost all cases, you can simply map the
+     windows in realize() ]
+
+   - For NO_WINDOW widgets, if you create windows in your realize()
+     method, you must map then in map() and unmap them in unmap().
Index: docs/widget_system.txt
===================================================================
RCS file: /cvs/gnome/gtk+/docs/widget_system.txt,v
retrieving revision 1.8
diff -u -r1.8 widget_system.txt
--- docs/widget_system.txt	2000/12/11 17:47:20	1.8
+++ docs/widget_system.txt	2001/07/07 06:59:04
@@ -88,6 +88,14 @@
 	Set by gtk_widget_hide.
 	Implies that a widget is not onscreen, therefore !GTK_MAPPED.
 
+GTK_CHILD_VISIBLE
+        Set by gtk_widget_set_child_visible, and if FALSE indicates that 
+        the widget should not be mapped even if the parent is mapped
+        and visible. Containers like GtkNotebook use this flag.
+        A private flag, not a public flag, so if you need to check
+        this flag, you should call gtk_widget_get_child_visible().
+        (Should be very rarely necesary.)
+
 GTK_SENSITIVE:
 	Set and unset by gtk_widget_set_sensitive.
 	The sensitivity of a widget determines whether it will receive
@@ -228,10 +236,12 @@
 5) if !GTK_WIDGET_TOPLEVEL (widget):
 
    GTK_WIDGET_MAPPED (widget) => GTK_WIDGET_VISIBLE (widget)
+                              => GTK_WIDGET_CHILD_VISIBLE (widget)
                               => GTK_WIDGET_REALIZED (widget)
 
    widget->parent && GTK_WIDGET_MAPPED (widget->parent) && 
-     GTK_WIDGET_VISIBLE (widget) => GTK_WIDGET_MAPPED (widget)
+     GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_CHILD_VISIBLE 
+       => GTK_WIDGET_MAPPED (widget)
 
 Note:, the definition
 
@@ -305,18 +315,9 @@
 
 When a widget is added to a container, the container:
 
-  1) calls gtk_widget_set_parent (widget, container)
-  2) calls gtk_widget_set_parent_window (widget, window) if 
+  1) calls gtk_widget_set_parent_window (widget, window) if 
      the widget is being added to something other than container->window
-  3) if container is realized, and not widget, realizes widget
-  4) if container is mapped, and not widget and widget is GTK_VISIBLE,
-     maps widget
-  5) Queues a resize if the widget is mapped
-
-Note: It would be nice to remove 3) and 4) out of widget specific code
-  since they are of the invariant-enforcing nature, but it is
-  a bit hard, since they can't be done until after 2)
-
+  2) calls gtk_widget_set_parent (widget, container)
 
 Removing from a container
 -------------------------
@@ -369,7 +370,9 @@
   1) Set the MAPPED flag
   2) If the widget has any windows, gdk_window_show those windows
   3) call gtk_widget_map for all child widgets that are 
-     VISIBLE and !MAPPED.
+     VISIBLE, CHILD_VISIBLE and !MAPPED. (A widget will only
+     be !CHILD_VISIBLE if the container set it that way, so
+     most containers will not have to check this.)
   3) Do any other functions related to putting the widget onscreen.
      (for instance, showing extra popup windows...)
 
Index: gtk/gtkbin.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkbin.c,v
retrieving revision 1.27
diff -u -r1.27 gtkbin.c
--- gtk/gtkbin.c	2001/05/25 03:42:40	1.27
+++ gtk/gtkbin.c	2001/07/07 06:59:04
@@ -29,8 +29,6 @@
 
 static void gtk_bin_class_init (GtkBinClass    *klass);
 static void gtk_bin_init       (GtkBin         *bin);
-static void gtk_bin_map        (GtkWidget      *widget);
-static void gtk_bin_unmap      (GtkWidget      *widget);
 static void gtk_bin_add        (GtkContainer   *container,
 			        GtkWidget      *widget);
 static void gtk_bin_remove     (GtkContainer   *container,
@@ -83,9 +81,6 @@
 
   parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
 
-  widget_class->map = gtk_bin_map;
-  widget_class->unmap = gtk_bin_unmap;
-
   container_class->add = gtk_bin_add;
   container_class->remove = gtk_bin_remove;
   container_class->forall = gtk_bin_forall;
@@ -111,44 +106,6 @@
 }
 
 static void
-gtk_bin_map (GtkWidget *widget)
-{
-  GtkBin *bin;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_BIN (widget));
-
-  GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-  bin = GTK_BIN (widget);
-
-  if (bin->child &&
-      GTK_WIDGET_VISIBLE (bin->child) &&
-      !GTK_WIDGET_MAPPED (bin->child))
-    gtk_widget_map (bin->child);
-
-  if (!GTK_WIDGET_NO_WINDOW (widget))
-    gdk_window_show (widget->window);
-}
-
-static void
-gtk_bin_unmap (GtkWidget *widget)
-{
-  GtkBin *bin;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_BIN (widget));
-
-  GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-  bin = GTK_BIN (widget);
-
-  if (!GTK_WIDGET_NO_WINDOW (widget))
-    gdk_window_hide (widget->window);
-
-  if (bin->child && GTK_WIDGET_MAPPED (bin->child))
-    gtk_widget_unmap (bin->child);
-}
-
-static void
 gtk_bin_add (GtkContainer *container,
 	     GtkWidget    *child)
 {
@@ -175,17 +132,6 @@
 
   gtk_widget_set_parent (child, GTK_WIDGET (bin));
   bin->child = child;
-
-  if (GTK_WIDGET_REALIZED (child->parent))
-    gtk_widget_realize (child);
-
-  if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
-    {
-      if (GTK_WIDGET_MAPPED (child->parent))
-	gtk_widget_map (child);
-
-      gtk_widget_queue_resize (child);
-    }
 }
 
 static void
Index: gtk/gtkbox.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkbox.c,v
retrieving revision 1.36
diff -u -r1.36 gtkbox.c
--- gtk/gtkbox.c	2001/07/06 02:10:32	1.36
+++ gtk/gtkbox.c	2001/07/07 06:59:04
@@ -52,8 +52,6 @@
 				  guint            prop_id,
 				  GValue          *value,
 				  GParamSpec      *pspec);
-static void gtk_box_map        (GtkWidget      *widget);
-static void gtk_box_unmap      (GtkWidget      *widget);
 static void gtk_box_add        (GtkContainer   *container,
 			        GtkWidget      *widget);
 static void gtk_box_remove     (GtkContainer   *container,
@@ -115,9 +113,6 @@
   gobject_class->set_property = gtk_box_set_property;
   gobject_class->get_property = gtk_box_get_property;
    
-  widget_class->map = gtk_box_map;
-  widget_class->unmap = gtk_box_unmap;
-
   container_class->add = gtk_box_add;
   container_class->remove = gtk_box_remove;
   container_class->forall = gtk_box_forall;
@@ -379,16 +374,6 @@
 
   gtk_widget_set_parent (child, GTK_WIDGET (box));
   
-  if (GTK_WIDGET_REALIZED (box))
-    gtk_widget_realize (child);
-
-  if (GTK_WIDGET_VISIBLE (box) && GTK_WIDGET_VISIBLE (child))
-    {
-      if (GTK_WIDGET_MAPPED (box))
-	gtk_widget_map (child);
-
-      gtk_widget_queue_resize (child);
-    }
   gtk_widget_child_notify (child, "expand");
   gtk_widget_child_notify (child, "fill");
   gtk_widget_child_notify (child, "padding");
@@ -425,16 +410,6 @@
 
   gtk_widget_set_parent (child, GTK_WIDGET (box));
 
-  if (GTK_WIDGET_REALIZED (box))
-    gtk_widget_realize (child);
-
-  if (GTK_WIDGET_VISIBLE (box) && GTK_WIDGET_VISIBLE (child))
-    {
-      if (GTK_WIDGET_MAPPED (box))
-	gtk_widget_map (child);
-
-      gtk_widget_queue_resize (child);
-    }
   gtk_widget_child_notify (child, "expand");
   gtk_widget_child_notify (child, "fill");
   gtk_widget_child_notify (child, "padding");
@@ -674,56 +649,6 @@
 	gtk_widget_queue_resize (child);
     }
   gtk_widget_thaw_child_notify (child);
-}
-
-static void
-gtk_box_map (GtkWidget *widget)
-{
-  GtkBox *box;
-  GtkBoxChild *child;
-  GList *children;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_BOX (widget));
-
-  box = GTK_BOX (widget);
-  GTK_WIDGET_SET_FLAGS (box, GTK_MAPPED);
-
-  children = box->children;
-  while (children)
-    {
-      child = children->data;
-      children = children->next;
-
-      if (GTK_WIDGET_VISIBLE (child->widget) &&
-	  !GTK_WIDGET_MAPPED (child->widget))
-	gtk_widget_map (child->widget);
-    }
-}
-
-static void
-gtk_box_unmap (GtkWidget *widget)
-{
-  GtkBox *box;
-  GtkBoxChild *child;
-  GList *children;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_BOX (widget));
-
-  box = GTK_BOX (widget);
-  GTK_WIDGET_UNSET_FLAGS (box, GTK_MAPPED);
-
-  children = box->children;
-  while (children)
-    {
-      child = children->data;
-      children = children->next;
-
-      if (GTK_WIDGET_VISIBLE (child->widget) &&
-	  GTK_WIDGET_MAPPED (child->widget))
-	gtk_widget_unmap (child->widget);
-    }
 }
 
 static void
Index: gtk/gtkcontainer.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkcontainer.c,v
retrieving revision 1.81
diff -u -r1.81 gtkcontainer.c
--- gtk/gtkcontainer.c	2001/07/01 00:57:20	1.81
+++ gtk/gtkcontainer.c	2001/07/07 06:59:05
@@ -98,6 +98,9 @@
 static void     gtk_container_hide_all             (GtkWidget         *widget);
 static gint     gtk_container_expose               (GtkWidget         *widget,
 						    GdkEventExpose    *event);
+static void     gtk_container_map                  (GtkWidget         *widget);
+static void     gtk_container_unmap                (GtkWidget         *widget);
+
 static gchar* gtk_container_child_default_composite_name (GtkContainer *container,
 							  GtkWidget    *child);
 
@@ -186,6 +189,8 @@
   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->map = gtk_container_map;
+  widget_class->unmap = gtk_container_unmap;
   widget_class->focus = gtk_container_focus;
   
   class->add = gtk_container_add_unimplemented;
@@ -2319,6 +2324,41 @@
   return TRUE;
 }
 
+static void
+gtk_container_map_child (GtkWidget *child,
+			 gpointer   client_data)
+{
+  if (GTK_WIDGET_VISIBLE (child) &&
+      GTK_WIDGET_CHILD_VISIBLE (child) &&
+      !GTK_WIDGET_MAPPED (child))
+    gtk_widget_map (child);
+}
+
+static void
+gtk_container_map (GtkWidget *widget)
+{
+  GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
+
+  gtk_container_forall (GTK_CONTAINER (widget),
+			gtk_container_map_child,
+			NULL);
+
+  if (!GTK_WIDGET_NO_WINDOW (widget))
+    gdk_window_show (widget->window);
+}
+
+static void
+gtk_container_unmap (GtkWidget *widget)
+{
+  GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
+
+  if (!GTK_WIDGET_NO_WINDOW (widget))
+    gdk_window_hide (widget->window);
+  else
+    gtk_container_forall (GTK_CONTAINER (widget),
+			  (GtkCallback)gtk_widget_unmap,
+			  NULL);
+}
 
 /**
  * gtk_container_propagate_expose:
Index: gtk/gtkcontainer.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkcontainer.h,v
retrieving revision 1.42
diff -u -r1.42 gtkcontainer.h
--- gtk/gtkcontainer.h	2001/07/01 00:57:21	1.42
+++ gtk/gtkcontainer.h	2001/07/07 06:59:05
@@ -191,7 +191,6 @@
 							 GtkWidget	   *child,
 							 const gchar	   *property_name,
 							 GValue		   *value);
-     
 
 #define GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) \
     G_OBJECT_WARN_INVALID_PSPEC ((object), "child property id", (property_id), (pspec))
Index: gtk/gtkfixed.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkfixed.c,v
retrieving revision 1.25
diff -u -r1.25 gtkfixed.c
--- gtk/gtkfixed.c	2001/03/18 04:50:33	1.25
+++ gtk/gtkfixed.c	2001/07/07 06:59:05
@@ -29,7 +29,6 @@
 
 static void gtk_fixed_class_init    (GtkFixedClass    *klass);
 static void gtk_fixed_init          (GtkFixed         *fixed);
-static void gtk_fixed_map           (GtkWidget        *widget);
 static void gtk_fixed_realize       (GtkWidget        *widget);
 static void gtk_fixed_size_request  (GtkWidget        *widget,
 				     GtkRequisition   *requisition);
@@ -87,7 +86,6 @@
 
   parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
 
-  widget_class->map = gtk_fixed_map;
   widget_class->realize = gtk_fixed_realize;
   widget_class->size_request = gtk_fixed_size_request;
   widget_class->size_allocate = gtk_fixed_size_allocate;
@@ -141,17 +139,6 @@
   gtk_widget_set_parent (widget, GTK_WIDGET (fixed));
 
   fixed->children = g_list_append (fixed->children, child_info); 
-
-  if (GTK_WIDGET_REALIZED (fixed))
-    gtk_widget_realize (widget);
-
-  if (GTK_WIDGET_VISIBLE (fixed) && GTK_WIDGET_VISIBLE (widget))
-    {
-      if (GTK_WIDGET_MAPPED (fixed))
-	gtk_widget_map (widget);
-      
-      gtk_widget_queue_resize (GTK_WIDGET (fixed));
-    }
 }
 
 void
@@ -184,33 +171,6 @@
           break;
         }
     }
-}
-
-static void
-gtk_fixed_map (GtkWidget *widget)
-{
-  GtkFixed *fixed;
-  GtkFixedChild *child;
-  GList *children;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_FIXED (widget));
-
-  GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-  fixed = GTK_FIXED (widget);
-
-  children = fixed->children;
-  while (children)
-    {
-      child = children->data;
-      children = children->next;
-
-      if (GTK_WIDGET_VISIBLE (child->widget) &&
-	  !GTK_WIDGET_MAPPED (child->widget))
-	gtk_widget_map (child->widget);
-    }
-
-  gdk_window_show (widget->window);
 }
 
 static void
Index: gtk/gtkframe.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkframe.c,v
retrieving revision 1.37
diff -u -r1.37 gtkframe.c
--- gtk/gtkframe.c	2001/06/24 15:34:47	1.37
+++ gtk/gtkframe.c	2001/07/07 06:59:05
@@ -60,8 +60,6 @@
 				     GtkRequisition *requisition);
 static void gtk_frame_size_allocate (GtkWidget      *widget,
 				     GtkAllocation  *allocation);
-static void gtk_frame_map           (GtkWidget      *widget);
-static void gtk_frame_unmap         (GtkWidget      *widget);
 static void gtk_frame_remove        (GtkContainer   *container,
 				     GtkWidget      *child);
 static void gtk_frame_forall        (GtkContainer   *container,
@@ -168,8 +166,6 @@
   widget_class->expose_event = gtk_frame_expose;
   widget_class->size_request = gtk_frame_size_request;
   widget_class->size_allocate = gtk_frame_size_allocate;
-  widget_class->map = gtk_frame_map;
-  widget_class->unmap = gtk_frame_unmap;
 
   container_class->remove = gtk_frame_remove;
   container_class->forall = gtk_frame_forall;
@@ -641,32 +637,6 @@
 
       gtk_widget_size_allocate (frame->label_widget, &child_allocation);
     }
-}
-
-static void
-gtk_frame_map (GtkWidget *widget)
-{
-  GtkFrame *frame = GTK_FRAME (widget);
-  
-  if (frame->label_widget &&
-      GTK_WIDGET_VISIBLE (frame->label_widget) &&
-      !GTK_WIDGET_MAPPED (frame->label_widget))
-    gtk_widget_map (frame->label_widget);
-
-  if (GTK_WIDGET_CLASS (parent_class)->map)
-    (* GTK_WIDGET_CLASS (parent_class)->map) (widget);
-}
-
-static void
-gtk_frame_unmap (GtkWidget *widget)
-{
-  GtkFrame *frame = GTK_FRAME (widget);
-
-  if (GTK_WIDGET_CLASS (parent_class)->unmap)
-    (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
-
-  if (frame->label_widget && GTK_WIDGET_MAPPED (frame->label_widget))
-    gtk_widget_unmap (frame->label_widget);
 }
 
 static void
Index: gtk/gtkhsv.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkhsv.c,v
retrieving revision 1.12
diff -u -r1.12 gtkhsv.c
--- gtk/gtkhsv.c	2001/06/08 18:09:33	1.12
+++ gtk/gtkhsv.c	2001/07/07 06:59:06
@@ -87,8 +87,6 @@
 static void gtk_hsv_class_init     (GtkHSVClass    *class);
 static void gtk_hsv_init           (GtkHSV         *hsv);
 static void gtk_hsv_destroy        (GtkObject      *object);
-static void gtk_hsv_map            (GtkWidget      *widget);
-static void gtk_hsv_unmap          (GtkWidget      *widget);
 static void gtk_hsv_realize        (GtkWidget      *widget);
 static void gtk_hsv_unrealize      (GtkWidget      *widget);
 static void gtk_hsv_size_request   (GtkWidget      *widget,
@@ -162,8 +160,6 @@
   
   object_class->destroy = gtk_hsv_destroy;
   
-  widget_class->map = gtk_hsv_map;
-  widget_class->unmap = gtk_hsv_unmap;
   widget_class->realize = gtk_hsv_realize;
   widget_class->unrealize = gtk_hsv_unrealize;
   widget_class->size_request = gtk_hsv_size_request;
@@ -264,42 +260,6 @@
 }
 
 /* Default signal handlers */
-
-/* Map handler for the HSV color selector */
-static void
-gtk_hsv_map (GtkWidget *widget)
-{
-  GtkHSV *hsv;
-  HSVPrivate *priv;
-  
-  hsv = GTK_HSV (widget);
-  priv = hsv->priv;
-  
-  if (GTK_WIDGET_MAPPED (widget))
-    return;
-  
-  GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-  
-  gdk_window_show (priv->window);
-}
-
-/* Unmap handler for the HSV color selector */
-static void
-gtk_hsv_unmap (GtkWidget *widget)
-{
-  GtkHSV *hsv;
-  HSVPrivate *priv;
-  
-  hsv = GTK_HSV (widget);
-  priv = hsv->priv;
-  
-  if (!GTK_WIDGET_MAPPED (widget))
-    return;
-  
-  GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-  
-  gdk_window_hide (priv->window);
-}
 
 /* Realize handler for the HSV color selector */
 static void
Index: gtk/gtkimagemenuitem.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkimagemenuitem.c,v
retrieving revision 1.8
diff -u -r1.8 gtkimagemenuitem.c
--- gtk/gtkimagemenuitem.c	2001/06/05 21:48:24	1.8
+++ gtk/gtkimagemenuitem.c	2001/07/07 06:59:06
@@ -43,8 +43,6 @@
 static void gtk_image_menu_item_toggle_size_request  (GtkMenuItem           *menu_item,
 						      gint                  *requisition);
 
-static void gtk_image_menu_item_map        (GtkWidget      *widget);
-static void gtk_image_menu_item_unmap      (GtkWidget      *widget);
 static void gtk_image_menu_item_forall     (GtkContainer   *container,
                                             gboolean	    include_internals,
                                             GtkCallback     callback,
@@ -111,8 +109,6 @@
   
   widget_class->size_request = gtk_image_menu_item_size_request;
   widget_class->size_allocate = gtk_image_menu_item_size_allocate;
-  widget_class->map = gtk_image_menu_item_map;
-  widget_class->unmap = gtk_image_menu_item_unmap;
 
   container_class->forall = gtk_image_menu_item_forall;
   container_class->remove = gtk_image_menu_item_remove;
@@ -269,44 +265,6 @@
 }
 
 static void
-gtk_image_menu_item_map (GtkWidget *widget)
-{
-  GtkImageMenuItem *image_menu_item;
-
-  g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (widget));
-
-  image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
-  
-  (* GTK_WIDGET_CLASS (parent_class)->map) (widget);
-
-  if (image_menu_item->image &&
-      GTK_WIDGET_VISIBLE (image_menu_item->image) &&
-      !GTK_WIDGET_MAPPED (image_menu_item->image))
-    gtk_widget_map (image_menu_item->image);
-
-  if (!GTK_WIDGET_NO_WINDOW (widget))
-    gdk_window_show (widget->window);  
-}
-
-static void
-gtk_image_menu_item_unmap (GtkWidget *widget)
-{
-  GtkImageMenuItem *image_menu_item;
-
-  g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (widget));
-
-  image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
-  
-  (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
-  
-  if (!GTK_WIDGET_NO_WINDOW (widget))
-    gdk_window_hide (widget->window);
-  
-  if (image_menu_item->image && GTK_WIDGET_MAPPED (image_menu_item->image))
-    gtk_widget_unmap (image_menu_item->image);  
-}
-
-static void
 gtk_image_menu_item_forall (GtkContainer   *container,
                             gboolean	    include_internals,
                             GtkCallback     callback,
@@ -443,17 +401,6 @@
   gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item));
 
   g_object_notify (G_OBJECT (image_menu_item), "image");
-  
-  if (GTK_WIDGET_REALIZED (image->parent))
-    gtk_widget_realize (image);
-  
-  if (GTK_WIDGET_VISIBLE (image->parent) && GTK_WIDGET_VISIBLE (image))
-    {
-      if (GTK_WIDGET_MAPPED (image->parent))
-	gtk_widget_map (image);
-
-      gtk_widget_queue_resize (image);
-    }
 }
 
 GtkWidget*
Index: gtk/gtkitem.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkitem.c,v
retrieving revision 1.21
diff -u -r1.21 gtkitem.c
--- gtk/gtkitem.c	2000/12/13 01:34:39	1.21
+++ gtk/gtkitem.c	2001/07/07 06:59:06
@@ -38,8 +38,6 @@
 
 static void gtk_item_class_init (GtkItemClass     *klass);
 static void gtk_item_init       (GtkItem          *item);
-static void gtk_item_map        (GtkWidget        *widget);
-static void gtk_item_unmap      (GtkWidget        *widget);
 static void gtk_item_realize    (GtkWidget        *widget);
 static gint gtk_item_enter      (GtkWidget        *widget,
 				 GdkEventCrossing *event);
@@ -85,8 +83,6 @@
   widget_class = (GtkWidgetClass*) class;
 
 
-  widget_class->map = gtk_item_map;
-  widget_class->unmap = gtk_item_unmap;
   widget_class->realize = gtk_item_realize;
   widget_class->enter_notify_event = gtk_item_enter;
   widget_class->leave_notify_event = gtk_item_leave;
@@ -143,37 +139,6 @@
   gtk_signal_emit (GTK_OBJECT (item), item_signals[TOGGLE]);
 }
 
-
-static void
-gtk_item_map (GtkWidget *widget)
-{
-  GtkBin *bin;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_ITEM (widget));
-
-  GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-
-  bin = GTK_BIN (widget);
-
-  if (bin->child &&
-      GTK_WIDGET_VISIBLE (bin->child) &&
-      !GTK_WIDGET_MAPPED (bin->child))
-    gtk_widget_map (bin->child);
-
-  gdk_window_show (widget->window);
-}
-
-static void
-gtk_item_unmap (GtkWidget *widget)
-{
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_ITEM (widget));
-
-  GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
-  gdk_window_hide (widget->window);
-}
 
 static void
 gtk_item_realize (GtkWidget *widget)
Index: gtk/gtklayout.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtklayout.c,v
retrieving revision 1.39
diff -u -r1.39 gtklayout.c
--- gtk/gtklayout.c	2001/06/24 15:34:47	1.39
+++ gtk/gtklayout.c	2001/07/07 06:59:07
@@ -240,20 +240,10 @@
 
   layout->children = g_list_append (layout->children, child);
   
-  gtk_widget_set_parent (child_widget, GTK_WIDGET (layout));
   if (GTK_WIDGET_REALIZED (layout))
     gtk_widget_set_parent_window (child->widget, layout->bin_window);
-
-  if (GTK_WIDGET_REALIZED (layout))
-    gtk_widget_realize (child_widget);
-    
-  if (GTK_WIDGET_VISIBLE (layout) && GTK_WIDGET_VISIBLE (child_widget))
-    {
-      if (GTK_WIDGET_MAPPED (layout))
-	gtk_widget_map (child_widget);
-
-      gtk_widget_queue_resize (child_widget);
-    }
+  
+  gtk_widget_set_parent (child_widget, GTK_WIDGET (layout));
 }
 
 void           
Index: gtk/gtklist.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtklist.c,v
retrieving revision 1.61
diff -u -r1.61 gtklist.c
--- gtk/gtklist.c	2001/07/02 05:03:20	1.61
+++ gtk/gtklist.c	2001/07/07 06:59:07
@@ -64,7 +64,6 @@
 static void gtk_list_size_allocate   (GtkWidget	     *widget,
 				      GtkAllocation  *allocation);
 static void gtk_list_realize	     (GtkWidget	     *widget);
-static void gtk_list_map	     (GtkWidget	     *widget);
 static void gtk_list_unmap	     (GtkWidget	     *widget);
 static void gtk_list_style_set	     (GtkWidget      *widget,
 				      GtkStyle       *previous_style);
@@ -219,7 +218,6 @@
   object_class->set_arg = gtk_list_set_arg;
   object_class->get_arg = gtk_list_get_arg;
 
-  widget_class->map = gtk_list_map;
   widget_class->unmap = gtk_list_unmap;
   widget_class->style_set = gtk_list_style_set;
   widget_class->realize = gtk_list_realize;
@@ -352,7 +350,6 @@
  * gtk_list_size_request
  * gtk_list_size_allocate
  * gtk_list_realize
- * gtk_list_map
  * gtk_list_unmap
  * gtk_list_motion_notify
  * gtk_list_button_press
@@ -482,33 +479,6 @@
 }
 
 static void
-gtk_list_map (GtkWidget *widget)
-{
-  GtkList *list;
-  GtkWidget *child;
-  GList *children;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_LIST (widget));
-
-  GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-  list = GTK_LIST (widget);
-
-  children = list->children;
-  while (children)
-    {
-      child = children->data;
-      children = children->next;
-
-      if (GTK_WIDGET_VISIBLE (child) &&
-	  !GTK_WIDGET_MAPPED (child))
-	gtk_widget_map (child);
-    }
-
-  gdk_window_show (widget->window);
-}
-
-static void
 gtk_list_unmap (GtkWidget *widget)
 {
   GtkList *list;
@@ -1091,17 +1061,6 @@
       gtk_signal_connect (GTK_OBJECT (widget), "toggle",
 			  GTK_SIGNAL_FUNC (gtk_list_signal_item_toggle),
 			  list);
-
-      if (GTK_WIDGET_REALIZED (widget->parent))
-	gtk_widget_realize (widget);
-
-      if (GTK_WIDGET_VISIBLE (widget->parent) && GTK_WIDGET_VISIBLE (widget))
-	{
-	  if (GTK_WIDGET_MAPPED (widget->parent))
-	    gtk_widget_map (widget);
-
-	  gtk_widget_queue_resize (widget);
-	}
     }
 
 
Index: gtk/gtkmenu.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenu.c,v
retrieving revision 1.65
diff -u -r1.65 gtkmenu.c
--- gtk/gtkmenu.c	2001/06/30 16:08:24	1.65
+++ gtk/gtkmenu.c	2001/07/07 06:59:08
@@ -456,9 +456,10 @@
 		 GtkWidget        *child,
 		 gint              position)
 {
-  GTK_MENU_SHELL_CLASS (parent_class)->insert (menu_shell, child, position);
+  if (GTK_WIDGET_REALIZED (menu_shell))
+    gtk_widget_set_parent_window (child, GTK_MENU (menu_shell)->bin_window);
   
-  gtk_widget_set_parent_window (child, GTK_MENU (menu_shell)->bin_window);
+  GTK_MENU_SHELL_CLASS (parent_class)->insert (menu_shell, child, position);
 }
 
 static void
Index: gtk/gtkmenushell.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmenushell.c,v
retrieving revision 1.43
diff -u -r1.43 gtkmenushell.c
--- gtk/gtkmenushell.c	2001/06/29 01:59:01	1.43
+++ gtk/gtkmenushell.c	2001/07/07 06:59:08
@@ -109,7 +109,6 @@
 
 static void gtk_menu_shell_class_init        (GtkMenuShellClass *klass);
 static void gtk_menu_shell_init              (GtkMenuShell      *menu_shell);
-static void gtk_menu_shell_map               (GtkWidget         *widget);
 static void gtk_menu_shell_realize           (GtkWidget         *widget);
 static gint gtk_menu_shell_button_press      (GtkWidget         *widget,
 					      GdkEventButton    *event);
@@ -192,7 +191,6 @@
 
   parent_class = gtk_type_class (gtk_container_get_type ());
 
-  widget_class->map = gtk_menu_shell_map;
   widget_class->realize = gtk_menu_shell_realize;
   widget_class->button_press_event = gtk_menu_shell_button_press;
   widget_class->button_release_event = gtk_menu_shell_button_release;
@@ -339,17 +337,6 @@
   menu_shell->children = g_list_insert (menu_shell->children, child, position);
 
   gtk_widget_set_parent (child, GTK_WIDGET (menu_shell));
-
-  if (GTK_WIDGET_REALIZED (child->parent))
-    gtk_widget_realize (child);
-
-  if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
-    {
-      if (GTK_WIDGET_MAPPED (child->parent))
-	gtk_widget_map (child);
-
-      gtk_widget_queue_resize (child);
-    }
 }
 
 void
@@ -359,32 +346,6 @@
   g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
 
   gtk_signal_emit (GTK_OBJECT (menu_shell), menu_shell_signals[DEACTIVATE]);
-}
-
-static void
-gtk_menu_shell_map (GtkWidget *widget)
-{
-  GtkMenuShell *menu_shell;
-  GtkWidget *child;
-  GList *children;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_MENU_SHELL (widget));
-
-  menu_shell = GTK_MENU_SHELL (widget);
-  GTK_WIDGET_SET_FLAGS (menu_shell, GTK_MAPPED);
-
-  children = menu_shell->children;
-  while (children)
-    {
-      child = children->data;
-      children = children->next;
-
-      if (GTK_WIDGET_VISIBLE (child) && !GTK_WIDGET_MAPPED (child))
-	gtk_widget_map (child);
-    }
-
-  gdk_window_show (widget->window);
 }
 
 static void
Index: gtk/gtknotebook.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtknotebook.c,v
retrieving revision 1.94
diff -u -r1.94 gtknotebook.c
--- gtk/gtknotebook.c	2001/06/29 16:30:22	1.94
+++ gtk/gtknotebook.c	2001/07/07 06:59:09
@@ -154,8 +154,6 @@
 static gint gtk_notebook_focus_in            (GtkWidget        *widget,
 					      GdkEventFocus    *event);
 static void gtk_notebook_draw_focus          (GtkWidget        *widget);
-static void gtk_notebook_style_set           (GtkWidget        *widget,
-					      GtkStyle         *previous_style);
 static gint gtk_notebook_focus               (GtkWidget        *widget,
 					      GtkDirectionType  direction);
 
@@ -306,7 +304,6 @@
   widget_class->leave_notify_event = gtk_notebook_leave_notify;
   widget_class->motion_notify_event = gtk_notebook_motion_notify;
   widget_class->focus_in_event = gtk_notebook_focus_in;
-  widget_class->style_set = gtk_notebook_style_set;
   widget_class->focus = gtk_notebook_focus;
   
   container_class->add = gtk_notebook_add;
@@ -846,8 +843,6 @@
 	  widget->requisition.height = MAX (widget->requisition.height,
 					    child_requisition.height);
 
-	  if (GTK_WIDGET_MAPPED (page->child) && page != notebook->cur_page)
-	    gtk_widget_unmap (page->child);
 	  if (notebook->menu && page->menu_label->parent &&
 	      !GTK_WIDGET_VISIBLE (page->menu_label->parent))
 	    gtk_widget_show (page->menu_label->parent);
@@ -1462,21 +1457,6 @@
     }
 }
 
-static void
-gtk_notebook_style_set (GtkWidget *widget,
-			GtkStyle  *previous_style)
-{
-  if (GTK_WIDGET_REALIZED (widget) &&
-      !GTK_WIDGET_NO_WINDOW (widget))
-    {
-      gtk_style_set_background (widget->style, widget->window, widget->state);
-      if (GTK_WIDGET_DRAWABLE (widget))
-	gdk_window_clear (widget->window);
-    }
-
-  gtk_notebook_set_shape (GTK_NOTEBOOK(widget));
-}
-
 /* Private GtkContainer Methods :
  * 
  * gtk_notebook_set_child_arg
@@ -2688,7 +2668,7 @@
       while (children)
 	{
 	  page = children->data;
-	  if (GTK_WIDGET_MAPPED (page->tab_label))
+	  if (gtk_widget_get_child_visible (page->tab_label))
 	    {
 	      x = page->allocation.x;
 	      y = page->allocation.y;
@@ -2947,16 +2927,16 @@
 						    STEP_NEXT, TRUE))
 	    {
 	      page = children->data;
-	      if (page->tab_label && GTK_WIDGET_MAPPED (page->tab_label))
-		gtk_widget_unmap (page->tab_label);
+	      if (page->tab_label)
+		gtk_widget_set_child_visible (page->tab_label, FALSE);
 	    }
 	  for (children = last_child; children;
 	       children = gtk_notebook_search_page (notebook, children,
 						    STEP_NEXT, TRUE))
 	    {
 	      page = children->data;
-	      if (page->tab_label && GTK_WIDGET_MAPPED (page->tab_label))
-		gtk_widget_unmap (page->tab_label);
+	      if (page->tab_label)
+		gtk_widget_set_child_visible (page->tab_label, FALSE);
 	    }
 	}
       else /* !showarrow */
@@ -3070,14 +3050,8 @@
 	  break;
 	}
 
-      if (GTK_WIDGET_REALIZED (notebook) &&
-	  page->tab_label && !GTK_WIDGET_MAPPED (page->tab_label))
-	{
-	  if (GTK_WIDGET_VISIBLE (page->tab_label))
-	    gtk_widget_map (page->tab_label);
-	  else
-	    gtk_widget_show (page->tab_label);
-	}
+      if (page->tab_label)
+	gtk_widget_set_child_visible (page->tab_label, TRUE);
     }
 
   if (children)
@@ -3143,14 +3117,8 @@
 	      break;
 	    }
 
-	  if (GTK_WIDGET_REALIZED (notebook) && page->tab_label &&
-	      !GTK_WIDGET_MAPPED (page->tab_label))
-	    {
-	      if (GTK_WIDGET_VISIBLE (page->tab_label))
-		gtk_widget_map (page->tab_label);
-	      else
-		gtk_widget_show (page->tab_label);
-	    }
+	  if (page->tab_label)
+	    gtk_widget_set_child_visible (page->tab_label, TRUE);
 	}
     }
 
@@ -3409,8 +3377,8 @@
   if (notebook->cur_page == page || !GTK_WIDGET_VISIBLE (page->child))
     return;
 
-  if (notebook->cur_page && GTK_WIDGET_MAPPED (notebook->cur_page->child))
-    gtk_widget_unmap (notebook->cur_page->child);
+  if (notebook->cur_page)
+    gtk_widget_set_child_visible (notebook->cur_page->child, FALSE);
   
   notebook->cur_page = page;
 
@@ -3419,8 +3387,7 @@
     notebook->focus_tab = 
       g_list_find (notebook->children, notebook->cur_page);
 
-  if (GTK_WIDGET_MAPPED (notebook))
-    gtk_widget_map (notebook->cur_page->child);
+  gtk_widget_set_child_visible (notebook->cur_page->child, TRUE);
 
   gtk_widget_queue_resize (GTK_WIDGET (notebook));
   g_object_notify (G_OBJECT (notebook), "page");
@@ -3864,6 +3831,19 @@
   if (!notebook->first_tab)
     notebook->first_tab = notebook->children;
 
+  if (!notebook->cur_page)
+    gtk_widget_set_child_visible (child, TRUE);
+  else
+    gtk_widget_set_child_visible (child, FALSE);
+  
+  if (tab_label)
+    {
+      if (notebook->show_tabs && GTK_WIDGET_VISIBLE (child))
+	gtk_widget_show (tab_label);
+      else
+	gtk_widget_hide (tab_label);
+    }
+
   gtk_widget_set_parent (child, GTK_WIDGET (notebook));
   if (tab_label)
     gtk_widget_set_parent (tab_label, GTK_WIDGET (notebook));
@@ -3872,41 +3852,6 @@
     {
       gtk_notebook_switch_page (notebook, page, 0);
       gtk_notebook_switch_focus_tab (notebook, NULL);
-    }
-
-  if (GTK_WIDGET_REALIZED (child->parent))
-    gtk_widget_realize (child);
-
-  if (GTK_WIDGET_VISIBLE (notebook))
-    {
-      if (GTK_WIDGET_VISIBLE (child))
-	{
-	  if (GTK_WIDGET_MAPPED (notebook) &&
-	      !GTK_WIDGET_MAPPED (child) &&
-	      notebook->cur_page == page)
-	    gtk_widget_map (child);
-	  
-	  gtk_widget_queue_resize (child);
-	}
-
-      if (tab_label)
-	{
-	  if (notebook->show_tabs && GTK_WIDGET_VISIBLE (child))
-	    {
-	      if (!GTK_WIDGET_VISIBLE (tab_label))
-		gtk_widget_show (tab_label);
-	      
-	      if (GTK_WIDGET_REALIZED (notebook) &&
-		  !GTK_WIDGET_REALIZED (tab_label))
-		gtk_widget_realize (tab_label);
-	      
-	      if (GTK_WIDGET_MAPPED (notebook) &&
-		  !GTK_WIDGET_MAPPED (tab_label))
-		gtk_widget_map (tab_label);
-	    }
-	  else if (GTK_WIDGET_VISIBLE (tab_label))
-	    gtk_widget_hide (tab_label);
-	}
     }
 
   if (tab_label)
Index: gtk/gtkpacker.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkpacker.c,v
retrieving revision 1.19
diff -u -r1.19 gtkpacker.c
--- gtk/gtkpacker.c	2001/05/15 15:31:45	1.19
+++ gtk/gtkpacker.c	2001/07/07 06:59:09
@@ -125,8 +125,6 @@
 
 static void gtk_packer_class_init    (GtkPackerClass   *klass);
 static void gtk_packer_init          (GtkPacker        *packer);
-static void gtk_packer_map           (GtkWidget        *widget);
-static void gtk_packer_unmap         (GtkWidget        *widget);
 static void gtk_packer_size_request  (GtkWidget      *widget,
                                       GtkRequisition *requisition);
 static void gtk_packer_size_allocate (GtkWidget      *widget,
@@ -215,9 +213,6 @@
   gobject_class->set_property = gtk_packer_set_property;
   gobject_class->get_property = gtk_packer_get_property;
 
-  widget_class->map = gtk_packer_map;
-  widget_class->unmap = gtk_packer_unmap;
-  
   widget_class->size_request = gtk_packer_size_request;
   widget_class->size_allocate = gtk_packer_size_allocate;
   
@@ -703,17 +698,6 @@
   packer->children = g_list_append(packer->children, (gpointer) pchild);
   
   gtk_widget_set_parent (child, GTK_WIDGET (packer));
-  
-  if (GTK_WIDGET_REALIZED (child->parent))
-    gtk_widget_realize (child);
-
-  if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
-    {
-      if (GTK_WIDGET_MAPPED (child->parent))
-	gtk_widget_map (child);
-
-      gtk_widget_queue_resize (child);
-    }
 }
 
 void 
@@ -753,17 +737,6 @@
   packer->children = g_list_append(packer->children, (gpointer) pchild);
   
   gtk_widget_set_parent (child, GTK_WIDGET (packer));
-  
-  if (GTK_WIDGET_REALIZED (child->parent))
-    gtk_widget_realize (child);
-
-  if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
-    {
-      if (GTK_WIDGET_MAPPED (child->parent))
-	gtk_widget_map (child);
-
-      gtk_widget_queue_resize (child);
-    }
 }
 
 void
@@ -915,56 +888,6 @@
 }
 
 static void 
-gtk_packer_map (GtkWidget *widget)
-{
-  GtkPacker *packer;
-  GtkPackerChild *child;
-  GList *children;
-  
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_PACKER (widget));
-  
-  packer = GTK_PACKER (widget);
-  GTK_WIDGET_SET_FLAGS (packer, GTK_MAPPED);
-  
-  children = g_list_first(packer->children);
-  while (children != NULL) 
-    {
-      child = children->data;
-      children = g_list_next(children);
-      
-      if (GTK_WIDGET_VISIBLE (child->widget) &&
-	  !GTK_WIDGET_MAPPED (child->widget))
-	gtk_widget_map (child->widget);
-    }
-}
-
-static void 
-gtk_packer_unmap (GtkWidget *widget)
-{
-  GtkPacker *packer;
-  GtkPackerChild *child;
-  GList *children;
-  
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_PACKER (widget));
-  
-  packer = GTK_PACKER (widget);
-  GTK_WIDGET_UNSET_FLAGS (packer, GTK_MAPPED);
-  
-  children = g_list_first(packer->children);
-  while (children) 
-    {
-      child = children->data;
-      children = g_list_next(children);
-      
-      if (GTK_WIDGET_VISIBLE (child->widget) &&
-	  GTK_WIDGET_MAPPED (child->widget))
-	gtk_widget_unmap (child->widget);
-    }
-}
-
-static void 
 gtk_packer_size_request (GtkWidget      *widget,
 			 GtkRequisition *requisition)
 {
@@ -1276,7 +1199,7 @@
  
         if (width <= 0 || height <= 0) 
 	  {
-            gtk_widget_unmap(child->widget);
+	    gtk_widget_set_child_visible (child->widget, FALSE);
 	  } 
 	else 
 	  {
@@ -1286,9 +1209,7 @@
 	    child_allocation.height = height;
 	    gtk_widget_size_allocate (child->widget, &child_allocation);
 	    
-	    if (GTK_WIDGET_MAPPED (widget) &&
-		!(GTK_WIDGET_MAPPED (child->widget)))
-	      gtk_widget_map(child->widget); 
+	    gtk_widget_set_child_visible (child->widget, TRUE);
 	  }
 	
         list = g_list_next(list);
Index: gtk/gtkpaned.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkpaned.c,v
retrieving revision 1.35
diff -u -r1.35 gtkpaned.c
--- gtk/gtkpaned.c	2001/05/21 15:56:19	1.35
+++ gtk/gtkpaned.c	2001/07/07 06:59:09
@@ -44,8 +44,6 @@
 				       GValue         *value,
 				       GParamSpec     *pspec);
 static void    gtk_paned_realize      (GtkWidget      *widget);
-static void    gtk_paned_map          (GtkWidget      *widget);
-static void    gtk_paned_unmap        (GtkWidget      *widget);
 static void    gtk_paned_unrealize    (GtkWidget      *widget);
 static gint    gtk_paned_expose       (GtkWidget      *widget,
 				       GdkEventExpose *event);
@@ -104,8 +102,6 @@
   object_class->get_property = gtk_paned_get_property;
 
   widget_class->realize = gtk_paned_realize;
-  widget_class->map = gtk_paned_map;
-  widget_class->unmap = gtk_paned_unmap;
   widget_class->unrealize = gtk_paned_unrealize;
   widget_class->expose_event = gtk_paned_expose;
   
@@ -273,40 +269,6 @@
 }
 
 static void
-gtk_paned_map (GtkWidget *widget)
-{
-  GtkPaned *paned;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_PANED (widget));
-
-  GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-  paned = GTK_PANED (widget);
-
-  if (paned->child1 &&
-      GTK_WIDGET_VISIBLE (paned->child1) &&
-      !GTK_WIDGET_MAPPED (paned->child1))
-    gtk_widget_map (paned->child1);
-  if (paned->child2 &&
-      GTK_WIDGET_VISIBLE (paned->child2) &&
-      !GTK_WIDGET_MAPPED (paned->child2))
-    gtk_widget_map (paned->child2);
-
-  gdk_window_show (widget->window);
-}
-
-static void
-gtk_paned_unmap (GtkWidget *widget)
-{
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_PANED (widget));
-
-  GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
-  gdk_window_hide (widget->window);
-}
-
-static void
 gtk_paned_unrealize (GtkWidget *widget)
 {
   GtkPaned *paned;
@@ -387,17 +349,6 @@
       paned->child1_shrink = shrink;
 
       gtk_widget_set_parent (child, GTK_WIDGET (paned));
-
-      if (GTK_WIDGET_REALIZED (child->parent))
-	gtk_widget_realize (child);
-
-      if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
-	{
-	  if (GTK_WIDGET_MAPPED (child->parent))
-	    gtk_widget_map (child);
-
-	  gtk_widget_queue_resize (child);
-	}
     }
 }
 
@@ -418,17 +369,6 @@
       paned->child2_shrink = shrink;
 
       gtk_widget_set_parent (child, GTK_WIDGET (paned));
-
-      if (GTK_WIDGET_REALIZED (child->parent))
-	gtk_widget_realize (child);
-
-      if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
-	{
-	  if (GTK_WIDGET_MAPPED (child->parent))
-	    gtk_widget_map (child);
-
-	  gtk_widget_queue_resize (child);
-	}
     }
 }
 
Index: gtk/gtkplug.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkplug.c,v
retrieving revision 1.28
diff -u -r1.28 gtkplug.c
--- gtk/gtkplug.c	2001/07/05 02:58:34	1.28
+++ gtk/gtkplug.c	2001/07/07 06:59:10
@@ -217,20 +217,10 @@
   plug->same_app = TRUE;
   socket->plug_widget = widget;
 
-  gtk_widget_set_parent (widget, GTK_WIDGET (socket));
-
   if (GTK_WIDGET_REALIZED (widget))
     gdk_window_reparent (widget->window, plug->socket_window, 0, 0);
-  else
-    gtk_widget_realize (widget);
 
-  if (GTK_WIDGET_VISIBLE (socket) && GTK_WIDGET_VISIBLE (widget))
-    {
-      if (GTK_WIDGET_MAPPED (socket))
-	gtk_widget_map (widget);
-
-      gtk_widget_queue_resize (widget);
-    }
+  gtk_widget_set_parent (widget, GTK_WIDGET (socket));
 
   g_signal_emit_by_name (G_OBJECT (socket), "plug_added", 0);
 }
Index: gtk/gtkprivate.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkprivate.h,v
retrieving revision 1.22
diff -u -r1.22 gtkprivate.h
--- gtk/gtkprivate.h	2001/03/08 06:14:42	1.22
+++ gtk/gtkprivate.h	2001/07/07 06:59:10
@@ -49,7 +49,8 @@
   PRIVATE_GTK_IN_REPARENT       = 1 <<  6,
   PRIVATE_GTK_DIRECTION_SET     = 1 <<  7,   /* If the reading direction is not DIR_NONE */
   PRIVATE_GTK_DIRECTION_LTR     = 1 <<  8,   /* If the reading direction is DIR_LTR */
-  PRIVATE_GTK_ANCHORED          = 1 <<  9    /* If widget has a GtkWindow ancestor */
+  PRIVATE_GTK_ANCHORED          = 1 <<  9,   /* If widget has a GtkWindow ancestor */
+  PRIVATE_GTK_CHILD_VISIBLE     = 1 <<  10   /* If widget should be mapped when parent is mapped */
 } GtkPrivateFlags;
 
 /* Macros for extracting a widgets private_flags from GtkWidget.
@@ -64,6 +65,7 @@
 #define GTK_WIDGET_DIRECTION_SET(obj)	  ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_DIRECTION_SET) != 0)
 #define GTK_WIDGET_DIRECTION_LTR(obj)     ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_DIRECTION_LTR) != 0)
 #define GTK_WIDGET_ANCHORED(obj)          ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_ANCHORED) != 0)
+#define GTK_WIDGET_CHILD_VISIBLE(obj)     ((GTK_PRIVATE_FLAGS (obj) & PRIVATE_GTK_CHILD_VISIBLE) != 0)
 
 /* Macros for setting and clearing private widget flags.
  * we use a preprocessor string concatenation here for a clear
Index: gtk/gtkscrolledwindow.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkscrolledwindow.c,v
retrieving revision 1.51
diff -u -r1.51 gtkscrolledwindow.c
--- gtk/gtkscrolledwindow.c	2001/06/24 15:34:47	1.51
+++ gtk/gtkscrolledwindow.c	2001/07/07 06:59:10
@@ -88,8 +88,6 @@
 						    guint                   arg_id);
 static void gtk_scrolled_window_destroy            (GtkObject              *object);
 static void gtk_scrolled_window_finalize           (GObject                *object);
-static void gtk_scrolled_window_map                (GtkWidget              *widget);
-static void gtk_scrolled_window_unmap              (GtkWidget              *widget);
 static gint gtk_scrolled_window_expose             (GtkWidget              *widget,
 						    GdkEventExpose         *event);
 static void gtk_scrolled_window_size_request       (GtkWidget              *widget,
@@ -158,8 +156,6 @@
   object_class->get_arg = gtk_scrolled_window_get_arg;
   object_class->destroy = gtk_scrolled_window_destroy;
 
-  widget_class->map = gtk_scrolled_window_map;
-  widget_class->unmap = gtk_scrolled_window_unmap;
   widget_class->expose_event = gtk_scrolled_window_expose;
   widget_class->size_request = gtk_scrolled_window_size_request;
   widget_class->size_allocate = gtk_scrolled_window_size_allocate;
@@ -583,48 +579,6 @@
 }
 
 static void
-gtk_scrolled_window_map (GtkWidget *widget)
-{
-  GtkScrolledWindow *scrolled_window;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_SCROLLED_WINDOW (widget));
-
-  scrolled_window = GTK_SCROLLED_WINDOW (widget);
-
-  /* chain parent class handler to map self and child */
-  GTK_WIDGET_CLASS (parent_class)->map (widget);
-  
-  if (GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar) &&
-      !GTK_WIDGET_MAPPED (scrolled_window->hscrollbar))
-    gtk_widget_map (scrolled_window->hscrollbar);
-  
-  if (GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar) &&
-      !GTK_WIDGET_MAPPED (scrolled_window->vscrollbar))
-    gtk_widget_map (scrolled_window->vscrollbar);
-}
-
-static void
-gtk_scrolled_window_unmap (GtkWidget *widget)
-{
-  GtkScrolledWindow *scrolled_window;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_SCROLLED_WINDOW (widget));
-
-  scrolled_window = GTK_SCROLLED_WINDOW (widget);
-
-  /* chain parent class handler to unmap self and child */
-  GTK_WIDGET_CLASS (parent_class)->unmap (widget);
-  
-  if (GTK_WIDGET_MAPPED (scrolled_window->hscrollbar))
-    gtk_widget_unmap (scrolled_window->hscrollbar);
-  
-  if (GTK_WIDGET_MAPPED (scrolled_window->vscrollbar))
-    gtk_widget_unmap (scrolled_window->vscrollbar);
-}
-
-static void
 gtk_scrolled_window_paint (GtkWidget    *widget,
 			   GdkRectangle *area)
 {
@@ -1076,17 +1030,6 @@
 					  gtk_range_get_adjustment (GTK_RANGE (scrolled_window->vscrollbar))))
     g_warning ("gtk_scrolled_window_add(): cannot add non scrollable widget "
 	       "use gtk_scrolled_window_add_with_viewport() instead");
-
-  if (GTK_WIDGET_REALIZED (child->parent))
-    gtk_widget_realize (child);
-
-  if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
-    {
-      if (GTK_WIDGET_MAPPED (child->parent))
-	gtk_widget_map (child);
-
-      gtk_widget_queue_resize (child);
-    }
 }
 
 static void
Index: gtk/gtktable.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktable.c,v
retrieving revision 1.45
diff -u -r1.45 gtktable.c
--- gtk/gtktable.c	2001/06/24 15:34:47	1.45
+++ gtk/gtktable.c	2001/07/07 06:59:10
@@ -54,8 +54,6 @@
 static void gtk_table_class_init    (GtkTableClass  *klass);
 static void gtk_table_init	    (GtkTable	    *table);
 static void gtk_table_finalize	    (GObject	    *object);
-static void gtk_table_map	    (GtkWidget	    *widget);
-static void gtk_table_unmap	    (GtkWidget	    *widget);
 static void gtk_table_size_request  (GtkWidget	    *widget,
 				     GtkRequisition *requisition);
 static void gtk_table_size_allocate (GtkWidget	    *widget,
@@ -141,8 +139,6 @@
   gobject_class->get_property = gtk_table_get_property;
   gobject_class->set_property = gtk_table_set_property;
   
-  widget_class->map = gtk_table_map;
-  widget_class->unmap = gtk_table_unmap;
   widget_class->size_request = gtk_table_size_request;
   widget_class->size_allocate = gtk_table_size_allocate;
   
@@ -612,17 +608,6 @@
   table->children = g_list_prepend (table->children, table_child);
   
   gtk_widget_set_parent (child, GTK_WIDGET (table));
-  
-  if (GTK_WIDGET_REALIZED (child->parent))
-    gtk_widget_realize (child);
-
-  if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
-    {
-      if (GTK_WIDGET_MAPPED (child->parent))
-	gtk_widget_map (child);
-
-      gtk_widget_queue_resize (child);
-    }
 }
 
 void
@@ -838,56 +823,6 @@
   g_free (table->cols);
   
   G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-gtk_table_map (GtkWidget *widget)
-{
-  GtkTable *table;
-  GtkTableChild *child;
-  GList *children;
-  
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_TABLE (widget));
-  
-  table = GTK_TABLE (widget);
-  GTK_WIDGET_SET_FLAGS (table, GTK_MAPPED);
-  
-  children = table->children;
-  while (children)
-    {
-      child = children->data;
-      children = children->next;
-      
-      if (GTK_WIDGET_VISIBLE (child->widget) &&
-	  !GTK_WIDGET_MAPPED (child->widget))
-	gtk_widget_map (child->widget);
-    }
-}
-
-static void
-gtk_table_unmap (GtkWidget *widget)
-{
-  GtkTable *table;
-  GtkTableChild *child;
-  GList *children;
-  
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_TABLE (widget));
-  
-  table = GTK_TABLE (widget);
-  GTK_WIDGET_UNSET_FLAGS (table, GTK_MAPPED);
-  
-  children = table->children;
-  while (children)
-    {
-      child = children->data;
-      children = children->next;
-      
-      if (GTK_WIDGET_VISIBLE (child->widget) &&
-	  GTK_WIDGET_MAPPED (child->widget))
-	gtk_widget_unmap (child->widget);
-    }
 }
 
 static void
Index: gtk/gtktextview.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextview.c,v
retrieving revision 1.99
diff -u -r1.99 gtktextview.c
--- gtk/gtktextview.c	2001/07/02 14:25:20	1.99
+++ gtk/gtktextview.c	2001/07/07 06:59:12
@@ -319,18 +319,17 @@
   gint y;
 };
 
-static GtkTextViewChild* text_view_child_new_anchored (GtkWidget          *child,
-                                                       GtkTextChildAnchor *anchor,
-                                                       GtkTextLayout      *layout);
-static GtkTextViewChild* text_view_child_new_window   (GtkWidget          *child,
-                                                       GtkTextWindowType   type,
-                                                       gint                x,
-                                                       gint                y);
-static void              text_view_child_free         (GtkTextViewChild   *child);
+static GtkTextViewChild* text_view_child_new_anchored      (GtkWidget          *child,
+							    GtkTextChildAnchor *anchor,
+							    GtkTextLayout      *layout);
+static GtkTextViewChild* text_view_child_new_window        (GtkWidget          *child,
+							    GtkTextWindowType   type,
+							    gint                x,
+							    gint                y);
+static void              text_view_child_free              (GtkTextViewChild   *child);
+static void              text_view_child_set_parent_window (GtkTextView        *text_view,
+							    GtkTextViewChild   *child);
 
-static void              text_view_child_realize      (GtkTextView      *text_view,
-                                                       GtkTextViewChild *child);
-
 struct _GtkTextWindow
 {
   GtkTextWindowType type;
@@ -6214,8 +6213,8 @@
 }
 
 static void
-text_view_child_realize (GtkTextView      *text_view,
-                         GtkTextViewChild *vc)
+text_view_child_set_parent_window (GtkTextView      *text_view,
+				   GtkTextViewChild *vc)
 {
   if (vc->anchor)
     gtk_widget_set_parent_window (vc->widget,
@@ -6227,8 +6226,6 @@
                                          vc->type);
       gtk_widget_set_parent_window (vc->widget, window);
     }
-
-  gtk_widget_realize (vc->widget);
 }
 
 static void
@@ -6238,18 +6235,10 @@
   text_view->children = g_slist_prepend (text_view->children,
                                          vc);
 
-  gtk_widget_set_parent (vc->widget, GTK_WIDGET (text_view));
-
   if (GTK_WIDGET_REALIZED (text_view))
-    text_view_child_realize (text_view, vc);
-
-  if (GTK_WIDGET_VISIBLE (text_view) && GTK_WIDGET_VISIBLE (vc->widget))
-    {
-      if (GTK_WIDGET_MAPPED (text_view))
-        gtk_widget_map (vc->widget);
-
-      gtk_widget_queue_resize (vc->widget);
-    }
+    text_view_child_set_parent_window (text_view, vc);
+  
+  gtk_widget_set_parent (vc->widget, GTK_WIDGET (text_view));
 }
 
 void
Index: gtk/gtktoolbar.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktoolbar.c,v
retrieving revision 1.59
diff -u -r1.59 gtktoolbar.c
--- gtk/gtktoolbar.c	2001/06/30 16:08:24	1.59
+++ gtk/gtktoolbar.c	2001/07/07 06:59:12
@@ -81,8 +81,6 @@
 						  GValue          *value,
 						  GParamSpec      *pspec);
 static void gtk_toolbar_destroy                  (GtkObject       *object);
-static void gtk_toolbar_map                      (GtkWidget       *widget);
-static void gtk_toolbar_unmap                    (GtkWidget       *widget);
 static gint gtk_toolbar_expose                   (GtkWidget       *widget,
 						  GdkEventExpose  *event);
 static void gtk_toolbar_size_request             (GtkWidget       *widget,
@@ -188,8 +186,6 @@
   gobject_class->set_property = gtk_toolbar_set_property;
   gobject_class->get_property = gtk_toolbar_get_property;
 
-  widget_class->map = gtk_toolbar_map;
-  widget_class->unmap = gtk_toolbar_unmap;
   widget_class->expose_event = gtk_toolbar_expose;
   widget_class->size_request = gtk_toolbar_size_request;
   widget_class->size_allocate = gtk_toolbar_size_allocate;
@@ -474,52 +470,6 @@
 }
 
 static void
-gtk_toolbar_map (GtkWidget *widget)
-{
-  GtkToolbar *toolbar;
-  GList *children;
-  GtkToolbarChild *child;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_TOOLBAR (widget));
-
-  toolbar = GTK_TOOLBAR (widget);
-  GTK_WIDGET_SET_FLAGS (toolbar, GTK_MAPPED);
-
-  for (children = toolbar->children; children; children = children->next)
-    {
-      child = children->data;
-
-      if ((child->type != GTK_TOOLBAR_CHILD_SPACE)
-	  && GTK_WIDGET_VISIBLE (child->widget) && !GTK_WIDGET_MAPPED (child->widget))
-	gtk_widget_map (child->widget);
-    }
-}
-
-static void
-gtk_toolbar_unmap (GtkWidget *widget)
-{
-  GtkToolbar *toolbar;
-  GList *children;
-  GtkToolbarChild *child;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_TOOLBAR (widget));
-
-  toolbar = GTK_TOOLBAR (widget);
-  GTK_WIDGET_UNSET_FLAGS (toolbar, GTK_MAPPED);
-
-  for (children = toolbar->children; children; children = children->next)
-    {
-      child = children->data;
-
-      if ((child->type != GTK_TOOLBAR_CHILD_SPACE)
-	  && GTK_WIDGET_VISIBLE (child->widget) && GTK_WIDGET_MAPPED (child->widget))
-	gtk_widget_unmap (child->widget);
-    }
-}
-
-static void
 gtk_toolbar_paint_space_line (GtkWidget       *widget,
 			      GdkRectangle    *area,
 			      GtkToolbarChild *child)
@@ -1451,20 +1401,7 @@
   toolbar->num_children++;
 
   if (type != GTK_TOOLBAR_CHILD_SPACE)
-    {
-      gtk_widget_set_parent (child->widget, GTK_WIDGET (toolbar));
-
-      if (GTK_WIDGET_REALIZED (child->widget->parent))
-	gtk_widget_realize (child->widget);
-
-      if (GTK_WIDGET_VISIBLE (child->widget->parent) && GTK_WIDGET_VISIBLE (child->widget))
-	{
-	  if (GTK_WIDGET_MAPPED (child->widget->parent))
-	    gtk_widget_map (child->widget);
-
-	  gtk_widget_queue_resize (child->widget);
-	}
-    }
+    gtk_widget_set_parent (child->widget, GTK_WIDGET (toolbar));
   else
     gtk_widget_queue_resize (GTK_WIDGET (toolbar));
 
Index: gtk/gtktree.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktree.c,v
retrieving revision 1.45
diff -u -r1.45 gtktree.c
--- gtk/gtktree.c	2001/03/16 20:12:40	1.45
+++ gtk/gtktree.c	2001/07/07 06:59:12
@@ -234,17 +234,6 @@
     tree->children = g_list_insert (tree->children, tree_item, position);
   
   gtk_widget_set_parent (tree_item, GTK_WIDGET (tree));
-  
-  if (GTK_WIDGET_REALIZED (tree_item->parent))
-    gtk_widget_realize (tree_item);
-
-  if (GTK_WIDGET_VISIBLE (tree_item->parent) && GTK_WIDGET_VISIBLE (tree_item))
-    {
-      if (GTK_WIDGET_MAPPED (tree_item->parent))
-	gtk_widget_map (tree_item);
-
-      gtk_widget_queue_resize (tree_item);
-    }
 }
 
 static void
@@ -262,17 +251,6 @@
   tree->children = g_list_append (tree->children, child);
   
   gtk_widget_set_parent (child, GTK_WIDGET (container));
-  
-  if (GTK_WIDGET_REALIZED (child->parent))
-    gtk_widget_realize (child);
-
-  if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))
-    {
-      if (GTK_WIDGET_MAPPED (child->parent))
-	gtk_widget_map (child);
-
-      gtk_widget_queue_resize (child);
-    }
   
   if (!tree->selection && (tree->selection_mode == GTK_SELECTION_BROWSE))
     gtk_tree_select_child (tree, child);
Index: gtk/gtktreeitem.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktreeitem.c,v
retrieving revision 1.49
diff -u -r1.49 gtktreeitem.c
--- gtk/gtktreeitem.c	2001/03/31 19:33:47	1.49
+++ gtk/gtktreeitem.c	2001/07/07 06:59:13
@@ -317,17 +317,6 @@
     gtk_widget_hide (subtree);
 
   gtk_widget_set_parent (subtree, GTK_WIDGET (tree_item)->parent);
-
-  if (GTK_WIDGET_REALIZED (subtree->parent))
-    gtk_widget_realize (subtree);
-
-  if (GTK_WIDGET_VISIBLE (subtree->parent) && GTK_WIDGET_VISIBLE (subtree))
-    {
-      if (GTK_WIDGET_MAPPED (subtree->parent))
-	gtk_widget_map (subtree);
-
-      gtk_widget_queue_resize (subtree);
-    }
 }
 
 void
Index: gtk/gtktreeviewcolumn.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktreeviewcolumn.c,v
retrieving revision 1.52
diff -u -r1.52 gtktreeviewcolumn.c
--- gtk/gtktreeviewcolumn.c	2001/07/05 02:58:34	1.52
+++ gtk/gtktreeviewcolumn.c	2001/07/07 06:59:13
@@ -500,9 +500,9 @@
   gtk_widget_pop_composite_child ();
 
   /* make sure we own a reference to it as well. */
-  gtk_widget_set_parent (tree_column->button, GTK_WIDGET (tree_view));
   if (tree_view->priv->header_window)
     gtk_widget_set_parent_window (tree_column->button, tree_view->priv->header_window);
+  gtk_widget_set_parent (tree_column->button, GTK_WIDGET (tree_view));
   
   gtk_signal_connect (GTK_OBJECT (tree_column->button), "realize",
 		      (GtkSignalFunc) gtk_tree_view_column_button_realize,
Index: gtk/gtkviewport.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkviewport.c,v
retrieving revision 1.47
diff -u -r1.47 gtkviewport.c
--- gtk/gtkviewport.c	2001/06/24 15:34:47	1.47
+++ gtk/gtkviewport.c	2001/07/07 06:59:13
@@ -50,8 +50,6 @@
 static void gtk_viewport_set_scroll_adjustments	  (GtkViewport	    *viewport,
 						   GtkAdjustment    *hadjustment,
 						   GtkAdjustment    *vadjustment);
-static void gtk_viewport_map                      (GtkWidget        *widget);
-static void gtk_viewport_unmap                    (GtkWidget        *widget);
 static void gtk_viewport_realize                  (GtkWidget        *widget);
 static void gtk_viewport_unrealize                (GtkWidget        *widget);
 static void gtk_viewport_paint                    (GtkWidget        *widget,
@@ -116,8 +114,6 @@
   gobject_class->get_property = gtk_viewport_get_property;
   object_class->destroy = gtk_viewport_destroy;
   
-  widget_class->map = gtk_viewport_map;
-  widget_class->unmap = gtk_viewport_unmap;
   widget_class->realize = gtk_viewport_realize;
   widget_class->unrealize = gtk_viewport_unrealize;
   widget_class->expose_event = gtk_viewport_expose;
@@ -415,36 +411,6 @@
   g_return_val_if_fail (GTK_IS_VIEWPORT (viewport), GTK_SHADOW_NONE);
 
   return viewport->shadow_type;
-}
-
-static void
-gtk_viewport_map (GtkWidget *widget)
-{
-  GtkBin *bin;
-
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_VIEWPORT (widget));
-
-  GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-  bin = GTK_BIN (widget);
-
-  if (bin->child &&
-      GTK_WIDGET_VISIBLE (bin->child) &&
-      !GTK_WIDGET_MAPPED (bin->child))
-    gtk_widget_map (bin->child);
-
-  gdk_window_show (widget->window);
-}
-
-static void
-gtk_viewport_unmap (GtkWidget *widget)
-{
-  g_return_if_fail (widget != NULL);
-  g_return_if_fail (GTK_IS_VIEWPORT (widget));
-
-  GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-  
-  gdk_window_hide (widget->window);
 }
 
 static void
Index: gtk/gtkwidget.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.c,v
retrieving revision 1.239
diff -u -r1.239 gtkwidget.c
--- gtk/gtkwidget.c	2001/07/06 19:41:00	1.239
+++ gtk/gtkwidget.c	2001/07/07 06:59:15
@@ -1290,7 +1290,7 @@
 {
   GdkColormap *colormap;
   
-  GTK_PRIVATE_FLAGS (widget) = 0;
+  GTK_PRIVATE_FLAGS (widget) = PRIVATE_GTK_CHILD_VISIBLE;
   widget->state = GTK_STATE_NORMAL;
   widget->saved_state = GTK_STATE_NORMAL;
   widget->name = NULL;
@@ -1607,6 +1607,12 @@
   if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_IN_REPARENT (widget))
     gtk_widget_unrealize (widget);
 
+  /* Removing a widget from a container restores the child visible
+   * flag to the default state, so it doesn't affect the child
+   * in the next parent.
+   */
+  GTK_PRIVATE_SET_FLAG (widget, GTK_CHILD_VISIBLE);
+    
   old_parent = widget->parent;
   widget->parent = NULL;
   gtk_widget_set_parent_window (widget, NULL);
@@ -1726,6 +1732,7 @@
 
       if (widget->parent &&
 	  GTK_WIDGET_MAPPED (widget->parent) &&
+	  GTK_WIDGET_CHILD_VISIBLE (widget) &&
 	  !GTK_WIDGET_MAPPED (widget))
 	gtk_widget_map (widget);
     }
@@ -1889,7 +1896,8 @@
 gtk_widget_map (GtkWidget *widget)
 {
   g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (GTK_WIDGET_VISIBLE (widget) == TRUE);
+  g_return_if_fail (GTK_WIDGET_VISIBLE (widget));
+  g_return_if_fail (GTK_WIDGET_CHILD_VISIBLE (widget));
   
   if (!GTK_WIDGET_MAPPED (widget))
     {
@@ -3475,6 +3483,21 @@
   if (GTK_WIDGET_ANCHORED (widget->parent))
     _gtk_widget_propagate_hierarchy_changed (widget, NULL);
   g_object_notify (G_OBJECT (widget), "parent");
+
+  /* Enforce realized/mapped invariants
+   */
+  if (GTK_WIDGET_REALIZED (widget->parent))
+    gtk_widget_realize (widget);
+
+  if (GTK_WIDGET_VISIBLE (widget->parent) &&
+      GTK_WIDGET_VISIBLE (widget))
+    {
+      if (GTK_WIDGET_CHILD_VISIBLE (widget) &&
+	  GTK_WIDGET_MAPPED (widget->parent))
+	gtk_widget_map (widget);
+
+      gtk_widget_queue_resize (widget);
+    }
 }
 
 /**
@@ -4188,6 +4211,86 @@
     }
 }
 
+
+/**
+ * gtk_widget_set_child_visible:
+ * @widget: a #GtkWidget
+ * @is_visible: if %TRUE, @widget should be mapped along with its parent.
+ *
+ * Sets whether @widget should be mapped along with its when its parent
+ * is mapped and @widget has been shown with gtk_widget_show(). 
+ *
+ * The child visibility can be set for widget before it is added to
+ * a container with gtk_widget_set_parent(), to avoid mapping
+ * children unnecessary before immediately unmapping them. However
+ * it will be reset to its default state of %TRUE when the widget
+ * is removed from a container.
+ * 
+ * Note that changing the child visibility of a widget does not
+ * queue a resize on the widget. Most of the time, the size of
+ * a widget is computed from all visible children, whether or
+ * not they are mapped. If this is not the case, the container
+ * can queue a resize itself.
+ *
+ * This function is only useful for container implementations and
+ * never should be called by an application.
+ **/
+void
+gtk_widget_set_child_visible (GtkWidget *widget,
+			      gboolean   is_visible)
+{
+  gboolean was_visible;
+
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  was_visible = GTK_WIDGET_CHILD_VISIBLE (widget);
+  is_visible = is_visible != FALSE;
+
+  if (is_visible != was_visible)
+    {
+      if (is_visible)
+	{
+	  GTK_PRIVATE_SET_FLAG (widget, GTK_CHILD_VISIBLE);
+
+	  if (widget->parent &&
+	      GTK_WIDGET_VISIBLE (widget->parent) &&
+	      GTK_WIDGET_VISIBLE (widget))
+	    {
+	      if (GTK_WIDGET_MAPPED (widget->parent))
+		gtk_widget_map (widget);
+	    }
+	}
+      else
+	{
+	  GTK_PRIVATE_UNSET_FLAG (widget, GTK_CHILD_VISIBLE);
+	  
+	  if (GTK_WIDGET_MAPPED (widget))
+	    gtk_widget_unmap (widget);
+	}
+    }
+}
+
+/**
+ * gtk_widget_get_child_visible:
+ * @widget: a #GtkWidget
+ * 
+ * Gets the value set with gtk_widget_set_child_visible().
+ * If you feel a need to use this function, your code probably
+ * needs reorganization. 
+ *
+ * This function is only useful for container implementations and
+ * never should be called by an application.
+ *
+ * Return value: %TRUE if the widget is mapped with the parent.
+ **/
+gboolean
+gtk_widget_get_child_visible (GtkWidget *widget)
+{
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  
+  return GTK_WIDGET_CHILD_VISIBLE (widget);
+}
+
 /*************************************************************
  * gtk_widget_get_parent_window:
  *     Get widget's parent window
@@ -5953,3 +6056,4 @@
     g_object_ref (G_OBJECT (accessible));
   return accessible;
 }
+
Index: gtk/gtkwidget.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.h,v
retrieving revision 1.116
diff -u -r1.116 gtkwidget.h
--- gtk/gtkwidget.h	2001/07/05 02:58:34	1.116
+++ gtk/gtkwidget.h	2001/07/07 06:59:15
@@ -444,9 +444,9 @@
 GtkWidget* gtk_widget_ref		  (GtkWidget	       *widget);
 void	   gtk_widget_unref		  (GtkWidget	       *widget);
 void	   gtk_widget_destroy		  (GtkWidget	       *widget);
+#ifndef GTK_DISABLE_DEPRECATED
 void	   gtk_widget_destroyed		  (GtkWidget	       *widget,
 					   GtkWidget	      **widget_pointer);
-#ifndef GTK_DISABLE_DEPRECATED
 void	   gtk_widget_set		  (GtkWidget	       *widget,
 					   const gchar         *first_property_name,
 					   ...);
@@ -554,6 +554,10 @@
 					   GtkWidget	       *parent);
 void	   gtk_widget_set_parent_window	  (GtkWidget	       *widget,
 					   GdkWindow	       *parent_window);
+void       gtk_widget_set_child_visible   (GtkWidget           *widget,
+					   gboolean             is_visible);
+gboolean   gtk_widget_get_child_visible   (GtkWidget           *widget);
+     
 GtkWidget *gtk_widget_get_parent          (GtkWidget           *widget);
 GdkWindow *gtk_widget_get_parent_window	  (GtkWidget	       *widget);
 gboolean   gtk_widget_child_focus         (GtkWidget           *widget,


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