def __copy_to_volume_cb(self, menu_item): uid_list = self._get_uid_list_cb() if len(uid_list) == 1: uid = uid_list[0] file_path = model.get_file(uid) if not file_path or not os.path.exists(file_path): logging.warn('Entries without a file cannot be copied.') self.emit('volume-error', _('Entries without a file cannot be copied.'), _('Warning')) return try: metadata = model.get(uid) model.copy(metadata, self._mount_point) except IOError as e: logging.exception('Error while copying the entry. %s', e.strerror) self.emit('volume-error', _('Error while copying the entry. %s') % e.strerror, _('Error')) else: BatchOperator(self._journalactivity, uid_list, _('Copy'), self._get_confirmation_alert_message(len(uid_list)), self._perform_copy)
def __copy_to_volume_cb(self, menu_item): uid_list = self._get_uid_list_cb() if len(uid_list) == 1: uid = uid_list[0] file_path = model.get_file(uid) if not file_path or not os.path.exists(file_path): logging.warn('Entries without a file cannot be copied.') self.emit('volume-error', _('Entries without a file cannot be copied.'), _('Warning')) return try: metadata = model.get(uid) model.copy(metadata, self._mount_point) except IOError as e: logging.exception('Error while copying the entry. %s', e.strerror) self.emit('volume-error', _('Error while copying the entry. %s') % e.strerror, _('Error')) else: BatchOperator( self._journalactivity, uid_list, _('Copy'), self._get_confirmation_alert_message(len(uid_list)), self._perform_copy)
def _duplicate_clicked_cb(self, button): try: model.copy(self._metadata, '/') except IOError as e: logging.exception('Error while copying the entry.') self.emit('volume-error', _('Error while copying the entry. %s') % (e.strerror, ), _('Error'))
def _duplicate_clicked_cb(self, button): try: model.copy(self._metadata, '/') except IOError, e: logging.exception('Error while copying the entry.') self.emit('volume-error', _('Error while copying the entry. %s') % (e.strerror, ), _('Error'))
def __duplicate_activate_cb(self, menu_item): try: model.copy(self._metadata, '/') except IOError, e: logging.exception('Error while copying the entry. %s', e.strerror) self.emit('volume-error', _('Error while copying the entry. %s') % e.strerror, _('Error'))
def __duplicate_activate_cb(self, menu_item): try: model.copy(self._metadata, '/') except IOError as e: logging.exception('Error while copying the entry. %s', e.strerror) self.emit('volume-error', _('Error while copying the entry. %s') % e.strerror, _('Error'))
def _perform_copy(self, metadata): file_path = model.get_file(metadata["uid"]) if not file_path or not os.path.exists(file_path): logging.warn("Entries without a file cannot be copied.") return try: model.copy(metadata, self._mount_point) except IOError, e: logging.exception("Error while copying the entry. %s", e.strerror)
def _perform_copy(self, metadata): file_path = model.get_file(metadata['uid']) if not file_path or not os.path.exists(file_path): logging.warn('Entries without a file cannot be copied.') return try: model.copy(metadata, self._mount_point) except IOError, e: logging.exception('Error while copying the entry. %s', e.strerror)
def resume(metadata, bundle_id=None, alert_window=None, force_bundle_downgrade=False): # These are set later, and used in the following functions. bundle = None activity_id = None def launch_activity(object_id): launch(bundle, activity_id=activity_id, object_id=object_id, color=get_icon_color(metadata), alert_window=alert_window) def ready_callback(metadata, source, destination): launch_activity(destination) registry = bundleregistry.get_registry() ds_bundle, downgrade_required = \ handle_bundle_installation(metadata, force_bundle_downgrade) if ds_bundle is not None and downgrade_required: # A bundle is being resumed but we didn't install it as that would # require a downgrade. _downgrade_option_alert(ds_bundle, metadata) return # Are we launching a bundle? if ds_bundle is not None and bundle_id is None: activity_bundle = registry.get_bundle(ds_bundle.get_bundle_id()) if activity_bundle is not None: launch(activity_bundle) return # Otherwise we are launching a regular journal entry activity_id = metadata.get('activity_id', '') if bundle_id is None: activities = get_activities(metadata) if not activities: logging.warning('No activity can open this object, %s.', metadata.get('mime_type', None)) return bundle_id = activities[0].get_bundle_id() bundle = registry.get_bundle(bundle_id) if metadata.get('mountpoint', '/') == '/': object_id = metadata['uid'] launch_activity(object_id) else: model.copy(metadata, '/', ready_callback=ready_callback)
def _drag_data_received_cb(self, widget, drag_context, x, y, selection_data, info, timestamp): object_id = selection_data.get_data() metadata = model.get(object_id) file_path = model.get_file(metadata["uid"]) if not file_path or not os.path.exists(file_path): logging.warn("Entries without a file cannot be copied.") self.emit("volume-error", _("Entries without a file cannot be copied."), _("Warning")) return try: model.copy(metadata, self.mount_point) except IOError, e: logging.exception("Error while copying the entry. %s", e.strerror) self.emit("volume-error", _("Error while copying the entry. %s") % e.strerror, _("Error"))
def resume(metadata, bundle_id=None): registry = bundleregistry.get_registry() if is_activity_bundle(metadata) and bundle_id is None: logging.debug("Creating activity bundle") file_path = model.get_file(metadata["uid"]) bundle = ActivityBundle(file_path) if not registry.is_installed(bundle): logging.debug("Installing activity bundle") try: registry.install(bundle) except AlreadyInstalledException: _downgrade_option_alert(bundle) return else: logging.debug("Upgrading activity bundle") registry.upgrade(bundle) _launch_bundle(bundle) elif is_content_bundle(metadata) and bundle_id is None: logging.debug("Creating content bundle") file_path = model.get_file(metadata["uid"]) bundle = ContentBundle(file_path) if not bundle.is_installed(): logging.debug("Installing content bundle") bundle.install() activities = _get_activities_for_mime("text/html") if len(activities) == 0: logging.warning("No activity can open HTML content bundles") return uri = bundle.get_start_uri() logging.debug("activityfactory.creating with uri %s", uri) activity_bundle = registry.get_bundle(activities[0].get_bundle_id()) launch(activity_bundle, uri=uri) else: activity_id = metadata.get("activity_id", "") if bundle_id is None: activities = get_activities(metadata) if not activities: logging.warning("No activity can open this object, %s.", metadata.get("mime_type", None)) return bundle_id = activities[0].get_bundle_id() bundle = registry.get_bundle(bundle_id) if metadata.get("mountpoint", "/") == "/": object_id = metadata["uid"] else: object_id = model.copy(metadata, "/") launch(bundle, activity_id=activity_id, object_id=object_id, color=get_icon_color(metadata))
def __copy_to_volume_cb(self, menu_item, mount_point): file_path = model.get_file(self._metadata['uid']) if not file_path or not os.path.exists(file_path): logging.warn('Entries without a file cannot be copied.') self.emit('volume-error', _('Entries without a file cannot be copied.'), _('Warning')) return try: model.copy(self._metadata, mount_point) except IOError, e: logging.exception('Error while copying the entry. %s', e.strerror) self.emit('volume-error', _('Error while copying the entry. %s') % e.strerror, _('Error'))
def __copy_to_volume_cb(self, menu_item): uid_list = self._get_uid_list_cb() if len(uid_list) == 1: uid = uid_list[0] file_path = model.get_file(uid) if not file_path or not os.path.exists(file_path): logging.warn("Entries without a file cannot be copied.") self.emit("volume-error", _("Entries without a file cannot be copied."), _("Warning")) return try: metadata = model.get(uid) model.copy(metadata, self._mount_point) except IOError, e: logging.exception("Error while copying the entry. %s", e.strerror) self.emit("volume-error", _("Error while copying the entry. %s") % e.strerror, _("Error"))
def _drag_data_received_cb(self, widget, drag_context, x, y, selection_data, info, timestamp): object_id = selection_data.get_data() metadata = model.get(object_id) file_path = model.get_file(metadata['uid']) if not file_path or not os.path.exists(file_path): logging.warn('Entries without a file cannot be copied.') self.emit('volume-error', _('Entries without a file cannot be copied.'), _('Warning')) return try: model.copy(metadata, self.mount_point) except IOError as e: logging.exception('Error while copying the entry. %s', e.strerror) self.emit('volume-error', _('Error while copying the entry. %s') % e.strerror, _('Error'))
def _drag_data_received_cb(self, widget, drag_context, x, y, selection_data, info, timestamp): object_id = selection_data.data metadata = model.get(object_id) file_path = model.get_file(metadata['uid']) if not file_path or not os.path.exists(file_path): logging.warn('Entries without a file cannot be copied.') self.emit('volume-error', _('Entries without a file cannot be copied.'), _('Warning')) return try: model.copy(metadata, self.mount_point) except IOError, e: logging.exception('Error while copying the entry. %s', e.strerror) self.emit('volume-error', _('Error while copying the entry. %s') % e.strerror, _('Error'))
def __copy_to_volume_cb(self, menu_item): uid_list = self._get_uid_list_cb() if len(uid_list) == 1: uid = uid_list[0] file_path = model.get_file(uid) if not file_path or not os.path.exists(file_path): logging.warn('Entries without a file cannot be copied.') self.emit('volume-error', _('Entries without a file cannot be copied.'), _('Warning')) return try: metadata = model.get(uid) model.copy(metadata, self._mount_point) except IOError, e: logging.exception('Error while copying the entry. %s', e.strerror) self.emit('volume-error', _('Error while copying the entry. %s') % e.strerror, _('Error'))
def resume(metadata, bundle_id=None, alert_window=None, force_bundle_downgrade=False): registry = bundleregistry.get_registry() ds_bundle, downgrade_required = handle_bundle_installation(metadata, force_bundle_downgrade) if ds_bundle is not None and downgrade_required: # A bundle is being resumed but we didn't install it as that would # require a downgrade. _downgrade_option_alert(ds_bundle, metadata) return # Are we launching a bundle? if ds_bundle is not None and bundle_id is None: activity_bundle = registry.get_bundle(ds_bundle.get_bundle_id()) if activity_bundle is not None: launch(activity_bundle) return # Otherwise we are launching a regular journal entry activity_id = metadata.get("activity_id", "") if bundle_id is None: activities = get_activities(metadata) if not activities: logging.warning("No activity can open this object, %s.", metadata.get("mime_type", None)) return bundle_id = activities[0].get_bundle_id() bundle = registry.get_bundle(bundle_id) if metadata.get("mountpoint", "/") == "/": object_id = metadata["uid"] else: object_id = model.copy(metadata, "/") launch( bundle, activity_id=activity_id, object_id=object_id, color=get_icon_color(metadata), alert_window=alert_window )
def __duplicate_activate_cb(self, menu_item): try: model.copy(self._metadata, "/") except IOError, e: logging.exception("Error while copying the entry. %s", e.strerror) self.emit("volume-error", _("Error while copying the entry. %s") % e.strerror, _("Error"))
def resume(metadata, bundle_id=None): registry = bundleregistry.get_registry() if is_activity_bundle(metadata) and bundle_id is None: logging.debug('Creating activity bundle') file_path = model.get_file(metadata['uid']) bundle = ActivityBundle(file_path) if not registry.is_installed(bundle): logging.debug('Installing activity bundle') try: registry.install(bundle) except AlreadyInstalledException: _downgrade_option_alert(bundle) return else: logging.debug('Upgrading activity bundle') registry.upgrade(bundle) _launch_bundle(bundle) elif is_content_bundle(metadata) and bundle_id is None: logging.debug('Creating content bundle') file_path = model.get_file(metadata['uid']) bundle = ContentBundle(file_path) if not bundle.is_installed(): logging.debug('Installing content bundle') bundle.install() activities = _get_activities_for_mime('text/html') if len(activities) == 0: logging.warning('No activity can open HTML content bundles') return uri = bundle.get_start_uri() logging.debug('activityfactory.creating with uri %s', uri) activity_bundle = registry.get_bundle(activities[0].get_bundle_id()) launch(activity_bundle, uri=uri) else: activity_id = metadata.get('activity_id', '') if bundle_id is None: activities = get_activities(metadata) if not activities: logging.warning('No activity can open this object, %s.', metadata.get('mime_type', None)) return bundle_id = activities[0].get_bundle_id() bundle = registry.get_bundle(bundle_id) if metadata.get('mountpoint', '/') == '/': object_id = metadata['uid'] else: object_id = model.copy(metadata, '/') launch(bundle, activity_id=activity_id, object_id=object_id, color=get_icon_color(metadata))