[polari/wip/raresv/nick-popover: 16/16] userPopover: Add notify button and action



commit ea3f005e72868e7eff424c9d345e534f6abc3cbe
Author: raresv <rares visalom gmail com>
Date:   Sat Aug 20 19:32:16 2016 +0300

    userPopover: Add notify button and action
    
    The ToggleButton (notifiButton) that is connected to the
    notify action is added to the popover. We also bind its
    visible property to its sensitive property, so that the
    button is hidden whenever the action is disabled. Moreover,
    the notifications-enabled property of the UserDetails are
    bound to the active property of the notifyButton, so that
    we can display the notifyLabel whenever the user is watched.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760853

 data/resources/user-popover.ui |   65 +++++++++++++++++++++++++++++++--------
 src/userList.js                |    4 ++
 2 files changed, 55 insertions(+), 14 deletions(-)
---
diff --git a/data/resources/user-popover.ui b/data/resources/user-popover.ui
index 9e9c164..764261c 100644
--- a/data/resources/user-popover.ui
+++ b/data/resources/user-popover.ui
@@ -8,26 +8,63 @@
         <property name="orientation">vertical</property>
         <property name="visible">True</property>
         <child>
-          <object class="GtkLabel" id="nickLabel">
-            <property name="halign">start</property>
-            <property name="margin-top">0</property>
-            <property name="ellipsize">end</property>
-            <property name="max-width-chars">17</property>
-            <property name="visible">True</property>
-          </object>
-        </child>
-        <child>
-          <object class="GtkLabel" id="statusLabel">
-            <property name="halign">start</property>
-            <property name="margin-bottom">0</property>
-            <property name="use-markup">True</property>
-            <property name="label" translatable="yes"></property>
+          <object class="GtkBox">
+            <property name="orientation">horizontal</property>
             <property name="visible">True</property>
+            <property name="halign">fill</property>
+            <property name="margin">9</property>
+            <child>
+              <object class="GtkBox">
+                <property name="orientation">vertical</property>
+                <property name="visible">True</property>
+                <property name="halign">fill</property>
+                <child>
+                  <object class="GtkLabel" id="nickLabel">
+                    <property name="halign">start</property>
+                    <property name="margin-top">0</property>
+                    <property name="ellipsize">end</property>
+                    <property name="max-width-chars">17</property>
+                    <property name="visible">True</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="statusLabel">
+                    <property name="halign">start</property>
+                    <property name="margin-bottom">0</property>
+                    <property name="use-markup">True</property>
+                    <property name="label" translatable="yes"></property>
+                    <property name="visible">True</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkToggleButton" id="notifyButton">
+                <property name="hexpand">True</property>
+                <property name="halign">end</property>
+                <property name="valign">center</property>
+                <property name="visible">True</property>
+                <property name="visible" bind-source="notifyButton"
+                          bind-property="sensitive"
+                          bind-flags="sync-create"/>
+                <child>
+                  <object class="GtkImage">
+                    <property name="icon-name">polari-user-notify-symbolic</property>
+                    <property name="visible">True</property>
+                    <property name="halign">center</property>
+                    <property name="visible">True</property>
+                  </object>
+                </child>
+              </object>
+            </child>
           </object>
         </child>
         <child>
           <object class="Gjs_UserDetails" id="userDetails">
             <property name="visible">True</property>
+            <property name="notifications-enabled" bind-source="notifyButton"
+                      bind-property="active"
+                      bind-flags="sync-create"/>
             <!-- trigger details update on visibility changes -->
             <property name="expanded" bind-source="Gjs_UserPopover"
                       bind-property="visible"
diff --git a/src/userList.js b/src/userList.js
index 0ba864c..ef9b98e 100644
--- a/src/userList.js
+++ b/src/userList.js
@@ -330,6 +330,7 @@ const UserPopover = new Lang.Class({
     Template: 'resource:///org/gnome/Polari/ui/user-popover.ui',
     InternalChildren: ['nickLabel',
                        'statusLabel',
+                       'notifyButton',
                        'userDetails'],
 
     _init: function(params) {
@@ -367,6 +368,9 @@ const UserPopover = new Lang.Class({
         this._nickLabel.label = this._nickname;
         this._userDetails.nickname = nickname;
 
+        let actionName = this._userTracker.getNotifyActionName(this._nickname);
+        this._notifyButton.action_name = actionName;
+
         this._setBasenick(Polari.util_get_basenick(nickname));
     },
 


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