mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
Merge branch 'wip/dboles/frame-yalign-byealign' into 'master'
Frame: Erase the now-useless property label-yalign See merge request GNOME/gtk!40
This commit is contained in:
commit
5fe14e06da
@ -46,9 +46,9 @@
|
||||
* @Title: GtkFrame
|
||||
*
|
||||
* The frame widget is a bin that surrounds its child with a decorative
|
||||
* frame and an optional label. If present, the label is drawn in a gap
|
||||
* in the top side of the frame. The position of the label can be
|
||||
* controlled with gtk_frame_set_label_align().
|
||||
* frame and an optional label. If present, the label is drawn inside
|
||||
* the top edge of the frame. The horizontal position of the label can
|
||||
* be controlled with gtk_frame_set_label_align().
|
||||
*
|
||||
* # GtkFrame as GtkBuildable
|
||||
*
|
||||
@ -94,8 +94,6 @@ struct _GtkFramePrivate
|
||||
|
||||
gint16 shadow_type;
|
||||
gfloat label_xalign;
|
||||
gfloat label_yalign;
|
||||
/* Properties */
|
||||
|
||||
GtkAllocation child_allocation;
|
||||
GtkAllocation label_allocation;
|
||||
@ -105,7 +103,6 @@ enum {
|
||||
PROP_0,
|
||||
PROP_LABEL,
|
||||
PROP_LABEL_XALIGN,
|
||||
PROP_LABEL_YALIGN,
|
||||
PROP_SHADOW_TYPE,
|
||||
PROP_LABEL_WIDGET,
|
||||
LAST_PROP
|
||||
@ -184,14 +181,6 @@ gtk_frame_class_init (GtkFrameClass *class)
|
||||
0.0,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
frame_props[PROP_LABEL_YALIGN] =
|
||||
g_param_spec_float ("label-yalign",
|
||||
P_("Label yalign"),
|
||||
P_("The vertical alignment of the label"),
|
||||
0.0, 1.0,
|
||||
0.5,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
frame_props[PROP_SHADOW_TYPE] =
|
||||
g_param_spec_enum ("shadow-type",
|
||||
P_("Frame shadow"),
|
||||
@ -252,7 +241,6 @@ gtk_frame_init (GtkFrame *frame)
|
||||
priv->label_widget = NULL;
|
||||
priv->shadow_type = GTK_SHADOW_ETCHED_IN;
|
||||
priv->label_xalign = 0.0;
|
||||
priv->label_yalign = 0.5;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -262,7 +250,6 @@ gtk_frame_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFrame *frame = GTK_FRAME (object);
|
||||
GtkFramePrivate *priv = frame->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@ -270,13 +257,8 @@ gtk_frame_set_property (GObject *object,
|
||||
gtk_frame_set_label (frame, g_value_get_string (value));
|
||||
break;
|
||||
case PROP_LABEL_XALIGN:
|
||||
gtk_frame_set_label_align (frame, g_value_get_float (value),
|
||||
priv->label_yalign);
|
||||
gtk_frame_set_label_align (frame, g_value_get_float (value));
|
||||
break;
|
||||
case PROP_LABEL_YALIGN:
|
||||
gtk_frame_set_label_align (frame, priv->label_xalign,
|
||||
g_value_get_float (value));
|
||||
break;
|
||||
case PROP_SHADOW_TYPE:
|
||||
gtk_frame_set_shadow_type (frame, g_value_get_enum (value));
|
||||
break;
|
||||
@ -306,9 +288,6 @@ gtk_frame_get_property (GObject *object,
|
||||
case PROP_LABEL_XALIGN:
|
||||
g_value_set_float (value, priv->label_xalign);
|
||||
break;
|
||||
case PROP_LABEL_YALIGN:
|
||||
g_value_set_float (value, priv->label_yalign);
|
||||
break;
|
||||
case PROP_SHADOW_TYPE:
|
||||
g_value_set_enum (value, priv->shadow_type);
|
||||
break;
|
||||
@ -497,18 +476,13 @@ gtk_frame_get_label_widget (GtkFrame *frame)
|
||||
* @xalign: The position of the label along the top edge
|
||||
* of the widget. A value of 0.0 represents left alignment;
|
||||
* 1.0 represents right alignment.
|
||||
* @yalign: The y alignment of the label. A value of 0.0 aligns under
|
||||
* the frame; 1.0 aligns above the frame. If the values are exactly
|
||||
* 0.0 or 1.0 the gap in the frame won’t be painted because the label
|
||||
* will be completely above or below the frame.
|
||||
*
|
||||
* Sets the alignment of the frame widget’s label. The
|
||||
* default values for a newly created frame are 0.0 and 0.5.
|
||||
* Sets the X alignment of the frame widget’s label. The
|
||||
* default value for a newly created frame is 0.0.
|
||||
**/
|
||||
void
|
||||
gtk_frame_set_label_align (GtkFrame *frame,
|
||||
gfloat xalign,
|
||||
gfloat yalign)
|
||||
gfloat xalign)
|
||||
{
|
||||
GtkFramePrivate *priv;
|
||||
|
||||
@ -517,7 +491,6 @@ gtk_frame_set_label_align (GtkFrame *frame,
|
||||
priv = frame->priv;
|
||||
|
||||
xalign = CLAMP (xalign, 0.0, 1.0);
|
||||
yalign = CLAMP (yalign, 0.0, 1.0);
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (frame));
|
||||
if (xalign != priv->label_xalign)
|
||||
@ -526,12 +499,6 @@ gtk_frame_set_label_align (GtkFrame *frame,
|
||||
g_object_notify_by_pspec (G_OBJECT (frame), frame_props[PROP_LABEL_XALIGN]);
|
||||
}
|
||||
|
||||
if (yalign != priv->label_yalign)
|
||||
{
|
||||
priv->label_yalign = yalign;
|
||||
g_object_notify_by_pspec (G_OBJECT (frame), frame_props[PROP_LABEL_YALIGN]);
|
||||
}
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (frame));
|
||||
gtk_widget_queue_resize (GTK_WIDGET (frame));
|
||||
}
|
||||
@ -539,29 +506,16 @@ gtk_frame_set_label_align (GtkFrame *frame,
|
||||
/**
|
||||
* gtk_frame_get_label_align:
|
||||
* @frame: a #GtkFrame
|
||||
* @xalign: (out) (allow-none): location to store X alignment of
|
||||
* frame’s label, or %NULL
|
||||
* @yalign: (out) (allow-none): location to store X alignment of
|
||||
* frame’s label, or %NULL
|
||||
*
|
||||
* Retrieves the X and Y alignment of the frame’s label. See
|
||||
* Retrieves the X alignment of the frame’s label. See
|
||||
* gtk_frame_set_label_align().
|
||||
**/
|
||||
void
|
||||
gtk_frame_get_label_align (GtkFrame *frame,
|
||||
gfloat *xalign,
|
||||
gfloat *yalign)
|
||||
gfloat
|
||||
gtk_frame_get_label_align (GtkFrame *frame)
|
||||
{
|
||||
GtkFramePrivate *priv;
|
||||
g_return_val_if_fail (GTK_IS_FRAME (frame), 0.0);
|
||||
|
||||
g_return_if_fail (GTK_IS_FRAME (frame));
|
||||
|
||||
priv = frame->priv;
|
||||
|
||||
if (xalign)
|
||||
*xalign = priv->label_xalign;
|
||||
if (yalign)
|
||||
*yalign = priv->label_yalign;
|
||||
return frame->priv->label_xalign;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,12 +97,9 @@ GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget *gtk_frame_get_label_widget (GtkFrame *frame);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_frame_set_label_align (GtkFrame *frame,
|
||||
gfloat xalign,
|
||||
gfloat yalign);
|
||||
gfloat xalign);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_frame_get_label_align (GtkFrame *frame,
|
||||
gfloat *xalign,
|
||||
gfloat *yalign);
|
||||
gfloat gtk_frame_get_label_align (GtkFrame *frame);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_frame_set_shadow_type (GtkFrame *frame,
|
||||
GtkShadowType type);
|
||||
|
@ -110,26 +110,11 @@ static void
|
||||
spin_xalign_cb (GtkSpinButton *spin, GtkFrame *frame)
|
||||
{
|
||||
gdouble xalign;
|
||||
gfloat yalign;
|
||||
|
||||
xalign = double_normalize (gtk_spin_button_get_value (spin));
|
||||
gtk_frame_get_label_align (frame, NULL, &yalign);
|
||||
gtk_frame_set_label_align (frame, xalign, yalign);
|
||||
gtk_frame_set_label_align (frame, xalign);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
spin_yalign_cb (GtkSpinButton *spin, GtkFrame *frame)
|
||||
{
|
||||
gdouble yalign;
|
||||
gfloat xalign;
|
||||
|
||||
yalign = double_normalize (gtk_spin_button_get_value (spin));
|
||||
gtk_frame_get_label_align (frame, &xalign, NULL);
|
||||
gtk_frame_set_label_align (frame, xalign, yalign);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
draw_border_cb (GtkToggleButton *toggle_button, GtkFrame *frame)
|
||||
{
|
||||
@ -145,7 +130,7 @@ int main (int argc, char **argv)
|
||||
GtkBox *vbox;
|
||||
GtkFrame *frame;
|
||||
GtkGrid *grid;
|
||||
gfloat xalign, yalign;
|
||||
gfloat xalign;
|
||||
gboolean draw_border;
|
||||
|
||||
gtk_init ();
|
||||
@ -171,7 +156,7 @@ int main (int argc, char **argv)
|
||||
gtk_grid_set_column_spacing (grid, 6);
|
||||
gtk_box_pack_start (vbox, GTK_WIDGET (grid));
|
||||
|
||||
gtk_frame_get_label_align (frame, &xalign, &yalign);
|
||||
xalign = gtk_frame_get_label_align (frame);
|
||||
|
||||
/* Spin to control :label-xalign */
|
||||
widget = gtk_label_new ("label xalign:");
|
||||
@ -182,18 +167,6 @@ int main (int argc, char **argv)
|
||||
g_signal_connect (widget, "value-changed", G_CALLBACK (spin_xalign_cb), frame);
|
||||
gtk_grid_attach (grid, widget, 1, 0, 1, 1);
|
||||
|
||||
/* Frame:label-yalign does nothing since the border node was removed */
|
||||
#if 0
|
||||
/* Spin to control :label-yalign */
|
||||
widget = gtk_label_new ("label yalign:");
|
||||
gtk_grid_attach (grid, widget, 0, 1, 1, 1);
|
||||
|
||||
widget = gtk_spin_button_new_with_range (0.0, 1.0, 0.1);
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), yalign);
|
||||
g_signal_connect (widget, "value-changed", G_CALLBACK (spin_yalign_cb), frame);
|
||||
gtk_grid_attach (grid, widget, 1, 1, 1, 1);
|
||||
#endif
|
||||
|
||||
/* Spin to control vertical padding */
|
||||
widget = gtk_label_new ("vertical padding:");
|
||||
gtk_grid_attach (grid, widget, 0, 1, 1, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user