Deal with formal release of upstream library
[pspp] / lib / gtk-contrib / gtkxpaned.c
index 9be83311f0f19b7562a8d8332c0c6930f43e7a01..06f642a24e02a59f2e961a5f7ec3125a6e75717b 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- **3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 
+ **3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
  **      10        20        30        40        50        60        70        80
  **
  **  library for GtkXPaned-widget, a 2x2 grid-like variation of GtkPaned of gtk+
@@ -54,7 +54,9 @@ enum ChildProperties
   {
     CHILD_PROP_0,
     CHILD_PROP_RESIZE,
-    CHILD_PROP_SHRINK
+    CHILD_PROP_SHRINK,
+    CHILD_PROP_LEFT_ATTACH,
+    CHILD_PROP_TOP_ATTACH
   };
 
 enum WidgetSignals
@@ -526,13 +528,36 @@ gtk_xpaned_class_init (GtkXPanedClass * class)
                                                      G_MAXINT,
                                                      G_PARAM_READABLE));
 
+
+  gtk_container_class_install_child_property (container_class,
+                                              CHILD_PROP_LEFT_ATTACH,
+                                              g_param_spec_int ("left-attach",
+                                                               "Left Attach",
+                                                               "The column number to which the  left side of the widget should be attached",
+                                                               0, 1,
+                                                               0,
+                                                               G_PARAM_READWRITE));
+
+
+
+  gtk_container_class_install_child_property (container_class,
+                                              CHILD_PROP_TOP_ATTACH,
+                                              g_param_spec_int ("top-attach",
+                                                               "Top Attach",
+                                                               "The row number to which the  top side of the widget should be attached",
+                                                               0, 1,
+                                                               0,
+                                                               G_PARAM_READWRITE));
+
+
+  
   /**
    * GtkPaned:resize:
    *
-   * The "resize" child property determines whether the child expands and 
+   * The "resize" child property determines whether the child expands and
    * shrinks along with the paned widget.
-   * 
-   * Since: 2.4 
+   *
+   * Since: 2.4
    */
   gtk_container_class_install_child_property (container_class,
                                               CHILD_PROP_RESIZE,
@@ -545,10 +570,10 @@ gtk_xpaned_class_init (GtkXPanedClass * class)
   /**
    * GtkPaned:shrink:
    *
-   * The "shrink" child property determines whether the child can be made 
+   * The "shrink" child property determines whether the child can be made
    * smaller than its requisition.
-   * 
-   * Since: 2.4 
+   *
+   * Since: 2.4
    */
   gtk_container_class_install_child_property (container_class,
                                               CHILD_PROP_SHRINK,
@@ -812,6 +837,12 @@ gtk_xpaned_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
   GtkRequisition bottom_right_child_requisition;
   gint handle_size;
 
+  g_print ("Allocate %p %p %p %p\n",
+          xpaned->top_left_child,
+          xpaned->top_right_child,
+          xpaned->bottom_left_child,
+          xpaned->bottom_right_child);
+  
   /* determine size of handle(s) */
   gtk_widget_style_get (widget, "handle-size", &handle_size, NULL);
 
@@ -1046,73 +1077,109 @@ gtk_xpaned_set_child_property (GtkContainer * container,
                                const GValue * value, GParamSpec * pspec)
 {
   GtkXPaned *xpaned = GTK_XPANED (container);
-  gboolean old_value = FALSE;
-  gboolean new_value = FALSE;
 
   g_assert (child == xpaned->top_left_child ||
             child == xpaned->top_right_child ||
             child == xpaned->bottom_left_child ||
             child == xpaned->bottom_right_child);
 
-  new_value = g_value_get_boolean (value);
-
+  gint attach = g_value_get_int (value);
   switch (property_id)
     {
+    case CHILD_PROP_LEFT_ATTACH:
+      g_object_ref (child);
+      gtk_widget_unparent (child);
+      if (attach == 0)
+      {
+       if (child == xpaned->top_right_child)
+         xpaned->top_left_child = child;
+       else if (child == xpaned->bottom_right_child)
+         xpaned->bottom_left_child = child;
+      }
+      else
+      {
+       if (child == xpaned->top_left_child)
+         xpaned->top_right_child = child;
+       else if (child == xpaned->bottom_left_child)
+         xpaned->bottom_right_child = child;
+      }
+      gtk_widget_set_parent (child, GTK_WIDGET (xpaned));
+      g_object_unref (child);
+      break;
+    case CHILD_PROP_TOP_ATTACH:
+      g_object_ref (child);
+      gtk_widget_unparent (child);
+      if (attach == 0)
+       {
+         if (child == xpaned->bottom_right_child)
+           xpaned->top_right_child = child;
+         else if (child == xpaned->bottom_left_child)
+           xpaned->top_left_child = child;
+       }
+      else
+       {
+         if (child == xpaned->top_left_child)
+           xpaned->bottom_left_child = child;
+         else if (child == xpaned->top_right_child)
+           xpaned->bottom_right_child = child;
+       }
+      gtk_widget_set_parent (child, GTK_WIDGET (xpaned));
+      g_object_unref (child);
+      break;
     case CHILD_PROP_RESIZE:
-      if (child == xpaned->top_left_child)
-        {
-          old_value = xpaned->top_left_child_resize;
-          xpaned->top_left_child_resize = new_value;
-        }
-      else if (child == xpaned->top_right_child)
-        {
-          old_value = xpaned->top_right_child_resize;
-          xpaned->top_right_child_resize = new_value;
-        }
-      else if (child == xpaned->bottom_left_child)
-        {
-          old_value = xpaned->bottom_left_child_resize;
-          xpaned->bottom_left_child_resize = new_value;
-        }
-      else if (child == xpaned->bottom_right_child)
-        {
-          old_value = xpaned->bottom_right_child_resize;
-          xpaned->bottom_right_child_resize = new_value;
-        }
+      {
+       gboolean  new_value = TRUE;
+       
+       if (child == xpaned->top_left_child)
+         {
+           xpaned->top_left_child_resize = new_value;
+         }
+       else if (child == xpaned->top_right_child)
+         {
+           xpaned->top_right_child_resize = new_value;
+         }
+       else if (child == xpaned->bottom_left_child)
+         {
+           xpaned->bottom_left_child_resize = new_value;
+         }
+       else if (child == xpaned->bottom_right_child)
+         {
+           xpaned->bottom_right_child_resize = new_value;
+         }
+      }
       break;
-
+      
     case CHILD_PROP_SHRINK:
-      if (child == xpaned->top_left_child)
-        {
-          old_value = xpaned->top_left_child_shrink;
-          xpaned->top_left_child_shrink = new_value;
-        }
-      else if (child == xpaned->top_right_child)
-        {
-          old_value = xpaned->top_right_child_shrink;
-          xpaned->top_right_child_shrink = new_value;
-        }
-      else if (child == xpaned->bottom_left_child)
-        {
-          old_value = xpaned->bottom_left_child_shrink;
-          xpaned->bottom_left_child_shrink = new_value;
-        }
-      else if (child == xpaned->bottom_right_child)
-        {
-          old_value = xpaned->bottom_right_child_shrink;
-          xpaned->bottom_right_child_shrink = new_value;
-        }
+      {
+       gboolean  new_value = FALSE;
+       
+       if (child == xpaned->top_left_child)
+         {
+           xpaned->top_left_child_shrink = new_value;
+         }
+       else if (child == xpaned->top_right_child)
+         {
+           xpaned->top_right_child_shrink = new_value;
+         }
+       else if (child == xpaned->bottom_left_child)
+         {
+           xpaned->bottom_left_child_shrink = new_value;
+         }
+       else if (child == xpaned->bottom_right_child)
+         {
+           xpaned->bottom_right_child_shrink = new_value;
+         }
+      }
       break;
 
     default:
       GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container,
                                                     property_id, pspec);
-      old_value = -1;           /* quiet gcc */
       break;
     }
 
-  if (old_value != new_value)
-    gtk_widget_queue_resize (GTK_WIDGET (container));
+  gtk_widget_queue_resize (GTK_WIDGET (container));
+  gtk_widget_queue_draw (GTK_WIDGET (container));
 }
 
 static void
@@ -1130,6 +1197,26 @@ gtk_xpaned_get_child_property (GtkContainer * container,
 
   switch (property_id)
     {
+    case CHILD_PROP_TOP_ATTACH:
+      if (child == xpaned->top_left_child)
+       g_value_set_int (value, 0);
+      if (child == xpaned->top_right_child)
+       g_value_set_int (value, 0);
+      if (child == xpaned->bottom_left_child)
+       g_value_set_int (value, 1);
+      if (child == xpaned->bottom_right_child)
+       g_value_set_int (value, 1);
+      break;
+    case CHILD_PROP_LEFT_ATTACH:
+      if (child == xpaned->top_left_child)
+       g_value_set_int (value, 0);
+      if (child == xpaned->bottom_left_child)
+       g_value_set_int (value, 0);
+      if (child == xpaned->top_right_child)
+       g_value_set_int (value, 1);
+      if (child == xpaned->bottom_right_child)
+       g_value_set_int (value, 1);
+      break;
     case CHILD_PROP_RESIZE:
       if (child == xpaned->top_left_child)
         g_value_set_boolean (value, xpaned->top_left_child_resize);
@@ -2014,9 +2101,9 @@ gtk_xpaned_forall (GtkContainer * container,
 /**
  * gtk_xpaned_get_position_x:
  * @paned: a #GtkXPaned widget
- * 
+ *
  * Obtains the x-position of the divider.
- * 
+ *
  * Return value: x-position of the divider
  **/
 gint
@@ -2030,9 +2117,9 @@ gtk_xpaned_get_position_x (GtkXPaned * xpaned)
 /**
  * gtk_xpaned_get_position_y:
  * @paned: a #GtkXPaned widget
- * 
+ *
  * Obtains the y-position of the divider.
- * 
+ *
  * Return value: y-position of the divider
  **/
 gint
@@ -2048,7 +2135,7 @@ gtk_xpaned_get_position_y (GtkXPaned * xpaned)
  * @paned: a #GtkXPaned widget
  * @xposition: pixel x-position of divider, a negative values
  *                        of a component mean that the position is unset.
- * 
+ *
  * Sets the x-position of the divider between the four panes.
  **/
 void
@@ -2097,7 +2184,7 @@ gtk_xpaned_set_position_x (GtkXPaned * xpaned, gint xposition)
  * @paned: a #GtkXPaned widget
  * @yposition: pixel y-position of divider, a negative values
  *                        of a component mean that the position is unset.
- * 
+ *
  * Sets the y-position of the divider between the four panes.
  **/
 void
@@ -2172,9 +2259,9 @@ gtk_xpaned_fetch_unmaximized_y (GtkXPaned * xpaned)
 /**
  * gtk_xpaned_get_top_left_child:
  * @xpaned: a #GtkXPaned widget
- * 
+ *
  * Obtains the top-left child of the xpaned widget.
- * 
+ *
  * Return value: top-left child, or %NULL if it is not set.
  *
  * Since: 2.4
@@ -2190,9 +2277,9 @@ gtk_xpaned_get_top_left_child (GtkXPaned * xpaned)
 /**
  * gtk_xpaned_get_top_right_child:
  * @xpaned: a #GtkXPaned widget
- * 
+ *
  * Obtains the top-right child of the xpaned widget.
- * 
+ *
  * Return value: top-right child, or %NULL if it is not set.
  *
  * Since: 2.4
@@ -2208,9 +2295,9 @@ gtk_xpaned_get_top_right_child (GtkXPaned * xpaned)
 /**
  * gtk_xpaned_get_bottom_left_child:
  * @xpaned: a #GtkXPaned widget
- * 
+ *
  * Obtains the bottom-left child of the xpaned widget.
- * 
+ *
  * Return value: bottom-left child, or %NULL if it is not set.
  *
  * Since: 2.4
@@ -2226,9 +2313,9 @@ gtk_xpaned_get_bottom_left_child (GtkXPaned * xpaned)
 /**
  * gtk_xpaned_get_bottom_right_child:
  * @xpaned: a #GtkXPaned widget
- * 
+ *
  * Obtains the bottom-right child of the xpaned widget.
- * 
+ *
  * Return value: bottom-right child, or %NULL if it is not set.
  *
  * Since: 2.4