Exemplo n.º 1
0
    def __init__(self, final_message: Dict,
                 progress_view: 'ProgressAndHistoryView', core: ApartCore,
                 z_options: List[str]):
        FinishedJob.__init__(self,
                             final_message,
                             progress_view,
                             core,
                             icon_name='dialog-error',
                             z_options=z_options)

        self.fail_reason = key_and_val('Failed', self.msg['error'])
        self.image_source = key_and_val('Restoring from', self.msg['source'])
        self.stats = Gtk.VBox()
        for stat in [self.fail_reason, self.image_source, self.duration]:
            self.stats.add(stat)
        self.stats.get_style_context().add_class('finished-job-stats')
        self.stats.show_all()
        self.extra.add(self.stats)
        # naive rerun is unsafe for restore jobs as /dev/abc1 may refer to different partition
        # than when last run
        self.rerun_btn.destroy()
Exemplo n.º 2
0
    def __init__(self, core: ApartCore, on_finish: Callable[[Dict], None]):
        """:param on_finish: called when job has received it's final message, with the this message as an arg"""
        self.core = core
        self.on_finish = on_finish
        self.last_message = None  # Dict
        self.fail_message = None  # Dict
        self.tenant = None  # GridRowTenant
        self.start = None  # datetime
        self.cancelling = False
        self.syncing = None  # Gtk.Box

        # row 1
        self.title_source = Gtk.Label('', xalign=0, visible=True)
        self.title_name = Gtk.Label('', xalign=0, visible=True)
        self.title_dest = Gtk.Label('', xalign=0, visible=True)
        self.title_box = Gtk.Box(visible=True)
        self.title_box.add(self.title_source)
        self.title_box.add(self.title_name)
        self.title_box.add(self.title_dest)
        self.cancel_btn = Gtk.Button('Cancel',
                                     visible=True,
                                     halign=Gtk.Align.END)
        self.cancel_btn.get_style_context().add_class('job-cancel-btn')
        self.cancel_btn.connect('clicked', self.cancel)

        # row 2
        self.rate = key_and_val('Rate', '')
        self.rate.show_all()
        self.elapsed = key_and_val('Elapsed', '')
        self.elapsed.show_all()
        self.estimated_completion = key_and_val('Remaining', '')
        self.stats = Gtk.Box(visible=True)
        self.stats.add(self.elapsed)
        self.stats.add(self.rate)
        self.stats.add(self.estimated_completion)
        self.stats.get_style_context().add_class('job-stats')

        # row 3
        self.progress_bar = Gtk.ProgressBar(hexpand=True, visible=True)
Exemplo n.º 3
0
    def __init__(self, final_message: Dict,
                 progress_view: 'ProgressAndHistoryView', core: ApartCore,
                 z_options: List[str]):
        FinishedJob.__init__(self,
                             final_message,
                             progress_view,
                             core,
                             icon_name='object-select-symbolic',
                             forget_on_rerun=False,
                             z_options=z_options)

        self.image_size = key_and_val(
            'Image size',
            humanize.naturalsize(self.msg['image_size'], binary=True))
        self.filename = key_and_val('Image file',
                                    extract_filename(self.msg['destination']))

        self.source_uuid = None
        if self.msg.get('source_uuid'):
            self.source_uuid = key_and_val('Partition uuid',
                                           self.msg['source_uuid'])

        self.stats = Gtk.VBox()
        for stat in [
                self.filename, self.image_size, self.source_uuid, self.duration
        ]:
            if stat:
                self.stats.add(stat)

        self.stats.get_style_context().add_class('finished-job-stats')
        self.stats.show_all()
        self.extra.add(self.stats)
        self.delete_image_btn = Gtk.Button.new_from_icon_name(
            'user-trash-full-symbolic', Gtk.IconSize.SMALL_TOOLBAR)
        self.delete_image_btn.set_tooltip_text(DELETE_TIP)
        self.delete_image_btn.show_all()
        self.delete_image_btn.connect('clicked', self.delete_image)
        self.buttons.add(self.delete_image_btn)
        self.buttons.reorder_child(self.delete_image_btn, 0)
Exemplo n.º 4
0
 def __init__(self, final_message: Dict,
              progress_view: 'ProgressAndHistoryView', core: ApartCore,
              z_options: List[str]):
     FinishedJob.__init__(self,
                          final_message,
                          progress_view,
                          core,
                          icon_name='dialog-error',
                          z_options=z_options)
     self.fail_reason = key_and_val('Failed', self.msg['error'])
     self.stats = Gtk.VBox()
     self.stats.add(self.fail_reason)
     self.stats.add(self.duration)
     self.stats.get_style_context().add_class('finished-job-stats')
     self.stats.show_all()
     self.extra.add(self.stats)
Exemplo n.º 5
0
    def __init__(self,
                 final_message: Dict,
                 progress_view: 'ProgressAndHistoryView',
                 core: ApartCore,
                 icon_name: str,
                 z_options: List[str],
                 forget_on_rerun: bool = True):
        self.msg = final_message
        self.finish = self.msg['finish']  # datetime
        self.core = core
        self.z_options = z_options
        self.progress_view = progress_view
        self.tenant = None
        self.forget_on_rerun = forget_on_rerun
        self.extra_user_state = None  # RevealState

        self.source_available = SourceAvailability.GONE

        self.duration = key_and_val(
            DURATION_KEY,
            str(round_to_second(self.msg['finish'] - self.msg['start'])))

        self.icon = Gtk.Image.new_from_icon_name(icon_name,
                                                 Gtk.IconSize.LARGE_TOOLBAR)
        title_source = Gtk.Label('', xalign=0)
        title_name = Gtk.Label('', xalign=0)
        title_destination = Gtk.Label('', xalign=0)

        if final_message['type'].startswith('clone'):
            title_source.set_text(rm_dev(self.msg['source']))
            title_name.set_text(extract_name(self.msg['destination']))
            title_name.get_style_context().add_class("job-name")
            title_destination.set_text(
                '-> ' + extract_directory(self.msg['destination']))
        else:
            title_source.set_text(extract_filename(self.msg['source']))
            title_destination.set_text(' -> ' +
                                       rm_dev(self.msg['destination']))

        self.title_inner_box = Gtk.Box(hexpand=True)
        self.title_inner_box.add(self.icon)
        self.title_inner_box.add(title_source)
        self.title_inner_box.add(title_name)
        self.title_inner_box.add(title_destination)
        self.title_inner_box.get_style_context().add_class(
            'finished-job-title')
        self.title_inner_box.show_all()
        self.title_box = Gtk.EventBox(visible=True)
        self.title_box.add(self.title_inner_box)

        self.title_box.connect('button-press-event', self.on_row_click)

        self.finish_label = Gtk.Label('',
                                      halign=Gtk.Align.START,
                                      visible=True,
                                      hexpand=True)
        self.finish_label.get_style_context().add_class('finish-label')
        self.finish_label.get_style_context().add_class('dim-label')
        self.finish_box = Gtk.EventBox(visible=True)
        self.finish_box.add(self.finish_label)
        self.finish_box.connect('button-press-event', self.on_row_click)

        self.rerun_btn = Gtk.Button.new_from_icon_name(
            'view-refresh-symbolic', Gtk.IconSize.SMALL_TOOLBAR)
        self.rerun_btn.set_tooltip_text(RERUN_TIP)
        self.rerun_btn.connect('clicked', self.rerun)
        self.forget_btn = Gtk.Button(FORGET_TEXT)
        self.forget_btn.set_tooltip_text(FORGET_TIP)
        self.forget_btn.connect('clicked', self.forget)
        self.buttons = Gtk.Box(visible=True, halign=Gtk.Align.END)
        self.buttons.add(self.rerun_btn)
        self.buttons.add(self.forget_btn)
        self.buttons.get_style_context().add_class('job-buttons')
        self.buttons.show_all()

        self.extra = Gtk.Revealer(
            transition_duration=settings.animation_duration_ms(), visible=True)
        self.extra.set_reveal_child(
            RevealState.default() is RevealState.REVEALED)
        self.compression_available = \
            extract_compression_option(self.msg['destination']) in z_options
        self.update()