Exemple #1
0
    def __init__(self, widget, notebook, path, update_links=True):
        assert path, 'Need a page here'
        Dialog.__init__(self, widget, _('Delete Page'))  # T: Dialog title
        self.notebook = notebook
        self.path = path
        self.update_links = update_links

        hbox = Gtk.HBox(spacing=12)
        self.vbox.add(hbox)

        img = Gtk.Image.new_from_stock(Gtk.STOCK_DIALOG_WARNING,
                                       Gtk.IconSize.DIALOG)
        hbox.pack_start(img, False, True, 0)

        vbox = Gtk.VBox(spacing=5)
        hbox.pack_start(vbox, False, True, 0)

        label = Gtk.Label()
        short = _('Delete page "%s"?') % self.path.basename
        # T: Heading in 'delete page' dialog - %s is the page name
        longmsg = _(
            'Page "%s" and all of it\'s\nsub-pages and attachments will be deleted'
        ) % self.path.name
        # T: Text in 'delete page' dialog - %s is the page name
        label.set_markup('<b>' + short + '</b>\n\n' + longmsg)
        vbox.pack_start(label, False, True, 0)

        # TODO use expander here
        page = self.notebook.get_page(self.path)
        text = page.source_file.path + '\n'
        n = 1
        dir = self.notebook.get_attachments_dir(self.path)
        if dir.exists():
            text += self._get_file_tree_as_text(dir)
            n = len([
                l for l in text.splitlines()
                if l.strip() and not l.endswith('/')
            ])

        string = ngettext('%i file will be deleted',
                          '%i files will be deleted', n) % n
        # T: label in the DeletePage dialog to warn user of attachments being deleted
        if n > 0:
            string = '<b>' + string + '</b>'

        label = Gtk.Label()
        label.set_markup('\n' + string + ':')
        self.vbox.add(label)
        window, textview = ScrolledTextView(text, monospace=True)
        window.set_size_request(250, 100)
        self.vbox.pack_start(window, True, True, 0)
Exemple #2
0
	def __init__(self, widget, notebook, path):
		assert path, 'Need a page here'
		Dialog.__init__(self, widget, self.title)
		self.notebook = notebook
		self.path = path

		hbox = Gtk.HBox(spacing=12)
		self.vbox.add(hbox)

		img = Gtk.Image.new_from_stock(Gtk.STOCK_DIALOG_WARNING, Gtk.IconSize.DIALOG)
		hbox.pack_start(img, False, True, 0)

		vbox = Gtk.VBox(spacing=5)
		hbox.pack_start(vbox, False, True, 0)

		label = Gtk.Label()
		string = '<b>' + (self.shortmsg % self.path.basename) + '</b>\n\n' + (self.longmsg  % self.path.name)
		label.set_markup(string)
		vbox.pack_start(label, False, True, 5)

		string = _('Remove links to %s') % self.path # T: label in DeletePageDialog
		self.uistate.setdefault('update_links', True)
		self.update_links_checkbutton = Gtk.CheckButton.new_with_mnemonic(string)
		self.update_links_checkbutton.set_active(self.uistate['update_links'])
		vbox.pack_start(self.update_links_checkbutton, False, True, 0)

		# TODO use expander here
		page = self.notebook.get_page(self.path)
		text = page.source_file.path + '\n'
		n = 1
		dir = self.notebook.get_attachments_dir(self.path)
		if dir.exists():
			text += self._get_file_tree_as_text(dir)
			n = len([l for l in text.splitlines() if l.strip() and not l.endswith('/')])

		string = self._ngettext_label_n_files(n)
		if n > 0:
			string = '<b>' + string + '</b>'

		label = Gtk.Label()
		label.set_markup('\n' + string + ':')
		self.vbox.add(label)
		window, textview = ScrolledTextView(text, monospace=True)
		window.set_size_request(250, 100)
		self.vbox.pack_start(window, True, True, 0)