[polari/wip/raresv/nick-popover] work so far, part 3



commit 99495ff0de5c4a90a019d9140c078b4967deeaa3
Author: raresv <rares visalom gmail com>
Date:   Tue Jun 21 14:34:50 2016 +0300

    work so far, part 3

 data/resources/user-details.ui |   13 +++++++++-
 src/chatView.js                |   18 +++++++++++++-
 src/userList.js                |   47 ++++++++++++++++++++++++++++++++++-----
 3 files changed, 68 insertions(+), 10 deletions(-)
---
diff --git a/data/resources/user-details.ui b/data/resources/user-details.ui
index 72e0cb0..7d15f33 100644
--- a/data/resources/user-details.ui
+++ b/data/resources/user-details.ui
@@ -8,7 +8,7 @@
       <object class="GtkBox" id="box">
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
-        <property name="margin">5</property>
+        <property name="margin">9</property>
         <property name="visible">True</property>
         <child>
           <object class="GtkBox" id="spinnerBox">
@@ -57,6 +57,9 @@
                 <property name="use-markup">True</property>
                 <property name="visible">True</property>
                 <property name="margin-start">20</property>
+                <style>
+                  <class name="dim-label" />
+                </style>
               </object>
               <packing>
                 <property name="top-attach">0</property>
@@ -71,6 +74,9 @@
                 <property name="hexpand">True</property>
                 <property name="visible">True</property>
                 <property name="hexpand">True</property>
+                <style>
+                  <class name="dim-label" />
+                </style>
               </object>
               <packing>
                 <property name="top-attach">0</property>
@@ -78,7 +84,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkImage">
+              <object class="GtkImage" id="userIcon">
                 <property name="icon-name">avatar-default-symbolic</property>
                 <property name="visible">True</property>
                 <property name="halign">start</property>
@@ -97,6 +103,9 @@
                 <property name="visible">True</property>
                 <property name="margin-start">20</property>
                 <property name="hexpand">True</property>
+                <style>
+                  <class name="dim-label" />
+                </style>
               </object>
               <packing>
                 <property name="width">2</property>
diff --git a/src/chatView.js b/src/chatView.js
index 31a6732..be67395 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -788,6 +788,9 @@ const ChatView = new Lang.Class({
         if (!alreadyTracked)
             nickTag._contacts.push(contact);
 
+        if (nickTag._popover.fallbackNick == contact.alias)
+            nickTag._popover.user = contact;
+
         this._updateTagStatus(nickTag);
     },
 
@@ -801,6 +804,13 @@ const ChatView = new Lang.Class({
         if (indexToDelete > -1) {
             nickTag._contacts.splice(indexToDelete, 1);
 
+        if (nickTag._popover.fallbackNick == contact.alias) {
+            if (nickTag._contacts[0])
+                nickTag._popover.user = nickTag._contacts[0];
+            else
+                nickTag._popober.user = null;
+        }
+
             this._updateTagStatus(nickTag);
         }
     },
@@ -1296,10 +1306,11 @@ const ChatView = new Lang.Class({
         let rect1 = view.get_iter_location(start);
         let rect2 = view.get_iter_location(end);
 
+        [rect1.y, rect1.height] = view.get_line_yrange(start);
+
         [rect1.x, rect1.y] = view.buffer_to_window_coords(Gtk.TextWindowType.WIDGET, rect1.x, rect1.y);
         [rect2.x, rect2.y] = view.buffer_to_window_coords(Gtk.TextWindowType.WIDGET, rect2.x, rect2.y);
         rect1.width = rect2.x - rect1.x;
-        rect1.height = rect2.y - rect1.y;
 
         //TODO: special chars?
         let actualNickName = view.get_buffer().get_slice(start, end, false);
@@ -1319,11 +1330,14 @@ const ChatView = new Lang.Class({
                     contactFound = true;
                     break;
                 }
+                else if (tag._popover.user == tag._contacts[i]) {
+                    contactFound = true;
+                    break;
+                }
             }
         }
 
         if (!contactFound) {
-            //tag._popover.user = null;
             if (tag._contacts[0]) {
                 tag._popover.user = tag._contacts[0];
             }
diff --git a/src/userList.js b/src/userList.js
index 307a4da..a831d16 100644
--- a/src/userList.js
+++ b/src/userList.js
@@ -106,6 +106,7 @@ const UserDetails = new Lang.Class({
     InternalChildren: ['spinnerBox',
                        'spinner',
                        'detailsGrid',
+                       'userIcon',
                        'fullnameLabel',
                        'lastHeader',
                        'lastLabel',
@@ -144,6 +145,11 @@ const UserDetails = new Lang.Class({
             this._selfContactChangedId = this._user.connection.connect('notify::self-contact',
                                                     Lang.bind(this, this._updateButtonVisibility));
 
+        if (this.expanded) {
+            this.expanded = false;
+            this.expanded = true;
+        }
+
         this._updateButtonVisibility();
     },
 
@@ -189,6 +195,8 @@ const UserDetails = new Lang.Class({
             this._user.request_contact_info_async(this._cancellable,
                                               Lang.bind(this, this._onContactInfoReady));
         //TODO: else use this._falbackNick to query tracker
+        else
+            this._trackFallbackNick(this._fallbackNick);
     },
 
     _unexpand: function() {
@@ -243,6 +251,7 @@ const UserDetails = new Lang.Class({
             fn = this._user.alias;
 
         this._fullnameLabel.label = fn;
+        this._userIcon.visible = true;
 
         if (last) {
             this._lastHeader.label = '<small>' + _("Last Activity:") + '</small>';
@@ -255,6 +264,19 @@ const UserDetails = new Lang.Class({
             this._lastLabel.hide();
         }
 
+        this._revealDetails();
+    },
+
+    _trackFallbackNick: function(fallbackNick) {
+        this._lastHeader.label = '<small>' + _("Last Activity:") + '</small>';
+        this._lastHeader.show();
+
+        this._userIcon.visible = false;
+
+        this._revealDetails();
+    },
+
+    _revealDetails: function() {
         this._spinner.stop();
         this._spinnerBox.hide();
         this._detailsGrid.show();
@@ -280,8 +302,15 @@ const UserDetails = new Lang.Class({
             return;
         }
 
-        let active = this._user != this._user.connection.self_contact;
-        this._messageButton.sensitive = active;
+        //let active = this._user != this._user.connection.self_contact;
+        //this._messageButton.sensitive = active;
+        if (this._user == this._user.connection.self_contact) {
+            this._messageButton.visible = false;
+            this._messageButton.sensitive = true; //does this even make sense?
+        } else {
+            this._messageButton.visible = true;
+            this._messageButton.sensitive = true;
+        }
     }
 });
 
@@ -292,11 +321,15 @@ const UserPopover = new Lang.Class({
     _init: function(params) {
         this.parent(params);
 
-        this._nickLabel = new Gtk.Label({ halign: Gtk.Align.START, margin_left: 5 });
-        this._statusLabel = new Gtk.Label({ halign: Gtk.Align.START, margin_left: 5, margin_bottom: 3 });
+        this._nickLabel = new Gtk.Label({ halign: Gtk.Align.START, margin_left: 9 });
+        this._statusLabel = new Gtk.Label({ halign: Gtk.Align.START, margin_left: 9, margin_bottom: 3 });
         this._userDetails = new UserDetails();
         this.bind_property('visible', this._userDetails, 'expanded', 0);
 
+        let context = this._statusLabel.get_style_context();
+        context.add_class('subtitle');
+        //context.save();
+
         this._vbox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
         this._vbox.add(this._nickLabel);
         this._vbox.add(this._statusLabel);
@@ -323,8 +356,11 @@ const UserPopover = new Lang.Class({
         this._updateContents();
     },
 
+    get fallbackNick() {
+        return this._fallbackNick;
+    },
+
     _updateContents: function() {
-        //this._nickLabel.set_label(this._user ? this._user.alias : this._fallbackNick);
         this._nickLabel.set_label(this._fallbackNick);
         this._statusLabel.set_label(this._user ? "Online" : "Offline");
 
@@ -412,7 +448,6 @@ const UserListRow = new Lang.Class({
         if (this._revealer.get_child())
             return;
 
-        //let details = new UserDetails({ user: this._user });
         let details = new UserDetails();
         details.user = this._user;
 


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