[gtk+/wip/css: 26/97] label: Don't use gtk_widget_get_pango_context()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/css: 26/97] label: Don't use gtk_widget_get_pango_context()
- Date: Mon, 2 Jan 2012 14:55:39 +0000 (UTC)
commit 08116d4ed291ea00aa3e56f222e0a69014173ca7
Author: Benjamin Otte <otte redhat com>
Date: Thu Dec 29 21:53:25 2011 +0100
label: Don't use gtk_widget_get_pango_context()
Instead, create a new context. This avoids GtkWidget updating the
context all the time on style changes and only "updates" it when we
create the PangoLayout.
gtk/gtklabel.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 589f20a..0382a03 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3271,7 +3271,6 @@ static void
gtk_label_update_layout_width (GtkLabel *label)
{
GtkLabelPrivate *priv = label->priv;
- GtkWidget *widget = GTK_WIDGET (label);
g_assert (priv->layout);
@@ -3288,7 +3287,7 @@ gtk_label_update_layout_width (GtkLabel *label)
if (priv->have_transform)
{
- PangoContext *context = gtk_widget_get_pango_context (widget);
+ PangoContext *context = pango_layout_get_context (priv->layout);
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) */
@@ -3372,8 +3371,10 @@ gtk_label_ensure_layout (GtkLabel *label)
if (!priv->layout)
{
PangoAlignment align = PANGO_ALIGN_LEFT; /* Quiet gcc */
+ PangoContext *context;
gdouble angle = gtk_label_get_angle (label);
+ context = gtk_widget_create_pango_context (widget);
if (angle != 0.0 && !priv->select_info)
{
PangoMatrix matrix = PANGO_MATRIX_INIT;
@@ -3384,19 +3385,20 @@ gtk_label_ensure_layout (GtkLabel *label)
*/
pango_matrix_rotate (&matrix, angle);
- pango_context_set_matrix (gtk_widget_get_pango_context (widget), &matrix);
+ pango_context_set_matrix (context, &matrix);
priv->have_transform = TRUE;
}
else
{
if (priv->have_transform)
- pango_context_set_matrix (gtk_widget_get_pango_context (widget), NULL);
+ pango_context_set_matrix (context, NULL);
priv->have_transform = FALSE;
}
- priv->layout = gtk_widget_create_pango_layout (widget, priv->text);
+ priv->layout = pango_layout_new (context);
+ g_object_unref (context);
if (priv->effective_attrs)
pango_layout_set_attributes (priv->layout, priv->effective_attrs);
@@ -3422,6 +3424,7 @@ gtk_label_ensure_layout (GtkLabel *label)
g_assert_not_reached();
}
+ pango_layout_set_text (priv->layout, priv->text, -1);
pango_layout_set_alignment (priv->layout, align);
pango_layout_set_ellipsize (priv->layout, priv->ellipsize);
pango_layout_set_wrap (priv->layout, priv->wrap_mode);
@@ -3910,7 +3913,7 @@ get_layout_location (GtkLabel *label,
if (priv->have_transform)
{
- PangoContext *context = gtk_widget_get_pango_context (widget);
+ PangoContext *context = pango_layout_get_context (priv->layout);
const PangoMatrix *matrix = pango_context_get_matrix (context);
pango_matrix_transform_rectangle (matrix, &logical);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]