[polari/wip/dmoelgaard/initial-setup] connections: Add :favorites-only property



commit 8d56764127db18b001dce75f436f5b4d5d1c6979
Author: Bastian Ilsø <bastianilso gnome org>
Date:   Wed Aug 2 01:01:03 2017 +0100

    connections: Add :favorites-only property

 src/connections.js |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/src/connections.js b/src/connections.js
index ddeef61..47d0d05 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -71,10 +71,20 @@ var ConnectionRow = new Lang.Class({
 var ConnectionsList = new Lang.Class({
     Name: 'ConnectionsList',
     Extends: Gtk.ScrolledWindow,
+    Properties: {
+        'favorites-only': GObject.ParamSpec.boolean('favorites-only',
+                                                    'favorites-only',
+                                                    'favorites-only',
+                                                    GObject.ParamFlags.READWRITE |
+                                                    GObject.ParamFlags.CONSTRUCT_ONLY,
+                                                    true)
+    },
     Signals: { 'account-created': { param_types: [Tp.Account.$gtype] },
                'account-selected': {}},
 
     _init: function(params) {
+        this._favoritesOnly = false;
+
         this.parent(params);
 
         this.hscrollbar_policy = Gtk.PolicyType.NEVER;
@@ -105,6 +115,18 @@ var ConnectionsList = new Lang.Class({
         this._networksChanged();
     },
 
+    get favorites_only() {
+        return this._favoritesOnly;
+    },
+
+    set favorites_only(favsOnly) {
+        if (this._favoritesOnly == favsOnly)
+            return;
+
+        this._favoritesOnly = favsOnly;
+        this.notify('favorites-only');
+    },
+
     setFilter: function(filter) {
         if (Utils.updateTerms(this._filterTerms, filter))
             this._list.invalidate_filter();
@@ -139,6 +161,10 @@ var ConnectionsList = new Lang.Class({
         }).map(a => a.service);
 
         this._networksManager.networks.forEach(network => {
+            if (this._favoritesOnly &&
+                !this._networksManager.getNetworkIsFavorite(network.id))
+                return;
+
             let sensitive = usedNetworks.indexOf(network.id) < 0;
             this._rows.set(network.id,
                            new ConnectionRow({ id: network.id,
@@ -173,6 +199,9 @@ var ConnectionsList = new Lang.Class({
         if (!this._networksManager.getAccountIsPredefined(account))
             return;
 
+        if (!this._rows.has(account.service))
+            return;
+
         this._rows.get(account.service).sensitive = sensitive;
     },
 


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