[kupfer: 13/53] volumes: Port to wants_context
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer: 13/53] volumes: Port to wants_context
- Date: Thu, 24 Mar 2011 16:31:39 +0000 (UTC)
commit 4aa519b30d6313dd19ed634d7ff97560543efc6d
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Thu Mar 24 17:22:34 2011 +0100
volumes: Port to wants_context
kupfer/plugin/volumes.py | 22 ++++++++++------------
1 files changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/kupfer/plugin/volumes.py b/kupfer/plugin/volumes.py
index f8b34e0..5fc8ba0 100644
--- a/kupfer/plugin/volumes.py
+++ b/kupfer/plugin/volumes.py
@@ -9,7 +9,6 @@ import gio
from kupfer.objects import Leaf, Action, Source, FileLeaf
from kupfer.obj.fileactions import Open, OpenTerminal
from kupfer.objects import OperationError
-from kupfer import commandexec
from kupfer import utils
@@ -51,30 +50,29 @@ class Unmount (Action):
def __init__(self, name=None):
super(Unmount, self).__init__(name or _("Unmount"))
- def eject_callback(self, mount, async_result, token):
- ctx = commandexec.DefaultActionExecutionContext()
+ def eject_callback(self, mount, async_result, ctx):
try:
mount.eject_finish(async_result)
except gio.Error:
- ctx.register_late_error(token)
+ ctx.register_late_error()
- def unmount_callback(self, mount, async_result, token):
- ctx = commandexec.DefaultActionExecutionContext()
+ def unmount_callback(self, mount, async_result, ctx):
try:
mount.unmount_finish(async_result)
except gio.Error:
- ctx.register_late_error(token)
+ ctx.register_late_error()
- def activate(self, leaf):
+ def wants_context(self):
+ return True
+
+ def activate(self, leaf, ctx):
if not leaf.is_valid():
return
- ctx = commandexec.DefaultActionExecutionContext()
- token = ctx.get_async_token()
vol = leaf.volume
if vol.can_eject():
- vol.eject(self.eject_callback, user_data=token)
+ vol.eject(self.eject_callback, user_data=ctx)
elif vol.can_unmount():
- vol.unmount(self.unmount_callback, user_data=token)
+ vol.unmount(self.unmount_callback, user_data=ctx)
def get_description(self):
return _("Unmount this volume")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]