Example #1
0
    def __init__(self, store, model=None):
        BaseEditor.__init__(self, store, model)
        self.progress_dialog = ProgressDialog()
        self.progress_dialog.connect('cancel',
                                     self._on_progress_dialog__cancel)
        self.progress_dialog.set_transient_for(self.main_dialog)

        if self.edit_mode:
            self.printer.set_sensitive(False)
            self.main_dialog.ok_button.grab_focus()
        else:
            self.edit_constants.hide()
            self.device_serial.hide()
            self.device_serial_label.hide()
            self.is_active.hide()
Example #2
0
    def confirm(self, retval=None):
        total_products = len(self.mass_editor.get_changed_objects())
        if total_products == 0:
            self.retval = False
            self.close()
            return

        retval = yesno(
            _('This will update {} products. Are you sure?'.format(
                total_products)), Gtk.ResponseType.NO, _('Apply changes'),
            _('Don\'t apply.'))
        if not retval:
            # Don't close the dialog. Let the user make more changes if he
            # wants to or cancel the dialog.
            return

        # FIXME: Is there a nicer way to display this progress?
        self.ok_button.set_sensitive(False)
        self.cancel_button.set_sensitive(False)
        d = ProgressDialog(_('Updating items'), pulse=False)
        d.set_transient_for(self)
        d.start(wait=0)
        d.cancel.hide()

        try:
            for i, total in self.mass_editor.confirm(self):
                d.progressbar.set_text('%s/%s' % (i + 1, total))
                d.progressbar.set_fraction((i + 1) / float(total))
                while Gtk.events_pending():
                    Gtk.main_iteration_do(False)
        except Exception as e:
            d.stop()
            self.retval = False
            log.error(''.join(traceback.format_exception(*sys.exc_info())))
            warning(_('There was an error saving one of the values'), str(e))
            self.close()
            return

        d.stop()
        self.retval = True
        self.close()
Example #3
0
    def _handle_action(self, action):
        retval = self._manager.handle_action(action)
        if action.threaded:
            thread = retval

            msg = _('Executing "%s". This might take a while...') % (
                action.label, )
            progress_dialog = ProgressDialog(msg, pulse=True)
            progress_dialog.start(wait=100)
            progress_dialog.set_transient_for(self.get_toplevel())
            progress_dialog.set_title(action.resource.label)
            progress_dialog.connect(
                'cancel', lambda d: terminate_thread(thread))

            while thread.is_alive():
                if Gtk.events_pending():
                    Gtk.main_iteration_do(False)

            progress_dialog.stop()

        self._update_ui()
Example #4
0
    def on_confirm(self):
        marker('Saving prices')
        # FIXME: Improve this part. This is just a quick workaround to
        # release the bugfix asap
        self.main_dialog.ok_button.set_sensitive(False)
        self.main_dialog.cancel_button.set_sensitive(False)
        d = ProgressDialog(_('Updating items'), pulse=False)
        d.set_transient_for(self.main_dialog)
        d.start(wait=0)
        d.cancel.hide()

        total = len(self.slave.listcontainer.list)
        for i, s in enumerate(self.slave.listcontainer.list):
            s.save_changes()
            d.progressbar.set_text('%s/%s' % (i + 1, total))
            d.progressbar.set_fraction((i + 1) / float(total))
            while gtk.events_pending():
                gtk.main_iteration(False)

        d.stop()
        marker('Done saving prices')
        self.slave.listcontainer.list.clear()
Example #5
0
 def _create_progress(self, title):
     self._progress_dialog = ProgressDialog(title, pulse=False)
     self._progress_dialog.set_transient_for(self.main_dialog)
     self._progress_dialog.start(wait=0)
     self._progress_dialog.cancel.hide()