[gnome-shell] ui: Allow moving menu items to a certain position
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] ui: Allow moving menu items to a certain position
- Date: Wed, 15 Feb 2017 21:50:11 +0000 (UTC)
commit c75785efffe945ae0d5c9eb6c51759f5404b5d24
Author: Benjamin Berg <bberg redhat com>
Date: Mon Feb 13 16:02:02 2017 +0100
ui: Allow moving menu items to a certain position
This function is a helper to simplify keeping menu items ordered when
their order is updated on the fly (e.g. network connections being
renamed).
https://bugzilla.gnome.org/show_bug.cgi?id=778686
js/ui/popupMenu.js | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js
index 52a58d6..011a95a 100644
--- a/js/ui/popupMenu.js
+++ b/js/ui/popupMenu.js
@@ -605,6 +605,24 @@ const PopupMenuBase = new Lang.Class({
menuItem.actor.show();
},
+ moveMenuItem: function(menuItem, position) {
+ let items = this._getMenuItems();
+ let i = 0;
+
+ while (i < items.length && position > 0) {
+ if (items[i] != menuItem)
+ position--;
+ i++;
+ }
+
+ if (i < items.length) {
+ if (items[i] != menuItem)
+ this.box.set_child_below_sibling(menuItem.actor, items[i].actor);
+ } else {
+ this.box.set_child_above_sibling(menuItem.actor, null);
+ }
+ },
+
addMenuItem: function(menuItem, position) {
let before_item = null;
if (position == undefined) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]