[gtk+/rendering-cleanup] label: Make angle part of GtkLabelPrivate
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup] label: Make angle part of GtkLabelPrivate
- Date: Sat, 7 Aug 2010 00:19:44 +0000 (UTC)
commit 01eaf5c01567df79194d63c794d1dec983a1fe0b
Author: Benjamin Otte <otte redhat com>
Date: Sat Aug 7 01:06:29 2010 +0200
label: Make angle part of GtkLabelPrivate
gtk/gtklabel.c | 55 +++++++++++++------------------------------------------
1 files changed, 13 insertions(+), 42 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 20ec39e..9caa49e 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -85,6 +85,8 @@ struct _GtkLabelPriv
gint wrap_width;
gint width_chars;
gint max_width_chars;
+
+ gdouble angle;
};
/* Notes about the handling of links:
@@ -346,8 +348,6 @@ static void gtk_label_get_height_for_width (GtkSizeRequest *
gint *minimum_height,
gint *natural_height);
-static GQuark quark_angle = 0;
-
static GtkBuildableIface *buildable_parent_iface = NULL;
G_DEFINE_TYPE_WITH_CODE (GtkLabel, gtk_label, GTK_TYPE_MISC,
@@ -387,8 +387,6 @@ gtk_label_class_init (GtkLabelClass *class)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GtkBindingSet *binding_set;
- quark_angle = g_quark_from_static_string ("angle");
-
gobject_class->set_property = gtk_label_set_property;
gobject_class->get_property = gtk_label_get_property;
gobject_class->finalize = gtk_label_finalize;
@@ -3420,7 +3418,6 @@ gtk_label_get_size (GtkSizeRequest *widget,
GtkLabelPriv *priv = label->priv;
PangoRectangle required_rect;
PangoRectangle natural_rect;
- gdouble angle;
gint xpad, ypad;
/* "width-chars" Hard-coded minimum width:
@@ -3439,8 +3436,6 @@ gtk_label_get_size (GtkSizeRequest *widget,
gtk_label_clear_layout (label);
gtk_label_ensure_layout (label, TRUE);
- angle = gtk_label_get_angle (label);
-
/* Start off with the pixel extents of the rendered layout */
pango_layout_get_extents (priv->layout, NULL, &required_rect);
required_rect.x = required_rect.y = 0;
@@ -3474,7 +3469,8 @@ gtk_label_get_size (GtkSizeRequest *widget,
* layout to not ellipsize when we know we have been allocated our
* full natural size, or it may be that pango needs a fix here).
*/
- if (priv->ellipsize && angle != 0 && angle != 90 && angle != 180 && angle != 270 && angle != 360)
+ 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
@@ -3498,7 +3494,7 @@ gtk_label_get_size (GtkSizeRequest *widget,
* ellipsized labels.
*/
if (!(priv->ellipsize && priv->have_transform) &&
- (angle == 90 || angle == 270))
+ (priv->angle == 90 || priv->angle == 270))
{
/* Doing a h4w request on a rotated label here, return the
* required width for the minimum height.
@@ -3525,7 +3521,7 @@ gtk_label_get_size (GtkSizeRequest *widget,
* ellipsized labels.
*/
if (!(priv->ellipsize && priv->have_transform) &&
- (angle == 0 || angle == 180))
+ (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.
@@ -3584,9 +3580,8 @@ gtk_label_get_width_for_height (GtkSizeRequest *widget,
{
GtkLabel *label = GTK_LABEL (widget);
GtkLabelPriv *priv = label->priv;
- gdouble angle = gtk_label_get_angle (label);
- if (priv->wrap && (angle == 90 || angle == 270))
+ if (priv->wrap && (priv->angle == 90 || priv->angle == 270))
{
gint xpad, ypad;
@@ -3617,9 +3612,8 @@ gtk_label_get_height_for_width (GtkSizeRequest *widget,
{
GtkLabel *label = GTK_LABEL (widget);
GtkLabelPriv *priv = label->priv;
- gdouble angle = gtk_label_get_angle (label);
- if (priv->wrap && (angle == 0 || angle == 180 || angle == 360))
+ if (priv->wrap && (priv->angle == 0 || priv->angle == 180 || priv->angle == 360))
{
gint xpad, ypad;
@@ -3837,12 +3831,10 @@ get_layout_location (GtkLabel *label,
gint xpad, ypad;
gfloat xalign, yalign;
PangoRectangle logical;
- gdouble angle;
misc = GTK_MISC (label);
widget = GTK_WIDGET (label);
priv = label->priv;
- angle = gtk_label_get_angle (label);
gtk_misc_get_alignment (misc, &xalign, &yalign);
gtk_misc_get_padding (misc, &xpad, &ypad);
@@ -5219,12 +5211,6 @@ gtk_label_get_selectable (GtkLabel *label)
return priv->select_info && priv->select_info->selectable;
}
-static void
-free_angle (gpointer angle)
-{
- g_slice_free (gdouble, angle);
-}
-
/**
* gtk_label_set_angle:
* @label: a #GtkLabel
@@ -5242,20 +5228,12 @@ void
gtk_label_set_angle (GtkLabel *label,
gdouble angle)
{
- gdouble *label_angle;
+ GtkLabelPriv *priv;
g_return_if_fail (GTK_IS_LABEL (label));
- label_angle = (gdouble *)g_object_get_qdata (G_OBJECT (label), quark_angle);
+ priv = label->priv;
- if (!label_angle)
- {
- label_angle = g_slice_new (gdouble);
- *label_angle = 0.0;
- g_object_set_qdata_full (G_OBJECT (label), quark_angle,
- label_angle, free_angle);
- }
-
/* 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.
@@ -5263,9 +5241,9 @@ gtk_label_set_angle (GtkLabel *label,
if (angle < 0 || angle > 360.0)
angle = angle - 360. * floor (angle / 360.);
- if (*label_angle != angle)
+ if (priv->angle != angle)
{
- *label_angle = angle;
+ priv->angle = angle;
gtk_label_clear_layout (label);
gtk_widget_queue_resize (GTK_WIDGET (label));
@@ -5288,16 +5266,9 @@ gtk_label_set_angle (GtkLabel *label,
gdouble
gtk_label_get_angle (GtkLabel *label)
{
- gdouble *angle;
-
g_return_val_if_fail (GTK_IS_LABEL (label), 0.0);
- angle = (gdouble *)g_object_get_qdata (G_OBJECT (label), quark_angle);
-
- if (angle)
- return *angle;
- else
- return 0.0;
+ return label->priv->angle;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]