[polari] connections: Add :favorites-only property



commit 9f5671e3bc5a0699497ada26f56125ecbbf81dc0
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Aug 2 01:01:03 2017 +0100

    connections: Add :favorites-only property
    
    In order to provide a better onboarding experience, we will add a guided
    initial setup mode based on the existing network/room configuration UI.
    However we don't want to display the full list of predefined networks as
    in the join dialog, or allow the creation of custom ones. To support this
    use case, add a new contruct-only property to limit the list to favorite
    networks rather than just prioritizing them over others.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772458

 src/connections.js |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/src/connections.js b/src/connections.js
index 099f7d0..e4d7b43 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -72,10 +72,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,
+                                                    false)
+    },
     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;
@@ -106,6 +116,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();
@@ -140,6 +162,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,
@@ -174,6 +200,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]