Ejemplo n.º 1
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
Ejemplo n.º 2
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
Ejemplo n.º 3
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
Ejemplo n.º 4
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
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
    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
Ejemplo n.º 7
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()