From d01648e9e3ec38fd404748ef83050d68f5741bd6 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Tue, 6 Aug 2013 15:48:56 -0700 Subject: Ellipisze long article titles To prevent the size request from jumping around --- wikipedia/TextButton.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'wikipedia') diff --git a/wikipedia/TextButton.js b/wikipedia/TextButton.js index 13a47ac..0960090 100644 --- a/wikipedia/TextButton.js +++ b/wikipedia/TextButton.js @@ -2,6 +2,11 @@ const Lang = imports.lang; const Gdk = imports.gi.Gdk; const GdkPixbuf = imports.gi.GdkPixbuf; const Gtk = imports.gi.Gtk; +const Pango = imports.gi.Pango; + +// This is an approximate number of characters that will keep the label from +// going over its specified 258px +const ARTICLE_LABEL_MAX_WIDTH_CHARS = 18; const TextButton = new Lang.Class({ Name: 'EndlessTextButton', @@ -25,7 +30,9 @@ const TextButton = new Lang.Class({ }); this._label = new Gtk.Label({ - label: label_text.toUpperCase() + label: label_text.toUpperCase(), + max_width_chars: ARTICLE_LABEL_MAX_WIDTH_CHARS, + ellipsize: Pango.EllipsizeMode.END }); this._box.pack_start(this._label, false, false, 0); -- cgit v1.2.3