[polari] chatView: Use unicode arrows in status summaries



commit 67d295a1db53450cb9ba9c20f2952a60f0e930ed
Author: Kunaal Jain <kunaalus gmail com>
Date:   Mon Feb 8 11:50:45 2016 +0530

    chatView: Use unicode arrows in status summaries
    
    Instead of ellipsis that we use currently to indicate
    that status summaries are expandable, use unicode arrows,
    which are more visually appealing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=759120

 src/chatView.js |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index c84b248..6cdfeb1 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -897,16 +897,22 @@ const ChatView = new Lang.Class({
         let headerMark = buffer.get_mark('idle-status-start');
 
         let headerTagName = 'status-compressed' + this._state.lastStatusGroup;
+        let headerArrowTagName = 'status-arrow-compressed' + this._state.lastStatusGroup;
         let groupTagName = 'status' + this._state.lastStatusGroup;
 
-        let headerTag, groupTag;
+        let headerTag, headerArrowTag, groupTag;
         if (!headerMark) {
             // we are starting a new group
             headerTag = new ButtonTag({ name: headerTagName, invisible: true });
+            headerArrowTag = new Gtk.TextTag({ name: headerArrowTagName, invisible: true });
             groupTag = new Gtk.TextTag({ name: groupTagName });
             buffer.tag_table.add(headerTag);
+            buffer.tag_table.add(headerArrowTag);
             buffer.tag_table.add(groupTag);
 
+            groupTag.bind_property('invisible', headerArrowTag, 'invisible',
+                                    GObject.BindingFlags.INVERT_BOOLEAN);
+
             headerTag.connect('clicked',
                 function() {
                     groupTag.invisible = !groupTag.invisible;
@@ -921,6 +927,7 @@ const ChatView = new Lang.Class({
             headerMark = buffer.create_mark('idle-status-start', buffer.get_end_iter(), true);
         } else {
             headerTag = this._lookupTag(headerTagName);
+            headerArrowTag = this._lookupTag(headerArrowTagName);
             groupTag = this._lookupTag(groupTagName);
 
             let start = buffer.get_iter_at_mark(headerMark);
@@ -942,9 +949,15 @@ const ChatView = new Lang.Class({
         if (this._statusCount.left > 0)
             stats.push(ngettext("%d user left",
                                 "%d users left", this._statusCount.left).format(this._statusCount.left));
-        this._insertWithTags(buffer.get_iter_at_mark(headerMark),
-                             stats.join(", ") + ' (\u2026)',
-                             [this._lookupTag('status'), headerTag]);
+        // TODO: How do we update the arrow direction when text direction change?
+        let iter = buffer.get_iter_at_mark(headerMark);
+        let tags = [this._lookupTag('status'), headerTag];
+        let headerText = stats.join(', ');
+        let baseDir = Pango.find_base_dir(headerText, -1);
+        this._insertWithTags(iter, headerText, tags);
+        this._insertWithTags(iter, baseDir == Pango.Direction.LTR ? '\u25B6' : '\u25C0',
+                             tags.concat(headerArrowTag));
+        this._insertWithTags(iter, '\u25BC', tags.concat(groupTag));
     },
 
     _insertStatus: function(text, member, type) {


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