[gnome-shell/hotplug: 17/21] autorun: refactor code a bit
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/hotplug: 17/21] autorun: refactor code a bit
- Date: Mon, 27 Jun 2011 19:53:23 +0000 (UTC)
commit 5849ca61734c73cc9b68515fb5f6fd2cfd05c642
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Jun 23 18:13:10 2011 -0400
autorun: refactor code a bit
js/ui/autorunManager.js | 37 +++++++++++--------------------------
1 files changed, 11 insertions(+), 26 deletions(-)
---
diff --git a/js/ui/autorunManager.js b/js/ui/autorunManager.js
index 99f1a54..6bf1d39 100644
--- a/js/ui/autorunManager.js
+++ b/js/ui/autorunManager.js
@@ -212,30 +212,27 @@ AutorunManager.prototype = {
drive.get_start_stop_type() == Gio.DriveStartStopType.SHUTDOWN &&
drive.can_stop()) {
drive.stop(0, mountOp.mountOp, null,
- Lang.bind(this, this._onDriveStop));
+ Lang.bind(this, this._onStop));
} else {
if (mount.can_eject()) {
mount.eject_with_operation(0, mountOp.mountOp, null,
- Lang.bind(this, this._onMountEject));
+ Lang.bind(this, this._onEject));
} else if (volume && volume.can_eject()) {
volume.eject_with_operation(0, mountOp.mountOp, null,
- Lang.bind(this, this._onVolumeEject));
+ Lang.bind(this, this._onEject));
} else if (drive && drive.can_eject()) {
drive.eject_with_operation(0, mountOp.mountOp, null,
- Lang.bind(this, this._onDriveEject));
+ Lang.bind(this, this._onEject));
} else if (mount.can_unmount()) {
mount.unmount_with_operation(0, mountOp.mountOp, null,
- Lang.bind(this, this._onMountEject));
+ Lang.bind(this, this._onUnmount));
}
}
},
- _onMountEject: function(mount, res) {
+ _onUnmount: function(mount, res) {
try {
- if (mount.can_eject())
- mount.eject_with_operation_finish(res);
- else
- mount.unmount_with_operation_finish(res);
+ mount.unmount_with_operation_finish(res);
} catch (e) {
// FIXME: we need to ignore G_IO_ERROR_FAILED_HANDLED errors here
// but we can't access the error code from JS.
@@ -245,19 +242,19 @@ AutorunManager.prototype = {
}
},
- _onDriveEject: function(drive, res) {
+ _onEject: function(source, res) {
try {
- drive.eject_with_operation_finish(res);
+ source.eject_with_operation_finish(res);
} catch (e) {
// FIXME: we need to ignore G_IO_ERROR_FAILED_HANDLED errors here
// but we can't access the error code from JS.
// See https://bugzilla.gnome.org/show_bug.cgi?id=591480
- log('Unable to eject the drive ' + drive.get_name()
+ log('Unable to eject the drive ' + source.get_name()
+ ': ' + e.toString());
}
},
- _onDriveStop: function(drive, res) {
+ _onStop: function(drive, res) {
try {
drive.stop_finish(res);
} catch (e) {
@@ -268,18 +265,6 @@ AutorunManager.prototype = {
+ ': ' + e.toString());
}
},
-
- _onVolumeEject: function(volume, res) {
- try {
- volume.eject_with_operation_finish(res);
- } catch (e) {
- // FIXME: we need to ignore G_IO_ERROR_FAILED_HANDLED errors here
- // but we can't access the error code from JS.
- // See https://bugzilla.gnome.org/show_bug.cgi?id=591480
- log('Unable to eject the volume ' + volume.get_name()
- + ': ' + e.toString());
- }
- },
}
function AutorunResidentSource() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]