[polari/wip/fmuellner/disconnect-accounts: 20/22] accounts: Add PolariAccount:visible property



commit ad853d6949cc32923e02c43317aee745a3f8dcba
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Nov 9 03:29:26 2017 +0100

    accounts: Add PolariAccount:visible property
    
    Ever since we removed the separate connections dialog in favor of
    the room list header popovers in commit 263ff952a, it has not been
    possible to enable or disable accounts from Polari itself. We would
    like to re-expose that functionality again, but nowadays we also
    use the disable mechanism to implement undo for account removals.
    So in order to "free" the :enabled property, add a separate :visible
    property that will be used to show or hide accounts from the UI.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=771889

 src/accountsMonitor.js | 43 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js
index 38a5a5e..5dce4d2 100644
--- a/src/accountsMonitor.js
+++ b/src/accountsMonitor.js
@@ -158,6 +158,45 @@ class ClientFactory extends Polari.ClientFactory {
     }
 });
 
-const PolariAccount = GObject.registerClass(
-class PolariAccount extends Tp.Account {
+const PolariAccount = GObject.registerClass({
+    Properties: {
+        visible: GObject.ParamSpec.boolean('visible',
+                                           'visible',
+                                           'visible',
+                                           GObject.ParamFlags.READABLE |
+                                           GObject.ParamFlags.EXPLICIT_NOTIFY,
+                                           true)
+    }
+}, class PolariAccount extends Tp.Account {
+    _init(params) {
+        this._visible = true;
+
+        super._init(params);
+    }
+
+    get visible() {
+        return this._visible;
+    }
+
+    on_notify(pspec) {
+        if (pspec.name == 'enabled' && this.enabled)
+            this._setVisibleInternal(true);
+    }
+
+    setVisible(value, callback) {
+        this.set_enabled_async(value, (o, res) => {
+            this.set_enabled_finish(res);
+
+            this._setVisibleInternal(value);
+            callback();
+        });
+    }
+
+    _setVisibleInternal(value) {
+        if (this._visible == value)
+            return;
+
+        this._visible = value;
+        this.notify('visible');
+    }
 });


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