[gtk+/dialogs: 5/25] Add an expand button box type
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/dialogs: 5/25] Add an expand button box type
- Date: Wed, 15 Jan 2014 12:32:46 +0000 (UTC)
commit 58319094f9a282c56fa8fee6cbf5709960d0bf37
Author: William Jon McCann <william jon mccann gmail com>
Date: Sat Jan 11 20:27:42 2014 -0500
Add an expand button box type
https://bugzilla.gnome.org/show_bug.cgi?id=720059
gtk/gtkbbox.c | 22 ++++++++++++++++++++++
gtk/gtkenums.h | 4 +++-
tests/testbbox.c | 1 +
3 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c
index 22ca734..becdca2 100644
--- a/gtk/gtkbbox.c
+++ b/gtk/gtkbbox.c
@@ -349,6 +349,10 @@ gtk_button_box_set_layout (GtkButtonBox *widget,
if (priv->layout_style != layout_style)
{
priv->layout_style = layout_style;
+ if (priv->layout_style == GTK_BUTTONBOX_EXPAND)
+ gtk_box_set_homogeneous (GTK_BOX (widget), TRUE);
+ else
+ gtk_box_set_homogeneous (GTK_BOX (widget), FALSE);
g_object_notify (G_OBJECT (widget), "layout-style");
gtk_widget_queue_resize (GTK_WIDGET (widget));
}
@@ -416,15 +420,25 @@ gtk_button_box_set_child_secondary (GtkButtonBox *widget,
GtkWidget *child,
gboolean is_secondary)
{
+ GtkButtonBox *bbox;
+
g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (widget));
+ bbox = GTK_BUTTON_BOX (widget);
+
g_object_set_data (G_OBJECT (child),
GTK_BOX_SECONDARY_CHILD,
is_secondary ? GINT_TO_POINTER (1) : NULL);
gtk_widget_child_notify (child, "secondary");
+ if (bbox->priv->layout_style == GTK_BUTTONBOX_EXPAND)
+ {
+ gtk_box_set_child_packing (GTK_BOX (bbox), child, TRUE, TRUE, 0,
+ is_secondary ? GTK_PACK_START : GTK_PACK_END);
+ }
+
if (gtk_widget_get_visible (GTK_WIDGET (widget)) &&
gtk_widget_get_visible (child))
gtk_widget_queue_resize (child);
@@ -714,6 +728,7 @@ gtk_button_box_size_request (GtkWidget *widget,
case GTK_BUTTONBOX_START:
case GTK_BUTTONBOX_END:
case GTK_BUTTONBOX_CENTER:
+ case GTK_BUTTONBOX_EXPAND:
if (orientation == GTK_ORIENTATION_HORIZONTAL)
requisition->width = total_size + ((nvis_children - 1)*spacing);
else
@@ -827,6 +842,13 @@ gtk_button_box_size_allocate (GtkWidget *widget,
bbox = GTK_BUTTON_BOX (widget);
priv = bbox->priv;
+ if (priv->layout_style == GTK_BUTTONBOX_EXPAND)
+ {
+ GTK_WIDGET_CLASS (gtk_button_box_parent_class)->size_allocate (widget, allocation);
+ return;
+ }
+
+
orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
spacing = gtk_box_get_spacing (GTK_BOX (widget));
diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h
index e87c983..dbd74be 100644
--- a/gtk/gtkenums.h
+++ b/gtk/gtkenums.h
@@ -162,6 +162,7 @@ typedef enum
* @GTK_BUTTONBOX_END: Buttons are grouped towards the end of the box,
* (on the right for a HBox, or the bottom for a VBox).
* @GTK_BUTTONBOX_CENTER: Buttons are centered in the box. Since 2.12.
+ * @GTK_BUTTONBOX_EXPAND: Buttons expand to fill the box. Since 3.12.
*
* Used to dictate the style that a #GtkButtonBox uses to layout the buttons it
* contains. (See also: #GtkVButtonBox and #GtkHButtonBox).
@@ -172,7 +173,8 @@ typedef enum
GTK_BUTTONBOX_EDGE,
GTK_BUTTONBOX_START,
GTK_BUTTONBOX_END,
- GTK_BUTTONBOX_CENTER
+ GTK_BUTTONBOX_CENTER,
+ GTK_BUTTONBOX_EXPAND
} GtkButtonBoxStyle;
diff --git a/tests/testbbox.c b/tests/testbbox.c
index 9526849..8f2444d 100644
--- a/tests/testbbox.c
+++ b/tests/testbbox.c
@@ -28,6 +28,7 @@ static const char* styles[] = { "GTK_BUTTONBOX_SPREAD",
"GTK_BUTTONBOX_START",
"GTK_BUTTONBOX_END",
"GTK_BUTTONBOX_CENTER",
+ "GTK_BUTTONBOX_EXPAND",
NULL};
static const char* types[] = { "GtkHButtonBox",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]