mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
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:
parent
d69aa7e9c1
commit
0b6c3f5497
17
ChangeLog
17
ChangeLog
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
142
gtk/gtkbbox.c
142
gtk/gtkbbox.c
@ -33,6 +33,11 @@ enum {
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
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,
|
||||
@ -43,6 +48,16 @@ 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,13 +94,18 @@ 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,12 +307,63 @@ 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.
|
||||
@ -242,6 +371,7 @@ GtkButtonBoxStyle gtk_button_box_get_layout (GtkButtonBox *widget)
|
||||
void
|
||||
_gtk_button_box_child_requisition (GtkWidget *widget,
|
||||
int *nvis_children,
|
||||
int *nvis_secondaries,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
@ -249,6 +379,7 @@ _gtk_button_box_child_requisition (GtkWidget *widget,
|
||||
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;
|
||||
if (child_requisition.height + ipad_h > needed_height)
|
||||
needed_height = child_requisition.height + ipad_h;
|
||||
if (child->is_secondary)
|
||||
nsecondaries++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nvis_children)
|
||||
*nvis_children = nchildren;
|
||||
if (nvis_secondaries)
|
||||
*nvis_secondaries = nsecondaries;
|
||||
if (width)
|
||||
*width = needed_width;
|
||||
if (height)
|
||||
*height = needed_height;
|
||||
}
|
||||
|
@ -69,25 +69,34 @@ 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);
|
||||
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);
|
||||
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);
|
||||
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 *nvis_secondaries,
|
||||
int *width,
|
||||
int *height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
@ -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);
|
||||
|
||||
|
@ -70,6 +70,7 @@ struct _GtkBoxChild
|
||||
guint expand : 1;
|
||||
guint fill : 1;
|
||||
guint pack : 1;
|
||||
guint is_secondary : 1;
|
||||
};
|
||||
|
||||
|
||||
|
@ -515,6 +515,9 @@ gtk_dialog_add_action_widget (GtkDialog *dialog,
|
||||
gtk_box_pack_end (GTK_BOX (dialog->action_area),
|
||||
child,
|
||||
FALSE, TRUE, 0);
|
||||
|
||||
if (response_id == GTK_RESPONSE_HELP)
|
||||
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (dialog->action_area), child, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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,32 +229,39 @@ 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);
|
||||
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 */
|
||||
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)
|
||||
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();
|
||||
@ -272,17 +283,24 @@ 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;
|
||||
|
||||
gtk_widget_size_allocate (child->widget, &child_allocation);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
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)
|
||||
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,10 +287,20 @@ gtk_vbutton_box_size_allocate (GtkWidget *widget,
|
||||
child_allocation.width = child_width;
|
||||
child_allocation.height = child_height;
|
||||
child_allocation.x = x;
|
||||
|
||||
if (child->is_secondary)
|
||||
{
|
||||
child_allocation.y = secondary_y;
|
||||
secondary_y += childspace;
|
||||
}
|
||||
else
|
||||
{
|
||||
child_allocation.y = y;
|
||||
gtk_widget_size_allocate (child->widget, &child_allocation);
|
||||
y += childspace;
|
||||
}
|
||||
|
||||
gtk_widget_size_allocate (child->widget, &child_allocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user