[gnome-shell] Add volumes support to places
- From: Colin Walters <walters src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-shell] Add volumes support to places
- Date: Wed, 2 Sep 2009 19:06:19 +0000 (UTC)
commit 090908439b113f6cb0dc9741d0573ca623c241c8
Author: Adel Gadllah <adel gadllah gmail com>
Date: Wed Sep 2 20:41:32 2009 +0200
Add volumes support to places
Display the mounted volumes in the places section of the overlay.
Signed-off-by: Adel Gadllah <adel gadllah gmail com>
Signed-off-by: Colin Walters <walters verbum org>
js/ui/places.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 76 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/places.js b/js/ui/places.js
index 12bb8bd..903cd4e 100644
--- a/js/ui/places.js
+++ b/js/ui/places.js
@@ -80,6 +80,9 @@ Places.prototype = {
this._menuBox = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
spacing: PLACES_VSPACING });
this.actor.append(this._menuBox, Big.BoxPackFlags.EXPAND);
+ this._devBox = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
+ spacing: PLACES_VSPACING });
+
this._dirsBox = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
spacing: PLACES_VSPACING });
this.actor.append(this._dirsBox, Big.BoxPackFlags.EXPAND);
@@ -98,6 +101,23 @@ Places.prototype = {
this._menuBox.append(home.actor, Big.BoxPackFlags.NONE);
+ /*
+ * Show devices, code more or less ported from nautilus-places-sidebar.c
+ */
+
+ this._menuBox.append(this._devBox, Big.BoxPackFlags.NONE);
+ this._volumeMonitor = Gio.VolumeMonitor.get();
+ this._volumeMonitor.connect('volume-added', Lang.bind(this, this._updateDevices));
+ this._volumeMonitor.connect('volume-removed',Lang.bind(this, this._updateDevices));
+ this._volumeMonitor.connect('volume-changed', Lang.bind(this, this._updateDevices));
+ this._volumeMonitor.connect('mount-added', Lang.bind(this, this._updateDevices));
+ this._volumeMonitor.connect('mount-removed', Lang.bind(this, this._updateDevices));
+ this._volumeMonitor.connect('mount-changed', Lang.bind(this, this._updateDevices));
+ this._volumeMonitor.connect('drive-connected', Lang.bind(this, this._updateDevices));
+ this._volumeMonitor.connect('drive-disconnected', Lang.bind(this, this._updateDevices));
+ this._volumeMonitor.connect('drive-changed', Lang.bind(this, this._updateDevices));
+ this._updateDevices();
+
let networkApp = null;
try {
networkApp = Shell.AppSystem.get_default().load_from_desktop_file('gnome-network-scheme.desktop');
@@ -197,6 +217,62 @@ Places.prototype = {
});
this._dirsBox.append(item.actor, Big.BoxPackFlags.NONE);
}
+ },
+
+ _updateDevices: function() {
+ this._devBox.remove_all();
+
+ /* first go through all connected drives */
+ let drives = this._volumeMonitor.get_connected_drives();
+ for (let i = 0; i < drives.length; i++) {
+ let volumes = drives[i].get_volumes();
+ for(let j = 0; j < volumes.length; j++) {
+ let mount = volumes[j].get_mount();
+ if(mount != null) {
+ this._addMount(mount);
+ }
+ }
+ }
+
+ /* add all volumes that is not associated with a drive */
+ let volumes = this._volumeMonitor.get_volumes();
+ for(let i = 0; i < volumes.length; i++) {
+ if(volumes[i].get_drive() != null)
+ continue;
+
+ let mount = volumes[i].get_mount();
+ if(mount != null) {
+ this._addMount(mount);
+ }
+ }
+
+ /* add mounts that have no volume (/etc/mtab mounts, ftp, sftp,...) */
+ let mounts = this._volumeMonitor.get_mounts();
+ for(let i = 0; i < mounts.length; i++) {
+ if(mounts[i].is_shadowed())
+ continue;
+
+ if(mounts[i].get_volume())
+ continue;
+
+ this._addMount(mounts[i]);
+ }
+ },
+
+ _addMount: function(mount) {
+ let mountLabel = mount.get_name();
+ let mountIcon = mount.get_icon();
+ let root = mount.get_root();
+ let mountUri = root.get_uri();
+ let devItem = new PlaceDisplay(mountLabel,
+ function() {
+ return Shell.TextureCache.get_default().load_gicon(mountIcon, PLACES_ICON_SIZE);
+ },
+ function() {
+ Gio.app_info_launch_default_for_uri(mountUri, Main.createAppLaunchContext());
+ });
+ this._devBox.append(devItem.actor, Big.BoxPackFlags.NONE);
}
+
};
Signals.addSignalMethods(Places.prototype);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]