diff --git a/ChangeLog b/ChangeLog index 330bc0e..a436a12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-04-11 Thomas Vander Stichele + + * examples/gtkcrc.py: + * morituri/common/task.py: + Add task object to listener interface methods. + 2009-04-11 Thomas Vander Stichele * morituri/common/task.py: diff --git a/examples/gtkcrc.py b/examples/gtkcrc.py index 4ac2a61..4e1737b 100644 --- a/examples/gtkcrc.py +++ b/examples/gtkcrc.py @@ -57,14 +57,14 @@ class TaskProgress(gtk.VBox, task.TaskRunner): gtk.main_iteration() task.start() - def started(self): + def started(self, task): pass - def stopped(self): + def stopped(self, task): self.emit('stop') # self._task.removeListener(self) - def progressed(self, value): + def progressed(self, task, value): gst.info('progressed') # FIXME: why is this not painting the progress bar ? self._progress.set_fraction(value) diff --git a/morituri/common/task.py b/morituri/common/task.py index ff16967..c7c8582 100644 --- a/morituri/common/task.py +++ b/morituri/common/task.py @@ -77,7 +77,7 @@ class Task(object): def _notifyListeners(self, methodName, *args, **kwargs): if self._listeners: for l in self._listeners: - getattr(l, methodName)(*args, **kwargs) + getattr(l, methodName)(self, *args, **kwargs) class TaskRunner: """ @@ -94,7 +94,7 @@ class TaskRunner: raise NotImplementedError # listener callbacks - def progressed(self, value): + def progressed(self, task, value): """ Implement me to be informed about progress. @@ -102,12 +102,12 @@ class TaskRunner: @param value: progress, from 0.0 to 1.0 """ - def started(self): + def started(self, task): """ Implement me to be informed about the task starting. """ - def stopped(self): + def stopped(self, task): """ Implement me to be informed about the task starting. """ @@ -120,7 +120,7 @@ class SyncRunner(TaskRunner): self._task.start() self._loop.run() - def progressed(self, value): + def progressed(self, task, value): sys.stdout.write('%s %3d %%\r' % ( self._task.description, value * 100.0)) sys.stdout.flush() @@ -129,5 +129,5 @@ class SyncRunner(TaskRunner): sys.stdout.write('%s %3d %%\n' % ( self._task.description, 100.0)) - def stopped(self): + def stopped(self, task): self._loop.quit()