[polari] Grow maxNickChars if nicks are longer



commit 9df5a656bf6ccd17d801d0abd089d9680aadada1
Author: Florian Müllner <florian muellner gmail com>
Date:   Sat Jul 20 20:38:13 2013 +0200

    Grow maxNickChars if nicks are longer
    
    ... I still think ellipsization would be nicer :-(

 src/chatView.js |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 26daaee..c93e456 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -37,6 +37,7 @@ const ChatView = new Lang.Class({
         this._scrollBottom = false;
         this._active = false;
         this._toplevelFocus = false;
+        this._maxNickChars = MAX_NICK_CHARS;
 
         let channelSignals = [
             { name: 'message-received',
@@ -111,10 +112,10 @@ const ChatView = new Lang.Class({
         let pixelWidth = Pango.units_to_double(charWidth);
 
         let tabs = Pango.TabArray.new(1, true);
-        tabs.set_tab(0, Pango.TabAlign.LEFT, MAX_NICK_CHARS * pixelWidth);
+        tabs.set_tab(0, Pango.TabAlign.LEFT, this._maxNickChars * pixelWidth);
         this._view.tabs = tabs;
-        this._view.indent = -MAX_NICK_CHARS * pixelWidth;
-        this._view.left_margin = MAX_NICK_CHARS * pixelWidth;
+        this._view.indent = -this._maxNickChars * pixelWidth;
+        this._view.left_margin = this._maxNickChars * pixelWidth;
     },
 
     _onParentSet: function(widget, oldParent) {
@@ -214,6 +215,11 @@ const ChatView = new Lang.Class({
 
         this._ensureNewLine();
 
+        if (nick.length > this._maxNickChars) {
+            this._maxNickChars = nick.length;
+            this._updateIndent();
+        }
+
         let tags = [];
         if (message.get_message_type() == Tp.ChannelTextMessageType.ACTION) {
             text = "%s %s".format(nick, text);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]