[kupfer] plugin.volumes: Combine Eject and Unmount action
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] plugin.volumes: Combine Eject and Unmount action
- Date: Wed, 9 Sep 2009 19:15:34 +0000 (UTC)
commit 6edc2bc18fffbb832d308c93e3da5d203e79abe8
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Wed Sep 9 00:26:25 2009 +0200
plugin.volumes: Combine Eject and Unmount action
kupfer/plugin/volumes.py | 31 ++++++++++++++-----------------
1 files changed, 14 insertions(+), 17 deletions(-)
---
diff --git a/kupfer/plugin/volumes.py b/kupfer/plugin/volumes.py
index f629c25..7989dec 100644
--- a/kupfer/plugin/volumes.py
+++ b/kupfer/plugin/volumes.py
@@ -39,37 +39,34 @@ class Volume (Leaf):
def get_icon_name(self):
return "drive-removable-media"
-class Eject (Action):
- def __init__(self):
- super(Eject, self).__init__(_("Eject"))
+class Unmount (Action):
+ def __init__(self, name=None):
+ super(Unmount, self).__init__(name or _("Unmount"))
def _callback(self, *args):
pass
def activate(self, leaf):
+ if not leaf.is_valid():
+ return
vol = leaf.volume
- vol.eject(self._callback)
+ if vol.can_eject():
+ vol.eject(self._callback)
+ elif vol.can_unmount():
+ vol.unmount(self._callback)
def get_description(self):
- return _("Unmount and eject this media")
+ return _("Unmount this volume")
+
def get_icon_name(self):
return "media-eject"
-class Unmount (Action):
+class Eject (Unmount):
def __init__(self):
- super(Unmount, self).__init__(_("Unmount"))
-
- def _callback(self, *args):
- pass
-
- def activate(self, leaf):
- vol = leaf.volume
- vol.unmount(self._callback)
+ super(Eject, self).__init__(_("Eject"))
def get_description(self):
- return _("Unmount this volume")
- def get_icon_name(self):
- return "media-eject"
+ return _("Unmount and eject this media")
class VolumesSource (Source):
def __init__(self, name=_("Volumes and Disks")):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]