def _downgrade_option_alert(bundle): alert = ConfirmationAlert() alert.props.title = _("Older Version Of %s Activity") % (bundle.get_name()) alert.props.msg = _("Do you want to downgrade to version %s") % bundle.get_activity_version() alert.connect("response", _downgrade_alert_response_cb, bundle) journalwindow.get_journal_window().add_alert(alert) alert.show()
def __erase_alert_response_cb(self, alert, response_id): journalwindow.get_journal_window().remove_alert(alert) if response_id is Gtk.ResponseType.OK: uid = self._metadata['uid'] list_model = self._journalactivity.get_list_view().get_model() if list_model.is_selected(uid): list_model.set_selected(uid, False) model.delete(uid)
def _downgrade_option_alert(bundle, metadata): alert = ConfirmationAlert() alert.props.title = _('Older Version Of %s Activity') % (bundle.get_name()) alert.props.msg = _('Do you want to downgrade to version %s') % \ bundle.get_activity_version() alert.connect('response', _downgrade_alert_response_cb, metadata) journalwindow.get_journal_window().add_alert(alert) alert.show()
def __display_alert_cb(self, widget, message): if self._alert is None: self._alert = NotifyAlert() self._alert.props.title = ACCOUNT_NAME self._alert.connect('response', self.__alert_response_cb) journalwindow.get_journal_window().add_alert(self._alert) self._alert.show() self._alert.props.msg = message
def __erase_alert_response_cb(self, alert, response_id): journalwindow.get_journal_window().remove_alert(alert) if response_id is Gtk.ResponseType.OK: registry = bundleregistry.get_registry() bundle = misc.get_bundle(self._metadata) if bundle is not None and registry.is_installed(bundle): registry.uninstall(bundle) model.delete(self._metadata['uid'])
def _downgrade_alert_response_cb(alert, response_id, bundle): if response_id is Gtk.ResponseType.OK: journalwindow.get_journal_window().remove_alert(alert) registry = bundleregistry.get_registry() registry.install(bundle, force_downgrade=True) _launch_bundle(bundle) elif response_id is Gtk.ResponseType.CANCEL: journalwindow.get_journal_window().remove_alert(alert)
def _transfer_state_changed_cb(self, widget, state_message): logging.debug('_transfer_state_changed_cb') # First, remove any existing alert if self._alert is None: self._alert = NotifyAlert() self._alert.props.title = ACCOUNT_NAME self._alert.connect('response', self._alert_response_cb) journalwindow.get_journal_window().add_alert(self._alert) self._alert.show() logging.debug(state_message) self._alert.props.msg = state_message
def __erase_activate_cb(self, menu_item): alert = Alert() erase_string = _("Erase") alert.props.title = erase_string alert.props.msg = _('Do you want to permanently erase "%s"?') % self._metadata["title"] icon = Icon(icon_name="dialog-cancel") alert.add_button(Gtk.ResponseType.CANCEL, _("Cancel"), icon) icon.show() ok_icon = Icon(icon_name="dialog-ok") alert.add_button(Gtk.ResponseType.OK, erase_string, ok_icon) ok_icon.show() alert.connect("response", self.__erase_alert_response_cb) journalwindow.get_journal_window().add_alert(alert) alert.show()
def _erase_button_clicked_cb(self, button): alert = Alert() erase_string = _('Erase') alert.props.title = erase_string alert.props.msg = _('Do you want to permanently erase \"%s\"?') \ % self._metadata['title'] icon = Icon(icon_name='dialog-cancel') alert.add_button(Gtk.ResponseType.CANCEL, _('Cancel'), icon) icon.show() ok_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, erase_string, ok_icon) ok_icon.show() alert.connect('response', self.__erase_alert_response_cb) journalwindow.get_journal_window().add_alert(alert) alert.show()
def _erase_alert_response_cb(self, alert, response_id, entry): journalwindow.get_journal_window().remove_alert(alert) if response_id is Gtk.ResponseType.OK: self._store.remove(entry) # Regenerate comments from current contents of store self._comments = [] for entry in self._store: self._comments.append({ self.FROM: entry[self.COMMENT_FROM], self.MESSAGE: entry[self.COMMENT_MESSAGE], self.ICON: entry[self.COMMENT_ICON], self.ICON_COLOR: '[%s]' % ( entry[self.COMMENT_ICON_COLOR].to_string()), }) self.emit('comments-changed', simplejson.dumps(self._comments))
def __item_activate_cb(self, menu_item, service_name): mime_type = self._metadata.get('mime_type', '') if mime_type: mime_registry = mimeregistry.get_registry() mime_registry.set_default_activity(mime_type, service_name) misc.resume(self._metadata, bundle_id=service_name, alert_window=journalwindow.get_journal_window())
def _resume_clicked_cb(self, button): if not misc.can_resume(self._metadata): palette = self._resume.get_palette() palette.popup(immediate=True) misc.resume(self._metadata, alert_window=journalwindow.get_journal_window())
def __icon_clicked_cb(self, cell, path): row = self.tree_view.get_model()[path] metadata = model.get(row[ListModel.COLUMN_UID]) if metadata["activity"] == PROJECT_BUNDLE_ID: self.emit("project-view-activate", metadata) return misc.resume(metadata, alert_window=journalwindow.get_journal_window())
def _erase_comment_cb(self, widget, event): alert = Alert() entry = self.get_selection().get_selected()[1] erase_string = _('Erase') alert.props.title = erase_string alert.props.msg = _('Do you want to permanently erase \"%s\"?') \ % self._store[entry][self.COMMENT_MESSAGE] icon = Icon(icon_name='dialog-cancel') alert.add_button(Gtk.ResponseType.CANCEL, _('Cancel'), icon) icon.show() ok_icon = Icon(icon_name='dialog-ok') alert.add_button(Gtk.ResponseType.OK, erase_string, ok_icon) ok_icon.show() alert.connect('response', self._erase_alert_response_cb, entry) journalwindow.get_journal_window().add_alert(alert) alert.show()
def _erase_alert_response_cb(self, alert, response_id, entry): journalwindow.get_journal_window().remove_alert(alert) if response_id is Gtk.ResponseType.OK: self._store.remove(entry) # Regenerate comments from current contents of store self._comments = [] for entry in self._store: self._comments.append({ self.FROM: entry[self.COMMENT_FROM], self.MESSAGE: entry[self.COMMENT_MESSAGE], self.ICON: entry[self.COMMENT_ICON], self.ICON_COLOR: '[%s]' % (entry[self.COMMENT_ICON_COLOR].to_string()), }) self.emit('comments-changed', json.dumps(self._comments))
def handle_bundle_installation(metadata, force_downgrade=False): """ Check metadata for a journal entry. If the metadata corresponds to a bundle, make sure that it is installed, and return the corresponding Bundle object. Installation sometimes requires a downgrade. Downgrades will not happen unless force_downgrade is set to True. Returns a tuple of two items: 1. The corresponding Bundle object for the journal entry, or None if installation failed. 2. A flag that indicates whether bundle installation was aborted due to a downgrade being required, and force_downgrade was False """ if metadata.get('progress', '').isdigit(): if int(metadata['progress']) < 100: return None, False bundle = get_bundle(metadata) if bundle is None: return None, False registry = bundleregistry.get_registry() window = journalwindow.get_journal_window().get_window() window.set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) Gdk.flush() try: installed = registry.install(bundle, force_downgrade) except AlreadyInstalledException: return bundle, True except (ZipExtractException, RegistrationException): logging.exception('Could not install bundle %s', bundle.get_path()) return None, False finally: window.set_cursor(None) Gdk.flush() # If we just installed a bundle, update the datastore accordingly. # We do not do this for JournalEntryBundles because the JEB code transforms # its own datastore entry and writes appropriate metadata. if installed and not isinstance(bundle, JournalEntryBundle): metadata['bundle_id'] = bundle.get_bundle_id() model.write(metadata) return bundle, False
def handle_bundle_installation(metadata, force_downgrade=False): """ Check metadata for a journal entry. If the metadata corresponds to a bundle, make sure that it is installed, and return the corresponding Bundle object. Installation sometimes requires a downgrade. Downgrades will not happen unless force_downgrade is set to True. Returns a tuple of two items: 1. The corresponding Bundle object for the journal entry, or None if installation failed. 2. A flag that indicates whether bundle installation was aborted due to a downgrade being required, and force_downgrade was False """ if metadata.get('progress', '').isdigit(): if int(metadata['progress']) < 100: return None, False bundle = get_bundle(metadata) if bundle is None: return None, False registry = bundleregistry.get_registry() window = journalwindow.get_journal_window().get_window() window.set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) Gdk.flush() try: installed = registry.install(bundle, force_downgrade) except AlreadyInstalledException: return bundle, True except (ZipExtractException, RegistrationException): logging.exception('Could not install bundle %s', bundle.get_path()) return None, False finally: window.set_cursor(None) # If we just installed a bundle, update the datastore accordingly. # We do not do this for JournalEntryBundles because the JEB code transforms # its own datastore entry and writes appropriate metadata. if installed and not isinstance(bundle, JournalEntryBundle): metadata['bundle_id'] = bundle.get_bundle_id() model.write(metadata) return bundle, False
def __icon_activate_cb(self, button): misc.resume(self._metadata, alert_window=journalwindow.get_journal_window()) return True
def _downgrade_alert_response_cb(alert, response_id, metadata): journalwindow.get_journal_window().remove_alert(alert) if response_id is Gtk.ResponseType.OK: resume(metadata, force_bundle_downgrade=True)
def _alert_response_cb(self, alert, response_id): journalwindow.get_journal_window().remove_alert(alert) self._alert = None
def __icon_clicked_cb(self, cell, path): row = self.tree_view.get_model()[path] metadata = model.get(row[ListModel.COLUMN_UID]) misc.resume(metadata, alert_window=journalwindow.get_journal_window())
def __alert_response_cb(self, alert, response_id): journalwindow.get_journal_window().remove_alert(alert) self._alert = None
def __start_activate_cb(self, menu_item): misc.resume(self._metadata, alert_window=journalwindow.get_journal_window())
def _preview_box_button_release_event_cb(self, button, event): logging.debug('_preview_box_button_release_event_cb') misc.resume(self._metadata, alert_window=journalwindow.get_journal_window()) return True
def __erase_alert_response_cb(self, alert, response_id): journalwindow.get_journal_window().remove_alert(alert) if response_id is Gtk.ResponseType.OK: model.delete(self._metadata['uid'])
def _resume_menu_item_activate_cb(self, menu_item, service_name): misc.resume(self._metadata, alert_window=journalwindow.get_journal_window())
def _resume_menu_item_activate_cb(self, menu_item, service_name): misc.resume(self._metadata, service_name, alert_window=journalwindow.get_journal_window())
def _resume_clicked_cb(self, button): misc.resume(self._metadata, alert_window=journalwindow.get_journal_window())