Improve callback usage

Julien LepillerSun Dec 13 03:14:19+0100 2020

276a05d

Improve callback usage

offlate/ui/editor.py

369369
    def save(self):
370370
        self.project.save()
371371
372-
    def send(self):
372+
    def send(self, callback=Interface()):
373373
        self.project.save()
374-
        self.project.send(Interface())
374+
        self.project.send(callback)
375375
376376
    def update(self, callback=Interface()):
377377
        self.project.save()

766766
        self.setGeometry(0, 0, 800, 600)
767767
        self.setWindowTitle('Offlate')
768768
769-
class UploadRunnable(RunnableCallback):
769+
class UploadRunnable(RunnableCallback, Interface):
770770
    def __init__(self, widget):
771-
        super().__init__()
771+
        Interface.__init__(self)
772+
        RunnableCallback.__init__(self)
772773
        self.widget = widget
773774
        self.parent = widget
774775
        self.signals = RunnableSignals()

777778
        self.name = self.widget.project.name
778779
779780
    def do_run(self):
780-
        self.widget.send()
781+
        self.widget.send(self)
781782
782783
    def do_finish(self):
783784
        self.signals.finished.emit(self.name)
784785
785-
class UpdateRunnable(RunnableCallback):
786+
class UpdateRunnable(RunnableCallback, Interface):
786787
    def __init__(self, widget):
787-
        super().__init__()
788+
        Interface.__init__(self)
789+
        RunnableCallback.__init__(self)
788790
        self.widget = widget
789791
        self.parent = widget
790792
        self.signals = RunnableSignals()

793795
        self.name = self.widget.project.name
794796
795797
    def do_run(self):
796-
        self.widget.update(Interface())
798+
        self.widget.update(self)
797799
798800
    def do_finish(self):
799801
        self.signals.finished.emit(self.name)