Пример #1
0
	def __init__(self, ui, window_ext, vcs):
		Dialog.__init__(self, ui, _('Save Version'), # T: dialog title
			button=(None, 'gtk-save'), help='Plugins:Version Control')
		self.window_ext = window_ext
		self.vcs = vcs

		self.vbox.pack_start(
			gtk.Label(_("Please enter a comment for this version")), False)  # T: Dialog text

		vpaned = VPaned()
		self.vbox.add(vpaned)

		window, self.textview = ScrolledTextView(_('Saved version from zim'))
			# T: default version comment in the "save version" dialog
		self.textview.set_editable(True)
		vpaned.add1(window)

		vbox = gtk.VBox()
		vpaned.add2(vbox)

		label = gtk.Label('<b>'+_('Details')+'</b>')
			# T: section for version details in "save version" dialog
		label.set_use_markup(True)
		label.set_alignment(0, 0.5)
		vbox.pack_start(label, False)

		status = self.vcs.get_status()
		window, textview = ScrolledTextView(text=''.join(status), monospace=True)
		vbox.add(window)
Пример #2
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)
Пример #3
0
 def _init_view(self):
     win, self.view = ScrolledTextView(monospace=True,
                                       hpolicy=Gtk.PolicyType.AUTOMATIC,
                                       vpolicy=Gtk.PolicyType.NEVER,
                                       shadow=Gtk.ShadowType.NONE)
     self.view.set_buffer(self.buffer)
     self.view.set_editable(True)
     self.add(win)
Пример #4
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)
Пример #5
0
    def __init__(self, dialog, plugins):
        gtk.VBox.__init__(self, spacing=5)
        self.dialog = dialog
        self.plugins = plugins

        self.hbox = gtk.HBox(self, spacing=12)
        self.hbox.set_border_width(5)
        self.add(self.hbox)

        #~ logger.debug('Plugins that are loaded: %s' % list(plugins))

        self.treeview = PluginsTreeView(self.plugins)
        self.treeview.connect('row-activated', self.do_row_activated)
        swindow = ScrolledWindow(self.treeview, hpolicy=gtk.POLICY_NEVER)
        self.hbox.pack_start(swindow, False)

        vbox = gtk.VBox()
        self.hbox.add(vbox)

        # Textview with scrollbars to show plugins info. Required by small screen devices
        swindow, textview = ScrolledTextView()
        textview.set_cursor_visible(False)
        self.textbuffer = textview.get_buffer()
        self.textbuffer.create_tag('bold', weight=pango.WEIGHT_BOLD)
        self.textbuffer.create_tag('red', foreground='#FF0000')
        vbox.pack_start(swindow, True)

        hbox = gtk.HBox(spacing=5)
        vbox.pack_end(hbox, False)

        self.plugin_help_button = \
         Button(stock=gtk.STOCK_HELP, label=_('_More')) # T: Button in plugin tab
        self.plugin_help_button.connect('clicked', self.on_help_button_clicked)
        hbox.pack_start(self.plugin_help_button, False)

        self.configure_button = \
         Button(stock=gtk.STOCK_PREFERENCES, label=_('C_onfigure')) # T: Button in plugin tab
        self.configure_button.connect('clicked',
                                      self.on_configure_button_clicked)
        hbox.pack_start(self.configure_button, False)

        try:
            self.do_row_activated(self.treeview, (0, ), 0)
        except:
            pass  # maybe loading plugins failed

        if gtk.gtk_version >= (2, 10) \
        and gtk.pygtk_version >= (2, 10):
            url_button = gtk.LinkButton(
                'https://github.com/jaap-karssenberg/zim-wiki/wiki/Plugins',
                _('Get more plugins online')  # T: label for button with URL
            )
            self.pack_start(url_button, False)
Пример #6
0
	def __init__(self, buffer):
		CustomObjectWidget.__init__(self)
		self.set_has_cursor(True)
		self.buffer = buffer

		win, self.view = ScrolledTextView(monospace=True,
			hpolicy=gtk.POLICY_AUTOMATIC, vpolicy=gtk.POLICY_NEVER, shadow=gtk.SHADOW_NONE)
		self.view.set_buffer(buffer)
		self.view.set_editable(True)
		self.vbox.pack_start(win)

		# Hook up integration with pageview cursor movement
		self.view.connect('move-cursor', self.on_move_cursor)
Пример #7
0
    def __init__(self, buffer):
        InsertedObjectWidget.__init__(self)
        self.set_has_cursor(True)
        self.buffer = buffer

        win, self.view = ScrolledTextView(monospace=True,
                                          hpolicy=Gtk.PolicyType.AUTOMATIC,
                                          vpolicy=Gtk.PolicyType.NEVER,
                                          shadow=Gtk.ShadowType.NONE)
        self.view.set_buffer(buffer)
        self.view.set_editable(True)
        self.add(win)

        self._init_signals()
Пример #8
0
    def __init__(self, buffer):
        CustomObjectWidget.__init__(self)
        self.set_has_cursor(True)
        self.buffer = buffer

        win, self.view = ScrolledTextView(monospace=True,
                                          hpolicy=gtk.POLICY_AUTOMATIC,
                                          vpolicy=gtk.POLICY_NEVER,
                                          shadow=gtk.SHADOW_NONE)
        self.view.set_buffer(buffer)
        self.view.set_editable(True)
        self.vbox.pack_start(win)

        self._init_signals()
Пример #9
0
	def __init__(self, attrib, data, ui=None):
		CustomObjectClass.__init__(self, attrib, data, ui)
		if self.ui and self.ui.__class__.__name__ == 'GtkInterface':  # XXX seperate widget and object
			import gtk
			from zim.gui.pageview import CustomObjectBin
			from zim.gui.widgets import ScrolledTextView

			self._widget = CustomObjectBin()
			box = gtk.VBox()
			box.set_border_width(5)
			type = attrib.get('type')
			plugin = ObjectManager.find_plugin(type) if type else None
			if plugin:
				key, name, activatable, klass = plugin
				hbox = gtk.HBox(False, 5)
				box.pack_start(hbox)
				label = gtk.Label(_("Plugin %s is required to display this object.") % name)
				hbox.pack_start(label)
				if activatable: # and False:
					# Plugin can be enabled
					button = gtk.Button(_("Enable plugin"))
					def load_plugin(button):
						self.ui.plugins.load_plugin(key)
						self.ui.reload_page()
					button.connect("clicked", load_plugin)
				else:
					# Plugin has some unresolved dependencies
					def plugin_info(button):
						from zim.gui.preferencesdialog import PreferencesDialog
						dialog = PreferencesDialog(self.ui, "Plugins", select_plugin=name)
						dialog.run()
						self.ui.reload_page()
					button = gtk.Button(_("Show plugin details"))
					button.connect("clicked", plugin_info)
				hbox.pack_start(button)
			else:
				label = gtk.Label(_("No plugin is available to display this object."))
				box.pack_start(label)

			win, self.view = ScrolledTextView(self._data, monospace=True)
			self.view.set_editable(True)
			buffer = self.view.get_buffer();
			buffer.connect('modified-changed', self.on_modified_changed)
			buffer.set_modified(False)
			self._data = None

			win.set_border_width(5)
			win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)
			box.pack_start(win)
			self._widget.add(box)
Пример #10
0
    def __init__(self, dialog, plugins):
        gtk.HBox.__init__(self, spacing=12)
        self.set_border_width(5)
        self.dialog = dialog
        self.plugins = plugins

        #~ logger.debug('Plugins that are loaded: %s' % list(plugins))

        self.treeview = PluginsTreeView(self.plugins)
        self.treeview.connect('row-activated', self.do_row_activated)
        swindow = ScrolledWindow(self.treeview, hpolicy=gtk.POLICY_NEVER)
        self.pack_start(swindow, False)

        vbox = gtk.VBox()
        self.add(vbox)

        # Textview with scrollbars to show plugins info. Required by small screen devices
        swindow, textview = ScrolledTextView()
        textview.set_cursor_visible(False)
        self.textbuffer = textview.get_buffer()
        self.textbuffer.create_tag('bold', weight=pango.WEIGHT_BOLD)
        self.textbuffer.create_tag('red', foreground='#FF0000')
        vbox.pack_start(swindow, True)

        hbox = gtk.HBox(spacing=5)
        vbox.pack_end(hbox, False)

        self.plugin_help_button = \
         Button(stock=gtk.STOCK_HELP, label=_('_More')) # T: Button in plugin tab
        self.plugin_help_button.connect('clicked', self.on_help_button_clicked)
        hbox.pack_start(self.plugin_help_button, False)

        self.configure_button = \
         Button(stock=gtk.STOCK_PREFERENCES, label=_('C_onfigure')) # T: Button in plugin tab
        self.configure_button.connect('clicked',
                                      self.on_configure_button_clicked)
        hbox.pack_start(self.configure_button, False)

        self.do_row_activated(self.treeview, (0, ), 0)
Пример #11
0
    def _init_inputs(self,
                     namespace,
                     basename,
                     append,
                     text,
                     template_options,
                     custom=None):
        if template_options is None:
            template_options = {}
        else:
            template_options = template_options.copy()

        if namespace is not None and basename is not None:
            page = namespace + ':' + basename
        else:
            page = namespace or basename

        self.form.add_inputs((
            ('page', 'page', _('Page')),
            ('namespace', 'namespace',
             _('Page section')),  # T: text entry field
            ('new_page', 'bool', _('Create a new page for each note')
             ),  # T: checkbox in Quick Note dialog
            ('basename', 'string', _('Title'))  # T: text entry field
        ))
        self.form.update({
            'page': page,
            'namespace': namespace,
            'new_page': True,
            'basename': basename,
        })

        self.uistate.setdefault('open_page', True)
        self.uistate.setdefault('new_page', True)

        if basename:
            self.uistate['new_page'] = True  # Be consistent with input

        # Set up the inputs and set page/ namespace to switch on
        # toggling the checkbox
        self.form.widgets['page'].set_no_show_all(True)
        self.form.widgets['namespace'].set_no_show_all(True)
        if append is None:
            self.form['new_page'] = bool(self.uistate['new_page'])
        else:
            self.form['new_page'] = not append

        def switch_input(*a):
            if self.form['new_page']:
                self.form.widgets['page'].hide()
                self.form.widgets['namespace'].show()
                self.form.widgets['basename'].set_sensitive(True)
            else:
                self.form.widgets['page'].show()
                self.form.widgets['namespace'].hide()
                self.form.widgets['basename'].set_sensitive(False)

        switch_input()
        self.form.widgets['new_page'].connect('toggled', switch_input)

        self.open_page_check = Gtk.CheckButton.new_with_mnemonic(
            _('Open _Page'))  # T: Option in quicknote dialog
        # Don't use "O" as accelerator here to avoid conflict with "Ok"
        self.open_page_check.set_active(self.uistate['open_page'])
        self.action_area.pack_start(self.open_page_check, False, True, 0)
        self.action_area.set_child_secondary(self.open_page_check, True)

        # Add the main textview and hook up the basename field to
        # sync with first line of the textview
        window, textview = ScrolledTextView()
        self.textview = textview
        self.textview.set_editable(True)
        self.vbox.pack_start(window, True, True, 0)

        self.form.widgets['basename'].connect('changed', self.on_title_changed)
        self.textview.get_buffer().connect('changed', self.on_text_changed)

        # Initialize text from template
        template = get_template('plugins', 'quicknote.txt')
        template_options['text'] = text or ''
        template_options.setdefault('url', '')

        lines = []
        template.process(lines, template_options)
        buffer = self.textview.get_buffer()
        buffer.set_text(''.join(lines))
        begin, end = buffer.get_bounds()
        buffer.place_cursor(begin)

        buffer.set_modified(False)

        self.connect('delete-event', self.do_delete_event)
Пример #12
0
    def __init__(self, dialog, plugins):
        gtk.VBox.__init__(self, spacing=5)
        self.dialog = dialog
        self.plugins = plugins

        self.hbox = gtk.HBox(self, spacing=12)
        self.hbox.set_border_width(5)
        self.add(self.hbox)

        #~ logger.debug('Plugins that are loaded: %s' % list(plugins))

        self.treeview = PluginsTreeView(self.plugins)
        self.treeselection = self.treeview.get_selection()
        self.treeselection.connect('changed', self.do_selection_changed)
        swindow = ScrolledWindow(self.treeview, hpolicy=gtk.POLICY_NEVER)
        self.hbox.pack_start(swindow, False)

        vbox = gtk.VBox()
        self.hbox.add(vbox)

        # Textview with scrollbars to show plugins info. Required by small screen devices
        swindow, textview = ScrolledTextView()
        textview.set_cursor_visible(False)
        self.textbuffer = textview.get_buffer()
        self.textbuffer.create_tag('bold', weight=pango.WEIGHT_BOLD)
        self.textbuffer.create_tag('red', foreground='#FF0000')
        vbox.pack_start(swindow, True)

        hbox = gtk.HBox(spacing=5)
        vbox.pack_end(hbox, False)

        self.plugin_help_button = \
         Button(stock=gtk.STOCK_HELP, label=_('_More')) # T: Button in plugin tab
        self.plugin_help_button.connect('clicked', self.on_help_button_clicked)
        hbox.pack_start(self.plugin_help_button, False)

        self.configure_button = \
         Button(stock=gtk.STOCK_PREFERENCES, label=_('C_onfigure')) # T: Button in plugin tab
        self.configure_button.connect('clicked',
                                      self.on_configure_button_clicked)
        hbox.pack_start(self.configure_button, False)

        try:
            self.treeselection.select_path(0)
        except:
            pass  # maybe loading plugins failed

        ## Add buttons to get and install new plugins
        hbox = gtk.HButtonBox()
        hbox.set_border_width(5)
        hbox.set_layout(gtk.BUTTONBOX_START)
        self.pack_start(hbox, False)

        assert hasattr(self.dialog, 'ui')
        open_button = gtk.Button(label=_('Open plugins folder'))
        open_button.connect('clicked',
                            lambda o: self.dialog.ui.open_dir(PLUGIN_FOLDER))
        hbox.pack_start(open_button, False)

        if gtk.gtk_version >= (2, 10) \
        and gtk.pygtk_version >= (2, 10):
            url_button = gtk.LinkButton(
                'http://zim-wiki.org/more_plugins.html',
                _('Get more plugins online')  # T: label for button with URL
            )
            hbox.pack_start(url_button, False)
Пример #13
0
 def __init__(self, ui, file):
     Dialog.__init__(self, ui, _('Log file'), buttons=gtk.BUTTONS_CLOSE)
     # T: dialog title for log view dialog - e.g. for Equation Editor
     self.set_default_size(600, 300)
     window, textview = ScrolledTextView(file.read(), monospace=True)
     self.vbox.add(window)
Пример #14
0
    def __init__(self, dialog, plugins):
        GObject.GObject.__init__(self)
        self.set_spacing(5)
        self.dialog = dialog
        self.plugins = plugins

        self.hbox = Gtk.HBox(self, spacing=12)
        self.hbox.set_border_width(5)
        self.add(self.hbox)

        #~ logger.debug('Plugins that are loaded: %s' % list(plugins))

        self.treeview = PluginsTreeView(self.plugins)
        self.treeselection = self.treeview.get_selection()
        self.treeselection.connect('changed', self.do_selection_changed)
        swindow = ScrolledWindow(self.treeview, hpolicy=Gtk.PolicyType.NEVER)
        self.hbox.pack_start(swindow, False, True, 0)

        vbox = Gtk.VBox()
        self.hbox.add(vbox)

        # Textview with scrollbars to show plugins info. Required by small screen devices
        swindow, textview = ScrolledTextView()
        textview.set_cursor_visible(False)
        self.textbuffer = textview.get_buffer()
        self.textbuffer.create_tag('bold', weight=Pango.Weight.BOLD)
        self.textbuffer.create_tag('red', foreground='#FF0000')
        vbox.pack_start(swindow, True, True, 0)

        hbox = Gtk.HBox(spacing=5)
        vbox.pack_end(hbox, False, True, 0)

        self.plugin_help_button = \
         Gtk.Button.new_with_mnemonic(_('_More')) # T: Button in plugin tab
        self.plugin_help_button.connect('clicked', self.on_help_button_clicked)
        hbox.pack_start(self.plugin_help_button, False, True, 0)

        self.configure_button = \
         Gtk.Button.new_with_mnemonic(_('C_onfigure')) # T: Button in plugin tab
        self.configure_button.connect('clicked',
                                      self.on_configure_button_clicked)
        hbox.pack_start(self.configure_button, False, True, 0)

        try:
            self.treeselection.select_path(0)
        except:
            pass  # maybe loading plugins failed

        ## Add buttons to get and install new plugins
        hbox = Gtk.HButtonBox()
        hbox.set_border_width(5)
        hbox.set_layout(Gtk.ButtonBoxStyle.START)
        self.pack_start(hbox, False, True, 0)

        open_button = Gtk.Button.new_with_mnemonic(_('Open plugins folder'))
        open_button.connect(
            'clicked', lambda o: open_folder_prompt_create(o, PLUGIN_FOLDER))
        hbox.pack_start(open_button, False, True, 0)

        url_button = Gtk.LinkButton(
            'http://zim-wiki.org/more_plugins.html',
            _('Get more plugins online')  # T: label for button with URL
        )
        hbox.pack_start(url_button, False, True, 0)
Пример #15
0
    def __init__(self, parent, vcs, notebook, page=None):
        Dialog.__init__(
            self,
            parent,
            _('Versions'),  # T: dialog title
            buttons=Gtk.ButtonsType.CLOSE,
            help='Plugins:Version Control')
        self.notebook = notebook
        self.vcs = vcs
        self._side_by_side_app = get_side_by_side_app()

        self.uistate.setdefault('windowsize', (600, 500), check=value_is_coord)
        self.uistate.setdefault('vpanepos', 300)

        self.vpaned = VPaned()
        self.vpaned.set_position(self.uistate['vpanepos'])
        self.vbox.pack_start(self.vpaned, True, True, 0)

        vbox = Gtk.VBox(spacing=5)
        self.vpaned.pack1(vbox, resize=True)

        # Choice between whole notebook or page
        label = Gtk.Label(label='<b>' + _('Versions') +
                          ':</b>')  # section label
        label.set_use_markup(True)
        label.set_alignment(0, 0.5)
        vbox.pack_start(label, False, True, 0)

        self.notebook_radio = Gtk.RadioButton.new_with_mnemonic_from_widget(
            None, _('Complete _notebook'))
        # T: Option in versions dialog to show version for complete notebook
        self.page_radio = Gtk.RadioButton.new_with_mnemonic_from_widget(
            self.notebook_radio,
            _('_Page') + ':')
        # T: Option in versions dialog to show version for single page
        #~ recursive_box = Gtk.CheckButton.new_with_mnemonic('Recursive')
        vbox.pack_start(self.notebook_radio, False, True, 0)

        # Page entry
        hbox = Gtk.HBox(spacing=5)
        vbox.pack_start(hbox, False, True, 0)
        hbox.pack_start(self.page_radio, False, True, 0)
        self.page_entry = PageEntry(self.notebook)
        if page:
            self.page_entry.set_path(page)
        hbox.pack_start(self.page_entry, False, True, 0)

        # View annotated button
        ann_button = Gtk.Button.new_with_mnemonic(
            _('View _Annotated'))  # T: Button label
        ann_button.connect('clicked', lambda o: self.show_annotated())
        hbox.pack_start(ann_button, False, True, 0)

        # Help text
        label = Gtk.Label(label='<i>\n' + _('''\
Select a version to see changes between that version and the current
state. Or select multiple versions to see changes between those versions.
''').strip() + '</i>')  # T: Help text in versions dialog
        label.set_use_markup(True)
        #~ label.set_alignment(0, 0.5)
        vbox.pack_start(label, False, True, 0)

        # Version list
        self.versionlist = VersionsTreeView()
        self.versionlist.load_versions(vcs.list_versions())
        scrolled = ScrolledWindow(self.versionlist)
        vbox.add(scrolled)

        col = self.uistate.setdefault('sortcol', self.versionlist.REV_SORT_COL)
        order = self.uistate.setdefault('sortorder', Gtk.SortType.DESCENDING)
        try:
            self.versionlist.get_model().set_sort_column_id(col, order)
        except:
            logger.exception('Invalid sort column: %s %s', col, order)

        # -----
        vbox = Gtk.VBox(spacing=5)
        self.vpaned.pack2(vbox, resize=False)

        label = Gtk.Label(label='<b>' + _('Comment') +
                          '</b>')  # T: version details
        label.set_use_markup(True)
        label.set_alignment(0.0, 0.5)
        vbox.pack_start(label, False, True, 0)

        # Comment text
        window, textview = ScrolledTextView()
        self.comment_textview = textview
        vbox.add(window)

        buttonbox = Gtk.HButtonBox()
        buttonbox.set_layout(Gtk.ButtonBoxStyle.END)
        vbox.pack_start(buttonbox, False, True, 0)

        # Restore version button
        revert_button = Gtk.Button.new_with_mnemonic(
            _('_Restore Version'))  # T: Button label
        revert_button.connect('clicked', lambda o: self.restore_version())
        buttonbox.add(revert_button)

        # Notebook Changes button
        diff_button = Gtk.Button.new_with_mnemonic(_('Show _Changes'))
        # T: button in versions dialog for diff
        diff_button.connect('clicked', lambda o: self.show_changes())
        buttonbox.add(diff_button)

        # Compare page button
        comp_button = Gtk.Button.new_with_mnemonic(_('_Side by Side'))
        # T: button in versions dialog for side by side comparison
        comp_button.connect('clicked', lambda o: self.show_side_by_side())
        buttonbox.add(comp_button)

        # UI interaction between selections and buttons

        def on_row_activated(o, iter, path):
            model = self.versionlist.get_model()
            comment = model[iter][VersionsTreeView.MSG_COL]
            buffer = textview.get_buffer()
            buffer.set_text(comment)

        self.versionlist.connect('row-activated', on_row_activated)

        def on_ui_change(o):
            usepage = self.page_radio.get_active()
            self.page_entry.set_sensitive(usepage)
            ann_button.set_sensitive(usepage)

            # side by side comparison can only be done for one page
            # revert can only be done to one version, not multiple
            selection = self.versionlist.get_selection()
            model, rows = selection.get_selected_rows()
            if not rows:
                revert_button.set_sensitive(False)
                diff_button.set_sensitive(False)
                comp_button.set_sensitive(False)
            elif len(rows) == 1:
                revert_button.set_sensitive(usepage)
                diff_button.set_sensitive(True)
                comp_button.set_sensitive(
                    bool(usepage and self._side_by_side_app))
            else:
                revert_button.set_sensitive(False)
                diff_button.set_sensitive(True)
                comp_button.set_sensitive(
                    bool(usepage and self._side_by_side_app))

        def on_page_change(o):
            pagesource = self._get_file()
            if pagesource:
                self.versionlist.load_versions(
                    vcs.list_versions(self._get_file()))

        def on_book_change(o):
            self.versionlist.load_versions(vcs.list_versions())

        self.page_radio.connect('toggled', on_ui_change)
        self.notebook_radio.connect('toggled', on_book_change)
        self.page_radio.connect('toggled', on_page_change)
        self.page_entry.connect('changed', on_page_change)
        selection = self.versionlist.get_selection()
        selection.connect('changed', on_ui_change)

        # select last version
        self.versionlist.get_selection().select_path((0, ))
        col = self.versionlist.get_column(0)
        self.versionlist.row_activated(Gtk.TreePath((0, )), col)
Пример #16
0
 def __init__(self, parent, title, lines):
     Dialog.__init__(self, parent, title, buttons=Gtk.ButtonsType.CLOSE)
     self.set_default_size(600, 300)
     self.uistate.setdefault('windowsize', (600, 500), check=value_is_coord)
     window, textview = ScrolledTextView(''.join(lines), monospace=True)
     self.vbox.pack_start(window, True, True, 0)
Пример #17
0
	def __init__(self, ui, title, lines):
		Dialog.__init__(self, ui, title, buttons=gtk.BUTTONS_CLOSE)
		self.set_default_size(600, 300)
		self.uistate.setdefault('windowsize', (600, 500), check=value_is_coord)
		window, textview = ScrolledTextView(''.join(lines), monospace=True)
		self.vbox.add(window)