Patch from Gregory Merchan to add gtk_button_box_set_secondary(), which

Thu Jul  5 21:53:46 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkbbox.[ch] gtk/gtkbox.[ch] gtk/gtk[hv]bbox.c:
	Patch from Gregory Merchan to add
	gtk_button_box_set_secondary(), which separates
	the child into a separate group from the normal
	buttons. (#56331)

	* gtk/gtkdialog.c: Make help buttons secondary by
	default.

	* gtk/gtkbbox.c: Added a child property "secondary".

	* gtk/testgtk.c: Turn on the help button for the
	color selector to check that it properly appears
	as secondary.
This commit is contained in:
Owen Taylor 2001-07-06 02:10:32 +00:00 committed by Owen Taylor
parent d69aa7e9c1
commit 0b6c3f5497
16 changed files with 379 additions and 64 deletions

View File

@ -1,3 +1,20 @@
Thu Jul 5 21:53:46 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkbbox.[ch] gtk/gtkbox.[ch] gtk/gtk[hv]bbox.c:
Patch from Gregory Merchan to add
gtk_button_box_set_secondary(), which separates
the child into a separate group from the normal
buttons. (#56331)
* gtk/gtkdialog.c: Make help buttons secondary by
default.
* gtk/gtkbbox.c: Added a child property "secondary".
* gtk/testgtk.c: Turn on the help button for the
color selector to check that it properly appears
as secondary.
Mon Jul 2 01:09:37 2001 Owen Taylor <otaylor@redhat.com> Mon Jul 2 01:09:37 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c * gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c

View File

@ -1,3 +1,20 @@
Thu Jul 5 21:53:46 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkbbox.[ch] gtk/gtkbox.[ch] gtk/gtk[hv]bbox.c:
Patch from Gregory Merchan to add
gtk_button_box_set_secondary(), which separates
the child into a separate group from the normal
buttons. (#56331)
* gtk/gtkdialog.c: Make help buttons secondary by
default.
* gtk/gtkbbox.c: Added a child property "secondary".
* gtk/testgtk.c: Turn on the help button for the
color selector to check that it properly appears
as secondary.
Mon Jul 2 01:09:37 2001 Owen Taylor <otaylor@redhat.com> Mon Jul 2 01:09:37 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c * gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c

View File

@ -1,3 +1,20 @@
Thu Jul 5 21:53:46 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkbbox.[ch] gtk/gtkbox.[ch] gtk/gtk[hv]bbox.c:
Patch from Gregory Merchan to add
gtk_button_box_set_secondary(), which separates
the child into a separate group from the normal
buttons. (#56331)
* gtk/gtkdialog.c: Make help buttons secondary by
default.
* gtk/gtkbbox.c: Added a child property "secondary".
* gtk/testgtk.c: Turn on the help button for the
color selector to check that it properly appears
as secondary.
Mon Jul 2 01:09:37 2001 Owen Taylor <otaylor@redhat.com> Mon Jul 2 01:09:37 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c * gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c

View File

@ -1,3 +1,20 @@
Thu Jul 5 21:53:46 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkbbox.[ch] gtk/gtkbox.[ch] gtk/gtk[hv]bbox.c:
Patch from Gregory Merchan to add
gtk_button_box_set_secondary(), which separates
the child into a separate group from the normal
buttons. (#56331)
* gtk/gtkdialog.c: Make help buttons secondary by
default.
* gtk/gtkbbox.c: Added a child property "secondary".
* gtk/testgtk.c: Turn on the help button for the
color selector to check that it properly appears
as secondary.
Mon Jul 2 01:09:37 2001 Owen Taylor <otaylor@redhat.com> Mon Jul 2 01:09:37 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c * gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c

View File

@ -1,3 +1,20 @@
Thu Jul 5 21:53:46 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkbbox.[ch] gtk/gtkbox.[ch] gtk/gtk[hv]bbox.c:
Patch from Gregory Merchan to add
gtk_button_box_set_secondary(), which separates
the child into a separate group from the normal
buttons. (#56331)
* gtk/gtkdialog.c: Make help buttons secondary by
default.
* gtk/gtkbbox.c: Added a child property "secondary".
* gtk/testgtk.c: Turn on the help button for the
color selector to check that it properly appears
as secondary.
Mon Jul 2 01:09:37 2001 Owen Taylor <otaylor@redhat.com> Mon Jul 2 01:09:37 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c * gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c

View File

@ -1,3 +1,20 @@
Thu Jul 5 21:53:46 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkbbox.[ch] gtk/gtkbox.[ch] gtk/gtk[hv]bbox.c:
Patch from Gregory Merchan to add
gtk_button_box_set_secondary(), which separates
the child into a separate group from the normal
buttons. (#56331)
* gtk/gtkdialog.c: Make help buttons secondary by
default.
* gtk/gtkbbox.c: Added a child property "secondary".
* gtk/testgtk.c: Turn on the help button for the
color selector to check that it properly appears
as secondary.
Mon Jul 2 01:09:37 2001 Owen Taylor <otaylor@redhat.com> Mon Jul 2 01:09:37 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c * gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c

View File

@ -1,3 +1,20 @@
Thu Jul 5 21:53:46 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkbbox.[ch] gtk/gtkbox.[ch] gtk/gtk[hv]bbox.c:
Patch from Gregory Merchan to add
gtk_button_box_set_secondary(), which separates
the child into a separate group from the normal
buttons. (#56331)
* gtk/gtkdialog.c: Make help buttons secondary by
default.
* gtk/gtkbbox.c: Added a child property "secondary".
* gtk/testgtk.c: Turn on the help button for the
color selector to check that it properly appears
as secondary.
Mon Jul 2 01:09:37 2001 Owen Taylor <otaylor@redhat.com> Mon Jul 2 01:09:37 2001 Owen Taylor <otaylor@redhat.com>
* gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c * gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c

View File

@ -190,6 +190,7 @@ the start (top/left) or end (bottom/right) of the GtkBox.</entry>
@expand: @expand:
@fill: @fill:
@pack: @pack:
@is_secondary:
<!-- ##### FUNCTION gtk_box_pack_start ##### --> <!-- ##### FUNCTION gtk_box_pack_start ##### -->
<para> <para>

View File

@ -33,16 +33,31 @@ enum {
PROP_LAST PROP_LAST
}; };
static void gtk_button_box_class_init (GtkButtonBoxClass *klass); enum {
static void gtk_button_box_init (GtkButtonBox *box); CHILD_PROP_0,
static void gtk_button_box_set_property (GObject *object, CHILD_PROP_SECONDARY
guint prop_id, };
const GValue *value,
GParamSpec *pspec); static void gtk_button_box_class_init (GtkButtonBoxClass *klass);
static void gtk_button_box_get_property (GObject *object, static void gtk_button_box_init (GtkButtonBox *box);
guint prop_id, static void gtk_button_box_set_property (GObject *object,
GValue *value, guint prop_id,
GParamSpec *pspec); const GValue *value,
GParamSpec *pspec);
static void gtk_button_box_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_button_box_set_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_button_box_get_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec);
#define DEFAULT_CHILD_MIN_WIDTH 85 #define DEFAULT_CHILD_MIN_WIDTH 85
#define DEFAULT_CHILD_MIN_HEIGHT 27 #define DEFAULT_CHILD_MIN_HEIGHT 27
@ -79,12 +94,17 @@ gtk_button_box_class_init (GtkButtonBoxClass *class)
{ {
GtkWidgetClass *widget_class; GtkWidgetClass *widget_class;
GObjectClass *gobject_class; GObjectClass *gobject_class;
GtkContainerClass *container_class;
gobject_class = G_OBJECT_CLASS (class); gobject_class = G_OBJECT_CLASS (class);
widget_class = (GtkWidgetClass*) class; widget_class = (GtkWidgetClass*) class;
container_class = (GtkContainerClass*) class;
gobject_class->set_property = gtk_button_box_set_property; gobject_class->set_property = gtk_button_box_set_property;
gobject_class->get_property = gtk_button_box_get_property; gobject_class->get_property = gtk_button_box_get_property;
container_class->set_child_property = gtk_button_box_set_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.
@ -133,6 +153,14 @@ gtk_button_box_class_init (GtkButtonBoxClass *class)
GTK_TYPE_BUTTON_BOX_STYLE, GTK_TYPE_BUTTON_BOX_STYLE,
GTK_BUTTONBOX_DEFAULT_STYLE, GTK_BUTTONBOX_DEFAULT_STYLE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_SECONDARY,
g_param_spec_boolean ("secondary",
_("Secondary"),
_("If TRUE, the child appears in a secondary group of children, suitable for, e.g., help buttons."),
FALSE,
G_PARAM_READWRITE));
} }
static void static void
@ -181,7 +209,57 @@ gtk_button_box_get_property (GObject *object,
} }
} }
static void
gtk_button_box_set_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
case CHILD_PROP_SECONDARY:
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (container), child,
g_value_get_boolean (value));
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
}
}
static void
gtk_button_box_get_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GList *list;
GtkBoxChild *child_info = NULL;
list = GTK_BOX (container)->children;
while (list)
{
child_info = list->data;
if (child_info->widget == child)
break;
list = list->next;
}
g_assert (list != NULL);
switch (property_id)
{
case CHILD_PROP_SECONDARY:
g_value_set_boolean (value, child_info->is_secondary);
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
}
}
/* set per widget values for spacing, child size and child internal padding */ /* set per widget values for spacing, child size and child internal padding */
@ -229,26 +307,79 @@ void gtk_button_box_get_child_ipadding (GtkButtonBox *widget,
*ipad_y = widget->child_ipad_y; *ipad_y = widget->child_ipad_y;
} }
GtkButtonBoxStyle gtk_button_box_get_layout (GtkButtonBox *widget) GtkButtonBoxStyle
gtk_button_box_get_layout (GtkButtonBox *widget)
{ {
g_return_val_if_fail (GTK_IS_BUTTON_BOX (widget), GTK_BUTTONBOX_SPREAD);
return widget->layout_style; return widget->layout_style;
} }
/**
* gtk_button_box_set_child_secondary
* @widget: a #GtkButtonBox
* @child: a child of @widget
* @is_secondary: if %TRUE, the @child appears in a secondary group of the
* button box.
*
* Sets whether @child should appear in a secondary group of children.
* A typical use of a secondary child is the help button in a dialog.
*
* This group appears after the other children if the style
* is %GTK_BUTTONBOX_START, %GTK_BUTTONBOX_SPREAD or
* %GTK_BUTTONBOX_EDGE, and before the the other children if the style
* is %GTK_BUTTONBOX_END. For horizontal button boxes, the definition
* of before/after depends on direction of the widget. (See
* gtk_widget_set_direction()) If the style is %GTK_BUTTONBOX_START,
* or %GTK_BUTTONBOX_START, then the secondary children are aligned at
* the other end of the button box from the main children. For the
* other styles, they appear immediately next to the main children.
**/
void
gtk_button_box_set_child_secondary (GtkButtonBox *widget,
GtkWidget *child,
gboolean is_secondary)
{
GList *list;
g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (child->parent == GTK_WIDGET (widget));
list = GTK_BOX (widget)->children;
while (list)
{
GtkBoxChild *child_info = list->data;
if (child_info->widget == child)
{
child_info->is_secondary = is_secondary;
break;
}
list = list->next;
}
gtk_widget_child_notify (child, "secondary");
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (child))
gtk_widget_queue_resize (child);
}
/* Ask children how much space they require and round up /* Ask children how much space they require and round up
to match minimum size and internal padding. to match minimum size and internal padding.
Returns the size each single child should have. */ Returns the size each single child should have. */
void void
_gtk_button_box_child_requisition (GtkWidget *widget, _gtk_button_box_child_requisition (GtkWidget *widget,
int *nvis_children, int *nvis_children,
int *width, int *nvis_secondaries,
int *height) int *width,
int *height)
{ {
GtkButtonBox *bbox; GtkButtonBox *bbox;
GtkBoxChild *child; GtkBoxChild *child;
GList *children; GList *children;
gint nchildren; gint nchildren;
gint nsecondaries;
gint needed_width; gint needed_width;
gint needed_height; gint needed_height;
GtkRequisition child_requisition; GtkRequisition child_requisition;
@ -289,6 +420,7 @@ _gtk_button_box_child_requisition (GtkWidget *widget,
? bbox->child_ipad_y : ipad_y_default; ? bbox->child_ipad_y : ipad_y_default;
nchildren = 0; nchildren = 0;
nsecondaries = 0;
children = GTK_BOX(bbox)->children; children = GTK_BOX(bbox)->children;
needed_width = child_min_width; needed_width = child_min_width;
needed_height = child_min_height; needed_height = child_min_height;
@ -304,14 +436,22 @@ _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)
needed_height = child_requisition.height + ipad_h; needed_height = child_requisition.height + ipad_h;
if (child->is_secondary)
nsecondaries++;
} }
} }
*nvis_children = nchildren; if (nvis_children)
*width = needed_width; *nvis_children = nchildren;
*height = needed_height; if (nvis_secondaries)
*nvis_secondaries = nsecondaries;
if (width)
*width = needed_width;
if (height)
*height = needed_height;
} }

View File

@ -66,28 +66,37 @@ struct _GtkButtonBoxClass
GtkType gtk_button_box_get_type (void) G_GNUC_CONST; GtkType gtk_button_box_get_type (void) G_GNUC_CONST;
GtkButtonBoxStyle gtk_button_box_get_layout (GtkButtonBox *widget); GtkButtonBoxStyle gtk_button_box_get_layout (GtkButtonBox *widget);
void gtk_button_box_set_layout (GtkButtonBox *widget, void gtk_button_box_set_layout (GtkButtonBox *widget,
GtkButtonBoxStyle layout_style); GtkButtonBoxStyle layout_style);
void gtk_button_box_set_child_secondary (GtkButtonBox *widget,
GtkWidget *child,
gboolean is_secondary);
#ifndef GTK_DISABLE_DEPRECATED #ifndef GTK_DISABLE_DEPRECATED
#define gtk_button_box_set_spacing gtk_box_set_spacing #define gtk_button_box_set_spacing gtk_box_set_spacing
#define gtk_button_box_get_spacing gtk_box_get_spacing #define gtk_button_box_get_spacing gtk_box_get_spacing
void gtk_button_box_set_child_size (GtkButtonBox *widget, void gtk_button_box_set_child_size (GtkButtonBox *widget,
gint min_width, gint min_height); gint min_width,
void gtk_button_box_set_child_ipadding (GtkButtonBox *widget, gint ipad_x, gint ipad_y); gint min_height);
void gtk_button_box_get_child_size (GtkButtonBox *widget, void gtk_button_box_set_child_ipadding (GtkButtonBox *widget,
gint *min_width, gint *min_height); gint ipad_x,
void gtk_button_box_get_child_ipadding (GtkButtonBox *widget, gint *ipad_x, gint *ipad_y); gint ipad_y);
void gtk_button_box_get_child_size (GtkButtonBox *widget,
gint *min_width,
gint *min_height);
void gtk_button_box_get_child_ipadding (GtkButtonBox *widget,
gint *ipad_x,
gint *ipad_y);
#endif #endif
/* Internal method - do not use. */ /* Internal method - do not use. */
void _gtk_button_box_child_requisition (GtkWidget *widget, void _gtk_button_box_child_requisition (GtkWidget *widget,
int *nvis_children, int *nvis_children,
int *width, int *nvis_secondaries,
int *height); int *width,
int *height);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -371,6 +371,7 @@ gtk_box_pack_start (GtkBox *box,
child_info->expand = expand ? TRUE : FALSE; child_info->expand = expand ? TRUE : FALSE;
child_info->fill = fill ? TRUE : FALSE; child_info->fill = fill ? TRUE : FALSE;
child_info->pack = GTK_PACK_START; child_info->pack = GTK_PACK_START;
child_info->is_secondary = FALSE;
box->children = g_list_append (box->children, child_info); box->children = g_list_append (box->children, child_info);
@ -416,6 +417,7 @@ gtk_box_pack_end (GtkBox *box,
child_info->expand = expand ? TRUE : FALSE; child_info->expand = expand ? TRUE : FALSE;
child_info->fill = fill ? TRUE : FALSE; child_info->fill = fill ? TRUE : FALSE;
child_info->pack = GTK_PACK_END; child_info->pack = GTK_PACK_END;
child_info->is_secondary = FALSE;
box->children = g_list_append (box->children, child_info); box->children = g_list_append (box->children, child_info);

View File

@ -70,6 +70,7 @@ struct _GtkBoxChild
guint expand : 1; guint expand : 1;
guint fill : 1; guint fill : 1;
guint pack : 1; guint pack : 1;
guint is_secondary : 1;
}; };

View File

@ -514,7 +514,10 @@ gtk_dialog_add_action_widget (GtkDialog *dialog,
gtk_box_pack_end (GTK_BOX (dialog->action_area), gtk_box_pack_end (GTK_BOX (dialog->action_area),
child, child,
FALSE, TRUE, 0); FALSE, TRUE, 0);
if (response_id == GTK_RESPONSE_HELP)
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (dialog->action_area), child, TRUE);
} }
/** /**

View File

@ -150,6 +150,7 @@ gtk_hbutton_box_size_request (GtkWidget *widget,
_gtk_button_box_child_requisition (widget, _gtk_button_box_child_requisition (widget,
&nvis_children, &nvis_children,
NULL,
&child_width, &child_width,
&child_height); &child_height);
@ -196,9 +197,11 @@ gtk_hbutton_box_size_allocate (GtkWidget *widget,
GList *children; GList *children;
GtkAllocation child_allocation; GtkAllocation child_allocation;
gint nvis_children; gint nvis_children;
gint n_secondaries;
gint child_width; gint child_width;
gint child_height; gint child_height;
gint x = 0; gint x = 0;
gint secondary_x = 0;
gint y = 0; gint y = 0;
gint width; gint width;
gint childspace; gint childspace;
@ -218,6 +221,7 @@ gtk_hbutton_box_size_allocate (GtkWidget *widget,
? box->layout_style : default_layout_style; ? box->layout_style : default_layout_style;
_gtk_button_box_child_requisition (widget, _gtk_button_box_child_requisition (widget,
&nvis_children, &nvis_children,
&n_secondaries,
&child_width, &child_width,
&child_height); &child_height);
widget->allocation = *allocation; widget->allocation = *allocation;
@ -225,39 +229,46 @@ gtk_hbutton_box_size_allocate (GtkWidget *widget,
switch (layout) switch (layout)
{ {
case GTK_BUTTONBOX_SPREAD: 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; x = allocation->x + GTK_CONTAINER (box)->border_width + childspacing;
secondary_x = x + ((nvis_children - n_secondaries) * (child_width + childspacing));
break; break;
case GTK_BUTTONBOX_EDGE: case GTK_BUTTONBOX_EDGE:
if (nvis_children >= 2) if (nvis_children >= 2)
{ {
childspacing = childspacing = (width - (nvis_children * child_width)) / (nvis_children - 1);
(width - (nvis_children*child_width)) / (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) * (child_width + childspacing));
} }
else else
{ {
/* one or zero children, just center */ /* one or zero children, just center */
childspacing = width; childspacing = width;
x = allocation->x + (allocation->width - child_width) / 2; x = secondary_x = allocation->x + (allocation->width - child_width) / 2;
} }
break; break;
case GTK_BUTTONBOX_START: case GTK_BUTTONBOX_START:
childspacing = spacing; childspacing = spacing;
x = allocation->x + GTK_CONTAINER (box)->border_width; 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; break;
case GTK_BUTTONBOX_END: case GTK_BUTTONBOX_END:
childspacing = spacing; childspacing = spacing;
x = allocation->x + allocation->width - child_width * nvis_children x = allocation->x + allocation->width
- spacing *(nvis_children-1) - child_width * (nvis_children - n_secondaries)
- GTK_CONTAINER (box)->border_width; - spacing * (nvis_children - n_secondaries - 1)
- GTK_CONTAINER (box)->border_width;
secondary_x = allocation->x + GTK_CONTAINER (box)->border_width;
break; break;
default: default:
g_assert_not_reached(); g_assert_not_reached();
break; break;
} }
y = allocation->y + (allocation->height - child_height) / 2; y = allocation->y + (allocation->height - child_height) / 2;
childspace = child_width + childspacing; childspace = child_width + childspacing;
@ -272,16 +283,23 @@ gtk_hbutton_box_size_allocate (GtkWidget *widget,
{ {
child_allocation.width = child_width; child_allocation.width = child_width;
child_allocation.height = child_height; 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; 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); gtk_widget_size_allocate (child->widget, &child_allocation);
x += childspace;
} }
} }
} }

View File

@ -152,6 +152,7 @@ gtk_vbutton_box_size_request (GtkWidget *widget,
_gtk_button_box_child_requisition (widget, _gtk_button_box_child_requisition (widget,
&nvis_children, &nvis_children,
NULL,
&child_width, &child_width,
&child_height); &child_height);
@ -199,10 +200,12 @@ gtk_vbutton_box_size_allocate (GtkWidget *widget,
GList *children; GList *children;
GtkAllocation child_allocation; GtkAllocation child_allocation;
gint nvis_children; gint nvis_children;
gint n_secondaries;
gint child_width; gint child_width;
gint child_height; gint child_height;
gint x = 0; gint x = 0;
gint y = 0; gint y = 0;
gint secondary_y = 0;
gint height; gint height;
gint childspace; gint childspace;
gint childspacing = 0; gint childspacing = 0;
@ -221,6 +224,7 @@ gtk_vbutton_box_size_allocate (GtkWidget *widget,
? box->layout_style : default_layout_style; ? box->layout_style : default_layout_style;
_gtk_button_box_child_requisition (widget, _gtk_button_box_child_requisition (widget,
&nvis_children, &nvis_children,
&n_secondaries,
&child_width, &child_width,
&child_height); &child_height);
widget->allocation = *allocation; widget->allocation = *allocation;
@ -228,32 +232,39 @@ gtk_vbutton_box_size_allocate (GtkWidget *widget,
switch (layout) switch (layout)
{ {
case GTK_BUTTONBOX_SPREAD: case GTK_BUTTONBOX_SPREAD:
childspacing = (height - (nvis_children*child_height)) / (nvis_children+1); childspacing = (height - (nvis_children * child_height)) / (nvis_children + 1);
y = allocation->y + GTK_CONTAINER (box)->border_width + childspacing; y = allocation->y + GTK_CONTAINER (box)->border_width + childspacing;
secondary_y = y + ((nvis_children - n_secondaries) * (child_height + childspacing));
break; break;
case GTK_BUTTONBOX_EDGE: case GTK_BUTTONBOX_EDGE:
if (nvis_children >= 2) if (nvis_children >= 2)
{ {
childspacing = childspacing = (height - (nvis_children*child_height)) / (nvis_children-1);
(height - (nvis_children*child_height)) / (nvis_children-1);
y = allocation->y + GTK_CONTAINER (box)->border_width; y = allocation->y + GTK_CONTAINER (box)->border_width;
secondary_y = y + ((nvis_children - n_secondaries) * (child_height + childspacing));
} }
else else
{ {
/* one or zero children, just center */ /* one or zero children, just center */
childspacing = height; childspacing = height;
y = allocation->y + (allocation->height - child_height) / 2; y = secondary_y = allocation->y + (allocation->height - child_height) / 2;
} }
break; break;
case GTK_BUTTONBOX_START: case GTK_BUTTONBOX_START:
childspacing = spacing; childspacing = spacing;
y = allocation->y + GTK_CONTAINER (box)->border_width; y = allocation->y + GTK_CONTAINER (box)->border_width;
secondary_y = allocation->y + allocation->height
- child_height * n_secondaries
- spacing * (n_secondaries - 1)
- GTK_CONTAINER (box)->border_width;
break; break;
case GTK_BUTTONBOX_END: case GTK_BUTTONBOX_END:
childspacing = spacing; childspacing = spacing;
y = allocation->y + allocation->height - child_height * nvis_children y = allocation->y + allocation->height
- spacing * (nvis_children-1) - child_height * (nvis_children - n_secondaries)
- GTK_CONTAINER (box)->border_width; - spacing * (nvis_children - n_secondaries - 1)
- 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();
@ -276,9 +287,19 @@ gtk_vbutton_box_size_allocate (GtkWidget *widget,
child_allocation.width = child_width; child_allocation.width = child_width;
child_allocation.height = child_height; child_allocation.height = child_height;
child_allocation.x = x; child_allocation.x = x;
child_allocation.y = y;
if (child->is_secondary)
{
child_allocation.y = secondary_y;
secondary_y += childspace;
}
else
{
child_allocation.y = y;
y += childspace;
}
gtk_widget_size_allocate (child->widget, &child_allocation); gtk_widget_size_allocate (child->widget, &child_allocation);
y += childspace;
} }
} }
} }

View File

@ -6143,6 +6143,7 @@ create_color_selection (void)
GtkWidget *check_button; GtkWidget *check_button;
window = gtk_color_selection_dialog_new ("color selection dialog"); window = gtk_color_selection_dialog_new ("color selection dialog");
gtk_widget_show (GTK_COLOR_SELECTION_DIALOG (window)->help_button);
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE); gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);