[geany/geany] 232919: GeanyWrapLabel: make sure we ask for the height matching our width

Colomban Wendling git-noreply at xxxxx
Tue May 29 23:44:49 UTC 2012


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Tue, 29 May 2012 23:44:49
Commit:      232919a16d95cf1351a11e1e3ee6f82e3218378b
             https://github.com/geany/geany/commit/232919a16d95cf1351a11e1e3ee6f82e3218378b

Log Message:
-----------
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


Modified Paths:
--------------
    src/geanywraplabel.c

Modified: src/geanywraplabel.c
18 files changed, 10 insertions(+), 8 deletions(-)
===================================================================
@@ -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;
 }
 
 


@@ Diff output truncated at 100000 characters. @@


--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).



More information about the Commits mailing list