Fix warning about uninitialized variable plus spacing and indentation cleanup

This commit is contained in:
Michael Natterer
2009-06-25 13:30:15 +02:00
parent 99b42cf006
commit f35c317b68

View File

@ -21,7 +21,7 @@
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog * file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with * files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/. * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/ */
#include "config.h" #include "config.h"
@ -49,10 +49,10 @@ static void gtk_button_box_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_button_box_size_request (GtkWidget *widget, static void gtk_button_box_size_request (GtkWidget *widget,
GtkRequisition *requisition); GtkRequisition *requisition);
static void gtk_button_box_size_allocate (GtkWidget *widget, static void gtk_button_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static void gtk_button_box_set_child_property (GtkContainer *container, static void gtk_button_box_set_child_property (GtkContainer *container,
GtkWidget *child, GtkWidget *child,
guint property_id, guint property_id,
@ -90,7 +90,7 @@ gtk_button_box_class_init (GtkButtonBoxClass *class)
container_class->set_child_property = gtk_button_box_set_child_property; container_class->set_child_property = gtk_button_box_set_child_property;
container_class->get_child_property = gtk_button_box_get_child_property; container_class->get_child_property = gtk_button_box_get_child_property;
/* FIXME we need to override the "spacing" property on GtkBox once /* FIXME we need to override the "spacing" property on GtkBox once
* libgobject allows that. * libgobject allows that.
*/ */
@ -164,7 +164,7 @@ gtk_button_box_set_property (GObject *object,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
switch (prop_id) switch (prop_id)
{ {
case PROP_LAYOUT_STYLE: case PROP_LAYOUT_STYLE:
gtk_button_box_set_layout (GTK_BUTTON_BOX (object), gtk_button_box_set_layout (GTK_BUTTON_BOX (object),
@ -459,7 +459,7 @@ _gtk_button_box_child_requisition (GtkWidget *widget,
{ {
nchildren += 1; nchildren += 1;
gtk_widget_size_request (child->widget, &child_requisition); gtk_widget_size_request (child->widget, &child_requisition);
if (child_requisition.width + ipad_w > needed_width) if (child_requisition.width + ipad_w > needed_width)
needed_width = child_requisition.width + ipad_w; needed_width = child_requisition.width + ipad_w;
if (child_requisition.height + ipad_h > needed_height) if (child_requisition.height + ipad_h > needed_height)
@ -558,14 +558,10 @@ gtk_button_box_size_request (GtkWidget *widget,
break; break;
} }
if (orientation == GTK_ORIENTATION_HORIZONTAL) if (orientation == GTK_ORIENTATION_HORIZONTAL)
{ requisition->height = child_height;
requisition->height = child_height; else
} requisition->width = child_width;
else
{
requisition->width = child_width;
}
} }
requisition->width += GTK_CONTAINER (box)->border_width * 2; requisition->width += GTK_CONTAINER (box)->border_width * 2;
@ -589,8 +585,8 @@ gtk_button_box_size_allocate (GtkWidget *widget,
gint y = 0; gint y = 0;
gint secondary_x = 0; gint secondary_x = 0;
gint secondary_y = 0; gint secondary_y = 0;
gint width; gint width = 0;
gint height; gint height = 0;
gint childspace; gint childspace;
gint childspacing = 0; gint childspacing = 0;
GtkButtonBoxStyle layout; GtkButtonBoxStyle layout;
@ -645,20 +641,20 @@ gtk_button_box_size_allocate (GtkWidget *widget,
if (orientation == GTK_ORIENTATION_HORIZONTAL) if (orientation == GTK_ORIENTATION_HORIZONTAL)
{ {
if (nvis_children >= 2) if (nvis_children >= 2)
{ {
childspacing = (width - (nvis_children * child_width)) childspacing = (width - (nvis_children * child_width))
/ (nvis_children - 1); / (nvis_children - 1);
x = allocation->x + GTK_CONTAINER (box)->border_width; x = allocation->x + GTK_CONTAINER (box)->border_width;
secondary_x = x + ((nvis_children - n_secondaries) secondary_x = x + ((nvis_children - n_secondaries)
* (child_width + childspacing)); * (child_width + childspacing));
} }
else else
{ {
/* one or zero children, just center */ /* one or zero children, just center */
childspacing = width; childspacing = width;
x = secondary_x = allocation->x x = secondary_x = allocation->x
+ (allocation->width - child_width) / 2; + (allocation->width - child_width) / 2;
} }
} }
else else
{ {
@ -735,8 +731,8 @@ gtk_button_box_size_allocate (GtkWidget *widget,
x = allocation->x + x = allocation->x +
(allocation->width (allocation->width
- (child_width * (nvis_children - n_secondaries) - (child_width * (nvis_children - n_secondaries)
+ spacing * (nvis_children - n_secondaries - 1)))/2 + spacing * (nvis_children - n_secondaries - 1))) / 2
+ (n_secondaries * child_width + n_secondaries * spacing)/2; + (n_secondaries * child_width + n_secondaries * spacing) / 2;
secondary_x = allocation->x + GTK_CONTAINER (box)->border_width; secondary_x = allocation->x + GTK_CONTAINER (box)->border_width;
} }
else else
@ -745,15 +741,15 @@ gtk_button_box_size_allocate (GtkWidget *widget,
y = allocation->y + y = allocation->y +
(allocation->height (allocation->height
- (child_height * (nvis_children - n_secondaries) - (child_height * (nvis_children - n_secondaries)
+ spacing * (nvis_children - n_secondaries - 1)))/2 + spacing * (nvis_children - n_secondaries - 1))) / 2
+ (n_secondaries * child_height + n_secondaries * spacing)/2; + (n_secondaries * child_height + n_secondaries * spacing) / 2;
secondary_y = allocation->y + GTK_CONTAINER (box)->border_width; secondary_y = allocation->y + GTK_CONTAINER (box)->border_width;
} }
break; break;
default: default:
g_assert_not_reached(); g_assert_not_reached ();
break; break;
} }