Exemple #1
0
    def reload_index(self, update_only=False):
        '''Check the notebook for changes and update the index.
		Shows an progressbar while updateing.
		@param update_only: if C{True} only updates are done, if C{False} also
		check is done for all files
		@returns: C{True} unless the user cancelled the update
		'''
        from zim.notebook.index import IndexCheckAndUpdateOperation, IndexUpdateOperation
        from zim.notebook.operations import ongoing_operation

        op = ongoing_operation(self.notebook)

        if isinstance(op, IndexUpdateOperation):
            dialog = ProgressDialog(self.widget, op)
            dialog.run()

            if update_only or isinstance(op, IndexCheckAndUpdateOperation):
                return not dialog.cancelled
            else:
                # ongoing op was update only but we want check, so try again
                if not dialog.cancelled:
                    return self.reload_index()  # recurs
                else:
                    return False

        else:
            op = IndexCheckAndUpdateOperation(self.notebook)
            dialog = ProgressDialog(self.widget, op)
            dialog.run()

            return not dialog.cancelled
Exemple #2
0
    def do_response_ok(self):
        output, exporter = self.get_exporter()
        selection = self.get_selection()
        logger.debug('exporter: %s, selection: %s',
                     exporter.__class__.__name__, selection.__class__.__name__)
        if exporter is None or selection is None:
            logger.debug('Cancelled - selection')
            return False  # canceled

        # Run export
        logging_context = LogContext()
        with logging_context:
            op = NotebookOperation(
                self.ui.notebook,
                _('Exporting notebook'),  # T: Title for progressbar window
                exporter.export_iter(selection))
            dialog = ProgressDialog(self, op)
            dialog.run()

        if op.cancelled:
            return False
        else:
            #~ print '>>> %s E: %i, W: %i' % (
            #~ logging_context.file.path,
            #~ logging_context.handler.n_error, logging_context.handler.n_warning)
            #~ print logging_context.file.read()
            #~ print '---'
            ExportDoneDialog(self, logging_context, output).run()
            return True
Exemple #3
0
	def do_response_ok(self):
		from zim.newfs.helpers import TrashNotSupportedError

		self.uistate['update_links'] = self.update_links_checkbutton.get_active()

		op = NotebookOperation(
			self.notebook,
			_('Removing Links'), # T: Title of progressbar dialog
			self.notebook.trash_page_iter(self.path, self.uistate['update_links'])
		)
		dialog = ProgressDialog(self, op)
		try:
			dialog.run()
		except TrashNotSupportedError:
			# only during test, else error happens in idle handler
			logger.info('Trash not supported: %s', op.exception.msg)
			self.result = TrashNotSupportedError
		else:
			if op.exception and isinstance(op.exception, TrashNotSupportedError):
				logger.info('Trash not supported: %s', op.exception.msg)
				self.result = TrashNotSupportedError
			elif op.exception:
				self.result = op.exception
				raise op.exception
			else:
				pass

		return True # we return error via result, handler always OK
Exemple #4
0
	def do_response_ok(self):
		name = self.form['name']
		parent = self.form['parent']
		head = self.form['head']
		update = self.form['update']

		newbasename = Path.makeValidPageName(name)
		newpath = parent + newbasename if parent else Path(newbasename)
		if newpath == self.path:
			return False

		self.hide() # hide this dialog before showing the progressbar
		op = NotebookOperation(
			self.notebook,
			_('Updating Links'), # T: label for progress dialog
			self.notebook.move_page_iter(
				self.path,
				newpath,
				update_links=update,
				update_heading=head
			)
		)
		dialog = ProgressDialog(self, op)
		dialog.run()

		return True
Exemple #5
0
    def do_response_ok(self):
        op = NotebookOperation(
            self.notebook,
            _('Removing Links'),  # T: Title of progressbar dialog
            self.notebook.delete_page_iter(self.path, self.update_links))
        dialog = ProgressDialog(self, op)
        dialog.run()

        return True
Exemple #6
0
	def do_response_ok(self):
		self.uistate['update_links'] = self.update_links_checkbutton.get_active()

		op = NotebookOperation(
			self.notebook,
			_('Removing Links'), # T: Title of progressbar dialog
			self.notebook.delete_page_iter(self.path, self.uistate['update_links'])
		)
		dialog = ProgressDialog(self, op)
		dialog.run()

		if op.exception:
			raise op.exception
		else:
			return True
    def do_response_ok(self):
        parent = self.form['parent']
        update = self.form['update']
        newpath = parent + self.path.basename
        if parent == self.path.parent:
            return False

        self.hide()  # hide this dialog before showing the progressbar
        op = NotebookOperation(
            self.notebook,
            _('Updating Links'),  # T: label for progress dialog
            self.notebook.move_page_iter(self.path, newpath, update))
        dialog = ProgressDialog(self, op)
        dialog.run()

        return True
    def do_response_ok(self):
        name = self.form['name']
        head = self.form['head']
        update = self.form['update']

        if name == self.path.basename:
            return False

        self.hide()  # hide this dialog before showing the progressbar
        op = NotebookOperation(
            self.notebook,
            _('Updating Links'),  # T: label for progress dialog
            self.notebook.rename_page_iter(self.path, name, head, update))
        dialog = ProgressDialog(self, op)
        dialog.run()

        return True
Exemple #9
0
    def delete_page(self, path=None):
        '''Delete a page by either trashing it, or permanent deletion after
		confirmation of a L{DeletePageDialog}. When trashing the update behavior
		depends on the "remove_links_on_delete" preference.

		@param path: a L{Path} object, or C{None} for the current selected page
		'''
        # Difficulty here is that we want to avoid unnecessary prompts.
        # So ideally we want to know whether trash is supported, but we only
        # know for sure when we try. Thus we risk prompting twice: once for
        # trash and once for deletion if trash fails.
        # On windows the system will also prompt to confirm trashing, once
        # for the file and once for the folder. So adding our own prompt
        # will make it worse.
        # So we first attempt to trash and only if it fails we prompt for
        # to confirm for permanent deletion. From the application point of
        # view this is not perfect since we can't undo deletion from within
        # the application.
        from zim.newfs.helpers import TrashNotSupportedError

        path = path or self.page
        assert path is not None

        if not self.ensure_index_uptodate():
            return

        preferences = ConfigManager.preferences['GtkInterface']
        update_links = preferences.setdefault('remove_links_on_delete', True)
        op = NotebookOperation(
            self.notebook,
            _('Removing Links'),  # T: Title of progressbar dialog
            self.notebook.trash_page_iter(path, update_links))
        dialog = ProgressDialog(self.widget, op)
        try:
            dialog.run()
        except TrashNotSupportedError:
            pass  # only during test, else error happens in idle handler

        if op.exception and isinstance(op.exception, TrashNotSupportedError):
            logger.info('Trash not supported: %s', op.exception.msg)
            DeletePageDialog(self.widget,
                             self.notebook,
                             path,
                             update_links=update_links).run()