label: Remove angle property

This commit is contained in:
Timm Bäder 2017-04-25 17:26:49 +02:00
parent cb80b32ee8
commit db4b1d28f5
19 changed files with 29 additions and 495 deletions

View File

@ -204,8 +204,6 @@ do_rotated_text (GtkWidget *do_widget)
label = gtk_label_new (text);
gtk_container_add (GTK_CONTAINER (box), label);
gtk_label_set_angle (GTK_LABEL (label), 45);
/* Set up fancy stuff on the label */
layout = gtk_label_get_layout (GTK_LABEL (label));
pango_cairo_context_set_shape_renderer (pango_layout_get_context (layout),

View File

@ -1654,12 +1654,10 @@ gtk_label_get_selection_bounds
gtk_label_get_use_markup
gtk_label_get_use_underline
gtk_label_get_single_line_mode
gtk_label_get_angle
gtk_label_set_label
gtk_label_set_use_markup
gtk_label_set_use_underline
gtk_label_set_single_line_mode
gtk_label_set_angle
gtk_label_get_current_uri
gtk_label_set_track_visited_links
gtk_label_get_track_visited_links

View File

@ -262,7 +262,6 @@ struct _GtkLabelPrivate
gchar *label;
gchar *text;
gdouble angle;
gfloat xalign;
gfloat yalign;
@ -273,7 +272,6 @@ struct _GtkLabelPrivate
guint use_markup : 1;
guint ellipsize : 3;
guint single_line_mode : 1;
guint have_transform : 1;
guint in_click : 1;
guint wrap_mode : 3;
guint pattern_set : 1;
@ -376,7 +374,6 @@ enum {
PROP_ELLIPSIZE,
PROP_WIDTH_CHARS,
PROP_SINGLE_LINE_MODE,
PROP_ANGLE,
PROP_MAX_WIDTH_CHARS,
PROP_TRACK_VISITED_LINKS,
PROP_LINES,
@ -387,11 +384,6 @@ enum {
static GParamSpec *label_props[NUM_PROPERTIES] = { NULL, };
/* When rotating ellipsizable text we want the natural size to request
* more to ensure the label wont ever ellipsize in an allocation of full natural size.
* */
#define ROTATION_ELLIPSIZE_PADDING 2
static guint signals[LAST_SIGNAL] = { 0 };
static GQuark quark_shortcuts_connected;
@ -982,24 +974,6 @@ gtk_label_class_init (GtkLabelClass *class)
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkLabel:angle:
*
* The angle that the baseline of the label makes with the horizontal,
* in degrees, measured counterclockwise. An angle of 90 reads from
* from bottom to top, an angle of 270, from top to bottom. Ignored
* if the label is selectable.
*
* Since: 2.6
**/
label_props[PROP_ANGLE] =
g_param_spec_double ("angle",
P_("Angle"),
P_("Angle at which the label is rotated"),
0.0, 360.0,
0.0,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkLabel:max-width-chars:
*
@ -1231,9 +1205,6 @@ gtk_label_set_property (GObject *object,
case PROP_SINGLE_LINE_MODE:
gtk_label_set_single_line_mode (label, g_value_get_boolean (value));
break;
case PROP_ANGLE:
gtk_label_set_angle (label, g_value_get_double (value));
break;
case PROP_MAX_WIDTH_CHARS:
gtk_label_set_max_width_chars (label, g_value_get_int (value));
break;
@ -1311,9 +1282,6 @@ gtk_label_get_property (GObject *object,
case PROP_SINGLE_LINE_MODE:
g_value_set_boolean (value, gtk_label_get_single_line_mode (label));
break;
case PROP_ANGLE:
g_value_set_double (value, gtk_label_get_angle (label));
break;
case PROP_MAX_WIDTH_CHARS:
g_value_set_int (value, gtk_label_get_max_width_chars (label));
break;
@ -3363,83 +3331,16 @@ static void
gtk_label_update_layout_width (GtkLabel *label)
{
GtkLabelPrivate *priv = label->priv;
GtkWidget *widget = GTK_WIDGET (label);
g_assert (priv->layout);
if (priv->ellipsize || priv->wrap)
{
GtkAllocation allocation;
PangoRectangle logical;
gint width, height;
gtk_css_gadget_get_content_allocation (priv->gadget, &allocation, NULL);
width = allocation.width;
height = allocation.height;
if (priv->have_transform)
{
PangoContext *context = gtk_widget_get_pango_context (widget);
const PangoMatrix *matrix = pango_context_get_matrix (context);
const gdouble dx = matrix->xx; /* cos (M_PI * angle / 180) */
const gdouble dy = matrix->xy; /* sin (M_PI * angle / 180) */
pango_layout_set_width (priv->layout, -1);
pango_layout_get_pixel_extents (priv->layout, NULL, &logical);
if (fabs (dy) < 0.01)
{
if (logical.width > width)
pango_layout_set_width (priv->layout, width * PANGO_SCALE);
}
else if (fabs (dx) < 0.01)
{
if (logical.width > height)
pango_layout_set_width (priv->layout, height * PANGO_SCALE);
}
else
{
gdouble x0, y0, x1, y1, length;
gboolean vertical;
gint cy;
x0 = width / 2;
y0 = dx ? x0 * dy / dx : G_MAXDOUBLE;
vertical = fabs (y0) > height / 2.0;
if (vertical)
{
y0 = height/2;
x0 = dy ? y0 * dx / dy : G_MAXDOUBLE;
}
length = 2 * sqrt (x0 * x0 + y0 * y0);
pango_layout_set_width (priv->layout, rint (length * PANGO_SCALE));
pango_layout_get_pixel_size (priv->layout, NULL, &cy);
x1 = +dy * cy/2;
y1 = -dx * cy/2;
if (vertical)
{
y0 = height/2 + y1 - y0;
x0 = -y0 * dx/dy;
}
else
{
x0 = width/2 + x1 - x0;
y0 = -x0 * dy/dx;
}
length = length - sqrt (x0 * x0 + y0 * y0) * 2;
pango_layout_set_width (priv->layout, rint (length * PANGO_SCALE));
}
}
else
{
pango_layout_set_width (priv->layout, width * PANGO_SCALE);
}
pango_layout_set_width (priv->layout, allocation.width * PANGO_SCALE);
}
else
{
@ -3523,29 +3424,6 @@ gtk_label_ensure_layout (GtkLabel *label)
if (!priv->layout)
{
PangoAlignment align = PANGO_ALIGN_LEFT; /* Quiet gcc */
gdouble angle = gtk_label_get_angle (label);
if (angle != 0.0 && !priv->select_info)
{
PangoMatrix matrix = PANGO_MATRIX_INIT;
/* We rotate the standard singleton PangoContext for the widget,
* depending on the fact that it's meant pretty much exclusively
* for our use.
*/
pango_matrix_rotate (&matrix, angle);
pango_context_set_matrix (gtk_widget_get_pango_context (widget), &matrix);
priv->have_transform = TRUE;
}
else
{
if (priv->have_transform)
pango_context_set_matrix (gtk_widget_get_pango_context (widget), NULL);
priv->have_transform = FALSE;
}
priv->layout = gtk_widget_create_pango_layout (widget, priv->text);
@ -3585,43 +3463,35 @@ static GtkSizeRequestMode
gtk_label_get_request_mode (GtkWidget *widget)
{
GtkLabel *label = GTK_LABEL (widget);
gdouble angle;
angle = gtk_label_get_angle (label);
if (label->priv->wrap)
return (angle == 90 || angle == 270)
? GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT
: GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
return GTK_SIZE_REQUEST_CONSTANT_SIZE;
}
static void
get_size_for_allocation (GtkLabel *label,
gint allocation,
gint *minimum_size,
gint *natural_size,
gint *minimum_baseline,
gint *natural_baseline)
get_height_for_width (GtkLabel *label,
gint width,
gint *minimum_height,
gint *natural_height,
gint *minimum_baseline,
gint *natural_baseline)
{
PangoLayout *layout;
gint text_height, baseline;
layout = gtk_label_get_measuring_layout (label, NULL, allocation * PANGO_SCALE);
layout = gtk_label_get_measuring_layout (label, NULL, width * PANGO_SCALE);
pango_layout_get_pixel_size (layout, NULL, &text_height);
*minimum_size = text_height;
*natural_size = text_height;
*minimum_height = text_height;
*natural_height = text_height;
if (minimum_baseline || natural_baseline)
{
baseline = pango_layout_get_baseline (layout) / PANGO_SCALE;
*minimum_baseline = baseline;
*natural_baseline = baseline;
}
baseline = pango_layout_get_baseline (layout) / PANGO_SCALE;
*minimum_baseline = baseline;
*natural_baseline = baseline;
g_object_unref (layout);
}
@ -3724,42 +3594,11 @@ gtk_label_get_preferred_size (GtkWidget *widget,
gint *natural_baseline)
{
GtkLabel *label = GTK_LABEL (widget);
GtkLabelPrivate *priv = label->priv;
PangoRectangle widest_rect;
PangoRectangle smallest_rect;
gtk_label_get_preferred_layout_size (label, &smallest_rect, &widest_rect);
/* Now that we have minimum and natural sizes in pango extents, apply a possible transform */
if (priv->have_transform)
{
PangoContext *context;
const PangoMatrix *matrix;
context = pango_layout_get_context (priv->layout);
matrix = pango_context_get_matrix (context);
pango_matrix_transform_rectangle (matrix, &widest_rect);
pango_matrix_transform_rectangle (matrix, &smallest_rect);
/* Bump the size in case of ellipsize to ensure pango has
* enough space in the angles (note, we could alternatively set the
* layout to not ellipsize when we know we have been allocated our
* full size, or it may be that pango needs a fix here).
*/
if (priv->ellipsize && priv->angle != 0 && priv->angle != 90 &&
priv->angle != 180 && priv->angle != 270 && priv->angle != 360)
{
/* For some reason we only need this at about 110 degrees, and only
* when gaining in height
*/
widest_rect.height += ROTATION_ELLIPSIZE_PADDING * 2 * PANGO_SCALE;
widest_rect.width += ROTATION_ELLIPSIZE_PADDING * 2 * PANGO_SCALE;
smallest_rect.height += ROTATION_ELLIPSIZE_PADDING * 2 * PANGO_SCALE;
smallest_rect.width += ROTATION_ELLIPSIZE_PADDING * 2 * PANGO_SCALE;
}
}
widest_rect.width = PANGO_PIXELS_CEIL (widest_rect.width);
widest_rect.height = PANGO_PIXELS_CEIL (widest_rect.height);
@ -3768,27 +3607,9 @@ gtk_label_get_preferred_size (GtkWidget *widget,
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
/* Note, we cant use get_size_for_allocation() when rotating
* ellipsized labels.
*/
if (!(priv->ellipsize && priv->have_transform) &&
(priv->angle == 90 || priv->angle == 270))
{
/* Doing a h4w request on a rotated label here, return the
* required width for the minimum height.
*/
get_size_for_allocation (label,
smallest_rect.height,
minimum_size, natural_size,
NULL, NULL);
}
else
{
/* Normal desired width */
*minimum_size = smallest_rect.width;
*natural_size = widest_rect.width;
}
/* Normal desired width */
*minimum_size = smallest_rect.width;
*natural_size = widest_rect.width;
if (minimum_baseline)
*minimum_baseline = -1;
@ -3798,36 +3619,8 @@ gtk_label_get_preferred_size (GtkWidget *widget,
}
else /* GTK_ORIENTATION_VERTICAL */
{
/* Note, we cant use get_size_for_allocation() when rotating
* ellipsized labels.
*/
if (!(priv->ellipsize && priv->have_transform) &&
(priv->angle == 0 || priv->angle == 180 || priv->angle == 360))
{
/* Doing a w4h request on a label here, return the required
* height for the minimum width.
*/
get_size_for_allocation (label,
widest_rect.width,
minimum_size, natural_size,
minimum_baseline, natural_baseline);
if (priv->angle == 180)
{
if (minimum_baseline)
*minimum_baseline = *minimum_size - *minimum_baseline;
if (natural_baseline)
*natural_baseline = *natural_size - *natural_baseline;
}
}
else
{
/* A vertically rotated label does w4h, so return the base
* desired height (text length)
*/
*minimum_size = MIN (smallest_rect.height, widest_rect.height);
*natural_size = MAX (smallest_rect.height, widest_rect.height);
}
*minimum_size = MIN (smallest_rect.height, widest_rect.height);
*natural_size = MAX (smallest_rect.height, widest_rect.height);
}
}
@ -3849,12 +3642,11 @@ gtk_label_measure (GtkCssGadget *gadget,
label = GTK_LABEL (widget);
priv = label->priv;
if ((orientation == GTK_ORIENTATION_VERTICAL && for_size != -1 && priv->wrap && (priv->angle == 0 || priv->angle == 180 || priv->angle == 360)) ||
(orientation == GTK_ORIENTATION_HORIZONTAL && priv->wrap && (priv->angle == 90 || priv->angle == 270)))
if (orientation == GTK_ORIENTATION_VERTICAL && for_size != -1 && priv->wrap)
{
gtk_label_clear_layout (label);
get_size_for_allocation (label, for_size, minimum, natural, minimum_baseline, natural_baseline);
get_height_for_width (label, for_size, minimum, natural, minimum_baseline, natural_baseline);
}
else
gtk_label_get_preferred_size (widget, orientation, minimum, natural, minimum_baseline, natural_baseline);
@ -3901,13 +3693,6 @@ get_layout_location (GtkLabel *label,
pango_layout_get_extents (priv->layout, NULL, &logical);
if (priv->have_transform)
{
PangoContext *context = gtk_widget_get_pango_context (widget);
const PangoMatrix *matrix = pango_context_get_matrix (context);
pango_matrix_transform_rectangle (matrix, &logical);
}
pango_extents_to_pixels (&logical, NULL);
req_width = logical.width;
@ -3920,7 +3705,7 @@ get_layout_location (GtkLabel *label,
x = floor (allocation.x + xalign * (allocation.width - req_width) - logical.x);
baseline_offset = 0;
if (baseline != -1 && !priv->have_transform)
if (baseline != -1)
{
layout_baseline = pango_layout_get_baseline (priv->layout) / PANGO_SCALE;
baseline_offset = baseline - layout_baseline;
@ -5465,66 +5250,6 @@ gtk_label_get_selectable (GtkLabel *label)
return priv->select_info && priv->select_info->selectable;
}
/**
* gtk_label_set_angle:
* @label: a #GtkLabel
* @angle: the angle that the baseline of the label makes with
* the horizontal, in degrees, measured counterclockwise
*
* Sets the angle of rotation for the label. An angle of 90 reads from
* from bottom to top, an angle of 270, from top to bottom. The angle
* setting for the label is ignored if the label is selectable,
* wrapped, or ellipsized.
*
* Since: 2.6
**/
void
gtk_label_set_angle (GtkLabel *label,
gdouble angle)
{
GtkLabelPrivate *priv;
g_return_if_fail (GTK_IS_LABEL (label));
priv = label->priv;
/* Canonicalize to [0,360]. We don't canonicalize 360 to 0, because
* double property ranges are inclusive, and changing 360 to 0 would
* make a property editor behave strangely.
*/
if (angle < 0 || angle > 360.0)
angle = angle - 360. * floor (angle / 360.);
if (priv->angle != angle)
{
priv->angle = angle;
gtk_label_clear_layout (label);
gtk_widget_queue_resize (GTK_WIDGET (label));
g_object_notify_by_pspec (G_OBJECT (label), label_props[PROP_ANGLE]);
}
}
/**
* gtk_label_get_angle:
* @label: a #GtkLabel
*
* Gets the angle of rotation for the label. See
* gtk_label_set_angle().
*
* Returns: the angle of rotation for the label
*
* Since: 2.6
**/
gdouble
gtk_label_get_angle (GtkLabel *label)
{
g_return_val_if_fail (GTK_IS_LABEL (label), 0.0);
return label->priv->angle;
}
static void
gtk_label_set_selection_text (GtkLabel *label,
GtkSelectionData *selection_data)

View File

@ -177,11 +177,6 @@ void gtk_label_set_selectable (GtkLabel *label,
GDK_AVAILABLE_IN_ALL
gboolean gtk_label_get_selectable (GtkLabel *label);
GDK_AVAILABLE_IN_ALL
void gtk_label_set_angle (GtkLabel *label,
gdouble angle);
GDK_AVAILABLE_IN_ALL
gdouble gtk_label_get_angle (GtkLabel *label);
GDK_AVAILABLE_IN_ALL
void gtk_label_select_region (GtkLabel *label,
gint start_offset,
gint end_offset);

View File

@ -422,7 +422,6 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
{
gfloat align;
gtk_label_set_angle (GTK_LABEL (label), 0);
align = gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button));
if (align < 0.4)
gtk_widget_set_halign (label, GTK_ALIGN_START);
@ -436,10 +435,6 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
gfloat align;
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_NONE);
if (gtk_widget_get_direction (GTK_WIDGET (tool_item)) == GTK_TEXT_DIR_RTL)
gtk_label_set_angle (GTK_LABEL (label), -90);
else
gtk_label_set_angle (GTK_LABEL (label), 90);
align = gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button));
if (align < 0.4)
gtk_widget_set_valign (label, GTK_ALIGN_END);

View File

@ -335,10 +335,8 @@ gtk_tool_item_group_header_adjust_style (GtkToolItemGroup *group)
{
GtkWidget *frame = gtk_bin_get_child (GTK_BIN (group->priv->header));
GtkWidget *label_widget = gtk_bin_get_child (GTK_BIN (frame));
GtkWidget *widget = GTK_WIDGET (group);
GtkToolItemGroupPrivate* priv = group->priv;
gint dx = 0, dy = 0;
GtkTextDirection direction = gtk_widget_get_direction (widget);
switch (gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group)))
{
@ -348,10 +346,6 @@ gtk_tool_item_group_header_adjust_style (GtkToolItemGroup *group)
if (GTK_IS_LABEL (label_widget))
{
gtk_label_set_ellipsize (GTK_LABEL (label_widget), PANGO_ELLIPSIZE_NONE);
if (GTK_TEXT_DIR_RTL == direction)
gtk_label_set_angle (GTK_LABEL (label_widget), -90);
else
gtk_label_set_angle (GTK_LABEL (label_widget), 90);
}
break;
@ -361,7 +355,6 @@ gtk_tool_item_group_header_adjust_style (GtkToolItemGroup *group)
if (GTK_IS_LABEL (label_widget))
{
gtk_label_set_ellipsize (GTK_LABEL (label_widget), priv->ellipsize);
gtk_label_set_angle (GTK_LABEL (label_widget), 0);
}
break;
}

View File

@ -24,7 +24,6 @@ static GtkWidget *test_window;
enum {
TEST_WIDGET_LABEL,
TEST_WIDGET_VERTICAL_LABEL,
TEST_WIDGET_WRAP_LABEL,
TEST_WIDGET_IMAGE,
TEST_WIDGET_BUTTON,
@ -41,16 +40,12 @@ create_image (void)
}
static GtkWidget*
create_label (gboolean vertical,
gboolean wrap)
create_label (gboolean wrap)
{
GtkWidget *widget;
widget = gtk_label_new ("This is a label, label label label");
if (vertical)
gtk_label_set_angle (GTK_LABEL (widget), 90);
if (wrap)
gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
@ -78,9 +73,8 @@ open_test_window (void)
gtk_window_set_resizable (GTK_WINDOW (test_window), FALSE);
test_widgets[TEST_WIDGET_IMAGE] = create_image ();
test_widgets[TEST_WIDGET_LABEL] = create_label (FALSE, FALSE);
test_widgets[TEST_WIDGET_VERTICAL_LABEL] = create_label (TRUE, FALSE);
test_widgets[TEST_WIDGET_WRAP_LABEL] = create_label (FALSE, TRUE);
test_widgets[TEST_WIDGET_LABEL] = create_label (FALSE);
test_widgets[TEST_WIDGET_WRAP_LABEL] = create_label (TRUE);
test_widgets[TEST_WIDGET_BUTTON] = create_button ();
grid = gtk_grid_new ();

View File

@ -55,10 +55,8 @@ static void
scale_changed_cb (GtkRange *range,
gpointer data)
{
double angle = gtk_range_get_value (range);
GtkWidget *label = GTK_WIDGET (data);
gtk_label_set_angle (GTK_LABEL (label), angle);
redraw_event_box (label);
}

View File

@ -35,7 +35,6 @@ enum {
static GtkFlowBox *the_flowbox = NULL;
static gint items_type = SIMPLE_ITEMS;
static GtkOrientation text_orientation = GTK_ORIENTATION_HORIZONTAL;
static void
populate_flowbox_simple (GtkFlowBox *flowbox)
@ -54,8 +53,6 @@ populate_flowbox_simple (GtkFlowBox *flowbox)
gtk_container_add (GTK_CONTAINER (frame), widget);
if (text_orientation == GTK_ORIENTATION_VERTICAL)
gtk_label_set_angle (GTK_LABEL (widget), 90);
g_object_set_data_full (G_OBJECT (frame), "id", (gpointer)g_strdup (text), g_free);
gtk_container_add (GTK_CONTAINER (flowbox), frame);
@ -148,9 +145,6 @@ populate_flowbox_wrappy (GtkFlowBox *flowbox)
gtk_widget_show (widget);
gtk_widget_show (frame);
if (text_orientation == GTK_ORIENTATION_VERTICAL)
gtk_label_set_angle (GTK_LABEL (widget), 90);
gtk_container_add (GTK_CONTAINER (frame), widget);
gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
@ -184,9 +178,6 @@ populate_flowbox_images (GtkFlowBox *flowbox)
gtk_container_add (GTK_CONTAINER (widget), image);
gtk_container_add (GTK_CONTAINER (widget), label);
if (text_orientation == GTK_ORIENTATION_VERTICAL)
gtk_label_set_angle (GTK_LABEL (widget), 90);
g_object_set_data_full (G_OBJECT (widget), "id", (gpointer)g_strdup (text), g_free);
gtk_container_add (GTK_CONTAINER (flowbox), widget);
@ -297,15 +288,6 @@ items_changed (GtkComboBox *box,
populate_items (flowbox);
}
static void
text_orientation_changed (GtkComboBox *box,
GtkFlowBox *flowbox)
{
text_orientation = gtk_combo_box_get_active (box);
populate_items (flowbox);
}
static void
homogeneous_toggled (GtkToggleButton *button,
GtkFlowBox *flowbox)
@ -634,20 +616,6 @@ create_window (void)
g_signal_connect (G_OBJECT (widget), "changed",
G_CALLBACK (items_changed), flowbox);
/* Add Text Orientation control */
widget = gtk_combo_box_text_new ();
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
gtk_widget_show (widget);
gtk_widget_set_tooltip_text (widget, "Set the item's text orientation");
gtk_box_pack_start (GTK_BOX (items_cntl), widget);
g_signal_connect (G_OBJECT (widget), "changed",
G_CALLBACK (text_orientation_changed), flowbox);
populate_items (GTK_FLOW_BOX (flowbox));
/* This line was added only for the convenience of reproducing

View File

@ -1,7 +1,7 @@
#include <gtk/gtk.h>
static GtkWidget *
oriented_test_widget (const gchar *label, const gchar *color, gdouble angle)
oriented_test_widget (const gchar *label, const gchar *color)
{
GtkWidget *box;
GtkWidget *widget;
@ -9,7 +9,6 @@ oriented_test_widget (const gchar *label, const gchar *color, gdouble angle)
gchar *data;
widget = gtk_label_new (label);
gtk_label_set_angle (GTK_LABEL (widget), angle);
box = gtk_event_box_new ();
provider = gtk_css_provider_new ();
data = g_strdup_printf ("GtkEventBox { background-color: %s; }", color);
@ -27,7 +26,7 @@ oriented_test_widget (const gchar *label, const gchar *color, gdouble angle)
static GtkWidget *
test_widget (const gchar *label, const gchar *color)
{
return oriented_test_widget (label, color, 0.0);
return oriented_test_widget (label, color);
}
static GtkOrientation o;
@ -262,7 +261,7 @@ scrolling (void)
gtk_container_add (GTK_CONTAINER (sw), viewport);
gtk_container_add (GTK_CONTAINER (viewport), grid);
child = oriented_test_widget ("#800080", "#800080", -45.0);
child = oriented_test_widget ("#800080", "#800080");
gtk_grid_attach (GTK_GRID (grid), child, 0, 0, 1, 1);
gtk_widget_set_hexpand (child, TRUE);
gtk_widget_set_vexpand (child, TRUE);
@ -281,7 +280,7 @@ scrolling (void)
{
gchar *color;
color = g_strdup_printf ("#%02x00%02x", 128 - 8*i, 128 + 8*i);
child = oriented_test_widget (color, color, -90.0);
child = oriented_test_widget (color, color);
gtk_grid_attach (GTK_GRID (grid), child, i, 0, 1, i);
gtk_widget_set_vexpand (child, TRUE);
g_free (color);

View File

@ -1371,73 +1371,6 @@ void create_labels (GtkWidget *widget)
gtk_widget_destroy (window);
}
static void
on_angle_scale_changed (GtkRange *range,
GtkLabel *label)
{
gtk_label_set_angle (GTK_LABEL (label), gtk_range_get_value (range));
}
static void
create_rotated_label (GtkWidget *widget)
{
static GtkWidget *window = NULL;
GtkWidget *content_area;
GtkWidget *vbox;
GtkWidget *hscale;
GtkWidget *label;
GtkWidget *scale_label;
GtkWidget *scale_hbox;
if (!window)
{
window = gtk_dialog_new_with_buttons ("Rotated Label",
GTK_WINDOW (gtk_widget_get_toplevel (widget)), 0,
"_Close", GTK_RESPONSE_CLOSE,
NULL);
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_window_set_screen (GTK_WINDOW (window),
gtk_widget_get_screen (widget));
g_signal_connect (window, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_box_pack_start (GTK_BOX (content_area), vbox);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label), "Hello World\n<i>Rotate</i> <span underline='single' foreground='blue'>me</span>");
gtk_box_pack_start (GTK_BOX (vbox), label);
scale_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start (GTK_BOX (vbox), scale_hbox);
scale_label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (scale_label), "<i>Angle: </i>");
gtk_box_pack_start (GTK_BOX (scale_hbox), scale_label);
hscale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
0, 360, 5);
g_signal_connect (hscale, "value-changed",
G_CALLBACK (on_angle_scale_changed), label);
gtk_range_set_value (GTK_RANGE (hscale), 45);
gtk_widget_set_size_request (hscale, 200, -1);
gtk_box_pack_start (GTK_BOX (scale_hbox), hscale);
}
if (!gtk_widget_get_visible (window))
gtk_widget_show (window);
else
gtk_widget_destroy (window);
}
#define DEFAULT_TEXT_RADIUS 200
static void
@ -8637,7 +8570,6 @@ struct {
{ "radio buttons", create_radio_buttons },
{ "range controls", create_range_controls },
{ "reparent", create_reparent },
{ "rotated label", create_rotated_label },
{ "rotated text", create_rotated_text },
{ "saved position", create_saved_position },
{ "scrolled windows", create_scrolled_windows },

View File

@ -19,18 +19,6 @@ vertical_policy_changed (GtkComboBox *combo_box,
gtk_scrollable_set_vscroll_policy (GTK_SCROLLABLE (viewport), policy);
}
static void
label_flip_changed (GtkComboBox *combo_box,
GtkLabel *label)
{
gint active = gtk_combo_box_get_active (combo_box);
if (active == 0)
gtk_label_set_angle (label, 0.0);
else
gtk_label_set_angle (label, 90.0);
}
static void
content_width_changed (GtkSpinButton *spin_button,
gpointer data)
@ -215,26 +203,6 @@ scrollable_policy (void)
g_signal_connect (G_OBJECT (widget), "value-changed",
G_CALLBACK (content_height_changed), swindow);
/* Add Label orientation control here */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
gtk_widget_show (hbox);
widget = gtk_label_new ("label-flip");
gtk_widget_set_hexpand (widget, TRUE);
gtk_box_pack_start (GTK_BOX (hbox), widget);
widget = gtk_combo_box_text_new ();
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
gtk_widget_set_hexpand (widget, TRUE);
gtk_box_pack_start (GTK_BOX (hbox), widget);
gtk_box_pack_start (GTK_BOX (cntl), hbox);
g_signal_connect (G_OBJECT (widget), "changed",
G_CALLBACK (label_flip_changed), label);
/* Add Kinetic scrolling control here */
widget = gtk_check_button_new_with_label ("Kinetic scrolling");
gtk_widget_set_hexpand (widget, TRUE);

View File

@ -50,7 +50,6 @@ cat << EOF
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">$hexpand</property>
<property name="angle">90</property>
</object>
<packing>
<property name="left_attach">$y</property>
@ -64,7 +63,6 @@ cat << EOF
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">$halign</property>
<property name="angle">90</property>
</object>
<packing>
<property name="left_attach">$y</property>

View File

@ -20,7 +20,6 @@
<object class="GtkLabel" id="one">
<property name="visible">True</property>
<property name="label">One</property>
<property name="angle">90</property>
</object>
<packing>
<property name="position">0</property>
@ -30,7 +29,6 @@
<object class="GtkLabel" id="two">
<property name="visible">True</property>
<property name="label">Two</property>
<property name="angle">90</property>
</object>
<packing>
<property name="position">1</property>
@ -40,7 +38,6 @@
<object class="GtkLabel" id="three">
<property name="visible">True</property>
<property name="label">Three</property>
<property name="angle">90</property>
</object>
<packing>
<property name="position">2</property>
@ -61,7 +58,6 @@
<object class="GtkLabel" id="long">
<property name="visible">True</property>
<property name="label">Verylongtext</property>
<property name="angle">90</property>
</object>
<packing>
<property name="position">0</property>
@ -71,7 +67,6 @@
<object class="GtkLabel" id="short">
<property name="visible">True</property>
<property name="label">Short</property>
<property name="angle">90</property>
</object>
<packing>
<property name="position">1</property>
@ -90,7 +85,6 @@
<object class="GtkLabel" id="a">
<property name="visible">True</property>
<property name="label">A</property>
<property name="angle">90</property>
</object>
<packing>
<property name="position">0</property>
@ -100,7 +94,6 @@
<object class="GtkLabel" id="b">
<property name="visible">True</property>
<property name="label">B</property>
<property name="angle">90</property>
</object>
<packing>
<property name="position">1</property>
@ -110,7 +103,6 @@
<object class="GtkLabel" id="c">
<property name="visible">True</property>
<property name="label">C</property>
<property name="angle">90</property>
</object>
<packing>
<property name="position">2</property>

View File

@ -18,7 +18,6 @@
<object class="GtkLabel" id="one">
<property name="visible">True</property>
<property name="label">One</property>
<property name="angle">90</property>
</object>
<packing>
<property name="left_attach">0</property>
@ -29,7 +28,6 @@
<object class="GtkLabel" id="two">
<property name="visible">True</property>
<property name="label">Two</property>
<property name="angle">90</property>
</object>
<packing>
<property name="left_attach">0</property>
@ -40,7 +38,6 @@
<object class="GtkLabel" id="three">
<property name="visible">True</property>
<property name="label">Three</property>
<property name="angle">90</property>
</object>
<packing>
<property name="left_attach">0</property>
@ -63,7 +60,6 @@
<object class="GtkLabel" id="long">
<property name="visible">True</property>
<property name="label">Verylongtext</property>
<property name="angle">90</property>
</object>
<packing>
<property name="left_attach">0</property>
@ -74,7 +70,6 @@
<object class="GtkLabel" id="short">
<property name="visible">True</property>
<property name="label">Short</property>
<property name="angle">90</property>
</object>
<packing>
<property name="left_attach">0</property>
@ -96,7 +91,6 @@
<object class="GtkLabel" id="a">
<property name="visible">True</property>
<property name="label">A</property>
<property name="angle">90</property>
</object>
<packing>
<property name="left_attach">0</property>
@ -108,7 +102,6 @@
<property name="visible">True</property>
<property name="label">B</property>
<property name="vexpand">True</property>
<property name="angle">90</property>
</object>
<packing>
<property name="left_attach">0</property>
@ -119,7 +112,6 @@
<object class="GtkLabel" id="c">
<property name="visible">True</property>
<property name="label">C</property>
<property name="angle">90</property>
</object>
<packing>
<property name="left_attach">0</property>

View File

@ -56,7 +56,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">ABC</property>
<property name="angle">90</property>
<attributes>
<attribute name="foreground" value="#ffff00000000"/>
</attributes>
@ -74,7 +73,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">ABC</property>
<property name="angle">90</property>
<style>
<class name="no-shadow" />
</style>
@ -97,7 +95,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">ABC</property>
<property name="angle">180</property>
<attributes>
<attribute name="foreground" value="#ffff00000000"/>
</attributes>
@ -115,7 +112,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">ABC</property>
<property name="angle">180</property>
<style>
<class name="no-shadow" />
</style>
@ -138,7 +134,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">ABC</property>
<property name="angle">270</property>
<attributes>
<attribute name="foreground" value="#ffff00000000"/>
</attributes>
@ -156,7 +151,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">ABC</property>
<property name="angle">270</property>
<style>
<class name="no-shadow" />
</style>

View File

@ -30,7 +30,6 @@
<property name="halign">start</property>
<property name="valign">start</property>
<property name="label" translatable="yes">ABC</property>
<property name="angle">90</property>
</object>
<packing>
<property name="left_attach">1</property>
@ -46,7 +45,6 @@
<property name="halign">start</property>
<property name="valign">start</property>
<property name="label" translatable="yes">ABC</property>
<property name="angle">180</property>
</object>
<packing>
<property name="left_attach">1</property>
@ -62,7 +60,6 @@
<property name="halign">start</property>
<property name="valign">start</property>
<property name="label" translatable="yes">ABC</property>
<property name="angle">270</property>
</object>
<packing>
<property name="left_attach">0</property>

View File

@ -26,7 +26,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
<property name="angle">90</property>
</object>
<packing>
<property name="left_attach">1</property>

View File

@ -13,7 +13,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
<property name="angle">90</property>
</object>
<packing>
<property name="left_attach">1</property>