[gnome-shell/hotplug: 13/14] automount: handle the drive-eject-button signal
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/hotplug: 13/14] automount: handle the drive-eject-button signal
- Date: Mon, 11 Jul 2011 14:40:53 +0000 (UTC)
commit 8f17bb4f8611a0665949e3854a4b56463aa1e7e1
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Jun 27 12:13:54 2011 -0400
automount: handle the drive-eject-button signal
The implementation is untested, as the signal is not emitted from the
Gdu GVfs volume monitor yet.
https://bugzilla.gnome.org/show_bug.cgi?id=653520
js/ui/automountManager.js | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/automountManager.js b/js/ui/automountManager.js
index d064388..4c15517 100644
--- a/js/ui/automountManager.js
+++ b/js/ui/automountManager.js
@@ -167,6 +167,10 @@ AutomountManager.prototype = {
this._volumeMonitor.connect('drive-disconnected',
Lang.bind(this,
this._onDriveDisconnected));
+
+ this._volumeMonitor.connect('drive-eject-button',
+ Lang.bind(this,
+ this._onDriveEjectButton));
},
_screenSaverActiveChanged: function(object, isActive) {
@@ -226,6 +230,35 @@ AutomountManager.prototype = {
global.play_theme_sound(0, 'device-removed-media');
},
+ _onDriveEjectButton: function(monitor, drive) {
+ // TODO: this code path is not tested, as the GVfs volume monitor
+ // doesn't emit this signal just yet.
+ if (!this.ckListener.sessionActive)
+ return;
+
+ if (drive.can_stop()) {
+ drive.stop
+ (Gio.MountUnmountFlags.FORCE, null, null,
+ Lang.bind(this, function(drive, res) {
+ try {
+ drive.stop_finish(res);
+ } catch (e) {
+ log("Unable to stop the drive after drive-eject-button " + e.toString());
+ }
+ }));
+ } else if (drive.can_eject()) {
+ drive.eject_with_operation
+ (Gio.MountUnmountFlags.FORCE, null, null,
+ Lang.bind(this, function(drive, res) {
+ try {
+ drive.eject_with_operation_finish(res);
+ } catch (e) {
+ log("Unable to eject the drive after drive-eject-button " + e.toString());
+ }
+ }));
+ }
+ },
+
_onVolumeAdded: function(monitor, volume) {
this._checkAndMountVolume(volume);
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]