[kupfer] task: Name is not a creation parameter



commit 1ea9723a334f5d3f4aebc57a77f627f4882ab89b
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Mon Aug 24 16:02:35 2009 +0200

    task: Name is not a creation parameter
    
    We should set name in the Action scheduling, not when creating tasks.

 kupfer/plugin/fileactions.py |    2 +-
 kupfer/plugin/urlactions.py  |    2 +-
 kupfer/task.py               |   15 +++++++++++----
 3 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/kupfer/plugin/fileactions.py b/kupfer/plugin/fileactions.py
index fd38285..96de375 100644
--- a/kupfer/plugin/fileactions.py
+++ b/kupfer/plugin/fileactions.py
@@ -110,7 +110,7 @@ class CopyTask (task.ThreadTask, pretty.OutputMixin):
 		self.sfile = gio.File(spath)
 		bname = self.sfile.get_basename()
 		self.dfile = gio.File(os_path.join(dpath, bname))
-		super(CopyTask, self).__init__("Copy %s" % bname)
+		super(CopyTask, self).__init__()
 
 	def thread_do(self):
 		self.ret = self.sfile.copy(self.dfile)
diff --git a/kupfer/plugin/urlactions.py b/kupfer/plugin/urlactions.py
index cee1d45..bae2e45 100644
--- a/kupfer/plugin/urlactions.py
+++ b/kupfer/plugin/urlactions.py
@@ -17,7 +17,7 @@ __author__ = "Ulrik Sverdrup <ulrik sverdrup gmail com>"
 
 class DownloadTask (task.StepTask):
 	def __init__(self, uri, destdir, finish_callback=None):
-		super(DownloadTask, self).__init__("Download %s" % uri)
+		super(DownloadTask, self).__init__()
 		self.response = urllib2.urlopen(uri)
 
 		header_basename = self.response.headers.get('Content-Disposition')
diff --git a/kupfer/task.py b/kupfer/task.py
index 1d38f20..1996369 100644
--- a/kupfer/task.py
+++ b/kupfer/task.py
@@ -4,10 +4,17 @@ from kupfer import scheduler, pretty
 
 class Task (object):
 	"""Represent a task that can be done in the background"""
-	def __init__(self, name):
-		self.name = name
+	def __init__(self):
+		self._name = None
+
+	def set_name(self, name):
+		"""Allow setting the user-visible name of this task"""
+		self._name = name
 
 	def __str__(self):
+		return self._name and self._name.decode("utf-8")
+
+	def __unicode__(self):
 		return self.name
 
 	def is_thread(self):
@@ -40,8 +47,8 @@ class StepTask (Task):
 
 class ThreadTask (Task):
 	"""Run in a thread"""
-	def __init__(self, name):
-		Task.__init__(self, name)
+	def __init__(self):
+		Task.__init__(self)
 		self._thread = None
 
 	def is_thread(self):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]