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
|
* @Title: GtkFrame
|
||||||
*
|
*
|
||||||
* The frame widget is a bin that surrounds its child with a decorative
|
* 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
|
* frame and an optional label. If present, the label is drawn inside
|
||||||
* in the top side of the frame. The position of the label can be
|
* the top edge of the frame. The horizontal position of the label can
|
||||||
* controlled with gtk_frame_set_label_align().
|
* be controlled with gtk_frame_set_label_align().
|
||||||
*
|
*
|
||||||
* # GtkFrame as GtkBuildable
|
* # GtkFrame as GtkBuildable
|
||||||
*
|
*
|
||||||
@ -94,8 +94,6 @@ struct _GtkFramePrivate
|
|||||||
|
|
||||||
gint16 shadow_type;
|
gint16 shadow_type;
|
||||||
gfloat label_xalign;
|
gfloat label_xalign;
|
||||||
gfloat label_yalign;
|
|
||||||
/* Properties */
|
|
||||||
|
|
||||||
GtkAllocation child_allocation;
|
GtkAllocation child_allocation;
|
||||||
GtkAllocation label_allocation;
|
GtkAllocation label_allocation;
|
||||||
@ -105,7 +103,6 @@ enum {
|
|||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_LABEL,
|
PROP_LABEL,
|
||||||
PROP_LABEL_XALIGN,
|
PROP_LABEL_XALIGN,
|
||||||
PROP_LABEL_YALIGN,
|
|
||||||
PROP_SHADOW_TYPE,
|
PROP_SHADOW_TYPE,
|
||||||
PROP_LABEL_WIDGET,
|
PROP_LABEL_WIDGET,
|
||||||
LAST_PROP
|
LAST_PROP
|
||||||
@ -184,14 +181,6 @@ gtk_frame_class_init (GtkFrameClass *class)
|
|||||||
0.0,
|
0.0,
|
||||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
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] =
|
frame_props[PROP_SHADOW_TYPE] =
|
||||||
g_param_spec_enum ("shadow-type",
|
g_param_spec_enum ("shadow-type",
|
||||||
P_("Frame shadow"),
|
P_("Frame shadow"),
|
||||||
@ -252,7 +241,6 @@ gtk_frame_init (GtkFrame *frame)
|
|||||||
priv->label_widget = NULL;
|
priv->label_widget = NULL;
|
||||||
priv->shadow_type = GTK_SHADOW_ETCHED_IN;
|
priv->shadow_type = GTK_SHADOW_ETCHED_IN;
|
||||||
priv->label_xalign = 0.0;
|
priv->label_xalign = 0.0;
|
||||||
priv->label_yalign = 0.5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -262,7 +250,6 @@ gtk_frame_set_property (GObject *object,
|
|||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
GtkFrame *frame = GTK_FRAME (object);
|
GtkFrame *frame = GTK_FRAME (object);
|
||||||
GtkFramePrivate *priv = frame->priv;
|
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
@ -270,13 +257,8 @@ gtk_frame_set_property (GObject *object,
|
|||||||
gtk_frame_set_label (frame, g_value_get_string (value));
|
gtk_frame_set_label (frame, g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
case PROP_LABEL_XALIGN:
|
case PROP_LABEL_XALIGN:
|
||||||
gtk_frame_set_label_align (frame, g_value_get_float (value),
|
gtk_frame_set_label_align (frame, g_value_get_float (value));
|
||||||
priv->label_yalign);
|
|
||||||
break;
|
break;
|
||||||
case PROP_LABEL_YALIGN:
|
|
||||||
gtk_frame_set_label_align (frame, priv->label_xalign,
|
|
||||||
g_value_get_float (value));
|
|
||||||
break;
|
|
||||||
case PROP_SHADOW_TYPE:
|
case PROP_SHADOW_TYPE:
|
||||||
gtk_frame_set_shadow_type (frame, g_value_get_enum (value));
|
gtk_frame_set_shadow_type (frame, g_value_get_enum (value));
|
||||||
break;
|
break;
|
||||||
@ -306,9 +288,6 @@ gtk_frame_get_property (GObject *object,
|
|||||||
case PROP_LABEL_XALIGN:
|
case PROP_LABEL_XALIGN:
|
||||||
g_value_set_float (value, priv->label_xalign);
|
g_value_set_float (value, priv->label_xalign);
|
||||||
break;
|
break;
|
||||||
case PROP_LABEL_YALIGN:
|
|
||||||
g_value_set_float (value, priv->label_yalign);
|
|
||||||
break;
|
|
||||||
case PROP_SHADOW_TYPE:
|
case PROP_SHADOW_TYPE:
|
||||||
g_value_set_enum (value, priv->shadow_type);
|
g_value_set_enum (value, priv->shadow_type);
|
||||||
break;
|
break;
|
||||||
@ -497,18 +476,13 @@ gtk_frame_get_label_widget (GtkFrame *frame)
|
|||||||
* @xalign: The position of the label along the top edge
|
* @xalign: The position of the label along the top edge
|
||||||
* of the widget. A value of 0.0 represents left alignment;
|
* of the widget. A value of 0.0 represents left alignment;
|
||||||
* 1.0 represents right 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
|
* Sets the X alignment of the frame widget’s label. The
|
||||||
* default values for a newly created frame are 0.0 and 0.5.
|
* default value for a newly created frame is 0.0.
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gtk_frame_set_label_align (GtkFrame *frame,
|
gtk_frame_set_label_align (GtkFrame *frame,
|
||||||
gfloat xalign,
|
gfloat xalign)
|
||||||
gfloat yalign)
|
|
||||||
{
|
{
|
||||||
GtkFramePrivate *priv;
|
GtkFramePrivate *priv;
|
||||||
|
|
||||||
@ -517,7 +491,6 @@ gtk_frame_set_label_align (GtkFrame *frame,
|
|||||||
priv = frame->priv;
|
priv = frame->priv;
|
||||||
|
|
||||||
xalign = CLAMP (xalign, 0.0, 1.0);
|
xalign = CLAMP (xalign, 0.0, 1.0);
|
||||||
yalign = CLAMP (yalign, 0.0, 1.0);
|
|
||||||
|
|
||||||
g_object_freeze_notify (G_OBJECT (frame));
|
g_object_freeze_notify (G_OBJECT (frame));
|
||||||
if (xalign != priv->label_xalign)
|
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]);
|
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));
|
g_object_thaw_notify (G_OBJECT (frame));
|
||||||
gtk_widget_queue_resize (GTK_WIDGET (frame));
|
gtk_widget_queue_resize (GTK_WIDGET (frame));
|
||||||
}
|
}
|
||||||
@ -539,29 +506,16 @@ gtk_frame_set_label_align (GtkFrame *frame,
|
|||||||
/**
|
/**
|
||||||
* gtk_frame_get_label_align:
|
* gtk_frame_get_label_align:
|
||||||
* @frame: a #GtkFrame
|
* @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().
|
* gtk_frame_set_label_align().
|
||||||
**/
|
**/
|
||||||
void
|
gfloat
|
||||||
gtk_frame_get_label_align (GtkFrame *frame,
|
gtk_frame_get_label_align (GtkFrame *frame)
|
||||||
gfloat *xalign,
|
|
||||||
gfloat *yalign)
|
|
||||||
{
|
{
|
||||||
GtkFramePrivate *priv;
|
g_return_val_if_fail (GTK_IS_FRAME (frame), 0.0);
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_FRAME (frame));
|
return frame->priv->label_xalign;
|
||||||
|
|
||||||
priv = frame->priv;
|
|
||||||
|
|
||||||
if (xalign)
|
|
||||||
*xalign = priv->label_xalign;
|
|
||||||
if (yalign)
|
|
||||||
*yalign = priv->label_yalign;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,12 +97,9 @@ GDK_AVAILABLE_IN_ALL
|
|||||||
GtkWidget *gtk_frame_get_label_widget (GtkFrame *frame);
|
GtkWidget *gtk_frame_get_label_widget (GtkFrame *frame);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gtk_frame_set_label_align (GtkFrame *frame,
|
void gtk_frame_set_label_align (GtkFrame *frame,
|
||||||
gfloat xalign,
|
gfloat xalign);
|
||||||
gfloat yalign);
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gtk_frame_get_label_align (GtkFrame *frame,
|
gfloat gtk_frame_get_label_align (GtkFrame *frame);
|
||||||
gfloat *xalign,
|
|
||||||
gfloat *yalign);
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gtk_frame_set_shadow_type (GtkFrame *frame,
|
void gtk_frame_set_shadow_type (GtkFrame *frame,
|
||||||
GtkShadowType type);
|
GtkShadowType type);
|
||||||
|
@ -110,26 +110,11 @@ static void
|
|||||||
spin_xalign_cb (GtkSpinButton *spin, GtkFrame *frame)
|
spin_xalign_cb (GtkSpinButton *spin, GtkFrame *frame)
|
||||||
{
|
{
|
||||||
gdouble xalign;
|
gdouble xalign;
|
||||||
gfloat yalign;
|
|
||||||
|
|
||||||
xalign = double_normalize (gtk_spin_button_get_value (spin));
|
xalign = double_normalize (gtk_spin_button_get_value (spin));
|
||||||
gtk_frame_get_label_align (frame, NULL, &yalign);
|
gtk_frame_set_label_align (frame, xalign);
|
||||||
gtk_frame_set_label_align (frame, xalign, yalign);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#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
|
static void
|
||||||
draw_border_cb (GtkToggleButton *toggle_button, GtkFrame *frame)
|
draw_border_cb (GtkToggleButton *toggle_button, GtkFrame *frame)
|
||||||
{
|
{
|
||||||
@ -145,7 +130,7 @@ int main (int argc, char **argv)
|
|||||||
GtkBox *vbox;
|
GtkBox *vbox;
|
||||||
GtkFrame *frame;
|
GtkFrame *frame;
|
||||||
GtkGrid *grid;
|
GtkGrid *grid;
|
||||||
gfloat xalign, yalign;
|
gfloat xalign;
|
||||||
gboolean draw_border;
|
gboolean draw_border;
|
||||||
|
|
||||||
gtk_init ();
|
gtk_init ();
|
||||||
@ -171,7 +156,7 @@ int main (int argc, char **argv)
|
|||||||
gtk_grid_set_column_spacing (grid, 6);
|
gtk_grid_set_column_spacing (grid, 6);
|
||||||
gtk_box_pack_start (vbox, GTK_WIDGET (grid));
|
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 */
|
/* Spin to control :label-xalign */
|
||||||
widget = gtk_label_new ("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);
|
g_signal_connect (widget, "value-changed", G_CALLBACK (spin_xalign_cb), frame);
|
||||||
gtk_grid_attach (grid, widget, 1, 0, 1, 1);
|
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 */
|
/* Spin to control vertical padding */
|
||||||
widget = gtk_label_new ("vertical padding:");
|
widget = gtk_label_new ("vertical padding:");
|
||||||
gtk_grid_attach (grid, widget, 0, 1, 1, 1);
|
gtk_grid_attach (grid, widget, 0, 1, 1, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user