[gnome-shell-extensions] drive-menu: fix interesting check
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] drive-menu: fix interesting check
- Date: Wed, 5 Feb 2014 00:02:06 +0000 (UTC)
commit a519c9fe911a87e54c67a449219c581924a4e8d5
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Wed Feb 5 01:00:35 2014 +0100
drive-menu: fix interesting check
In case of shadowed mounts, mounts can become uninteresting
after they are added, according to whether our handler or gvfs
runs first, so we need to watch for changes. The easiest way
is to create an item for all mounts, and only show the interesting
ones.
extensions/drive-menu/extension.js | 58 +++++++++++++++++++++---------------
1 files changed, 34 insertions(+), 24 deletions(-)
---
diff --git a/extensions/drive-menu/extension.js b/extensions/drive-menu/extension.js
index 62de8bf..7f73477 100644
--- a/extensions/drive-menu/extension.js
+++ b/extensions/drive-menu/extension.js
@@ -36,6 +36,39 @@ const MountMenuItem = new Lang.Class({
let ejectButton = new St.Button({ child: ejectIcon });
ejectButton.connect('clicked', Lang.bind(this, this._eject));
this.actor.add(ejectButton);
+
+ this._changedId = mount.connect('changed', Lang.bind(this, this._syncVisibility));
+ this._syncVisibility();
+ },
+
+ destroy: function() {
+ if (this._changedId) {
+ this.mount.disconnect(this._changedId);
+ this._changedId = 0;
+ }
+
+ this.parent();
+ },
+
+ _isInteresting: function() {
+ if (!this.mount.can_eject() && !this.mount.can_unmount())
+ return false;
+ if (this.mount.is_shadowed())
+ return false;
+
+ let volume = this.mount.get_volume();
+
+ if (volume == null) {
+ // probably a GDaemonMount, could be network or
+ // local, but we can't tell; assume it's local for now
+ return true;
+ }
+
+ return volume.get_identifier('class') != 'network';
+ },
+
+ _syncVisibility: function() {
+ this.actor.visible = this._isInteresting();
},
_eject: function() {
@@ -124,42 +157,19 @@ const DriveMenu = new Lang.Class({
},
_updateMenuVisibility: function() {
- if (this._mounts.length > 0)
+ if (this._mounts.filter(function(i) i.actor.visible).length > 0)
this.actor.show();
else
this.actor.hide();
},
- _isMountInteresting: function(mount) {
- if (!mount.can_eject() && !mount.can_unmount())
- return false;
- if (mount.is_shadowed())
- return false;
-
- let volume = mount.get_volume();
-
- if (volume == null) {
- // probably a GDaemonMount, could be network or
- // local, but we can't tell; assume it's local for now
- return true;
- }
-
- return volume.get_identifier('class') != 'network';
- },
-
_addMount: function(mount) {
- if (!this._isMountInteresting(mount))
- return;
-
let item = new MountMenuItem(mount);
this._mounts.unshift(item);
this.menu.addMenuItem(item, 0);
},
_removeMount: function(mount) {
- if (!this._isMountInteresting(mount))
- return;
-
for (let i = 0; i < this._mounts.length; i++) {
let item = this._mounts[i];
if (item.mount == mount) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]