]> Pileus Git - ~andy/gtk/commitdiff
Edited section on the ScrolledWindow.
authorOwen Taylor <otaylor@redhat.com>
Tue, 24 Nov 1998 19:33:01 +0000 (19:33 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Tue, 24 Nov 1998 19:33:01 +0000 (19:33 +0000)
Tue Nov 24 11:31:06 1998  Owen Taylor  <otaylor@redhat.com>

* docs/Changes-1.2.txt: Edited section on the ScrolledWindow.

* gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
some code duplication.

* gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
and child widgets when scrolling greater than 32k pixels.

* testgtk.c: Modified layout test to test scrolling over
long distances.

* gtk/gtkplug.c: Added a few blank lines.

13 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/Changes-1.2.txt
gtk/gtklayout.c
gtk/gtklayout.h
gtk/gtkplug.c
gtk/testgtk.c
tests/testgtk.c

index 3f09102f8e374fa57d64cb9eef0993d76fb257d6..14464a8c135b703c13e47c6a5816816cc5f63cb5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Tue Nov 24 11:31:06 1998  Owen Taylor  <otaylor@redhat.com>
+
+       * docs/Changes-1.2.txt: Edited section on the ScrolledWindow.
+
+       * gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
+       some code duplication.
+
+       * gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
+       and child widgets when scrolling greater than 32k pixels.
+
+       * testgtk.c: Modified layout test to test scrolling over 
+       long distances.
+
 Tue Nov 24 11:11:05 1998  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtklayout.[ch]: Fixed up copyright message.
index 3f09102f8e374fa57d64cb9eef0993d76fb257d6..14464a8c135b703c13e47c6a5816816cc5f63cb5 100644 (file)
@@ -1,3 +1,16 @@
+Tue Nov 24 11:31:06 1998  Owen Taylor  <otaylor@redhat.com>
+
+       * docs/Changes-1.2.txt: Edited section on the ScrolledWindow.
+
+       * gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
+       some code duplication.
+
+       * gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
+       and child widgets when scrolling greater than 32k pixels.
+
+       * testgtk.c: Modified layout test to test scrolling over 
+       long distances.
+
 Tue Nov 24 11:11:05 1998  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtklayout.[ch]: Fixed up copyright message.
index 3f09102f8e374fa57d64cb9eef0993d76fb257d6..14464a8c135b703c13e47c6a5816816cc5f63cb5 100644 (file)
@@ -1,3 +1,16 @@
+Tue Nov 24 11:31:06 1998  Owen Taylor  <otaylor@redhat.com>
+
+       * docs/Changes-1.2.txt: Edited section on the ScrolledWindow.
+
+       * gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
+       some code duplication.
+
+       * gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
+       and child widgets when scrolling greater than 32k pixels.
+
+       * testgtk.c: Modified layout test to test scrolling over 
+       long distances.
+
 Tue Nov 24 11:11:05 1998  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtklayout.[ch]: Fixed up copyright message.
index 3f09102f8e374fa57d64cb9eef0993d76fb257d6..14464a8c135b703c13e47c6a5816816cc5f63cb5 100644 (file)
@@ -1,3 +1,16 @@
+Tue Nov 24 11:31:06 1998  Owen Taylor  <otaylor@redhat.com>
+
+       * docs/Changes-1.2.txt: Edited section on the ScrolledWindow.
+
+       * gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
+       some code duplication.
+
+       * gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
+       and child widgets when scrolling greater than 32k pixels.
+
+       * testgtk.c: Modified layout test to test scrolling over 
+       long distances.
+
 Tue Nov 24 11:11:05 1998  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtklayout.[ch]: Fixed up copyright message.
index 3f09102f8e374fa57d64cb9eef0993d76fb257d6..14464a8c135b703c13e47c6a5816816cc5f63cb5 100644 (file)
@@ -1,3 +1,16 @@
+Tue Nov 24 11:31:06 1998  Owen Taylor  <otaylor@redhat.com>
+
+       * docs/Changes-1.2.txt: Edited section on the ScrolledWindow.
+
+       * gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
+       some code duplication.
+
+       * gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
+       and child widgets when scrolling greater than 32k pixels.
+
+       * testgtk.c: Modified layout test to test scrolling over 
+       long distances.
+
 Tue Nov 24 11:11:05 1998  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtklayout.[ch]: Fixed up copyright message.
index 3f09102f8e374fa57d64cb9eef0993d76fb257d6..14464a8c135b703c13e47c6a5816816cc5f63cb5 100644 (file)
@@ -1,3 +1,16 @@
+Tue Nov 24 11:31:06 1998  Owen Taylor  <otaylor@redhat.com>
+
+       * docs/Changes-1.2.txt: Edited section on the ScrolledWindow.
+
+       * gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
+       some code duplication.
+
+       * gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
+       and child widgets when scrolling greater than 32k pixels.
+
+       * testgtk.c: Modified layout test to test scrolling over 
+       long distances.
+
 Tue Nov 24 11:11:05 1998  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtklayout.[ch]: Fixed up copyright message.
index 3f09102f8e374fa57d64cb9eef0993d76fb257d6..14464a8c135b703c13e47c6a5816816cc5f63cb5 100644 (file)
@@ -1,3 +1,16 @@
+Tue Nov 24 11:31:06 1998  Owen Taylor  <otaylor@redhat.com>
+
+       * docs/Changes-1.2.txt: Edited section on the ScrolledWindow.
+
+       * gtk/gtklayout.c (gtk_layout_set_[hv]adjustment): Remove
+       some code duplication.
+
+       * gtk/gtklayout.[ch] Fixed mapping and unmapping of child windows
+       and child widgets when scrolling greater than 32k pixels.
+
+       * testgtk.c: Modified layout test to test scrolling over 
+       long distances.
+
 Tue Nov 24 11:11:05 1998  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtklayout.[ch]: Fixed up copyright message.
index 301991f4150f985d27d27057b5764947b844736b..83312b3dcdb840ce3ab7c10a080c6137dc982505 100644 (file)
@@ -60,24 +60,28 @@ Incompatible Changes from GTK+-1.0 to GTK+-1.2:
      If you need to do that, use a GtkDrawingArea or (for a 
      toplevel) the new GtkDrawWindow widget.
 
-* Scrolled windows do not create an automatic viewport anymore, and
-  self scrolling widgets do not provide their own scrollbars any
-  further. Self scrolling widgets of the Gtk+ core currently are
-  GtkViewport, GtkCList, GtkCTree, GtkText and GtkLayout. All of
-  these widgets can be added to a scrolled window as normal children
-  with gtk_container_add() and their scrolling abilities will be setup
-  appropriatedly in an automatic manner.
-  Widgets that do not implement own scrolling abilities but get added
-  to a scrolled window in order to have their allocations scrollable
-  inside of the scrolled window (e.g. a GtkList) have first to be added
-  to a GtkViewport, and then the viewport needs to be added to the
-  scrolled window.
-  However, the scrolled window code provides a convenience function to
-  achive this:
-  gtk_scrolled_window_add_with_viewport() which will do exactly what
-  it says, add a child widget to a viewport and put that viewport into
-  the scrolled window.
-  Scrollbar policy adjustment needs to be perfomed on the scrolled window
-  with gtk_scrolled_window_set_policy() and is not longer maintained for
-  the child widgets (e.g. GtkCList's gtk_clist_set_policy() got removed).
+* The ScrolledWindow widget no longer creates a Viewport
+  automatically. Instead, it has been generalized to accept
+  any "self-scrolling" widget.
+
+  The self-scrolling widgets in the Gtk+ core are GtkViewport,
+  GtkCList, GtkCTree, GtkText, and GtkLayout. All of these widgets can
+  be added to a scrolled window as normal children with
+  gtk_container_add() and scrollbars will be set up automatically.
+
+  To add scrollbars to a non self-scrolling widget, (such as a GtkList),
+  first add it to a viewport, then add the viewport to a scrolled window.
+  The scrolled window code provides a convenience function to do this:
+
+  void gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrollwin,
+                                             GtkWidget         *child);
+
+  This does exactly what it says - it creates a Viewport, adds the child
+  widget to it, then adds the Viewport to the scrolled window.
+
+  The scrollbars have been removed from the GtkCList and GtkCTree,
+  because they are now scrolled by simply adding them to a Scrolled
+  Window. The scrollbar policy is set on the scrolled window with
+  gtk_scrolled_window_set_policy() and not on the child widgets
+  (e.g. GtkCList's gtk_clist_set_policy() was removed).
   
index 801dca958825dab76e259c9427c660bf646e504e..784cf73f0b20fa392ebea87f8b654be132df5606 100644 (file)
@@ -90,8 +90,7 @@ gtk_layout_new (GtkAdjustment *hadjustment,
 
   layout = gtk_type_new (gtk_layout_get_type());
 
-  gtk_layout_set_hadjustment (layout, hadjustment);
-  gtk_layout_set_vadjustment (layout, vadjustment);
+  gtk_layout_set_adjustments (layout, hadjustment, vadjustment);
 
   return GTK_WIDGET (layout);
 }
@@ -118,6 +117,8 @@ gtk_layout_set_adjustments (GtkLayout     *layout,
                            GtkAdjustment *hadj,
                            GtkAdjustment *vadj)
 {
+  gboolean need_adjust = FALSE;
+
   g_return_if_fail (layout != NULL);
   g_return_if_fail (GTK_IS_LAYOUT (layout));
 
@@ -151,7 +152,7 @@ gtk_layout_set_adjustments (GtkLayout     *layout,
       gtk_signal_connect (GTK_OBJECT (layout->hadjustment), "value_changed",
                          (GtkSignalFunc) gtk_layout_adjustment_changed,
                          layout);
-      gtk_layout_adjustment_changed (hadj, layout);
+      need_adjust = TRUE;
     }
   
   if (layout->vadjustment != vadj)
@@ -163,8 +164,11 @@ gtk_layout_set_adjustments (GtkLayout     *layout,
       gtk_signal_connect (GTK_OBJECT (layout->vadjustment), "value_changed",
                          (GtkSignalFunc) gtk_layout_adjustment_changed,
                          layout);
-      gtk_layout_adjustment_changed (vadj, layout);
+      need_adjust = TRUE;
     }
+
+  if (need_adjust)
+    gtk_layout_adjustment_changed (NULL, layout);
 }
 
 void           
@@ -174,19 +178,7 @@ gtk_layout_set_hadjustment (GtkLayout     *layout,
   g_return_if_fail (layout != NULL);
   g_return_if_fail (GTK_IS_LAYOUT (layout));
 
-  if (layout->hadjustment)
-    gtk_object_unref (GTK_OBJECT (layout->hadjustment));
-
-  if (!adjustment)
-    adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 10.0, 0.0, 0.0));
-  else
-    gtk_object_ref (GTK_OBJECT (adjustment));
-
-  gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
-                     GTK_SIGNAL_FUNC (gtk_layout_adjustment_changed),
-                     layout);
-
-  layout->hadjustment = adjustment;
+  gtk_layout_set_adjustments (layout, adjustment, layout->vadjustment);
 }
  
 
@@ -197,19 +189,7 @@ gtk_layout_set_vadjustment (GtkLayout     *layout,
   g_return_if_fail (layout != NULL);
   g_return_if_fail (GTK_IS_LAYOUT (layout));
   
-  if (layout->vadjustment)
-    gtk_object_unref (GTK_OBJECT (layout->hadjustment));
-
-  if (!adjustment)
-    adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 10.0, 0.0, 0.0));
-  else
-    gtk_object_ref (GTK_OBJECT (adjustment));
-
-  gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
-                     GTK_SIGNAL_FUNC (gtk_layout_adjustment_changed),
-                     layout);
-
-  layout->vadjustment = adjustment;
+  gtk_layout_set_adjustments (layout, layout->hadjustment, adjustment);
 }
 
 
@@ -232,6 +212,7 @@ gtk_layout_put (GtkLayout     *layout,
   child->y = y;
   child->widget->requisition.width = 0;
   child->widget->requisition.height = 0;
+  child->mapped = FALSE;
 
   layout->children = g_list_append (layout->children, child);
   
@@ -481,12 +462,14 @@ gtk_layout_map (GtkWidget *widget)
     {
       GtkLayoutChild *child = tmp_list->data;
 
-      if (GTK_WIDGET_VISIBLE (child->widget) &&
-         !GTK_WIDGET_MAPPED (child->widget))
-       gtk_widget_map (child->widget);
-
-      if (child->window)
-       gdk_window_show (child->window);
+      if (child->mapped && GTK_WIDGET_VISIBLE (child->widget))
+       {
+         if (!GTK_WIDGET_MAPPED (child->widget))
+           gtk_widget_map (child->widget);
+         
+         if (child->window)
+           gdk_window_show (child->window);
+       }
 
       tmp_list = tmp_list->next;
     }
@@ -761,12 +744,21 @@ gtk_layout_position_child (GtkLayout      *layout,
   if ((x >= G_MINSHORT) && (x <= G_MAXSHORT) &&
       (y >= G_MINSHORT) && (y <= G_MAXSHORT))
     {
-      if (GTK_WIDGET_VISIBLE (child->widget) &&
-         GTK_WIDGET_MAPPED (layout) &&
-         !GTK_WIDGET_MAPPED (child->widget))
+      if (!child->mapped)
        {
-         gtk_widget_map (child->widget);
-         force_allocate = TRUE;
+         child->mapped = TRUE;
+
+         if (GTK_WIDGET_MAPPED (layout) &&
+             GTK_WIDGET_VISIBLE (child->widget))
+           {
+             if (child->window)
+               gdk_window_show (child->window);
+             if (!GTK_WIDGET_MAPPED (child->widget))
+               gtk_widget_map (child->widget);
+             
+             child->mapped = TRUE;
+             force_allocate = TRUE;
+           }
        }
       
       if (force_allocate)
@@ -800,10 +792,14 @@ gtk_layout_position_child (GtkLayout      *layout,
     }
   else
     {
-      if (child->window)
-       gdk_window_hide (child->window);
-      else if (GTK_WIDGET_MAPPED (child->widget))
-       gtk_widget_unmap (child->widget);
+      if (child->mapped)
+       {
+         child->mapped = FALSE;
+         if (child->window)
+           gdk_window_hide (child->window);
+         else if (GTK_WIDGET_MAPPED (child->widget))
+           gtk_widget_unmap (child->widget);
+       }
     }
 }
 
@@ -914,10 +910,11 @@ gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
   if (layout->frozen)
     return;
 
-  gtk_layout_position_children (layout);
-
   if (!GTK_WIDGET_MAPPED (layout))
-    return;
+    {
+      gtk_layout_position_children (layout);
+      return;
+    }
 
   if (dx > 0)
     {
@@ -1016,6 +1013,8 @@ gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
                              -dy);
     }
 
+  gtk_layout_position_children (layout);
+
   /* We have to make sure that all exposes from this scroll get
    * processed before we scroll again, or the expose events will
    * have invalid coordinates.
index 1e4298af56658ffc59b6d22e3fb721c41488c273..0b8198fb1b2b4670c13480c1875f7383ec70d9d6 100644 (file)
@@ -45,6 +45,7 @@ struct _GtkLayoutChild {
   GdkWindow *window;   /* For NO_WINDOW widgets */
   gint x;
   gint y;
+  gboolean mapped : 1;
 };
 
 struct _GtkLayout {
index 4e95bb1e96f15510c959483960641eebb44a43d7..69431c82d80737d2d7fbd2ee45459bcac76a66b3 100644 (file)
@@ -88,6 +88,7 @@ gtk_plug_init (GtkPlug *plug)
   window->type = GTK_WINDOW_TOPLEVEL;
   window->auto_shrink = TRUE;
 }
+
 void
 gtk_plug_construct (GtkPlug *plug, guint32 socket_id)
 {
@@ -100,6 +101,7 @@ gtk_plug_construct (GtkPlug *plug, guint32 socket_id)
       plug->same_app = FALSE;
     }
 }
+
 GtkWidget*
 gtk_plug_new (guint32 socket_id)
 {
index ec5cfdf5d5d53b59f7b1cb8b3db75200ebf8d5a4..05bf83c98d034ea9f5906bc3213f9a0af4fae59e 100644 (file)
@@ -7994,7 +7994,6 @@ void create_layout (void)
       gtk_widget_set_usize (window, 200, 200);
 
       scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
-      gtk_widget_show (scrolledwindow);
 
       gtk_container_add (GTK_CONTAINER (window), scrolledwindow);
       
@@ -8005,8 +8004,7 @@ void create_layout (void)
       gtk_signal_connect (GTK_OBJECT (layout), "expose_event",
                          GTK_SIGNAL_FUNC (layout_expose_handler), NULL);
       
-      gtk_layout_set_size (GTK_LAYOUT (layout), 1600, 1600);
-      gtk_widget_show (layout);
+      gtk_layout_set_size (GTK_LAYOUT (layout), 1600, 64000);
       
       for (i=0 ; i < 16 ; i++)
        for (j=0 ; j < 16 ; j++)
@@ -8016,14 +8014,26 @@ void create_layout (void)
              button = gtk_button_new_with_label (buf);
            else
              button = gtk_label_new (buf);
+
            gtk_layout_put (GTK_LAYOUT (layout), button,
                            j*100, i*100);
-           gtk_widget_show (button);
          }
+
+      for (i=16; i < 640; i++)
+       {
+         sprintf(buf, "Button %d, %d", i, 0);
+         if (i % 2)
+           button = gtk_button_new_with_label (buf);
+         else
+           button = gtk_label_new (buf);
+
+         gtk_layout_put (GTK_LAYOUT (layout), button,
+                         0, i*100);
+       }
     }
 
   if (!GTK_WIDGET_VISIBLE (window))
-    gtk_widget_show (window);
+    gtk_widget_show_all (window);
   else
     gtk_widget_destroy (window);
 }
index ec5cfdf5d5d53b59f7b1cb8b3db75200ebf8d5a4..05bf83c98d034ea9f5906bc3213f9a0af4fae59e 100644 (file)
@@ -7994,7 +7994,6 @@ void create_layout (void)
       gtk_widget_set_usize (window, 200, 200);
 
       scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
-      gtk_widget_show (scrolledwindow);
 
       gtk_container_add (GTK_CONTAINER (window), scrolledwindow);
       
@@ -8005,8 +8004,7 @@ void create_layout (void)
       gtk_signal_connect (GTK_OBJECT (layout), "expose_event",
                          GTK_SIGNAL_FUNC (layout_expose_handler), NULL);
       
-      gtk_layout_set_size (GTK_LAYOUT (layout), 1600, 1600);
-      gtk_widget_show (layout);
+      gtk_layout_set_size (GTK_LAYOUT (layout), 1600, 64000);
       
       for (i=0 ; i < 16 ; i++)
        for (j=0 ; j < 16 ; j++)
@@ -8016,14 +8014,26 @@ void create_layout (void)
              button = gtk_button_new_with_label (buf);
            else
              button = gtk_label_new (buf);
+
            gtk_layout_put (GTK_LAYOUT (layout), button,
                            j*100, i*100);
-           gtk_widget_show (button);
          }
+
+      for (i=16; i < 640; i++)
+       {
+         sprintf(buf, "Button %d, %d", i, 0);
+         if (i % 2)
+           button = gtk_button_new_with_label (buf);
+         else
+           button = gtk_label_new (buf);
+
+         gtk_layout_put (GTK_LAYOUT (layout), button,
+                         0, i*100);
+       }
     }
 
   if (!GTK_WIDGET_VISIBLE (window))
-    gtk_widget_show (window);
+    gtk_widget_show_all (window);
   else
     gtk_widget_destroy (window);
 }