|
|
f3cbb9 |
From ec8c1bbcb97699e51a2aa0306a7811c911f1a930 Mon Sep 17 00:00:00 2001
|
|
|
f3cbb9 |
From: Benjamin Berg <bberg@redhat.com>
|
|
|
f3cbb9 |
Date: Mon, 13 Feb 2017 16:02:02 +0100
|
|
|
f3cbb9 |
Subject: [PATCH 1/2] ui: Allow moving menu items to a certain position
|
|
|
f3cbb9 |
|
|
|
f3cbb9 |
This function is a helper to simplify keeping menu items ordered when
|
|
|
f3cbb9 |
their order is updated on the fly (e.g. network connections being
|
|
|
f3cbb9 |
renamed).
|
|
|
f3cbb9 |
|
|
|
f3cbb9 |
https://bugzilla.gnome.org/show_bug.cgi?id=778686
|
|
|
f3cbb9 |
---
|
|
|
f3cbb9 |
js/ui/popupMenu.js | 18 ++++++++++++++++++
|
|
|
f3cbb9 |
1 file changed, 18 insertions(+)
|
|
|
f3cbb9 |
|
|
|
f3cbb9 |
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
|
|
|
f3cbb9 |
index 52a58d6b8..011a95ac0 100644
|
|
|
f3cbb9 |
--- a/js/ui/popupMenu.js
|
|
|
f3cbb9 |
+++ b/js/ui/popupMenu.js
|
|
|
f3cbb9 |
@@ -605,6 +605,24 @@ const PopupMenuBase = new Lang.Class({
|
|
|
f3cbb9 |
menuItem.actor.show();
|
|
|
f3cbb9 |
},
|
|
|
f3cbb9 |
|
|
|
f3cbb9 |
+ moveMenuItem: function(menuItem, position) {
|
|
|
f3cbb9 |
+ let items = this._getMenuItems();
|
|
|
f3cbb9 |
+ let i = 0;
|
|
|
f3cbb9 |
+
|
|
|
f3cbb9 |
+ while (i < items.length && position > 0) {
|
|
|
f3cbb9 |
+ if (items[i] != menuItem)
|
|
|
f3cbb9 |
+ position--;
|
|
|
f3cbb9 |
+ i++;
|
|
|
f3cbb9 |
+ }
|
|
|
f3cbb9 |
+
|
|
|
f3cbb9 |
+ if (i < items.length) {
|
|
|
f3cbb9 |
+ if (items[i] != menuItem)
|
|
|
f3cbb9 |
+ this.box.set_child_below_sibling(menuItem.actor, items[i].actor);
|
|
|
f3cbb9 |
+ } else {
|
|
|
f3cbb9 |
+ this.box.set_child_above_sibling(menuItem.actor, null);
|
|
|
f3cbb9 |
+ }
|
|
|
f3cbb9 |
+ },
|
|
|
f3cbb9 |
+
|
|
|
f3cbb9 |
addMenuItem: function(menuItem, position) {
|
|
|
f3cbb9 |
let before_item = null;
|
|
|
f3cbb9 |
if (position == undefined) {
|
|
|
f3cbb9 |
--
|
|
|
f3cbb9 |
2.12.0
|
|
|
f3cbb9 |
|
|
|
f3cbb9 |
|
|
|
f3cbb9 |
From 40bb56b24c95289ee4bfc121cf9405d303a22609 Mon Sep 17 00:00:00 2001
|
|
|
f3cbb9 |
From: Benjamin Berg <bberg@redhat.com>
|
|
|
f3cbb9 |
Date: Mon, 13 Feb 2017 14:52:23 +0100
|
|
|
f3cbb9 |
Subject: [PATCH 2/2] network: Ensure the connection list is sorted after
|
|
|
f3cbb9 |
rename
|
|
|
f3cbb9 |
|
|
|
f3cbb9 |
Items were inserted correctly but the synchronisation was lost if the
|
|
|
f3cbb9 |
name of a connection was changed. Simply making sure the position is
|
|
|
f3cbb9 |
correct after a connection is updated fixes the issue.
|
|
|
f3cbb9 |
|
|
|
f3cbb9 |
Reported-by: Oliver Haessler <ohaessle@redhat.com>
|
|
|
f3cbb9 |
|
|
|
f3cbb9 |
https://bugzilla.gnome.org/show_bug.cgi?id=778686
|
|
|
f3cbb9 |
---
|
|
|
f3cbb9 |
js/ui/status/network.js | 13 ++++++++++++-
|
|
|
f3cbb9 |
1 file changed, 12 insertions(+), 1 deletion(-)
|
|
|
f3cbb9 |
|
|
|
f3cbb9 |
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
|
|
|
f3cbb9 |
index c386bff1d..11ca16014 100644
|
|
|
f3cbb9 |
--- a/js/ui/status/network.js
|
|
|
f3cbb9 |
+++ b/js/ui/status/network.js
|
|
|
f3cbb9 |
@@ -299,11 +299,22 @@ const NMConnectionSection = new Lang.Class({
|
|
|
f3cbb9 |
|
|
|
f3cbb9 |
let item = this._connectionItems.get(connection.get_uuid());
|
|
|
f3cbb9 |
if (item)
|
|
|
f3cbb9 |
- item.updateForConnection(connection);
|
|
|
f3cbb9 |
+ this._updateForConnection(item, connection);
|
|
|
f3cbb9 |
else
|
|
|
f3cbb9 |
this._addConnection(connection);
|
|
|
f3cbb9 |
},
|
|
|
f3cbb9 |
|
|
|
f3cbb9 |
+ _updateForConnection: function(item, connection) {
|
|
|
f3cbb9 |
+ let pos = this._connections.indexOf(connection);
|
|
|
f3cbb9 |
+
|
|
|
f3cbb9 |
+ this._connections.splice(pos, 1);
|
|
|
f3cbb9 |
+ pos = Util.insertSorted(this._connections, connection, Lang.bind(this, this._connectionSortFunction));
|
|
|
f3cbb9 |
+ this._labelSection.moveMenuItem(item.labelItem, pos);
|
|
|
f3cbb9 |
+ this._radioSection.moveMenuItem(item.radioItem, pos);
|
|
|
f3cbb9 |
+
|
|
|
f3cbb9 |
+ item.updateForConnection(connection);
|
|
|
f3cbb9 |
+ },
|
|
|
f3cbb9 |
+
|
|
|
f3cbb9 |
_addConnection: function(connection) {
|
|
|
f3cbb9 |
let item = this._makeConnectionItem(connection);
|
|
|
f3cbb9 |
if (!item)
|
|
|
f3cbb9 |
--
|
|
|
f3cbb9 |
2.12.0
|
|
|
f3cbb9 |
|