]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkpacker.c
Adapt cast macros to standard.
[~andy/gtk] / gtk / gtkpacker.c
index 00e8dedd438a7b3a1788f37497b00bfa213e7ade..095855b4fff24dde66cc0de72d1af2b129b5a373 100644 (file)
@@ -85,6 +85,14 @@ terms specified in this license.
  *
  */
 
+/*
+ * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
+ * file for a list of people on the GTK+ Team.  See the ChangeLog
+ * files for a list of changes.  These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
+ */
+
+
 
 #include "gtkpacker.h"
 
@@ -131,7 +139,8 @@ static void gtk_packer_container_add (GtkContainer   *container,
                                       GtkWidget      *child);
 static void gtk_packer_remove        (GtkContainer   *container,
                                       GtkWidget      *widget);
-static void gtk_packer_foreach       (GtkContainer   *container,
+static void gtk_packer_forall        (GtkContainer   *container,
+                                     gboolean        include_internals,
                                       GtkCallback     callback,
                                       gpointer        callback_data);
 static void gtk_packer_set_arg      (GtkObject      *object,
@@ -160,15 +169,15 @@ gtk_packer_get_type (void)
 
   if (!packer_type)
     {
-      GtkTypeInfo packer_info =
+      static const GtkTypeInfo packer_info =
       {
         "GtkPacker",
         sizeof (GtkPacker),
         sizeof (GtkPackerClass),
         (GtkClassInitFunc) gtk_packer_class_init,
         (GtkObjectInitFunc) gtk_packer_init,
-        /* reversed_1 */ NULL,
-       /* reversed_2 */ NULL,
+        /* reserved_1 */ NULL,
+       /* reserved_2 */ NULL,
        (GtkClassInitFunc) NULL,
       };
 
@@ -223,7 +232,7 @@ gtk_packer_class_init (GtkPackerClass *klass)
   
   container_class->add = gtk_packer_container_add;
   container_class->remove = gtk_packer_remove;
-  container_class->foreach = gtk_packer_foreach;
+  container_class->forall = gtk_packer_forall;
   container_class->child_type = gtk_packer_child_type;
   container_class->get_child_arg = gtk_packer_get_child_arg;
   container_class->set_child_arg = gtk_packer_set_child_arg;
@@ -490,7 +499,7 @@ gtk_packer_get_child_arg (GtkContainer   *container,
 static void
 gtk_packer_init (GtkPacker *packer)
 {
-  GTK_WIDGET_SET_FLAGS (packer, GTK_NO_WINDOW | GTK_BASIC);
+  GTK_WIDGET_SET_FLAGS (packer, GTK_NO_WINDOW);
   
   packer->children = NULL;
   packer->spacing = 0;
@@ -508,7 +517,7 @@ gtk_packer_set_spacing (GtkPacker *packer,
       packer->spacing = spacing;
       gtk_widget_queue_resize (GTK_WIDGET (packer));
     }
-};
+}
 
 GtkWidget*
 gtk_packer_new (void)
@@ -627,20 +636,16 @@ gtk_packer_add_defaults (GtkPacker       *packer,
   
   gtk_widget_set_parent (child, GTK_WIDGET (packer));
   
-  if (GTK_WIDGET_VISIBLE (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_REALIZED (GTK_WIDGET (packer)) &&
-          !GTK_WIDGET_REALIZED (child)) 
-        gtk_widget_realize (child);
-      
-      if (GTK_WIDGET_MAPPED (GTK_WIDGET (packer)) &&
-          !GTK_WIDGET_MAPPED (child)) 
-        gtk_widget_map (child);
-    }
+      if (GTK_WIDGET_MAPPED (child->parent))
+       gtk_widget_map (child);
 
-  if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (packer))
-    gtk_widget_queue_resize (child);
-  
+      gtk_widget_queue_resize (child);
+    }
 }
 
 void 
@@ -681,33 +686,29 @@ gtk_packer_add (GtkPacker       *packer,
   
   gtk_widget_set_parent (child, GTK_WIDGET (packer));
   
-  if (GTK_WIDGET_VISIBLE (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_REALIZED (GTK_WIDGET (packer)) &&
-          !GTK_WIDGET_REALIZED (child)) 
-        gtk_widget_realize (child);
-      
-      if (GTK_WIDGET_MAPPED (GTK_WIDGET (packer)) &&
-          !GTK_WIDGET_MAPPED (child)) 
-        gtk_widget_map (child);
+      if (GTK_WIDGET_MAPPED (child->parent))
+       gtk_widget_map (child);
+
+      gtk_widget_queue_resize (child);
     }
-  
-  if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (packer))
-    gtk_widget_queue_resize (child);
-  
 }
 
 void
-gtk_packer_configure (GtkPacker       *packer,
-                      GtkWidget       *child,
-                      GtkSideType      side,
-                      GtkAnchorType    anchor,
-                      GtkPackerOptions options,
-                      guint            border_width,
-                      guint            pad_x,
-                      guint            pad_y,
-                      guint            i_pad_x,
-                      guint            i_pad_y)
+gtk_packer_set_child_packing (GtkPacker       *packer,
+                             GtkWidget       *child,
+                             GtkSideType      side,
+                             GtkAnchorType    anchor,
+                             GtkPackerOptions options,
+                             guint            border_width,
+                             guint            pad_x,
+                             guint            pad_y,
+                             guint            i_pad_x,
+                             guint            i_pad_y)
 {
   GList *list;
   GtkPackerChild *pchild;
@@ -741,8 +742,7 @@ gtk_packer_configure (GtkPacker       *packer,
       list = g_list_next(list);
     }
 
-  g_warning ("gtk_packer_configure(): couldn't find child `%s' amongst the packer's children", gtk_type_name (GTK_OBJECT_TYPE (child)));
-
+  g_warning ("couldn't find child `%s' amongst the packer's children", gtk_type_name (GTK_OBJECT_TYPE (child)));
 }
 
 void
@@ -897,7 +897,8 @@ gtk_packer_unmap (GtkWidget *widget)
 }
 
 static void 
-gtk_packer_draw (GtkWidget *widget, GdkRectangle     *area)
+gtk_packer_draw (GtkWidget    *widget,
+                GdkRectangle *area)
 {
   GtkPacker *packer;
   GtkPackerChild *child;
@@ -925,7 +926,8 @@ gtk_packer_draw (GtkWidget *widget, GdkRectangle     *area)
 }
 
 static gint 
-gtk_packer_expose (GtkWidget *widget, GdkEventExpose *event)
+gtk_packer_expose (GtkWidget      *widget,
+                  GdkEventExpose *event)
 {
   GtkPacker *packer;
   GtkPackerChild *child;
@@ -958,7 +960,8 @@ gtk_packer_expose (GtkWidget *widget, GdkEventExpose *event)
 }
 
 static void 
-gtk_packer_size_request (GtkWidget *widget, GtkRequisition *requisition)
+gtk_packer_size_request (GtkWidget      *widget,
+                        GtkRequisition *requisition)
 {
   GtkPacker *packer;
   GtkContainer *container;
@@ -990,27 +993,29 @@ gtk_packer_size_request (GtkWidget *widget, GtkRequisition *requisition)
       
       if (GTK_WIDGET_VISIBLE (child->widget)) 
        {
-         gtk_widget_size_request (child->widget, &child->widget->requisition);
+         GtkRequisition child_requisition;
+
+         gtk_widget_size_request (child->widget, &child_requisition);
          
-         if((child->side == GTK_SIDE_TOP) || (child->side == GTK_SIDE_BOTTOM))
+         if ((child->side == GTK_SIDE_TOP) || (child->side == GTK_SIDE_BOTTOM))
            {
              maxWidth = MAX (maxWidth,
-                             (child->widget->requisition.width +
+                             (child_requisition.width +
                               2 * child->border_width +
                               child->pad_x + child->i_pad_x +
                               width));
-             height += (child->widget->requisition.height +
+             height += (child_requisition.height +
                         2 * child->border_width +
                         child->pad_y + child->i_pad_y);
             } 
          else 
            {
              maxHeight = MAX (maxHeight,
-                              (child->widget->requisition.height +
+                              (child_requisition.height +
                                2 * child->border_width +
                                child->pad_y + child->i_pad_y +
                                height));
-             width += (child->widget->requisition.width +
+             width += (child_requisition.width +
                        2 * child->border_width +
                        child->pad_x + child->i_pad_x);
             }
@@ -1024,7 +1029,8 @@ gtk_packer_size_request (GtkWidget *widget, GtkRequisition *requisition)
 }
 
 static gint
-YExpansion (GList *children, gint cavityHeight)
+YExpansion (GList *children,
+           gint   cavityHeight)
 {
   GList *list;
   GtkPackerChild *child;
@@ -1038,9 +1044,13 @@ YExpansion (GList *children, gint cavityHeight)
   list = children;
   while (list != NULL) 
     {
+      GtkRequisition child_requisition;
+
       child = list->data;
       widget = child->widget;
-      childHeight = (widget->requisition.height +
+      gtk_widget_get_child_requisition (widget, &child_requisition);
+
+      childHeight = (child_requisition.height +
                     2 * child->border_width +
                     child->i_pad_y +
                     child->pad_y);
@@ -1064,7 +1074,8 @@ YExpansion (GList *children, gint cavityHeight)
 }
 
 static gint
-XExpansion (GList *children, gint cavityWidth)
+XExpansion (GList *children,
+           gint   cavityWidth)
 {
   GList *list;
   GtkPackerChild *child;
@@ -1078,9 +1089,13 @@ XExpansion (GList *children, gint cavityWidth)
   list = children;
   while (list != NULL) 
     {
+      GtkRequisition child_requisition;
+
       child = list->data;
       widget = child->widget;
-      childWidth = (widget->requisition.width +
+      gtk_widget_get_child_requisition (widget, &child_requisition);
+
+      childWidth = (child_requisition.width +
                    2 * child->border_width +
                    child->i_pad_x +
                    child->pad_x);
@@ -1102,10 +1117,11 @@ XExpansion (GList *children, gint cavityWidth)
   if (curExpand < minExpand)
     minExpand = curExpand;
   return (minExpand < 0) ? 0 : minExpand; 
-};
+}
 
 static void 
-gtk_packer_size_allocate (GtkWidget *widget, GtkAllocation  *allocation)
+gtk_packer_size_allocate (GtkWidget      *widget,
+                         GtkAllocation  *allocation)
 {
   GtkPacker *packer;
   GtkContainer *container;
@@ -1137,12 +1153,15 @@ gtk_packer_size_allocate (GtkWidget *widget, GtkAllocation  *allocation)
   list = g_list_first (packer->children);
   while (list != NULL)
     {
+      GtkRequisition child_requisition;
+
       child = list->data;
+      gtk_widget_get_child_requisition (child->widget, &child_requisition);
       
       if ((child->side == GTK_SIDE_TOP) || (child->side == GTK_SIDE_BOTTOM)) 
        {
          frameWidth = cavityWidth;
-         frameHeight = (child->widget->requisition.height +
+         frameHeight = (child_requisition.height +
                         2 * child->border_width +
                         child->pad_y +
                         child->i_pad_y);
@@ -1168,7 +1187,7 @@ gtk_packer_size_allocate (GtkWidget *widget, GtkAllocation  *allocation)
       else 
        {
          frameHeight = cavityHeight;
-         frameWidth = (child->widget->requisition.width +
+         frameWidth = (child_requisition.width +
                        2 * child->border_width +
                        child->pad_x +
                        child->i_pad_x);
@@ -1194,13 +1213,13 @@ gtk_packer_size_allocate (GtkWidget *widget, GtkAllocation  *allocation)
       borderX = child->pad_x + 2 * child->border_width;
       borderY = child->pad_y + 2 * child->border_width;
       
-      width = (child->widget->requisition.width +
+      width = (child_requisition.width +
               2 * child->border_width +
               child->i_pad_x);
       if ((child->options & GTK_FILL_X) || (width > (frameWidth - borderX)))
        width = frameWidth - borderX;
 
-      height = (child->widget->requisition.height +
+      height = (child_requisition.height +
                2 * child->border_width +
                child->i_pad_y);
       if ((child->options & GTK_FILL_Y) || (height > (frameHeight - borderY)))
@@ -1272,9 +1291,10 @@ gtk_packer_size_allocate (GtkWidget *widget, GtkAllocation  *allocation)
 }
 
 static void
-gtk_packer_foreach (GtkContainer *container,
-                    GtkCallback   callback,
-                    gpointer      callback_data)
+gtk_packer_forall (GtkContainer *container,
+                  gboolean      include_internals,
+                  GtkCallback   callback,
+                  gpointer      callback_data)
 {
   GtkPacker *packer;
   GtkPackerChild *child;
@@ -1286,7 +1306,7 @@ gtk_packer_foreach (GtkContainer *container,
   
   packer = GTK_PACKER (container);
   
-  children = g_list_first(packer->children);
+  children = g_list_first (packer->children);
   while (children != NULL) 
     {
       child = children->data;