[polari/wip/raresv/finalRebase: 10/18] userDetails: add notification support.



commit b7ae5e92811a57f9166c7006dbd40503930893cb
Author: raresv <rares visalom gmail com>
Date:   Thu Aug 18 21:00:31 2016 +0300

    userDetails: add notification support.

 data/resources/user-details.ui |   40 ++++++++++++++++++++++++++++++++++++++++
 src/userList.js                |   24 +++++++++++++++++++++++-
 2 files changed, 63 insertions(+), 1 deletions(-)
---
diff --git a/data/resources/user-details.ui b/data/resources/user-details.ui
index 91be102..f166d62 100644
--- a/data/resources/user-details.ui
+++ b/data/resources/user-details.ui
@@ -126,6 +126,46 @@
                 <property name="left-attach">0</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkImage">
+                <property name="icon-name">polari-user-notify-symbolic</property>
+                <property name="visible" bind-source="notificationLabel"
+                          bind-property="visible" bind-flags="sync-create"/>
+                <property name="opacity" bind-source="notificationLabel"
+                          bind-property="opacity" bind-flags="sync-create"/>
+                <property name="no-show-all">True</property>
+                <property name="halign">start</property>
+                <property name="margin-left">0</property>
+                <style>
+                  <class name="dim-label" />
+                </style>
+              </object>
+              <packing>
+                <property name="width">1</property>
+                <property name="top-attach">2</property>
+                <property name="left-attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="notificationLabel">
+                <property name="ellipsize">end</property>
+                <property name="halign">start</property>
+                <property name="visible">True</property>
+                <property name="margin-start">20</property>
+                <property name="hexpand">True</property>
+                <property name="no-show-all">True</property>
+                <property name="use-markup">True</property>
+                <property name="label" translatable="yes">Will notify if user appears online.</property>
+                <style>
+                  <class name="dim-label" />
+                </style>
+              </object>
+              <packing>
+                <property name="width">2</property>
+                <property name="top-attach">2</property>
+                <property name="left-attach">0</property>
+              </packing>
+            </child>
           </object>
         </child>
         <child>
diff --git a/src/userList.js b/src/userList.js
index 4a80d24..0681d4e 100644
--- a/src/userList.js
+++ b/src/userList.js
@@ -108,12 +108,18 @@ const UserDetails = new Lang.Class({
                        'detailsGrid',
                        'fullnameLabel',
                        'lastLabel',
+                       'notificationLabel',
                        'messageButton'],
     Properties: { 'expanded': GObject.ParamSpec.boolean('expanded',
                                                         'expanded',
                                                         'expanded',
                                                         READWRITE,
-                                                        false)},
+                                                        false),
+                  'notifications-enabled': GObject.ParamSpec.boolean('notifications-enabled',
+                                                             'notifications-enabled',
+                                                             'notifications-enabled',
+                                                             READWRITE,
+                                                             false)},
 
     _init: function(params) {
         this._expanded = false;
@@ -130,6 +136,21 @@ const UserDetails = new Lang.Class({
         this._fullnameLabel.max_width_chars = 50;
     },
 
+    get notifications_enabled() {
+        return this._notificationsEnabled;
+    },
+
+    set notifications_enabled(value) {
+        if (this._notificationsEnabled == value)
+            return;
+
+        this._notificationsEnabled = value;
+
+        this.notify('notifications-enabled');
+
+        this._notificationLabel.opacity = value ? 1. : 0.;
+    },
+
     set user(user) {
         if (this._user == user)
             return;
@@ -148,6 +169,7 @@ const UserDetails = new Lang.Class({
             this._expand();
 
         this._updateButtonVisibility();
+        this._notificationLabel.visible = this._user == null;
         this._lastLabel.visible = this._user != null;
     },
 


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