예제 #1
0
 def __init__(self, ui, title, size, abort_cb, ctx, dialog):
     self.ui = ui
     self.title = title
     self.abort_cb = abort_cb
     self.ctx = ctx
     self.iter = None
     self.dialog = dialog
     self.finished = False
     self.eta = None
     self.eta = ETA(size)
예제 #2
0
class Transfer_Item:
    def __init__(self, ui, title, size, abort_cb, ctx, dialog):
        self.ui = ui
        self.title = title
        self.abort_cb = abort_cb
        self.ctx = ctx
        self.iter = None
        self.dialog = dialog
        self.finished = False
        self.eta = None
        self.eta = ETA(size)

    def update(self, increment):
        eta = self.eta.update(increment)
        if self.dialog != None:
            self.dialog.update(eta)

        (seconds_left, v, progress) = eta
        if progress != None:
            text = "%s\n%s sec remaining" % (self.title, str(seconds_left))
            self.ui.transfer_list.set_value(self.iter, self.ui.COL_MSG, text)
            self.ui.transfer_list.set_value(self.iter, self.ui.COL_PROG, int(progress * 100))

    def cleanup(self, msg):
        if self.dialog != None:
            self.dialog.cleanup(msg)

        text = "%s\n%s" % (self.title, msg)
        self.ui.transfer_list.set_value(self.iter, self.ui.COL_MSG, text)
        self.ui.transfer_list.set_value(self.iter, self.ui.COL_PROG, 100)
        self.ui.transfer_list.set_value(self.iter, self.ui.COL_DELETE, self.ui.delete_icon)
        self.finished = True

    def abort(self):
        if not self.finished:
            self.abort_cb(self.ctx)

    def delete(self):
        if self.finished:
            self.ui.transfer_list.remove(self.iter)

    def clicked(self):
        if not self.finished:
            self.abort()
        else:
            self.delete()