[polari] networksManager: Prioritize favorite networks
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] networksManager: Prioritize favorite networks
- Date: Sun, 17 Apr 2016 21:32:18 +0000 (UTC)
commit 3bea70eef97779588c6031f9c2442c6461219382
Author: raresv <rares visalom gmail com>
Date: Sun Apr 17 14:13:23 2016 +0300
networksManager: Prioritize favorite networks
Using the "favorite" property enables us to flag specific
networks as important. We want this property because the
networks list is long and naturally, we want to put the
favorite ones on top of the list. Furthermore, the current
designs for initial setup use a reduced list of networks,
thus prioritization would make it easier to display the new
list.
Moreover, the sorting function is changed in order to account
for the favorite proprty first, and then the alphabetic order.
https://bugzilla.gnome.org/show_bug.cgi?id=762733
data/resources/networks.json | 2 ++
src/connections.js | 6 ++++++
src/networksManager.js | 9 +++++++++
3 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/data/resources/networks.json b/data/resources/networks.json
index e358341..6f33818 100644
--- a/data/resources/networks.json
+++ b/data/resources/networks.json
@@ -268,6 +268,7 @@
{
"name": "Freenode",
"id": "freenode",
+ "favorite": true,
"servers": [
{ "ssl": true, "port": 6697, "address": "chat.freenode.net" },
{ "ssl": true, "port": 7000, "address": "chat.freenode.net" },
@@ -307,6 +308,7 @@
{
"name": "GNOME",
"id": "gimpnet",
+ "favorite": true,
"servers": [
{ "ssl": false, "port": 6667, "address": "irc.gnome.org" },
{ "ssl": false, "port": 6667, "address": "irc.gimp.net" },
diff --git a/src/connections.js b/src/connections.js
index f0d5144..577f54a 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -171,6 +171,12 @@ const ConnectionsList = new Lang.Class({
},
_sort: function(row1, row2) {
+ let isFavorite1 = this._networksManager.getNetworkIsFavorite(row1.id);
+ let isFavorite2 = this._networksManager.getNetworkIsFavorite(row2.id);
+
+ if (isFavorite1 != isFavorite2)
+ return isFavorite1 ? -1 : 1;
+
let name1 = this._networksManager.getNetworkName(row1.id);
let name2 = this._networksManager.getNetworkName(row2.id);
diff --git a/src/networksManager.js b/src/networksManager.js
index 6b04261..af482f4 100644
--- a/src/networksManager.js
+++ b/src/networksManager.js
@@ -68,6 +68,15 @@ const NetworksManager = new Lang.Class({
return this._lookupNetwork(id).name;
},
+ getNetworkIsFavorite: function(id) {
+ let network = this._lookupNetwork(id);
+
+ if (network.hasOwnProperty('favorite'))
+ return network['favorite'];
+
+ return false;
+ },
+
getNetworkDetails: function(id) {
let network = this._lookupNetwork(id);
if (!network.servers || !network.servers.length)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]