[polari] chatView: Add hack to force TextView to wrap rather than grow
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] chatView: Add hack to force TextView to wrap rather than grow
- Date: Mon, 14 Oct 2013 17:58:12 +0000 (UTC)
commit 65ce0de0e3abc9de4fd672c31a92120bf548c518
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Oct 12 11:41:29 2013 +0200
chatView: Add hack to force TextView to wrap rather than grow
GtkTextView's horizontal size request will grow over time when
added to a GtkScrolledWindow with horizontal scrolling disabled,
even when the TextView is set up to wrap lines.
As a workaround, subclass GtkTextView to overwrite its size request
with a constant width to force the text to wrap around.
https://bugzilla.gnome.org/show_bug.cgi?id=709977
src/chatView.js | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index bcb5bed..9a2af36 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -51,6 +51,17 @@ function findUrls(str) {
return res;
}
+// Workaround for GtkTextView growing horizontally over time when
+// added to a GtkScrolledWindow with horizontal scrolling disabled
+const TextView = new Lang.Class({
+ Name: 'TextView',
+ Extends: Gtk.TextView,
+
+ vfunc_get_preferred_width: function() {
+ return [1, 1];
+ }
+});
+
const ChatView = new Lang.Class({
Name: 'ChatView',
@@ -177,9 +188,9 @@ const ChatView = new Lang.Class({
this.widget.hscrollbar_policy = Gtk.PolicyType.NEVER;
this.widget.resize_mode = Gtk.ResizeMode.QUEUE;
- this._view = new Gtk.TextView({ editable: false, cursor_visible: false,
- visible: true,
- wrap_mode: Gtk.WrapMode.WORD_CHAR });
+ this._view = new TextView({ editable: false, cursor_visible: false,
+ visible: true,
+ wrap_mode: Gtk.WrapMode.WORD_CHAR });
this._view.set_border_window_size(Gtk.TextWindowType.TOP, 6);
this._view.set_border_window_size(Gtk.TextWindowType.BOTTOM, 6);
this._view.set_border_window_size(Gtk.TextWindowType.LEFT, 6);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]