static gint default_spacing = 30;
static gint default_layout_style = GTK_BUTTONBOX_EDGE;
-GtkType
+GType
gtk_hbutton_box_get_type (void)
{
- static GtkType hbutton_box_type = 0;
+ static GType hbutton_box_type = 0;
if (!hbutton_box_type)
{
- static const GtkTypeInfo hbutton_box_info =
+ static const GTypeInfo hbutton_box_info =
{
- "GtkHButtonBox",
- sizeof (GtkHButtonBox),
sizeof (GtkHButtonBoxClass),
- (GtkClassInitFunc) gtk_hbutton_box_class_init,
- (GtkObjectInitFunc) gtk_hbutton_box_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_hbutton_box_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkHButtonBox),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gtk_hbutton_box_init,
};
- hbutton_box_type = gtk_type_unique (GTK_TYPE_BUTTON_BOX, &hbutton_box_info);
+ hbutton_box_type =
+ g_type_register_static (GTK_TYPE_BUTTON_BOX, "GtkHButtonBox",
+ &hbutton_box_info, 0);
}
return hbutton_box_type;
{
GtkHButtonBox *hbutton_box;
- hbutton_box = gtk_type_new (GTK_TYPE_HBUTTON_BOX);
+ hbutton_box = g_object_new (GTK_TYPE_HBUTTON_BOX, NULL);
return GTK_WIDGET (hbutton_box);
}
/* set default value for spacing */
-void gtk_hbutton_box_set_spacing_default (gint spacing)
+void
+gtk_hbutton_box_set_spacing_default (gint spacing)
{
default_spacing = spacing;
}
/* set default value for layout style */
-void gtk_hbutton_box_set_layout_default (GtkButtonBoxStyle layout)
+void
+gtk_hbutton_box_set_layout_default (GtkButtonBoxStyle layout)
{
g_return_if_fail (layout >= GTK_BUTTONBOX_DEFAULT_STYLE &&
layout <= GTK_BUTTONBOX_END);
/* get default value for spacing */
-gint gtk_hbutton_box_get_spacing_default (void)
+gint
+gtk_hbutton_box_get_spacing_default (void)
{
return default_spacing;
}
/* get default value for layout style */
-GtkButtonBoxStyle gtk_hbutton_box_get_layout_default (void)
+GtkButtonBoxStyle
+gtk_hbutton_box_get_layout_default (void)
{
return default_layout_style;
}
gint spacing;
GtkButtonBoxStyle layout;
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_HBUTTON_BOX (widget));
- g_return_if_fail (requisition != NULL);
-
box = GTK_BOX (widget);
bbox = GTK_BUTTON_BOX (widget);
_gtk_button_box_child_requisition (widget,
&nvis_children,
+ NULL,
&child_width,
&child_height);
GList *children;
GtkAllocation child_allocation;
gint nvis_children;
+ gint n_secondaries;
gint child_width;
gint child_height;
gint x = 0;
+ gint secondary_x = 0;
gint y = 0;
gint width;
gint childspace;
GtkButtonBoxStyle layout;
gint spacing;
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_HBUTTON_BOX (widget));
- g_return_if_fail (allocation != NULL);
-
base_box = GTK_BOX (widget);
box = GTK_BUTTON_BOX (widget);
hbox = GTK_HBUTTON_BOX (widget);
? box->layout_style : default_layout_style;
_gtk_button_box_child_requisition (widget,
&nvis_children,
+ &n_secondaries,
&child_width,
&child_height);
widget->allocation = *allocation;
switch (layout)
{
case GTK_BUTTONBOX_SPREAD:
- childspacing = (width - (nvis_children*child_width)) / (nvis_children+1);
+ childspacing = (width - (nvis_children * child_width)) / (nvis_children + 1);
x = allocation->x + GTK_CONTAINER (box)->border_width + childspacing;
+ secondary_x = x + ((nvis_children - n_secondaries) * (child_width + childspacing));
break;
case GTK_BUTTONBOX_EDGE:
if (nvis_children >= 2)
- {
- childspacing =
- (width - (nvis_children*child_width)) / (nvis_children-1);
- x = allocation->x + GTK_CONTAINER (box)->border_width;
- }
+ {
+ childspacing = (width - (nvis_children * child_width)) / (nvis_children - 1);
+ x = allocation->x + GTK_CONTAINER (box)->border_width;
+ secondary_x = x + ((nvis_children - n_secondaries) * (child_width + childspacing));
+ }
else
{
- /* one or zero children, just center */
+ /* one or zero children, just center */
childspacing = width;
- x = allocation->x + (allocation->width - child_width) / 2;
+ x = secondary_x = allocation->x + (allocation->width - child_width) / 2;
}
break;
case GTK_BUTTONBOX_START:
childspacing = spacing;
x = allocation->x + GTK_CONTAINER (box)->border_width;
+ secondary_x = allocation->x + allocation->width
+ - child_width * n_secondaries
+ - spacing * (n_secondaries - 1)
+ - GTK_CONTAINER (box)->border_width;
break;
case GTK_BUTTONBOX_END:
childspacing = spacing;
- x = allocation->x + allocation->width - child_width * nvis_children
- - spacing *(nvis_children-1)
- - GTK_CONTAINER (box)->border_width;
+ x = allocation->x + allocation->width
+ - child_width * (nvis_children - n_secondaries)
+ - spacing * (nvis_children - n_secondaries - 1)
+ - GTK_CONTAINER (box)->border_width;
+ secondary_x = allocation->x + GTK_CONTAINER (box)->border_width;
break;
default:
g_assert_not_reached();
break;
}
+
-
y = allocation->y + (allocation->height - child_height) / 2;
childspace = child_width + childspacing;
{
child_allocation.width = child_width;
child_allocation.height = child_height;
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
- child_allocation.x = x;
- else
- child_allocation.x = allocation->x + allocation->width - (x - allocation->x + child_width);
-
child_allocation.y = y;
+
+ if (child->is_secondary)
+ {
+ child_allocation.x = secondary_x;
+ secondary_x += childspace;
+ }
+ else
+ {
+ child_allocation.x = x;
+ x += childspace;
+ }
+ 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);
- x += childspace;
}
}
}