[geany/geany] c84d48: GeanyWrapLabel: fix rendering issues

Colomban Wendling git-noreply at xxxxx
Tue May 29 23:50:08 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:50:08
Commit:      c84d486472c19ae388fc068b82bd12c6e470fe7d
             https://github.com/geany/geany/commit/c84d486472c19ae388fc068b82bd12c6e470fe7d

Log Message:
-----------
GeanyWrapLabel: fix rendering issues

GtkLabel may re-create its PangoLayout between calls leading to the
final layout used for rendering not to be set up with the appropriate
values for our sizing.  Then, re-set up the layout each time we have to
deal with it and straight before GtkLabel renders it.


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

Modified: src/geanywraplabel.c
17 files changed, 16 insertions(+), 1 deletions(-)
===================================================================
@@ -51,6 +51,7 @@ struct _GeanyWrapLabel
 
 static void geany_wrap_label_size_request	(GtkWidget *widget, GtkRequisition *req);
 static void geany_wrap_label_size_allocate	(GtkWidget *widget, GtkAllocation *alloc);
+static gboolean geany_wrap_label_expose		(GtkWidget *widget, GdkEventExpose *event);
 static void geany_wrap_label_set_wrap_width	(GtkWidget *widget, gint width);
 static void geany_wrap_label_label_notify	(GObject *object, GParamSpec *pspec, gpointer data);
 
@@ -63,6 +64,7 @@ static void geany_wrap_label_class_init(GeanyWrapLabelClass *klass)
 
 	widget_class->size_request = geany_wrap_label_size_request;
 	widget_class->size_allocate = geany_wrap_label_size_allocate;
+	widget_class->expose_event = geany_wrap_label_expose;
 
 	g_type_class_add_private(klass, sizeof (GeanyWrapLabelPrivate));
 }
@@ -77,7 +79,6 @@ static void geany_wrap_label_init(GeanyWrapLabel *self)
 	self->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);
 	gtk_misc_set_alignment(GTK_MISC(self), 0.0, 0.0);
 }
 
@@ -98,6 +99,7 @@ static void geany_wrap_label_set_wrap_width(GtkWidget *widget, gint width)
 	* or not we've changed the width.
 	*/
 	pango_layout_set_width(layout, width * PANGO_SCALE);
+	pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
 	pango_layout_get_pixel_size(layout, NULL, &self->priv->wrap_height);
 
 	if (self->priv->wrap_width != width)
@@ -117,6 +119,19 @@ static void geany_wrap_label_label_notify(GObject *object, GParamSpec *pspec, gp
 }
 
 
+/* makes sure the layout is setup for rendering and chains to parent renderer */
+static gboolean geany_wrap_label_expose(GtkWidget *widget, GdkEventExpose *event)
+{
+	GeanyWrapLabel *self = GEANY_WRAP_LABEL(widget);
+	PangoLayout *layout = gtk_label_get_layout(GTK_LABEL(widget));
+
+	pango_layout_set_width(layout, self->priv->wrap_width * PANGO_SCALE);
+	pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
+
+	return (* GTK_WIDGET_CLASS(geany_wrap_label_parent_class)->expose_event)(widget, event);
+}
+
+
 /* Forces the height to be the size necessary for the Pango layout, while allowing the
  * width to be flexible. */
 static void geany_wrap_label_size_request(GtkWidget *widget, GtkRequisition *req)


@@ 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