From 232919a16d95cf1351a11e1e3ee6f82e3218378b Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Wed, 30 May 2012 01:23:27 +0200 Subject: [PATCH] GeanyWrapLabel: make sure we ask for the height matching our width With this patch, we make sure the height we query is the one matching the width we stored and not a newer or older one. This only fixes the sizing problem, the rendering issue visible in some situations is still present. This fix is replicated from the fix in libview's WrapLabel, see http://view.svn.sourceforge.net/viewvc/view/trunk/libview/libview/wrapLabel.cc?revision=132&view=markup It also includes the "fix for the fix", http://view.svn.sourceforge.net/viewvc/view/trunk/libview/libview/wrapLabel.cc?revision=135&view=markup --- src/geanywraplabel.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/geanywraplabel.c b/src/geanywraplabel.c index 6ab4a79a..738e0731 100644 --- a/src/geanywraplabel.c +++ b/src/geanywraplabel.c @@ -42,6 +42,7 @@ struct _GeanyWrapLabelClass typedef struct { gint wrap_width; + gint wrap_height; } GeanyWrapLabelPrivate; struct _GeanyWrapLabel @@ -79,6 +80,7 @@ static void geany_wrap_label_init(GeanyWrapLabel *self) priv = self->priv; priv->wrap_width = 0; + priv->wrap_height = 0; g_signal_connect(self, "notify::label", G_CALLBACK(geany_wrap_label_label_notify), NULL); pango_layout_set_wrap(gtk_label_get_layout(GTK_LABEL(self)), PANGO_WRAP_WORD_CHAR); @@ -90,17 +92,21 @@ static void geany_wrap_label_init(GeanyWrapLabel *self) static void geany_wrap_label_set_wrap_width(GtkWidget *widget, gint width) { GeanyWrapLabelPrivate *priv; + PangoLayout *layout; if (width <= 0) return; + priv = GEANY_WRAP_LABEL_GET_PRIVATE(widget); + layout = gtk_label_get_layout(GTK_LABEL(widget)); + /* * We may need to reset the wrap width, so do this regardless of whether * or not we've changed the width. */ - pango_layout_set_width(gtk_label_get_layout(GTK_LABEL(widget)), width * PANGO_SCALE); + pango_layout_set_width(layout, width * PANGO_SCALE); + pango_layout_get_pixel_size(layout, NULL, &priv->wrap_height); - priv = GEANY_WRAP_LABEL_GET_PRIVATE(widget); if (priv->wrap_width != width) { priv->wrap_width = width; @@ -122,12 +128,8 @@ static void geany_wrap_label_label_notify(GObject *object, GParamSpec *pspec, gp * width to be flexible. */ static void geany_wrap_label_size_request(GtkWidget *widget, GtkRequisition *req) { - gint height; - - pango_layout_get_pixel_size(gtk_label_get_layout(GTK_LABEL(widget)), NULL, &height); - - req->width = 0; - req->height = height; + req->width = 0; + req->height = GEANY_WRAP_LABEL_GET_PRIVATE(widget)->wrap_height; }