|
|
|
@ -54,8 +54,6 @@
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "gtkbbox.h"
|
|
|
|
|
#include "gtkhbbox.h"
|
|
|
|
|
#include "gtkvbbox.h"
|
|
|
|
|
#include "gtkorientable.h"
|
|
|
|
|
#include "gtkprivate.h"
|
|
|
|
|
#include "gtkintl.h"
|
|
|
|
@ -64,11 +62,6 @@
|
|
|
|
|
struct _GtkButtonBoxPriv
|
|
|
|
|
{
|
|
|
|
|
GtkButtonBoxStyle layout_style;
|
|
|
|
|
|
|
|
|
|
gint child_ipad_x;
|
|
|
|
|
gint child_ipad_y;
|
|
|
|
|
gint child_min_width;
|
|
|
|
|
gint child_min_height;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
@ -112,6 +105,7 @@ static void gtk_button_box_get_child_property (GtkContainer *container,
|
|
|
|
|
#define DEFAULT_CHILD_MIN_HEIGHT 27
|
|
|
|
|
#define DEFAULT_CHILD_IPAD_X 4
|
|
|
|
|
#define DEFAULT_CHILD_IPAD_Y 0
|
|
|
|
|
#define DEFAULT_LAYOUT_STYLE GTK_BUTTONBOX_EDGE
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GtkButtonBox, gtk_button_box, GTK_TYPE_BOX)
|
|
|
|
|
|
|
|
|
@ -178,9 +172,9 @@ gtk_button_box_class_init (GtkButtonBoxClass *class)
|
|
|
|
|
PROP_LAYOUT_STYLE,
|
|
|
|
|
g_param_spec_enum ("layout-style",
|
|
|
|
|
P_("Layout style"),
|
|
|
|
|
P_("How to layout the buttons in the box. Possible values are default, spread, edge, start and end"),
|
|
|
|
|
P_("How to layout the buttons in the box. Possible values are spread, edge, start and end"),
|
|
|
|
|
GTK_TYPE_BUTTON_BOX_STYLE,
|
|
|
|
|
GTK_BUTTONBOX_DEFAULT_STYLE,
|
|
|
|
|
DEFAULT_LAYOUT_STYLE,
|
|
|
|
|
GTK_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
|
gtk_container_class_install_child_property (container_class,
|
|
|
|
@ -205,11 +199,7 @@ gtk_button_box_init (GtkButtonBox *button_box)
|
|
|
|
|
priv = button_box->priv;
|
|
|
|
|
|
|
|
|
|
gtk_box_set_spacing (GTK_BOX (button_box), 0);
|
|
|
|
|
priv->child_min_width = GTK_BUTTONBOX_DEFAULT;
|
|
|
|
|
priv->child_min_height = GTK_BUTTONBOX_DEFAULT;
|
|
|
|
|
priv->child_ipad_x = GTK_BUTTONBOX_DEFAULT;
|
|
|
|
|
priv->child_ipad_y = GTK_BUTTONBOX_DEFAULT;
|
|
|
|
|
priv->layout_style = GTK_BUTTONBOX_DEFAULT_STYLE;
|
|
|
|
|
priv->layout_style = DEFAULT_LAYOUT_STYLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
@ -293,7 +283,8 @@ gtk_button_box_remove (GtkContainer *container,
|
|
|
|
|
GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
/* clear is_secondary flag in case the widget
|
|
|
|
|
* is added to another container */
|
|
|
|
|
* is added to another container
|
|
|
|
|
*/
|
|
|
|
|
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (container),
|
|
|
|
|
widget,
|
|
|
|
|
FALSE);
|
|
|
|
@ -315,8 +306,6 @@ gtk_button_box_set_layout (GtkButtonBox *widget,
|
|
|
|
|
GtkButtonBoxPriv *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
|
|
|
|
|
g_return_if_fail (layout_style >= GTK_BUTTONBOX_DEFAULT_STYLE &&
|
|
|
|
|
layout_style <= GTK_BUTTONBOX_CENTER);
|
|
|
|
|
|
|
|
|
|
priv = widget->priv;
|
|
|
|
|
|
|
|
|
@ -339,7 +328,7 @@ gtk_button_box_set_layout (GtkButtonBox *widget,
|
|
|
|
|
GtkButtonBoxStyle
|
|
|
|
|
gtk_button_box_get_layout (GtkButtonBox *widget)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_BUTTON_BOX (widget), GTK_BUTTONBOX_SPREAD);
|
|
|
|
|
g_return_val_if_fail (GTK_IS_BUTTON_BOX (widget), DEFAULT_LAYOUT_STYLE);
|
|
|
|
|
|
|
|
|
|
return widget->priv->layout_style;
|
|
|
|
|
}
|
|
|
|
@ -399,8 +388,8 @@ gtk_button_box_set_child_secondary (GtkButtonBox *widget,
|
|
|
|
|
is_secondary ? GINT_TO_POINTER (1) : NULL);
|
|
|
|
|
gtk_widget_child_notify (child, "secondary");
|
|
|
|
|
|
|
|
|
|
if (gtk_widget_get_visible (GTK_WIDGET (widget))
|
|
|
|
|
&& gtk_widget_get_visible (child))
|
|
|
|
|
if (gtk_widget_get_visible (GTK_WIDGET (widget)) &&
|
|
|
|
|
gtk_widget_get_visible (child))
|
|
|
|
|
gtk_widget_queue_resize (child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -428,7 +417,6 @@ _gtk_button_box_child_requisition (GtkWidget *widget,
|
|
|
|
|
gint height_default;
|
|
|
|
|
gint ipad_x_default;
|
|
|
|
|
gint ipad_y_default;
|
|
|
|
|
|
|
|
|
|
gint child_min_width;
|
|
|
|
|
gint child_min_height;
|
|
|
|
|
gint ipad_x;
|
|
|
|
@ -446,14 +434,10 @@ _gtk_button_box_child_requisition (GtkWidget *widget,
|
|
|
|
|
"child-internal-pad-y", &ipad_y_default,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
child_min_width = priv->child_min_width != GTK_BUTTONBOX_DEFAULT
|
|
|
|
|
? priv->child_min_width : width_default;
|
|
|
|
|
child_min_height = priv->child_min_height != GTK_BUTTONBOX_DEFAULT
|
|
|
|
|
? priv->child_min_height : height_default;
|
|
|
|
|
ipad_x = priv->child_ipad_x != GTK_BUTTONBOX_DEFAULT
|
|
|
|
|
? priv->child_ipad_x : ipad_x_default;
|
|
|
|
|
ipad_y = priv->child_ipad_y != GTK_BUTTONBOX_DEFAULT
|
|
|
|
|
? priv->child_ipad_y : ipad_y_default;
|
|
|
|
|
child_min_width = width_default;
|
|
|
|
|
child_min_height = height_default;
|
|
|
|
|
ipad_x = ipad_x_default;
|
|
|
|
|
ipad_y = ipad_y_default;
|
|
|
|
|
|
|
|
|
|
nchildren = 0;
|
|
|
|
|
nsecondaries = 0;
|
|
|
|
@ -499,23 +483,6 @@ _gtk_button_box_child_requisition (GtkWidget *widget,
|
|
|
|
|
*height = needed_height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* this is a kludge function to support the deprecated
|
|
|
|
|
* gtk_[vh]button_box_set_layout_default() just in case anyone is still
|
|
|
|
|
* using it (why?)
|
|
|
|
|
*/
|
|
|
|
|
static GtkButtonBoxStyle
|
|
|
|
|
gtk_button_box_kludge_get_layout_default (GtkButtonBox *widget)
|
|
|
|
|
{
|
|
|
|
|
GtkOrientation orientation;
|
|
|
|
|
|
|
|
|
|
orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
|
|
|
|
|
|
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
|
return _gtk_hbutton_box_get_layout_default ();
|
|
|
|
|
else
|
|
|
|
|
return _gtk_vbutton_box_get_layout_default ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_button_box_size_request (GtkWidget *widget,
|
|
|
|
|
GtkRequisition *requisition)
|
|
|
|
@ -528,7 +495,6 @@ gtk_button_box_size_request (GtkWidget *widget,
|
|
|
|
|
gint child_height;
|
|
|
|
|
gint spacing;
|
|
|
|
|
guint border_width;
|
|
|
|
|
GtkButtonBoxStyle layout;
|
|
|
|
|
GtkOrientation orientation;
|
|
|
|
|
|
|
|
|
|
box = GTK_BOX (widget);
|
|
|
|
@ -537,8 +503,6 @@ gtk_button_box_size_request (GtkWidget *widget,
|
|
|
|
|
|
|
|
|
|
orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
|
|
|
|
|
spacing = gtk_box_get_spacing (box);
|
|
|
|
|
layout = priv->layout_style != GTK_BUTTONBOX_DEFAULT_STYLE
|
|
|
|
|
? priv->layout_style : gtk_button_box_kludge_get_layout_default (GTK_BUTTON_BOX (widget));
|
|
|
|
|
|
|
|
|
|
_gtk_button_box_child_requisition (widget,
|
|
|
|
|
&nvis_children,
|
|
|
|
@ -553,7 +517,7 @@ gtk_button_box_size_request (GtkWidget *widget,
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (layout)
|
|
|
|
|
switch (priv->layout_style)
|
|
|
|
|
{
|
|
|
|
|
case GTK_BUTTONBOX_SPREAD:
|
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
@ -613,7 +577,6 @@ gtk_button_box_size_allocate (GtkWidget *widget,
|
|
|
|
|
gint height = 0;
|
|
|
|
|
gint childspace;
|
|
|
|
|
gint childspacing = 0;
|
|
|
|
|
GtkButtonBoxStyle layout;
|
|
|
|
|
gint spacing;
|
|
|
|
|
guint border_width;
|
|
|
|
|
GtkOrientation orientation;
|
|
|
|
@ -625,8 +588,6 @@ gtk_button_box_size_allocate (GtkWidget *widget,
|
|
|
|
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (box));
|
|
|
|
|
orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
|
|
|
|
|
spacing = gtk_box_get_spacing (base_box);
|
|
|
|
|
layout = priv->layout_style != GTK_BUTTONBOX_DEFAULT_STYLE
|
|
|
|
|
? priv->layout_style : gtk_button_box_kludge_get_layout_default (GTK_BUTTON_BOX (widget));
|
|
|
|
|
_gtk_button_box_child_requisition (widget,
|
|
|
|
|
&nvis_children,
|
|
|
|
|
&n_secondaries,
|
|
|
|
@ -639,7 +600,7 @@ gtk_button_box_size_allocate (GtkWidget *widget,
|
|
|
|
|
else
|
|
|
|
|
height = allocation->height - border_width*2;
|
|
|
|
|
|
|
|
|
|
switch (layout)
|
|
|
|
|
switch (priv->layout_style)
|
|
|
|
|
{
|
|
|
|
|
case GTK_BUTTONBOX_SPREAD:
|
|
|
|
|
|
|
|
|
|