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



commit e1c70984b68f8c613422d446be4367b1c771a1f8
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 unless in the join dialog, we don't want to display the full list
    of predefined networks there, 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.

 src/connections.js |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/src/connections.js b/src/connections.js
index 099f7d0..9033b13 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,
+                                                    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;
@@ -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]