diff options
author | Owen Taylor <otaylor@redhat.com> | 2001-07-06 02:10:32 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2001-07-06 02:10:32 +0000 |
commit | 0b6c3f54974234f04835911c8846f304401bd4e4 (patch) | |
tree | 31134c5b98e9719c4ab4a6c052bb894bc5a10390 | |
parent | d69aa7e9c1a07fc5188555038c2bffc4ee3ea24d (diff) | |
download | gtk+-0b6c3f54974234f04835911c8846f304401bd4e4.tar.gz |
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.
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 17 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 17 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 17 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 17 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 17 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 17 | ||||
-rw-r--r-- | docs/reference/gtk/tmpl/gtkbox.sgml | 1 | ||||
-rw-r--r-- | gtk/gtkbbox.c | 180 | ||||
-rw-r--r-- | gtk/gtkbbox.h | 35 | ||||
-rw-r--r-- | gtk/gtkbox.c | 2 | ||||
-rw-r--r-- | gtk/gtkbox.h | 1 | ||||
-rw-r--r-- | gtk/gtkdialog.c | 5 | ||||
-rw-r--r-- | gtk/gtkhbbox.c | 56 | ||||
-rw-r--r-- | gtk/gtkvbbox.c | 43 | ||||
-rw-r--r-- | tests/testgtk.c | 1 |
16 files changed, 379 insertions, 64 deletions
@@ -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> * gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 7598feba52..6a3383edc4 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -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> * gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 7598feba52..6a3383edc4 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -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> * gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 7598feba52..6a3383edc4 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -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> * gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 7598feba52..6a3383edc4 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -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> * gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 7598feba52..6a3383edc4 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -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> * gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 7598feba52..6a3383edc4 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -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> * gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c diff --git a/docs/reference/gtk/tmpl/gtkbox.sgml b/docs/reference/gtk/tmpl/gtkbox.sgml index a4a12188b7..eef0351f9a 100644 --- a/docs/reference/gtk/tmpl/gtkbox.sgml +++ b/docs/reference/gtk/tmpl/gtkbox.sgml @@ -190,6 +190,7 @@ the start (top/left) or end (bottom/right) of the GtkBox.</entry> @expand: @fill: @pack: +@is_secondary: <!-- ##### FUNCTION gtk_box_pack_start ##### --> <para>
diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c index 81b02d401e..d4c11c2c61 100644 --- a/gtk/gtkbbox.c +++ b/gtk/gtkbbox.c @@ -33,16 +33,31 @@ enum { PROP_LAST }; -static void gtk_button_box_class_init (GtkButtonBoxClass *klass); -static void gtk_button_box_init (GtkButtonBox *box); -static void gtk_button_box_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gtk_button_box_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); +enum { + CHILD_PROP_0, + CHILD_PROP_SECONDARY +}; + +static void gtk_button_box_class_init (GtkButtonBoxClass *klass); +static void gtk_button_box_init (GtkButtonBox *box); +static void gtk_button_box_set_property (GObject *object, + guint prop_id, + 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_HEIGHT 27 @@ -79,12 +94,17 @@ gtk_button_box_class_init (GtkButtonBoxClass *class) { GtkWidgetClass *widget_class; GObjectClass *gobject_class; + GtkContainerClass *container_class; gobject_class = G_OBJECT_CLASS (class); widget_class = (GtkWidgetClass*) class; + container_class = (GtkContainerClass*) class; gobject_class->set_property = gtk_button_box_set_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 * libgobject allows that. @@ -133,6 +153,14 @@ gtk_button_box_class_init (GtkButtonBoxClass *class) GTK_TYPE_BUTTON_BOX_STYLE, GTK_BUTTONBOX_DEFAULT_STYLE, 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 @@ -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 */ @@ -229,26 +307,79 @@ void gtk_button_box_get_child_ipadding (GtkButtonBox *widget, *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; } +/** + * 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 to match minimum size and internal padding. Returns the size each single child should have. */ void _gtk_button_box_child_requisition (GtkWidget *widget, - int *nvis_children, - int *width, - int *height) + int *nvis_children, + int *nvis_secondaries, + int *width, + int *height) { GtkButtonBox *bbox; GtkBoxChild *child; GList *children; gint nchildren; + gint nsecondaries; gint needed_width; gint needed_height; GtkRequisition child_requisition; @@ -289,6 +420,7 @@ _gtk_button_box_child_requisition (GtkWidget *widget, ? bbox->child_ipad_y : ipad_y_default; nchildren = 0; + nsecondaries = 0; children = GTK_BOX(bbox)->children; needed_width = child_min_width; needed_height = child_min_height; @@ -304,14 +436,22 @@ _gtk_button_box_child_requisition (GtkWidget *widget, { nchildren += 1; gtk_widget_size_request (child->widget, &child_requisition); + 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) - needed_height = child_requisition.height + ipad_h; + needed_height = child_requisition.height + ipad_h; + if (child->is_secondary) + nsecondaries++; } } - - *nvis_children = nchildren; - *width = needed_width; - *height = needed_height; + + if (nvis_children) + *nvis_children = nchildren; + if (nvis_secondaries) + *nvis_secondaries = nsecondaries; + if (width) + *width = needed_width; + if (height) + *height = needed_height; } diff --git a/gtk/gtkbbox.h b/gtk/gtkbbox.h index 5ac286e799..8a7853f783 100644 --- a/gtk/gtkbbox.h +++ b/gtk/gtkbbox.h @@ -66,28 +66,37 @@ struct _GtkButtonBoxClass GtkType gtk_button_box_get_type (void) G_GNUC_CONST; -GtkButtonBoxStyle gtk_button_box_get_layout (GtkButtonBox *widget); -void gtk_button_box_set_layout (GtkButtonBox *widget, - GtkButtonBoxStyle layout_style); +GtkButtonBoxStyle gtk_button_box_get_layout (GtkButtonBox *widget); +void gtk_button_box_set_layout (GtkButtonBox *widget, + GtkButtonBoxStyle layout_style); +void gtk_button_box_set_child_secondary (GtkButtonBox *widget, + GtkWidget *child, + gboolean is_secondary); #ifndef GTK_DISABLE_DEPRECATED #define gtk_button_box_set_spacing gtk_box_set_spacing #define gtk_button_box_get_spacing gtk_box_get_spacing -void gtk_button_box_set_child_size (GtkButtonBox *widget, - gint min_width, gint min_height); -void gtk_button_box_set_child_ipadding (GtkButtonBox *widget, gint ipad_x, 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); +void gtk_button_box_set_child_size (GtkButtonBox *widget, + gint min_width, + gint min_height); +void gtk_button_box_set_child_ipadding (GtkButtonBox *widget, + gint ipad_x, + 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 /* Internal method - do not use. */ void _gtk_button_box_child_requisition (GtkWidget *widget, - int *nvis_children, - int *width, - int *height); - + int *nvis_children, + int *nvis_secondaries, + int *width, + int *height); #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c index 36ea538db8..979bf02ee9 100644 --- a/gtk/gtkbox.c +++ b/gtk/gtkbox.c @@ -371,6 +371,7 @@ gtk_box_pack_start (GtkBox *box, child_info->expand = expand ? TRUE : FALSE; child_info->fill = fill ? TRUE : FALSE; child_info->pack = GTK_PACK_START; + child_info->is_secondary = FALSE; 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->fill = fill ? TRUE : FALSE; child_info->pack = GTK_PACK_END; + child_info->is_secondary = FALSE; box->children = g_list_append (box->children, child_info); diff --git a/gtk/gtkbox.h b/gtk/gtkbox.h index 6b4055e6bc..9d5ca4b38c 100644 --- a/gtk/gtkbox.h +++ b/gtk/gtkbox.h @@ -70,6 +70,7 @@ struct _GtkBoxChild guint expand : 1; guint fill : 1; guint pack : 1; + guint is_secondary : 1; }; diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c index 18b28df3bf..4dba60f1b5 100644 --- a/gtk/gtkdialog.c +++ b/gtk/gtkdialog.c @@ -514,7 +514,10 @@ gtk_dialog_add_action_widget (GtkDialog *dialog, gtk_box_pack_end (GTK_BOX (dialog->action_area), 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); } /** diff --git a/gtk/gtkhbbox.c b/gtk/gtkhbbox.c index af95fe73ef..5c6c18555a 100644 --- a/gtk/gtkhbbox.c +++ b/gtk/gtkhbbox.c @@ -150,6 +150,7 @@ gtk_hbutton_box_size_request (GtkWidget *widget, _gtk_button_box_child_requisition (widget, &nvis_children, + NULL, &child_width, &child_height); @@ -196,9 +197,11 @@ gtk_hbutton_box_size_allocate (GtkWidget *widget, 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; @@ -218,6 +221,7 @@ gtk_hbutton_box_size_allocate (GtkWidget *widget, ? box->layout_style : default_layout_style; _gtk_button_box_child_requisition (widget, &nvis_children, + &n_secondaries, &child_width, &child_height); widget->allocation = *allocation; @@ -225,39 +229,46 @@ gtk_hbutton_box_size_allocate (GtkWidget *widget, 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; @@ -272,16 +283,23 @@ gtk_hbutton_box_size_allocate (GtkWidget *widget, { 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; } } } diff --git a/gtk/gtkvbbox.c b/gtk/gtkvbbox.c index d427d2917a..f7abb6aa5a 100644 --- a/gtk/gtkvbbox.c +++ b/gtk/gtkvbbox.c @@ -152,6 +152,7 @@ gtk_vbutton_box_size_request (GtkWidget *widget, _gtk_button_box_child_requisition (widget, &nvis_children, + NULL, &child_width, &child_height); @@ -199,10 +200,12 @@ gtk_vbutton_box_size_allocate (GtkWidget *widget, GList *children; GtkAllocation child_allocation; gint nvis_children; + gint n_secondaries; gint child_width; gint child_height; gint x = 0; gint y = 0; + gint secondary_y = 0; gint height; gint childspace; gint childspacing = 0; @@ -221,6 +224,7 @@ gtk_vbutton_box_size_allocate (GtkWidget *widget, ? box->layout_style : default_layout_style; _gtk_button_box_child_requisition (widget, &nvis_children, + &n_secondaries, &child_width, &child_height); widget->allocation = *allocation; @@ -228,32 +232,39 @@ gtk_vbutton_box_size_allocate (GtkWidget *widget, switch (layout) { 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; + secondary_y = y + ((nvis_children - n_secondaries) * (child_height + childspacing)); break; case GTK_BUTTONBOX_EDGE: if (nvis_children >= 2) { - 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; + secondary_y = y + ((nvis_children - n_secondaries) * (child_height + childspacing)); } else { - /* one or zero children, just center */ - childspacing = height; - y = allocation->y + (allocation->height - child_height) / 2; + /* one or zero children, just center */ + childspacing = height; + y = secondary_y = allocation->y + (allocation->height - child_height) / 2; } break; case GTK_BUTTONBOX_START: childspacing = spacing; 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; case GTK_BUTTONBOX_END: childspacing = spacing; - y = allocation->y + allocation->height - child_height * nvis_children - - spacing * (nvis_children-1) - - GTK_CONTAINER (box)->border_width; + y = allocation->y + allocation->height + - child_height * (nvis_children - n_secondaries) + - spacing * (nvis_children - n_secondaries - 1) + - GTK_CONTAINER (box)->border_width; + secondary_y = allocation->y + GTK_CONTAINER (box)->border_width; break; default: g_assert_not_reached(); @@ -276,9 +287,19 @@ gtk_vbutton_box_size_allocate (GtkWidget *widget, child_allocation.width = child_width; child_allocation.height = child_height; 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); - y += childspace; } } } diff --git a/tests/testgtk.c b/tests/testgtk.c index b9a1fa9a20..c9269263c8 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -6143,6 +6143,7 @@ create_color_selection (void) GtkWidget *check_button; 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); |