[polari/wip/raresv/nick-popover: 15/16] userDetails: Add notification icon and label



commit fb05a8f8c24ad38ff22fb71fbd14b281d5cd5adb
Author: raresv <rares visalom gmail com>
Date:   Thu Aug 18 20:58:10 2016 +0300

    userDetails: Add notification icon and label
    
    The UserDetails needs additional features before the
    actual notification feature is added. The two features
    are a new icon that will be used in both the UserPopover
    and the UserDetails and the label that signals that the
    user is being watched.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760853

 data/org.gnome.Polari.data.gresource.xml       |    1 +
 data/resources/polari-user-notify-symbolic.svg |   18 +++++++++++
 data/resources/user-details.ui                 |   40 ++++++++++++++++++++++++
 src/userList.js                                |   24 +++++++++++++-
 4 files changed, 82 insertions(+), 1 deletions(-)
---
diff --git a/data/org.gnome.Polari.data.gresource.xml b/data/org.gnome.Polari.data.gresource.xml
index 1c4d3fc..b21bb85 100644
--- a/data/org.gnome.Polari.data.gresource.xml
+++ b/data/org.gnome.Polari.data.gresource.xml
@@ -5,6 +5,7 @@
     <file alias="data/networks.json">resources/networks.json</file>
     <file alias="gtk/help-overlay.ui" preprocess="xml-stripblanks">resources/help-overlay.ui</file>
     <file alias="gtk/menus.ui" preprocess="xml-stripblanks">resources/menus.ui</file>
+    <file alias="icons/polari-user-notify-symbolic.svg" 
preprocess="xml-stripblanks">resources/polari-user-notify-symbolic.svg</file>
     <file alias="ui/connection-details.ui" 
preprocess="xml-stripblanks">resources/connection-details.ui</file>
     <file alias="ui/connection-properties.ui" 
preprocess="xml-stripblanks">resources/connection-properties.ui</file>
     <file alias="ui/entry-area.ui" preprocess="xml-stripblanks">resources/entry-area.ui</file>
diff --git a/data/resources/polari-user-notify-symbolic.svg b/data/resources/polari-user-notify-symbolic.svg
new file mode 100644
index 0000000..c28a4d4
--- /dev/null
+++ b/data/resources/polari-user-notify-symbolic.svg
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:cc="http://creativecommons.org/ns#"; 
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; xmlns:svg="http://www.w3.org/2000/svg"; 
xmlns="http://www.w3.org/2000/svg"; xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"; 
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"; version="1.1" id="svg10865" viewBox="0 0 
15.999999 15.999999" height="4.5155554mm" width="4.5155554mm" inkscape:version="0.91 r13725" 
sodipodi:docname="polari-user-notify-symbolic.svg">
+  <sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" borderopacity="1" objecttolerance="10" 
gridtolerance="10" guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" 
inkscape:window-width="1920" inkscape:window-height="1080" id="namedview10" showgrid="false" 
inkscape:zoom="29.500001" inkscape:cx="1.6963679" inkscape:cy="10.950363" inkscape:window-x="0" 
inkscape:window-y="0" inkscape:window-maximized="0" inkscape:current-layer="svg10865"/>
+  <defs id="defs10867"/>
+  <metadata id="metadata10870">
+    <rdf:RDF>
+      <cc:Work rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+        <dc:title/>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g id="g35541" transform="translate(-346.1907,-963.1781)">
+    <path inkscape:connector-curvature="0" style="fill:#bebebe;fill-opacity:1;stroke:none" d="m 
354.25319,964.67814 c -1.65686,0 -3,1.34315 -3,3 0,1.27269 -0.0169,4.99999 -3.5625,7 l 13,0 c 
-3.45455,-2.00001 -3.4375,-5.72731 -3.4375,-7 0,-1.65685 -1.34314,-3 -3,-3 z" id="path5705-7"/>
+    <path inkscape:connector-curvature="0" style="fill:#bebebe;fill-opacity:1;stroke:none" id="path5707-8" 
d="m 356.24405,975.6781 a 2.0000288,2.0000186 0 0 1 -1.00002,1.73207 2.0000288,2.0000186 0 0 1 -2.00003,0 
2.0000288,2.0000186 0 0 1 -1.00001,-1.73207 l 2.00003,0 z"/>
+  </g>
+</svg>
\ No newline at end of file
diff --git a/data/resources/user-details.ui b/data/resources/user-details.ui
index a9349ec..003768b 100644
--- a/data/resources/user-details.ui
+++ b/data/resources/user-details.ui
@@ -127,6 +127,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="margin-start">20</property>
+                <property name="hexpand">True</property>
+                <property name="no-show-all">True</property>
+                <property name="visible">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 2326142..0ba864c 100644
--- a/src/userList.js
+++ b/src/userList.js
@@ -112,12 +112,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 = {}) {
         let user = params.user;
@@ -137,6 +143,21 @@ const UserDetails = new Lang.Class({
         this._detailsGrid.hide();
     },
 
+    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;
@@ -155,6 +176,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]