PsppireButtonBox: Do not use the GtkBoxChild structure.
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 14 May 2013 09:52:27 +0000 (11:52 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 14 May 2013 13:25:36 +0000 (15:25 +0200)
Avoid using Gtk features which are (soon to be) deprecated.

src/ui/gui/psppire-buttonbox.c
src/ui/gui/psppire-hbuttonbox.c
src/ui/gui/psppire-vbuttonbox.c

index 24d82d27d3ac9a9b2e139cf2306880c98dd4bb81..a9480a331198e450fa5a5056531d76edbba79040 100644 (file)
@@ -406,8 +406,9 @@ psppire_button_box_init (PsppireButtonBox *bb)
 }
 
 
-/* This function is lifted verbatim from the Gtk2.10.6 library */
-
+/* This function was lifted verbatim from the Gtk2.10.6 library.
+   But later modified to fit Gtk2.24
+ */
 void
 _psppire_button_box_child_requisition (GtkWidget *widget,
                                       int       *nvis_children,
@@ -416,7 +417,6 @@ _psppire_button_box_child_requisition (GtkWidget *widget,
                                       int       *height)
 {
   GtkButtonBox *bbox;
-  GtkBoxChild *child;
   GList *children;
   gint nchildren;
   gint nsecondaries;
@@ -457,27 +457,32 @@ _psppire_button_box_child_requisition (GtkWidget *widget,
 
   nchildren = 0;
   nsecondaries = 0;
-  children = GTK_BOX(bbox)->children;
+
   needed_width = child_min_width;
   needed_height = child_min_height;
   ipad_w = ipad_x * 2;
   ipad_h = ipad_y * 2;
 
+  children = gtk_container_get_children (GTK_CONTAINER (bbox));
   while (children)
     {
-      child = children->data;
+      GtkWidget *child = children->data;
       children = children->next;
 
-      if (gtk_widget_get_visible (child->widget))
+      if (gtk_widget_get_visible (child))
        {
+          gboolean is_secondary = FALSE;
          nchildren += 1;
-         gtk_widget_size_request (child->widget, &child_requisition);
+         gtk_widget_size_request (child, &child_requisition);
 
          if (child_requisition.width + ipad_w > needed_width)
            needed_width = child_requisition.width + ipad_w;
          if (child_requisition.height + ipad_h > needed_height)
            needed_height = child_requisition.height + ipad_h;
-         if (child->is_secondary)
+
+          gtk_container_child_get (GTK_CONTAINER (bbox), child, "secondary", &is_secondary, NULL);
+
+          if (is_secondary)
            nsecondaries++;
        }
     }
index 2d036a415630df7621df1afd9df9de4a0a14117c..9ce34bb491e3de783550ef7b9ad74fae347c08fd 100644 (file)
@@ -162,7 +162,6 @@ gtk_hbutton_box_size_allocate (GtkWidget     *widget,
 {
   GtkBox *base_box;
   GtkButtonBox *box;
-  GtkBoxChild *child;
   GList *children;
   GtkAllocation child_allocation;
   gint nvis_children;
@@ -236,25 +235,29 @@ gtk_hbutton_box_size_allocate (GtkWidget     *widget,
   y = allocation->y + (allocation->height - child_height) / 2;
   childspace = child_width + childspacing;
 
-  children = GTK_BOX (box)->children;
+  children = gtk_container_get_children (GTK_CONTAINER (box));
 
   while (children)
     {
-      child = children->data;
+      GtkWidget *child = children->data;
       children = children->next;
 
-      if (gtk_widget_get_visible (child->widget))
+      if (gtk_widget_get_visible (child))
        {
+          gboolean is_secondary = FALSE;
+          gtk_container_child_get (GTK_CONTAINER (box), child, "secondary", &is_secondary, NULL);
+
+
          child_allocation.width = child_width;
          child_allocation.height = child_height;
          child_allocation.y = y;
 
-         if (child->is_secondary)
-           {
+          if (is_secondary)
+            {
              child_allocation.x = secondary_x;
              secondary_x += childspace;
            }
-         else
+          else
            {
              child_allocation.x = x;
              x += childspace;
@@ -263,7 +266,7 @@ gtk_hbutton_box_size_allocate (GtkWidget     *widget,
          if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
            child_allocation.x = (allocation->x + allocation->width) - (child_allocation.x + child_width - allocation->x);
 
-         gtk_widget_size_allocate (child->widget, &child_allocation);
+         gtk_widget_size_allocate (child, &child_allocation);
        }
     }
 }
index e1496576a586e9ee042aa3c002d7ce5b2c199136..eb9a662ecb215e7080094a269ecf5ec9c7afe106 100644 (file)
@@ -162,7 +162,6 @@ gtk_vbutton_box_size_allocate (GtkWidget     *widget,
 {
   GtkBox *base_box;
   GtkButtonBox *box;
-  GtkBoxChild *child;
   GList *children;
   GtkAllocation child_allocation;
   gint nvis_children;
@@ -235,20 +234,22 @@ gtk_vbutton_box_size_allocate (GtkWidget     *widget,
   x = allocation->x + (allocation->width - child_width) / 2;
   childspace = child_height + childspacing;
 
-  children = GTK_BOX (box)->children;
-
+  children = gtk_container_get_children (GTK_CONTAINER (box));
   while (children)
     {
-      child = children->data;
+      GtkWidget *child = children->data;
       children = children->next;
 
-      if (gtk_widget_get_visible (child->widget))
+      if (gtk_widget_get_visible (child))
        {
+          gboolean is_secondary = FALSE;
+          gtk_container_child_get (GTK_CONTAINER (box), child, "secondary", &is_secondary, NULL);
+
          child_allocation.width = child_width;
          child_allocation.height = child_height;
          child_allocation.x = x;
 
-         if (child->is_secondary)
+         if (is_secondary)
            {
              child_allocation.y = secondary_y;
              secondary_y += childspace;
@@ -259,7 +260,7 @@ gtk_vbutton_box_size_allocate (GtkWidget     *widget,
              y += childspace;
            }
 
-         gtk_widget_size_allocate (child->widget, &child_allocation);
+         gtk_widget_size_allocate (child, &child_allocation);
        }
     }
 }