From: John Darrington Date: Tue, 14 May 2013 09:52:27 +0000 (+0200) Subject: PsppireButtonBox: Do not use the GtkBoxChild structure. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3b56644beb1cd50981ccf646dcc96200afe468f;p=pspp PsppireButtonBox: Do not use the GtkBoxChild structure. Avoid using Gtk features which are (soon to be) deprecated. --- diff --git a/src/ui/gui/psppire-buttonbox.c b/src/ui/gui/psppire-buttonbox.c index 24d82d27d3..a9480a3311 100644 --- a/src/ui/gui/psppire-buttonbox.c +++ b/src/ui/gui/psppire-buttonbox.c @@ -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++; } } diff --git a/src/ui/gui/psppire-hbuttonbox.c b/src/ui/gui/psppire-hbuttonbox.c index 2d036a4156..9ce34bb491 100644 --- a/src/ui/gui/psppire-hbuttonbox.c +++ b/src/ui/gui/psppire-hbuttonbox.c @@ -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); } } } diff --git a/src/ui/gui/psppire-vbuttonbox.c b/src/ui/gui/psppire-vbuttonbox.c index e1496576a5..eb9a662ecb 100644 --- a/src/ui/gui/psppire-vbuttonbox.c +++ b/src/ui/gui/psppire-vbuttonbox.c @@ -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); } } }