mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 14:00:09 +00:00
spinbutton: Don't expand the buttons
When the spinbutton grows larger, distribute horizontal size to the entry and vertical size to the buttons. Obviously, horizontal size only matters for horizontal spinbuttons and vertical for vertical spinbuttons.
This commit is contained in:
parent
2c350f4469
commit
ae31c00092
@ -726,32 +726,36 @@ static void
|
|||||||
update_node_ordering (GtkSpinButton *spin_button)
|
update_node_ordering (GtkSpinButton *spin_button)
|
||||||
{
|
{
|
||||||
GtkSpinButtonPrivate *priv = spin_button->priv;
|
GtkSpinButtonPrivate *priv = spin_button->priv;
|
||||||
GtkCssGadget *middle, *last;
|
int down_button_pos, up_button_pos;
|
||||||
|
|
||||||
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
{
|
{
|
||||||
if (gtk_widget_get_direction (GTK_WIDGET (spin_button)) == GTK_TEXT_DIR_LTR)
|
if (gtk_widget_get_direction (GTK_WIDGET (spin_button)) == GTK_TEXT_DIR_LTR)
|
||||||
{
|
{
|
||||||
middle = priv->down_button;
|
down_button_pos = 1;
|
||||||
last = priv->up_button;
|
up_button_pos = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
middle = priv->down_button;
|
down_button_pos = 1;
|
||||||
last = gtk_entry_get_gadget (GTK_ENTRY (spin_button));
|
up_button_pos = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
middle = gtk_entry_get_gadget (GTK_ENTRY (spin_button));
|
up_button_pos = 0;
|
||||||
last = priv->down_button;
|
down_button_pos = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_box_gadget_set_orientation (GTK_BOX_GADGET (priv->gadget), priv->orientation);
|
gtk_box_gadget_set_orientation (GTK_BOX_GADGET (priv->gadget), priv->orientation);
|
||||||
gtk_box_gadget_remove_gadget (GTK_BOX_GADGET (priv->gadget), middle);
|
gtk_box_gadget_remove_gadget (GTK_BOX_GADGET (priv->gadget), priv->up_button);
|
||||||
gtk_box_gadget_remove_gadget (GTK_BOX_GADGET (priv->gadget), last);
|
gtk_box_gadget_remove_gadget (GTK_BOX_GADGET (priv->gadget), priv->down_button);
|
||||||
gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget), -1, middle, TRUE, TRUE, GTK_ALIGN_FILL);
|
gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget),
|
||||||
gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget), -1, last, TRUE, TRUE, GTK_ALIGN_FILL);
|
up_button_pos, priv->up_button,
|
||||||
|
FALSE, TRUE, GTK_ALIGN_FILL);
|
||||||
|
gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget),
|
||||||
|
down_button_pos, priv->down_button,
|
||||||
|
FALSE, TRUE, GTK_ALIGN_FILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -796,7 +800,7 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
|
|||||||
g_object_unref (entry_node);
|
g_object_unref (entry_node);
|
||||||
gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget),
|
gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget),
|
||||||
-1, gtk_entry_get_gadget (GTK_ENTRY (spin_button)),
|
-1, gtk_entry_get_gadget (GTK_ENTRY (spin_button)),
|
||||||
TRUE, TRUE, GTK_ALIGN_FILL);
|
TRUE, FALSE, GTK_ALIGN_FILL);
|
||||||
|
|
||||||
priv->down_button = gtk_icon_helper_new_named ("button",
|
priv->down_button = gtk_icon_helper_new_named ("button",
|
||||||
GTK_WIDGET (spin_button));
|
GTK_WIDGET (spin_button));
|
||||||
@ -807,7 +811,7 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
|
|||||||
gtk_css_node_set_state (gtk_css_gadget_get_node (priv->down_button), gtk_css_node_get_state (widget_node));
|
gtk_css_node_set_state (gtk_css_gadget_get_node (priv->down_button), gtk_css_node_get_state (widget_node));
|
||||||
gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget),
|
gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget),
|
||||||
-1, priv->down_button,
|
-1, priv->down_button,
|
||||||
TRUE, TRUE, GTK_ALIGN_FILL);
|
FALSE, TRUE, GTK_ALIGN_FILL);
|
||||||
|
|
||||||
priv->up_button = gtk_icon_helper_new_named ("button",
|
priv->up_button = gtk_icon_helper_new_named ("button",
|
||||||
GTK_WIDGET (spin_button));
|
GTK_WIDGET (spin_button));
|
||||||
@ -818,7 +822,7 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
|
|||||||
gtk_css_node_set_state (gtk_css_gadget_get_node (priv->down_button), gtk_css_node_get_state (widget_node));
|
gtk_css_node_set_state (gtk_css_gadget_get_node (priv->down_button), gtk_css_node_get_state (widget_node));
|
||||||
gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget),
|
gtk_box_gadget_insert_gadget (GTK_BOX_GADGET (priv->gadget),
|
||||||
-1, priv->up_button,
|
-1, priv->up_button,
|
||||||
TRUE, TRUE, GTK_ALIGN_FILL);
|
FALSE, TRUE, GTK_ALIGN_FILL);
|
||||||
|
|
||||||
gtk_spin_button_set_adjustment (spin_button, NULL);
|
gtk_spin_button_set_adjustment (spin_button, NULL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user