Example #1
0
File: linkmap.py Project: gdw2/zim
	def __init__(self, ui, linkmap, opener):
		Dialog.__init__(self, ui, 'LinkMap',
			defaultwindowsize=(400, 400), buttons=gtk.BUTTONS_CLOSE)
		self.linkmap = linkmap
		self.opener = opener

		hbox = gtk.HBox(spacing=5)
		self.vbox.add(hbox)

		self.xdotview = xdot.DotWidget()
		self.xdotview.set_filter('fdp')
		self.xdotview.set_dotcode(linkmap.get_dotcode())
		self.xdotview.connect('clicked', self.on_node_clicked)
		hbox.add(self.xdotview)

		vbox = gtk.VBox()
		hbox.pack_start(vbox, False)
		for stock, method in (
			(gtk.STOCK_ZOOM_IN,  self.xdotview.on_zoom_in ),
			(gtk.STOCK_ZOOM_OUT, self.xdotview.on_zoom_out),
			(gtk.STOCK_ZOOM_FIT, self.xdotview.on_zoom_fit),
			(gtk.STOCK_ZOOM_100, self.xdotview.on_zoom_100),
		):
			button = IconButton(stock)
			button.connect('clicked', method)
			vbox.pack_start(button, False)
Example #2
0
    def __init__(self, ui, vcs):
        Dialog.__init__(self, ui, _('Save Version'), # T: dialog title
            button=(None, 'gtk-save'), help='Plugins:Version Control')
        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)
Example #3
0
    def __init__(self, ui, plugin):
        Dialog.__init__(self, ui, _('Insert Symbol'), # T: Dialog title
            button=(_('_Insert'), 'gtk-ok'),  # T: Button label
            defaultwindowsize=(350, 400) )
        self.plugin = plugin

        self.textentry = InputEntry()
        self.vbox.pack_start(self.textentry, False)

        # TODO make this iconview single-click
        model = gtk.ListStore(str, str) # text, shortcut
        self.iconview = gtk.IconView(model)
        self.iconview.set_text_column(0)
        self.iconview.set_column_spacing(0)
        self.iconview.set_row_spacing(0)
        if gtk.gtk_version >= (2, 12, 0):
            self.iconview.set_property('has-tooltip', True)
            self.iconview.connect('query-tooltip', self.on_query_tooltip)
        self.iconview.connect('item-activated', self.on_activated)

        self.vbox.add(ScrolledWindow(self.iconview))

        button = gtk.Button(stock=gtk.STOCK_EDIT)
        button.connect('clicked', self.on_edit)
        self.action_area.add(button)
        self.action_area.reorder_child(button, 0)

        self.load_symbols()
Example #4
0
	def __init__(self, ui, notebook=None, namespace=None, basename=None, append=None, text=None, template_options=None, attachments=None):
		self.config = get_config('quicknote.conf')
		self.uistate = self.config['QuickNoteDialog']

		Dialog.__init__(self, ui, _('Quick Note'))
		self._updating_title = False
		self._title_set_manually = not basename is None
		self.attachments = attachments

		if notebook and not isinstance(notebook, basestring):
			notebook = notebook.uri

		self.uistate.setdefault('lastnotebook', None, basestring)
		if self.uistate['lastnotebook']:
			notebook = notebook or self.uistate['lastnotebook']
			self.config['Namespaces'].setdefault(notebook, None, basestring)
			namespace = namespace or self.config['Namespaces'][notebook]

		self.form = InputForm()
		self.vbox.pack_start(self.form, False)

		# TODO dropdown could use an option "Other..."
		label = gtk.Label(_('Notebook')+': ')
		label.set_alignment(0.0, 0.5)
		self.form.attach(label, 0,1, 0,1, xoptions=gtk.FILL)
			# T: Field to select Notebook from drop down list
		self.notebookcombobox = NotebookComboBox(current=notebook)
		self.notebookcombobox.connect('changed', self.on_notebook_changed)
		self.form.attach(self.notebookcombobox, 1,2, 0,1)

		self._init_inputs(namespace, basename, append, text, template_options)

		self.uistate['lastnotebook'] = notebook
		self._set_autocomplete(notebook)
	def __init__(self, dialog, plugin):
		Dialog.__init__(self, dialog, _('Configure Plugin')) # T: Dialog title
		self.plugin = plugin

		label = gtk.Label()
		label.set_markup(
			'<b>'+_('Options for plugin %s') % plugin.plugin_info['name']+'</b>')
			# T: Heading for 'configure plugin' dialog - %s is the plugin name
		self.vbox.add(label)

		fields = []
		for pref in self.plugin.plugin_preferences:
			if len(pref) == 4:
				key, type, label, default = pref
				self.plugin.preferences.setdefault(key, default) # just to be sure
			else:
				key, type, label, default, check = pref
				self.plugin.preferences.setdefault(key, default, check=check) # just to be sure

			if type in ('int', 'choice'):
				fields.append((key, type, label, check))
			else:
				fields.append((key, type, label))

		self.add_form(fields, self.plugin.preferences)
Example #6
0
File: gui.py Project: Jam71/Zim-QDA
    def __init__(self, ui, linkmap):
        if ui_environment['platform'] == 'maemo':
            defaultsize = (800, 480)
            # The dialog hides the main window, so use all available screen anyway
            # setting defaultsize doesn't work because maemo makes the dialog
            # window as small as possible to fit the window's internal widgets
        else:
            defaultsize = (400, 400)
        Dialog.__init__(self, ui, 'LinkMap',
            defaultwindowsize=defaultsize, buttons=gtk.BUTTONS_CLOSE)
        self.linkmap = linkmap

        hbox = gtk.HBox(spacing=5)
        self.vbox.add(hbox)

        self.xdotview = xdot.DotWidget()
        self.xdotview.set_filter('fdp')
        self.xdotview.set_dotcode(linkmap.get_dotcode())
        self.xdotview.connect('clicked', self.on_node_clicked)
        hbox.add(self.xdotview)

        vbox = gtk.VBox()
        hbox.pack_start(vbox, False)
        for stock, method in (
            (gtk.STOCK_ZOOM_IN,  self.xdotview.on_zoom_in ),
            (gtk.STOCK_ZOOM_OUT, self.xdotview.on_zoom_out),
            (gtk.STOCK_ZOOM_FIT, self.xdotview.on_zoom_fit),
            (gtk.STOCK_ZOOM_100, self.xdotview.on_zoom_100),
        ):
            button = IconButton(stock)
            button.connect('clicked', method)
            vbox.pack_start(button, False)
Example #7
0
	def __init__(self, ui):
		Dialog.__init__(self, ui, _('Cleanup Attachments'), buttons=None) # T: dialog title
		self.set_default_size(600, 400)
		#self.set_help(':Help:Clean_Notebook') #TODO
		self.ui = ui

		self.ui.add_actions(ui_actions, self)
		self.ui.add_ui(ui_xml,self)

		# Buttons
		# [cancel] [delete]
		self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
		self.add_button('Delete', gtk.RESPONSE_OK)
		self._no_ok_action = False

		button = gtk.Button(_('Invert Selection'))
			# T: Button in "Clean Notebook" dialog
		button.connect('clicked', self.do_response_toggle)
		self.action_area.add(button)
		self.action_area.set_child_secondary(button, True)

		self.add_help_text(_(
				'The files below were found in the attachment directory of zim but are no longer \n'
				'linked in the notebook. '
		) ) # T: help text in "Clean Notebook" dialog

		self.treeview = OrphanedFilesTreeView(ui)
		self.treeview.connect_object(
					'button-press-event', self.__class__.on_treeview_click, self)

		hbox = gtk.HBox(spacing=5)
		self.vbox.add(hbox)

		swindow = ScrolledWindow(self.treeview)
		hbox.add(swindow)
Example #8
0
	def __init__(self, ui, pageview, table=None, edit=False):
		if not edit:
			Dialog.__init__(self, ui, _('Insert Table'), # T: Dialog title
				button=(_('_Insert'), 'gtk-ok'),  # T: Button label
				buttons=gtk.BUTTONS_OK_CANCEL)
		else:
			Dialog.__init__(self, ui, _('Edit Table'), # T: Dialog title
				button=(_('_Edit'), 'gtk-ok'),  # T: Button label
				buttons=gtk.BUTTONS_OK_CANCEL)
		self.edit = edit
		self.table = table
		self.pageview = pageview
		
		self.rownames = gtk.ListStore(int, gobject.TYPE_STRING)
		self.columnNames = gtk.ListStore(int, str)

		self.template = get_template('plugins', 'equationeditor.tex')
		self.texfile = TmpFile(self.scriptname)
		
		self.rowIds = [1,2]
		self.colIds = [1,2]
		if table is not None:
			self.init_table(table=self.table)
		else:
			self.init_table()
Example #9
0
	def __init__(self, ui, query=None):
		Dialog.__init__(self, ui, _('Search'), # T: Dialog title
			buttons=gtk.BUTTONS_CLOSE, help='Help:Searching')

		hbox = gtk.HBox(spacing=5)
		self.vbox.pack_start(hbox, False)
		hbox.pack_start(gtk.Label(_('Search')+': '), False) # T: input label
		self.query_entry = gtk.Entry()
		hbox.add(self.query_entry)
		button = gtk.Button(stock=gtk.STOCK_FIND)
		hbox.pack_start(button, False)

		# TODO advanced query editor
		# TODO checkbox _('Match c_ase')
		# TODO checkbox _('Whole _word')

		scrollwindow = gtk.ScrolledWindow()
		scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		scrollwindow.set_shadow_type(gtk.SHADOW_IN)
		self.vbox.add(scrollwindow)

		self.results_treeview = SearchResultsTreeView(self.ui)
		scrollwindow.add(self.results_treeview)

		if query:
			self.query_entry.set_text(query)
			self.results_treeview.set_query(query)


		def search(*a):
			self.results_treeview.set_query( self.query_entry.get_text() )

		button.connect('clicked', search)
		self.query_entry.connect('activate', search)
Example #10
0
    def __init__(self, ui, tool=None):
        Dialog.__init__(self, ui, _('Edit Custom Tool')) # T: Dialog title
        self.set_help(':Help:Custom Tools')
        self.vbox.set_spacing(12)

        if tool:
            name = tool.name
            comment = tool.comment
            execcmd = tool.execcmd
            readonly = tool.isreadonly
            toolbar = tool.showintoolbar
        else:
            name = ''
            comment = ''
            execcmd = ''
            readonly = False
            toolbar = False

        self.add_form((
            ('Name', 'string', _('Name')), # T: Input in "Edit Custom Tool" dialog
            ('Comment', 'string', _('Description')), # T: Input in "Edit Custom Tool" dialog
            ('X-Zim-ExecTool', 'string', _('Command')), # T: Input in "Edit Custom Tool" dialog
        ), {
            'Name': name,
            'Comment': comment,
            'X-Zim-ExecTool': execcmd,
        }, trigger_response=False)

        # FIXME need ui builder to take care of this as well
        self.iconbutton = IconChooserButton(stock=gtk.STOCK_EXECUTE)
        if tool and tool.icon and tool.icon != gtk.STOCK_EXECUTE:
            try:
                self.iconbutton.set_file(File(tool.icon))
            except Exception, error:
                logger.exception('Could not load: %s', tool.icon)
Example #11
0
    def __init__(self, ui):
        Dialog.__init__(self, ui, _('Custom Tools'), buttons=gtk.BUTTONS_CLOSE) # T: Dialog title
        self.set_help(':Help:Custom Tools')
        self.manager = CustomToolManager()

        self.add_help_text(_(
            'You can configure custom tools that will appear\n'
            'in the tool menu and in the tool bar or context menus.'
        ) ) # T: help text in "Custom Tools" dialog

        hbox = gtk.HBox(spacing=5)
        self.vbox.add(hbox)

        self.listview = CustomToolList(self.manager)
        hbox.add(self.listview)

        vbox = gtk.VBox(spacing=5)
        hbox.pack_start(vbox, False)

        for stock, handler, data in (
            (gtk.STOCK_ADD, self.__class__.on_add, None),
            (gtk.STOCK_EDIT, self.__class__.on_edit, None),
            (gtk.STOCK_DELETE, self.__class__.on_delete, None),
            (gtk.STOCK_GO_UP, self.__class__.on_move, -1),
            (gtk.STOCK_GO_DOWN, self.__class__.on_move, 1),
        ):
            button = IconButton(stock) # TODO tooltips for icon button
            if data:
                button.connect_object('clicked', handler, self, data)
            else:
                button.connect_object('clicked', handler, self)
            vbox.pack_start(button, False)
Example #12
0
    def __init__(self, ui, mimetype):
        '''Constructor
        @param ui: the parent window or C{GtkInterface} object
        @param mimetype: mime-type for which we want to create a new
        application
        '''
        Dialog.__init__(self, ui, _('Configure Applications'),  # T: Dialog title
            buttons=gtk.BUTTONS_CLOSE, help='Help:Default Applications')
        self.mimetype = mimetype
        self.add_text(_mimetype_dialog_text(mimetype))

        # Combo to set default
        self.default_combo = ApplicationComboBox()
        self.default_combo.connect('changed', self.on_default_changed)
        hbox = gtk.HBox(spacing=12)
        self.vbox.add(hbox)
        hbox.pack_start(gtk.Label(_('Default')+':'), False) # T: label for default application
        hbox.pack_start(self.default_combo)

        # Button to add new
        button = gtk.Button(_('Add Application'))
            # T: Button for adding a new application to the 'open with' menu
        button.connect('clicked', self.on_add_application)
        self.add_extra_button(button)

        self.reload()
Example #13
0
    def __init__(self, plugin):
        if ui_environment['platform'] == 'maemo':
            defaultsize = (800, 480)
        else:
            defaultsize = (900, 500)

        Dialog.__init__(self, plugin.ui, _('Qda Codes'),  # T: dialog title
            buttons=gtk.BUTTONS_CLOSE, help=':Plugins:Qda Codes',
            defaultwindowsize=defaultsize)

        self.plugin = plugin
        if ui_environment['platform'] == 'maemo':
            self.resize(800, 480)
            # Force maximum dialog size under maemo, otherwise
            # we'll end with a too small dialog and no way to resize it
            
        hbox = gtk.HBox(spacing=5)
        self.vbox.pack_start(hbox, False)
        self.hpane = HPaned()
        self.uistate.setdefault('hpane_pos', 75)
        self.hpane.set_position(self.uistate['hpane_pos'])
        self.vbox.add(self.hpane)

        # Code list
        self.qda_codes = QdaCodesTreeView(self.ui, plugin)
        self.qda_codes.set_headers_visible(True)  # Fix for maemo
        self.hpane.add2(ScrolledWindow(self.qda_codes))

        # Tag list
        self.tag_list = TagListTreeView(self.qda_codes)
        self.hpane.add1(ScrolledWindow(self.tag_list))

        # Filter input
        hbox.pack_start(gtk.Label(_('Filter') + ': '), False)  # T: Input label
        filter_entry = InputEntry()
        filter_entry.set_icon_to_clear()
        hbox.pack_start(filter_entry, False)
        filter_cb = DelayedCallback(500, lambda o: self.qda_codes.set_filter(filter_entry.get_text()))
        filter_entry.connect('changed', filter_cb)

        # Statistics label
        # self.statistics_label = gtk.Label()
        # hbox.pack_end(self.statistics_label, False)

        export_button = gtk.Button(_('_Export') )
        export_button.connect_object('clicked', self.qda_codes.get_data_as_page, self.qda_codes )
        hbox.pack_end(export_button, False )


        def on_qdacodes_changed(o):
            self.qda_codes.refresh()
            self.tag_list.refresh(self.qda_codes)
            # set_statistics()

        callback = DelayedCallback(10, on_qdacodes_changed)
            # Don't really care about the delay, but want to
            # make it less blocking - should be async preferably
            # now it is at least on idle

        self.connectto(plugin, 'qdacodes-changed', callback)
Example #14
0
    def __init__(self, window, index, uistate):

        Dialog.__init__(self, window, _('Tags Manager (IconTags plugin)'), # T: dialog title
                        buttons=gtk.BUTTONS_OK_CANCEL,
                        defaultwindowsize=(450, 400) )

        # Don't confuse with local variable 'self.uistate',
        # which is already determined for this class.
        self._window = window
        self.plugin_uistate = uistate
        self.show_pages_button = gtk.ToggleButton('Show Pages')
        self.show_pages_button.connect('toggled', self.toggle_show_pages)
        self.add_extra_button(self.show_pages_button)

        self.treeview_tags = TagsManagerTagsView(index, self.plugin_uistate['Icons for Tags'])
        self.treeview_pages = TagsManagerPagesView(index, window.ui)
        self.scrolled_widget = ScrolledWindow(self.treeview_tags)
        self.vbox.pack_start(self.scrolled_widget, True)

        self.treeview_tags.connect('row-activated', self.get_tag)

        # Enable left/right arrows to navigate between views.
        self.treeview_tags.connect('key-release-event', self.toggle_view)
        self.treeview_pages.connect('key-release-event', self.toggle_view)

        # Update if tags change.
        self.connectto_all(index.update_iter.tags, (
            ('tag-row-inserted', lambda *a: self.update()),
            ('tag-row-deleted', lambda *a: self.update())
        ))

        self.show_all()
Example #15
0
	def __init__(self, ui, callback=None):
		Dialog.__init__(self, ui, _('Open Notebook')) # T: dialog title
		# TODO set button to "OPEN" instead of "OK"
		self.callback = callback
		self.set_default_size(500, 400)
		self.set_help(':Help:Notebooks')

		# show some art work in an otherwise boring dialog
		path = data_file('globe_banner_small.png').path
		image = gtk.Image()
		image.set_from_file(path) # new_from_file not in 2.6
		align = gtk.Alignment(0,0.5, 0,0)
		align.add(image)
		self.vbox.pack_start(align, False)

		# split between treeview and vbuttonbox
		hbox = gtk.HBox(spacing=12)
		self.vbox.add(hbox)

		# add notebook list - open notebook on clicking a row
		self.treeview = NotebookTreeView()
		self.treeview.connect(
			'row-activated', lambda *a: self.response(gtk.RESPONSE_OK))

		swindow = gtk.ScrolledWindow()
		swindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
		swindow.set_shadow_type(gtk.SHADOW_IN)
		swindow.add(self.treeview)
		hbox.add(swindow)

		# add buttons for modifying the treeview
		vbbox = gtk.VButtonBox()
		vbbox.set_layout(gtk.BUTTONBOX_START)
		hbox.pack_start(vbbox, False)
		add_button = gtk.Button(stock='gtk-add')
		add_button.connect('clicked', self.do_add_notebook)
		#~ edit_button = gtk.Button(stock='gtk-edit')
		#~ edit_button.connect('clicked', self.do_edit_notebook)
		rm_button = gtk.Button(stock='gtk-remove')
		rm_button.connect('clicked', self.do_remove_notebook)
		#~ for b in (add_button, edit_button, rm_button):
		for b in (add_button, rm_button):
			b.set_alignment(0.0, 0.5)
			vbbox.add(b)
		# FIXME buttons for "up" and "down" ?

		# add dropdown to select default
		self.combobox = DefaultNotebookComboBox(self.treeview.get_model())

		# clear button de-selects any item in the combobox
		clear_button = IconButton('gtk-clear')
		clear_button.connect('clicked', lambda o: self.combobox.set_active(-1))

		hbox = gtk.HBox(spacing=5)
		hbox.pack_start(gtk.Label(_('Default notebook')+': '), False)
			# T: Input label in 'open notebook' dialog
		hbox.pack_start(self.combobox, False)
		hbox.pack_start(clear_button, False)
		self.vbox.pack_start(hbox, False)
Example #16
0
	def __init__(self, ui, type):
		Dialog.__init__(self, ui, _('Custom Command')) # T: Dialog title
		assert type in ('file_browser', 'web_browser', 'email_client')
		self.type = type
		self.add_fields(
			('name', 'string', _('Name'), ''), # T: Field in 'custom command' dialog
			('exec', 'string', _('Command'), ''), # T: Field in 'custom command' dialog
		)
Example #17
0
	def show_help(self, page=None):
		# Overloaded because self.ui may be None
		if self.ui:
			Dialog.show_help(self, page)
		else:
			if page is None:
				page = self.help_page
			zim.main.get_zim_application('--manual', page).spawn()
	def __init__(self, ui, default_tab=None, select_plugin=None):
		Dialog.__init__(self, ui, _('Preferences')) # T: Dialog title
		gtknotebook = gtk.Notebook()
		self.vbox.add(gtknotebook)
		# saves a list of loaded plugins to be used later
		self.p_save_loaded = [p.__class__ for p in self.ui.plugins]

		# Dynamic tabs
		self.forms = {}
		for category, preferences in ui.preferences_register.items():
			vbox = gtk.VBox()
			index = gtknotebook.append_page(vbox, gtk.Label(_(category)))
			# From GTK Doc: Note that due to historical reasons, GtkNotebook refuses
			# to switch to a page unless the child widget is visible.
			vbox.show()
			if category == default_tab: gtknotebook.set_current_page(index)

			fields = []
			values = {}
			sections = {}
			for p in preferences:
				if len(p) == 4:
					section, key, type, label = p
					fields.append((key, type, label))
				else:
					section, key, type, label, check = p
					fields.append((key, type, label, check))

				values[key] = ui.preferences[section][key]
				sections[key] = section

			form = InputForm(fields, values)
			form.preferences_sections = sections
			vbox.pack_start(form, False)
			self.forms[category] = form

			if category == 'Interface':
				self._add_font_selection(form)

		# Styles tab
		#~ gtknotebook.append_page(StylesTab(self), gtk.Label(_('Styles')))

		# Keybindings tab
		#~ gtknotebook.append_page(KeyBindingsTab(self), gtk.Label(_('Key bindings')))

		# Plugins tab
		plugins_tab = PluginsTab(self, self.ui.plugins)
		plugins_tab_index = gtknotebook.append_page(plugins_tab, gtk.Label(_('Plugins')))
				# T: Heading in preferences dialog
		plugins_tab.show()
		#~ print default_tab, index
		if default_tab == "Plugins":
			gtknotebook.set_current_page(plugins_tab_index)
			if not select_plugin is None:
					plugins_tab.select_plugin(select_plugin)

		# Applications tab
		gtknotebook.append_page(ApplicationsTab(self), gtk.Label(_('Applications')))
Example #19
0
	def show_help(self, page=None):
		# Overloaded because self.ui may be None
		if self.ui:
			Dialog.show_help(self, page)
		else:
			from zim import ZimCmd
			if page is None:
				page = self.help_page
			ZimCmd(('--manual', page)).spawn()
	def __init__(self, ui):
		Dialog.__init__(self, ui,
			_('Templates'), help='Help:Templates', buttons=gtk.BUTTONS_CLOSE,
			defaultwindowsize=(400, 450))
			# T: Dialog title

		label = gtk.Label()
		label.set_markup('<b>'+_('Templates')+'</b>')
			# T: Section in dialog
		label.set_alignment(0.0, 0.5)
		self.vbox.pack_start(label, False)

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

		self.view = TemplateListView()
		self.view.connect('row-activated', self.on_selection_changed)
		hbox.add(ScrolledWindow(self.view))

		vbbox = gtk.VButtonBox()
		vbbox.set_layout(gtk.BUTTONBOX_START)
		hbox.pack_start(vbbox, False)

		view_button = Button(stock='gtk-file', label=_('_View')) # T: button label
		view_button.connect('clicked', self.on_view)

		copy_button = Button(stock='gtk-copy')
		copy_button.connect('clicked', self.on_copy)

		edit_button = Button(stock='gtk-edit')
		edit_button.connect('clicked', self.on_edit)

		delete_button = gtk.Button(stock='gtk-remove')
		delete_button.connect('clicked', self.on_delete)

		for b in (view_button, copy_button, edit_button, delete_button):
			b.set_alignment(0.0, 0.5)
			vbbox.add(b)

		browse_button = Button(_('Browse')) # T: button label
		browse_button.connect('clicked', self.on_browse)
		self.add_extra_button(browse_button)

		self._buttonbox = vbbox
		self._delete_button = delete_button
		self.on_selection_changed()

		## Same button appears in export dialog
		if gtk.gtk_version >= (2, 10) \
		and gtk.pygtk_version >= (2, 10):
			url_button = gtk.LinkButton(
				'https://github.com/jaap-karssenberg/zim-wiki/wiki/Templates',
				_('Get more templates online') # T: label for button with URL
			)
			self.vbox.pack_start(url_button, False)
Example #21
0
	def __init__(self, ui, name=None, folder=None):
		Dialog.__init__(self, ui, self.title)
		if name is None and folder is None:
			name = 'Notes'
			folder = '~/Notes'
		if self.text:
			self.add_text(self.text)
		self.add_fields((
			('name', 'string', _('Name'), name), # T: input field in 'Add Notebook' dialog
			('folder', 'dir', _('Folder'), folder), # T: input field in 'Add Notebook' dialog
		))
Example #22
0
    def __init__(self, ui):
        Dialog.__init__(self, ui, _('Recent Changes'), # T: Dialog title
            buttons=gtk.BUTTONS_CLOSE,
            defaultwindowsize=(400, 300)
        )

        self.treeview = RecentChangesTreeView(ui)
        self.vbox.add(ScrolledWindow(self.treeview))

        self.update()
        self.ui.notebook.connect_after('stored-page', lambda *a: self.update())
Example #23
0
	def __init__(self, ui, page=None, namespace=None, basename=None, append=None, text=None, template_options=None, attachments=None):
		Dialog.__init__(self, ui, _('Quick Note'))
		self._updating_title = False
		self._title_set_manually = not basename is None
		self.attachments = attachments

		self.uistate.setdefault('namespace', None, basestring)
		namespace = namespace or self.uistate['namespace']

		self.form = InputForm(notebook=self.ui.notebook)
		self.vbox.pack_start(self.form, False)
		self._init_inputs(namespace, basename, append, text, template_options)
	def __init__(self, ui, title, generator, image=None, **opt):
		Dialog.__init__(self, ui, title, defaultwindowsize=(450, 300), **opt)
		self.generator = generator
		self.imagefile = None
		self.logfile = None
		self._existing_file = None

		self.vpane = gtk.VPaned()
		self.vpane.set_position(100)
		self.vbox.add(self.vpane)

		self.imageview = ImageView(bgcolor='#FFF', checkboard=False)
		# TODO scrolled window
		self.vpane.add1(self.imageview)

		self.textview = gtk.TextView()
		# TODO scrolled window
		# TODO supply at least an Undo stack for this textview
		# or optionally subclass from gtksourceview
		self.textview.set_left_margin(5)
		self.textview.set_right_margin(5)
		self.vpane.add2(self.textview)

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

		self.previewbutton = Button(_('_Preview'), stock='gtk-refresh')
			# T: button in e.g. equation editor dialog
		self.previewbutton.set_sensitive(False)
		self.previewbutton.connect_object(
			'clicked', self.__class__.preview, self)
		hbox.pack_start(self.previewbutton, False)

		self.textview.get_buffer().connect('modified-changed',
			lambda b: self.previewbutton.set_sensitive(b.get_modified()))

		self.logbutton = Button(_('View _Log'), stock='gtk-file')
			# T: button in e.g. equation editor dialog
		self.logbutton.set_sensitive(False)
		self.logbutton.connect_object(
			'clicked', self.__class__.show_log, self)
		hbox.pack_start(self.logbutton, False)

		if image:
			file = image['_src_file'] # FIXME ?
			textfile = self._stitch_fileextension(file, self.generator.basename)
			if file.exists() and textfile.exists():
				self._existing_file = textfile
				self.imageview.set_file(file)
				self.set_text(textfile.read())

		self.textview.grab_focus()
	def __init__(self, ui):
		Dialog.__init__(self, ui, _('Preferences')) # T: Dialog title
		gtknotebook = gtk.Notebook()
		self.vbox.add(gtknotebook)

		# Dynamic tabs
		for category, preferences in ui.preferences_register.items():
			table = gtk.Table()
			table.set_border_width(5)
			table.set_row_spacings(12)
			table.set_col_spacings(12)
			vbox = gtk.VBox()
			vbox.pack_start(table, False)
			gtknotebook.append_page(vbox, gtk.Label(category))
			fields = []
			for p in preferences:
				section, key, type, label = p
				value = ui.preferences[section][key]
				fields.append(((section, key), type, label, value))
				# a tuple is hashable and can be used as field name...
			self.add_fields(fields, table=table, trigger_response=False)
			if category == 'Interface':
				self._add_font_selection(table, vbox)

		# Styles tab
		#~ gtknotebook.append_page(StylesTab(self), gtk.Label('Styles'))

		# Keybindings tab
		#~ gtknotebook.append_page(KeyBindingsTab(self), gtk.Label('Key bindings'))

		# Applications tab
		table = gtk.Table()
		table.set_border_width(5)
		table.set_row_spacings(12)
		table.set_col_spacings(12)
		self.add_fields( (
			('file_browser', 'list', _('File browser'), (None, ())),
				# T: Input for application type in preferences dialog
			('web_browser', 'list', _('Web browser'), (None, ())),
				# T: Input for application type in preferences dialog
			('email_client', 'list', _('Email client'), (None, ())),
				# T: Input for application type in preferences dialog
		), table=table, trigger_response=False)
		for type in ('file_browser', 'web_browser', 'email_client'):
			self._append_applications(type)
		vbox = gtk.VBox()
		vbox.pack_start(table, False)
		gtknotebook.append_page(vbox, gtk.Label(_('Applications')))
				# T: Heading in preferences dialog

		# Plugins tab
		gtknotebook.append_page(PluginsTab(self), gtk.Label(_('Plugins')))
Example #26
0
	def __init__(self, ui):
		Dialog.__init__(self, ui, _('Search'), # T: Dialog title
			buttons=gtk.BUTTONS_CLOSE, help='Help:Searching',
			defaultwindowsize=(400, 300)
		)

		hbox = gtk.HBox(spacing=5)
		self.vbox.pack_start(hbox, False)
		hbox.pack_start(gtk.Label(_('Search')+': '), False) # T: input label
		self.query_entry = InputEntry()
		hbox.add(self.query_entry)
		self.search_button = gtk.Button(stock=gtk.STOCK_FIND)
		hbox.pack_start(self.search_button, False)

		if gtk.gtk_version >= (2, 20) \
		and gtk.pygtk_version >= (2, 22): # update in pygtk was later
			self.spinner = gtk.Spinner()
			hbox.pack_start(self.spinner, False)
		else:
			self.spinner = None

		self.cancel_button = gtk.Button(stock=gtk.STOCK_STOP)
		hbox.pack_start(self.cancel_button, False)
		self._set_state(self.READY)

		help_text = _(
			'For advanced search you can use operators like\n'
			'AND, OR and NOT. See the help page for more details.'
		) # T: help text for the search dialog
		if gtk.gtk_version >= (2, 12) \
		and gtk.pygtk_version >= (2, 12):
			self.query_entry.set_tooltip_text(help_text)
		else:
			tooltips = gtk.Tooltips()
			tooltips.set_tip(self.query_entry, help_text)

		self.namespacecheckbox = gtk.CheckButton(_('Limit search to the current page and sub-pages'))
			# T: checkbox option in search dialog
		self.vbox.pack_start(self.namespacecheckbox, False)

		# TODO advanced query editor
		# TODO checkbox _('Match c_ase')
		# TODO checkbox _('Whole _word')

		self.results_treeview = SearchResultsTreeView(self.ui)
		self.vbox.add(ScrolledWindow(self.results_treeview))

		self.search_button.connect_object('clicked', self.__class__._search, self)
		self.cancel_button.connect_object('clicked', self.__class__._cancel, self)
		self.query_entry.connect_object('activate', self.__class__._search, self)
Example #27
0
	def __init__(self, ui):
		Dialog.__init__(self, ui, _('Insert Screenshot')) # T: dialog title
		self.screen_radio = gtk.RadioButton(None, _('Capture whole screen')) # T: option in 'insert screenshot' dialog
		self.select_radio = gtk.RadioButton(self.screen_radio, _('Select window or region')) # T: option in 'insert screenshot' dialog
		self.vbox.add(self.screen_radio)
		self.vbox.add(self.select_radio)

		hbox = gtk.HBox()
		self.vbox.add(hbox)
		hbox.add(gtk.Label(_('Delay')+': ')) # T: input in 'insert screenshot' dialog
		self.time_spin = gtk.SpinButton()
		self.time_spin.set_range(0, 99)
		self.time_spin.set_increments(1, 5)
		hbox.add(self.time_spin)
		hbox.add(gtk.Label(' '+_('seconds'))) # T: label behind timer
	def __init__(self, ui):
		Dialog.__init__(self, ui, _('Properties')) # T: Dialog title
		label = gtk.Label()
		label.set_markup('<b>'+_('Notebook Properties')+'</b>')
			# T: Section in notbook dialog
		label.set_alignment(0.0, 0.5)
		self.vbox.pack_start(label, False)
		fields = []
		config = self.ui.notebook.config['Notebook']
		for name, type, label in self.ui.notebook.properties:
			fields.append((name, type, label, config[name]))
		self.add_fields(fields)
		if self.ui.readonly:
			for widget in self.inputs.values():
				widget.set_sensitive(False)
Example #29
0
 def __init__(self, ui, mimetype):
     '''Constructor
     @param ui: the parent window or C{GtkInterface} object
     @param mimetype: mime-type for which we want to create a new
     application
     '''
     Dialog.__init__(self, ui, _('Add Application')) # T: Dialog title
     self.mimetype = mimetype
     self.add_text(_mimetype_dialog_text(mimetype))
     self.add_form( (
         ('name', 'string', _('Name')), # T: Field in 'custom command' dialog
         ('exec', 'string', _('Command')), # T: Field in 'custom command' dialog
         ('default', 'bool', _('Make default application')), # T: Field in 'custom command' dialog
     ) )
     self.form['default'] = True
Example #30
0
	def __init__(self, plugin):
		Dialog.__init__(self, plugin.ui, _('Calendar'), buttons=gtk.BUTTONS_CLOSE) # T: dialog title
		self.set_resizable(False)
		self.plugin = plugin

		self.calendar_widget = CalendarPluginWidget(plugin)
		self.calendar_widget.set_select_date_callback(self.on_select_date)
		self.vbox.add(self.calendar_widget)

		button = Button(_('_Today'), gtk.STOCK_JUMP_TO) # T: button label
		button.connect('clicked', self.do_today )
		self.action_area.add(button)
		self.action_area.reorder_child(button, 0)
		self.dateshown = datetime.date.today()

		self.connectto(self.plugin.ui, 'open-page')
Example #31
0
    def __init__(self, ui, tablemodel=None):
        '''
		Constructor, which intializes the dialog window
		:param ui:
		:param tablemodel: list of row-data
		:return:
		'''
        title = _('Insert Table') if tablemodel is None else _(
            'Edit Table')  # T: Dialog title
        Dialog.__init__(self, ui, title)

        # Prepare treeview in which all columns of the table are listed
        self.creation_mode = tablemodel is None
        self.default_column_item = [
            -1, "", 0, "left", gtk.STOCK_JUSTIFY_LEFT,
            _("Left")
        ]
        # currently edited cell - tuple (editable, path, colid) save it on exit
        self.currently_edited = None

        # Set layout of Window
        self.add_help_text(_('Managing table columns')
                           )  # T: Description of "Table-Insert" Dialog
        self.set_default_size(380, 400)

        liststore = self._prepare_liststore(tablemodel)
        self.treeview = self._prepare_treeview_with_headcolumn_list(liststore)
        hbox = gtk.HBox(spacing=5)
        hbox.set_size_request(300, 300)
        self.vbox.pack_start(hbox, False)
        header_scrolled_area = ScrolledWindow(self.treeview)
        header_scrolled_area.set_size_request(200, -1)
        hbox.add(header_scrolled_area)
        hbox.add(self._button_box())

        self.show_all()
        if self.creation_mode:  # preselect first entry
            path = self.treeview.get_model().get_path(
                self.treeview.get_model().get_iter_first())
            self.treeview.set_cursor_on_cell(path,
                                             self.treeview.get_column(0),
                                             start_editing=True)
Example #32
0
    def __init__(self, parent):
        Dialog.__init__(self, parent,
                        _('Insert Code Block'))  # T: dialog title
        self.result = (None, None)
        self.uistate.define(lang=String(None))
        self.uistate.define(line_numbers=Boolean(True))
        defaultlang = self.uistate['lang']

        menu = {}
        for l in sorted(LANGUAGES, key=lambda k: k.lower()):
            key = l[0].upper()
            if not key in menu:
                menu[key] = []
            menu[key].append(l)

        model = Gtk.TreeStore(str)
        defaultiter = None
        for key in sorted(menu):
            iter = model.append(None, [key])
            for lang in menu[key]:
                myiter = model.append(iter, [lang])
                if LANGUAGES[lang] == defaultlang:
                    defaultiter = myiter

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        hbox.set_spacing(5)
        label = Gtk.Label(_('Syntax') + ':')  # T: input label
        hbox.add(label)

        combobox = Gtk.ComboBox.new_with_model(model)
        renderer_text = Gtk.CellRendererText()
        combobox.pack_start(renderer_text, True)
        combobox.add_attribute(renderer_text, "text", 0)
        if defaultiter is not None:
            combobox.set_active_iter(defaultiter)
        hbox.add(combobox)
        self.combobox = combobox
        self.vbox.add(hbox)
        self.checkbox = Gtk.CheckButton(
            _('Display line numbers'))  # T: input checkbox
        self.checkbox.set_active(self.uistate['line_numbers'])
        self.vbox.add(self.checkbox)
Example #33
0
    def __init__(self, widget, notebook, path):
        Dialog.__init__(self, widget, _('Rename Page'))  # T: Dialog title
        self.notebook = notebook
        self.path = path
        page = self.notebook.get_page(self.path)

        self.vbox.add(Gtk.Label(label=_('Rename page "%s"') % self.path.name))
        # T: label in 'rename page' dialog - %s is the page name

        try:
            i = self.notebook.links.n_list_links_section(
                path, LINK_DIR_BACKWARD)
        except IndexNotFoundError:
            i = 0

        label = ngettext('Update %i page linking to this page',
                         'Update %i pages linking to this page', i) % i
        # T: label in MovePage dialog - %i is number of backlinks
        # TODO update label to reflect that links can also be to child pages

        self.add_form(
            [
                ('name', 'string', _('Name')),
                # T: Input label in the 'rename page' dialog for the new name
                ('head', 'bool', _('Update the heading of this page')),
                # T: Option in the 'rename page' dialog
                ('update', 'bool', label),
                # T: Option in the 'rename page' dialog
            ],
            {
                'name': self.path.basename,
                'head': page.heading_matches_pagename(),
                'update': True,
            })

        if not page.exists():
            self.form['head'] = False
            self.form.widgets['head'].set_sensitive(False)

        if i == 0:
            self.form['update'] = False
            self.form.widgets['update'].set_sensitive(False)
Example #34
0
    def __init__(self, plugin, window):
        Dialog.__init__(self, window, _('Calendar'),
                        buttons=gtk.BUTTONS_CLOSE)  # T: dialog title
        self.set_resizable(False)
        self.plugin = plugin
        self.opener = window.get_resource_opener()

        notebook = window.ui.notebook  # XXX
        model = CalendarWidgetModel(self.plugin, notebook)
        self.calendar_widget = CalendarWidget(model)
        self.vbox.add(self.calendar_widget)

        button = Button(_('_Today'), gtk.STOCK_JUMP_TO)  # T: button label
        button.connect('clicked', self.do_today)
        self.action_area.add(button)
        self.action_area.reorder_child(button, 0)
        self.dateshown = datetime.date.today()

        self.connectto(self.calendar_widget, 'date-activated')
        self.connectto(window.ui, 'open-page')  # XXX
Example #35
0
    def __init__(self, pageview, preferences):
        """Initialize the Input Box with options."""
        Dialog.__init__(self, pageview, _('Search in Zotero'),  # T: Dialog title
                        button=_('_GO'),  # T: Button label
                        defaultwindowsize=(350, 200))

        self.pageview = pageview
        self.textentry = InputEntry()
        self.vbox.pack_start(self.textentry, False, True, 0)
        self.preferences = preferences
        first = None
        options = ["Search in Title, Author and Date",
                   "Search in All Fields and Tags",
                   "Search Everywhere"]
        for text in options:
            self.radio = Gtk.RadioButton.new_with_mnemonic_from_widget(first, text)
            if not first:
                first = self.radio
            self.vbox.pack_start(self.radio, False, True, 0)
            self.radio.show()
    def __init__(self, parent, notebook):
        Dialog.__init__(self, parent, _('Properties'),
                        help='Help:Properties')  # T: Dialog title
        self.notebook = notebook

        stack = Gtk.Stack()
        sidebar = Gtk.StackSidebar()
        sidebar.set_stack(stack)

        hbox = Gtk.Box()
        hbox.add(sidebar)
        hbox.add(stack)
        self.vbox.add(hbox)

        self.form = InputForm(inputs=notebook_properties,
                              values=notebook.config['Notebook'])
        self.form.widgets['icon'].set_use_relative_paths(self.notebook)
        if self.notebook.readonly:
            for widget in list(self.form.widgets.values()):
                widget.set_sensitive(False)
        box = Gtk.VBox()
        box.pack_start(self.form, False, False, 0)
        stack.add_titled(box, 'notebook', _('Notebook'))

        self.plugin_forms = {}
        plugins = PluginManager()
        for name in plugins:
            plugin = plugins[name]
            if plugin.plugin_notebook_properties:
                key = plugin.config_key
                form = InputForm(inputs=plugin.form_fields(
                    plugin.plugin_notebook_properties),
                                 values=notebook.config[key])
                self.plugin_forms[key] = form
                if self.notebook.readonly:
                    for widget in list(form.widgets.values()):
                        widget.set_sensitive(False)

                box = Gtk.VBox()
                box.pack_start(form, False, False, 0)
                stack.add_titled(box, name, plugin.plugin_info['name'])
    def __init__(self, parent):
        Dialog.__init__(self, parent,
                        _("Enable Version Control?"))  # T: Question dialog
        self.add_text(
            _("Version control is currently not enabled for this notebook.\n"
              "Do you want to enable it?")  # T: Detailed question
        )

        self.combobox = Gtk.ComboBoxText()
        for option in (VCS.BZR, VCS.GIT, VCS.HG, VCS.FOSSIL):
            if VCS.check_dependencies(option):
                self.combobox.append_text(option)
        self.combobox.set_active(0)

        hbox = Gtk.Box(spacing=5)
        hbox.add(Gtk.Label(_('Backend') + ':'))
        hbox.add(self.combobox)
        # T: option to chose versioncontrol backend
        hbox.set_halign(Gtk.Align.CENTER)
        self.vbox.pack_start(hbox, False, False, 0)
        hbox.show_all()
Example #38
0
	def __init__(self, window, notebook=None,
		page=None, namespace=None, basename=None,
		append=None, text=None, template_options=None, attachments=None
	):
		assert page is None, 'TODO'

		manager = ConfigManager() # FIXME should be passed in
		self.config = manager.get_config_dict('quicknote.conf')
		self.uistate = self.config['QuickNoteDialog']

		Dialog.__init__(self, window, _('Quick Note'))
		self._updating_title = False
		self._title_set_manually = not basename is None
		self.attachments = attachments

		if notebook and not isinstance(notebook, basestring):
			notebook = notebook.uri

		self.uistate.setdefault('lastnotebook', None, basestring)
		if self.uistate['lastnotebook']:
			notebook = notebook or self.uistate['lastnotebook']
			self.config['Namespaces'].setdefault(notebook, None, basestring)
			namespace = namespace or self.config['Namespaces'][notebook]

		self.form = InputForm()
		self.vbox.pack_start(self.form, False)

		# TODO dropdown could use an option "Other..."
		label = gtk.Label(_('Notebook')+': ')
		label.set_alignment(0.0, 0.5)
		self.form.attach(label, 0,1, 0,1, xoptions=gtk.FILL)
			# T: Field to select Notebook from drop down list
		self.notebookcombobox = NotebookComboBox(current=notebook)
		self.notebookcombobox.connect('changed', self.on_notebook_changed)
		self.form.attach(self.notebookcombobox, 1,2, 0,1)

		self._init_inputs(namespace, basename, append, text, template_options)

		self.uistate['lastnotebook'] = notebook
		self._set_autocomplete(notebook)
Example #39
0
    def __init__(self, parent: PageViewExtension, entry: ProjectEntry,
                 projects_list: ProjectsList):
        self.textview = parent.pageview.textview
        self.date = '-'.join(
            parent.pageview.get_page().source_file.pathnames[-3:]).rstrip(
                '.txt')
        self.entry = entry

        preferences = parent.plugin.preferences  # type: ConfigDict
        rpc_server_socket = preferences.get('url')
        self.rpc = Rpc(rpc_server_socket)

        Dialog.__init__(
            self,
            parent,
            title=_(
                'Bitte den Eintrag überprüfen (Stunden: {0:.2f} von {1:.2f})').
            format(
                entry.time_total(),
                projects_list.time_total(),
            ),
            button=_('Alles korrekt. Jetzt Speichern'))  # T: Dialog button
        self.add_text(entry.check_description())
Example #40
0
    def __init__(self,
                 window,
                 notebook,
                 ui,
                 page=None,
                 namespace=None,
                 basename=None,
                 append=None,
                 text=None,
                 template_options=None,
                 attachments=None):
        Dialog.__init__(self, window, _('Quick Note'))
        self._ui = ui
        self._updating_title = False
        self._title_set_manually = not basename is None
        self.attachments = attachments

        self.uistate.setdefault('namespace', None, basestring)
        namespace = namespace or self.uistate['namespace']

        self.form = InputForm(notebook=notebook)
        self.vbox.pack_start(self.form, False)
        self._init_inputs(namespace, basename, append, text, template_options)
Example #41
0
    def __init__(self, widget, navigation, notebook, path=None, subpage=False):
        if subpage:
            title = _('New Page in %s') % path  # T: Dialog title
        else:
            title = _('New Page')  # T: Dialog title

        Dialog.__init__(
            self,
            widget,
            title,
            help_text=_('Please note that linking to a non-existing page\n'
                        'also creates a new page automatically.'),
            # T: Dialog text in 'new page' dialog
            help=':Help:Pages')
        self.notebook = notebook
        self.navigation = navigation

        default = notebook.get_page_template_name(path)
        templates = [t[0] for t in list_templates('wiki')]
        if not default in templates:
            templates.insert(0, default)

        self.add_form([
            ('page', 'page', _('Page Name'), path),  # T: Input label
            ('template', 'choice', _('Page Template'), templates
             )  # T: Choice label
        ])
        self.form['template'] = default
        # TODO: reset default when page input changed -
        # especially if namespace has other template

        self.form.set_default_activate(
            'page'
        )  # close dialog on <Enter> immediatly, do not select template

        if subpage:
            self.form.widgets['page'].subpaths_only = True
Example #42
0
    def __init__(self, widget, file):
        Dialog.__init__(self, widget, _('File Exists'),
                        buttons=None)  # T: Dialog title
        self.add_help_text(
            _('''\
A file with the name <b>"%s"</b> already exists.
You can use another name or overwrite the existing file.''' % file.basename),
        )  # T: Dialog text in 'new filename' dialog
        self.folder = file.parent()
        self.old_file = file

        suggested_filename = self.folder.new_file(file.basename).basename
        self.add_form(
            (
                ('name', 'string', _('Filename')),  # T: Input label
            ),
            {'name': suggested_filename})
        self.form.widgets['name'].set_check_func(self._check_valid)

        # all buttons are defined in this class, to get the ordering right
        # [show folder]      [overwrite] [cancel] [ok]
        button = Gtk.Button.new_with_mnemonic(_('_Browse'))  # T: Button label
        button.connect('clicked', self.do_show_folder)
        self.action_area.add(button)
        self.action_area.set_child_secondary(button, True)

        button = Gtk.Button.new_with_mnemonic(
            _('Overwrite'))  # T: Button label
        button.connect('clicked', self.do_response_overwrite)
        self.add_action_widget(button, Gtk.ResponseType.NONE)

        self.add_button(_('_Cancel'),
                        Gtk.ResponseType.CANCEL)  # T: Button label
        self.add_button(_('_OK'), Gtk.ResponseType.OK)  # T: Button label
        self._no_ok_action = False

        self.form.widgets['name'].connect('focus-in-event', self._on_focus)
Example #43
0
	def __init__(self, ui, tool=None):
		Dialog.__init__(self, ui, _('Edit Custom Tool')) # T: Dialog title
		self.set_help(':Help:Custom Tools')
		self.vbox.set_spacing(12)

		if tool:
			name = tool.name
			comment = tool.comment
			execcmd = tool.execcmd
			readonly = tool.isreadonly
			toolbar = tool.showintoolbar
			replaceselection = tool.replaceselection
		else:
			name = ''
			comment = ''
			execcmd = ''
			readonly = False
			toolbar = False
			replaceselection = False

		self.add_form((
			('Name', 'string', _('Name')), # T: Input in "Edit Custom Tool" dialog
			('Comment', 'string', _('Description')), # T: Input in "Edit Custom Tool" dialog
			('X-Zim-ExecTool', 'string', _('Command')), # T: Input in "Edit Custom Tool" dialog
		), {
			'Name': name,
			'Comment': comment,
			'X-Zim-ExecTool': execcmd,
		}, trigger_response=False)

		# FIXME need ui builder to take care of this as well
		self.iconbutton = IconChooserButton(stock=gtk.STOCK_EXECUTE)
		if tool and tool.icon and tool.icon != gtk.STOCK_EXECUTE:
			try:
				self.iconbutton.set_file(File(tool.icon))
			except Exception, error:
				logger.exception('Could not load: %s', tool.icon)
    def __init__(self, parent, window_ext, vcs):
        Dialog.__init__(
            self,
            parent,
            _('Save Version'),  # T: dialog title
            button=_('_Save'),  # T: button label
            help='Plugins:Version Control')
        self.window_ext = window_ext
        self.vcs = vcs

        label = Gtk.Label(
            _("Please enter a comment for this version"))  # T: Dialog text
        self.vbox.pack_start(label, False, True, 0)

        vpaned = VPaned()
        self.vbox.pack_start(vpaned, True, True, 0)

        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(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, True, 0)

        self.vcs.stage()
        status = self.vcs.status()
        window, textview = ScrolledTextView(text=''.join(status),
                                            monospace=True)
        vbox.add(window)
Example #45
0
	def __init__(self, ui, name=None, folder=None):
		Dialog.__init__(self, ui, _('Add Notebook')) # T: Dialog window title

		label = gtk.Label(_('Please select a name and a folder for the notebook.')) # T: Label in Add Notebook dialog
		label.set_alignment(0.0, 0.5)
		self.vbox.pack_start(label, False)

		self._name_set = not name is None
		self._folder_set = not folder is None

		nb_folder = '~/Notebooks/'

		if not self._name_set and not self._folder_set:
			name = 'Notes'
			folder = nb_folder + name
		# else set below by _changed methods

		self.add_form((
			('name', 'string', _('Name')), # T: input field in 'Add Notebook' dialog
			('folder', 'dir', _('Folder')), # T: input field in 'Add Notebook' dialog
		), {
			'name': name,
			'folder': folder,
		})

		self.add_help_text(_('''\
To create a new notebook you need to select an empty folder.
Of course you can also select an existing zim notebook folder.
''')) # T: help text in the 'Add Notebook' dialog

		# Hook entries to copy name when appropriate
		self._block_update = False
		self.on_name_changed(None, interactive=False)
		self.on_folder_changed(None, interactive=False)
		self.form.widgets['name'].connect('changed', self.on_name_changed)
		self.form.widgets['folder'].connect('changed', self.on_folder_changed)
Example #46
0
 def do_response(self, id):
     if id == Gtk.ResponseType.DELETE_EVENT:
         if self.textview.get_buffer().get_modified():
             ok = QuestionDialog(self, _('Discard note?')).run()
             # T: confirm closing quick note dialog
             if ok:
                 Dialog.do_response(self, id)
             # else pass
         else:
             Dialog.do_response(self, id)
     else:
         Dialog.do_response(self, id)
Example #47
0
	def show_all(self):
		# We focus on the treeview so that the user can start typing the
		# notebook name directly when the dialog opens.
		Dialog.show_all(self)
		self.treeview.grab_focus()
Example #48
0
 def run(self):
     self.iconview.grab_focus()
     Dialog.run(self)
Example #49
0
 def __init__(self, ui):
     Dialog.__init__(self, ui, _('Copy Template'))  # T: Dialog title
     self.add_form([
         ('name', 'string', _('Name')),
         # T: Input label for the new name when copying a template
     ])
Example #50
0
 def show(self):
     self.textview.grab_focus()
     Dialog.show(self)
Example #51
0
 def run(self):
     self.textview.grab_focus()
     Dialog.run(self)
Example #52
0
    def __init__(self, parent, tasksview, properties):
        Dialog.__init__(
            self,
            parent,
            _('Task List'),  # T: dialog title
            buttons=Gtk.ButtonsType.CLOSE,
            help=':Plugins:Task List',
            defaultwindowsize=(550, 400))
        self.properties = properties
        self.tasksview = tasksview
        self.notebook = parent.notebook

        hbox = Gtk.HBox(spacing=5)
        self.vbox.pack_start(hbox, False, True, 0)
        self.hpane = HPaned()
        self.uistate.setdefault('hpane_pos', 75)
        self.hpane.set_position(self.uistate['hpane_pos'])
        self.vbox.pack_start(self.hpane, True, True, 0)

        # Task list
        self.uistate.setdefault('only_show_act', False)
        self.uistate.setdefault('show_flatlist', False)
        self.uistate.setdefault('sort_column', 0)
        self.uistate.setdefault('sort_order', int(Gtk.SortType.DESCENDING))

        opener = parent.navigation
        self.task_list = TaskListTreeView(
            self.tasksview,
            opener,
            _parse_task_labels(properties['labels']),
            nonactionable_tags=_parse_task_labels(
                properties['nonactionable_tags']),
            filter_actionable=self.uistate['only_show_act'],
            tag_by_page=properties['tag_by_page'],
            use_workweek=properties['use_workweek'],
            flatlist=self.uistate['show_flatlist'],
            sort_column=self.uistate['sort_column'],
            sort_order=self.uistate['sort_order'])
        self.task_list.set_headers_visible(True)
        self.task_list.connect('populate-popup', self.on_populate_popup)
        self.hpane.add2(ScrolledWindow(self.task_list))

        # Tag list
        self.tag_list = TagListTreeView(self.task_list)
        self.hpane.add1(ScrolledWindow(self.tag_list))

        self.connectto(properties, 'changed', self.on_properties_changed)

        # Filter input
        hbox.pack_start(Gtk.Label(_('Filter') + ': '), False, True,
                        0)  # T: Input label
        filter_entry = InputEntry()
        filter_entry.set_icon_to_clear()
        hbox.pack_start(filter_entry, False, True, 0)
        filter_cb = DelayedCallback(
            500, lambda o: self.task_list.set_filter(filter_entry.get_text()))
        filter_entry.connect('changed', filter_cb)

        # TODO: use menu button here and add same options as in context menu
        #       for filtering the list
        def on_show_active_toggle(o):
            active = self.act_toggle.get_active()
            if self.uistate['only_show_act'] != active:
                self.uistate['only_show_act'] = active
                self.task_list.set_filter_actionable(active)

        self.act_toggle = Gtk.CheckButton.new_with_mnemonic(
            _('Only Show Active Tasks'))
        # T: Checkbox in task list - this options hides tasks that are not yet started
        self.act_toggle.set_active(self.uistate['only_show_act'])
        self.act_toggle.connect('toggled', on_show_active_toggle)
        self.uistate.connect(
            'changed', lambda o: self.act_toggle.set_active(self.uistate[
                'only_show_act']))
        hbox.pack_start(self.act_toggle, False, True, 0)

        # Statistics label
        self.statistics_label = Gtk.Label()
        hbox.pack_end(self.statistics_label, False, True, 0)

        def set_statistics():
            total = self.task_list.get_n_tasks()
            text = ngettext('%i open item', '%i open items', total) % total
            # T: Label for task List, %i is the number of tasks
            self.statistics_label.set_text(text)

        set_statistics()

        def on_tasklist_changed(o):
            self.task_list.refresh()
            self.tag_list.refresh(self.task_list)
            set_statistics()

        callback = DelayedCallback(10, on_tasklist_changed)
        # Don't really care about the delay, but want to
        # make it less blocking - should be async preferably
        # now it is at least on idle

        from . import TaskListNotebookExtension
        nb_ext = find_extension(self.notebook, TaskListNotebookExtension)
        self.connectto(nb_ext, 'tasklist-changed', callback)
    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)
Example #54
0
 def destroy(self):
     self.generator.cleanup()
     Dialog.destroy(self)
Example #55
0
    def __init__(self,
                 window,
                 title,
                 generator,
                 image=None,
                 syntax=None,
                 **opt):
        '''Constructor

		@param window: the L{MainWindow}
		@param title: the dialog title
		@param generator: an L{ImageGeneratorClass} object
		@param image: image data for an image in the
		L{TextBuffer<zim.gui.pageview.TextBuffer>}
		@param syntax: optional syntax name (as understood by gtksourceview)
		@param opt: any other arguments to pass to the L{Dialog} constructor
		'''
        Dialog.__init__(self,
                        window,
                        title,
                        defaultwindowsize=(450, 300),
                        **opt)
        self.app_window = window
        self.generator = generator
        self.imagefile = None
        self.logfile = None

        self.vpane = VPaned()
        self.vpane.set_position(150)
        self.vbox.add(self.vpane)

        self.imageview = ImageView(bgcolor='#FFF', checkerboard=False)
        self.vpane.pack1(self.imageview, resize=True)
        # TODO scrolled window and option to zoom in / real size

        window, textview = ScrolledSourceView(syntax=syntax)
        self.textview = textview
        self.textview.set_editable(True)
        self.vpane.pack2(window, resize=False)

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

        self.previewbutton = Button(_('_Preview'), stock='gtk-refresh')
        # T: button in e.g. equation editor dialog
        self.previewbutton.set_sensitive(False)
        self.previewbutton.connect_object('clicked', self.__class__.preview,
                                          self)
        hbox.pack_start(self.previewbutton, False)

        self.textview.get_buffer().connect(
            'modified-changed',
            lambda b: self.previewbutton.set_sensitive(b.get_modified()))

        self.logbutton = Button(_('View _Log'), stock='gtk-file')
        # T: button in e.g. equation editor dialog
        self.logbutton.set_sensitive(False)
        self.logbutton.connect_object('clicked', self.__class__.show_log, self)
        if generator.uses_log_file:
            hbox.pack_start(self.logbutton, False)
        # else keep hidden

        if image:
            file = image['_src_file']  # FIXME ?
            textfile = self._stitch_fileextension(file,
                                                  self.generator.scriptname)
            self._existing_file = textfile
            self.imageview.set_file(file)
            self.set_text(self.generator.filter_input(textfile.read()))
        else:
            self._existing_file = None
            self.set_text(
                self.generator.filter_input(self.generator.get_default_text()))

        self.textview.grab_focus()
 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)
Example #57
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)
    def __init__(self, widget, config, default_tab=None, select_plugin=None):
        Dialog.__init__(self, widget, _('Preferences'))  # T: Dialog title
        self.config = config
        self.preferences = self.config.get_config_dict(
            '<profile>/preferences.conf')

        # saves a list of loaded plugins to be used later
        self.plugins = get_window(widget).__pluginmanager__  # XXX
        self.p_save_loaded = list(self.plugins)

        # Dynamic tabs
        gtknotebook = Gtk.Notebook()
        self.vbox.pack_start(gtknotebook, True, True, 0)
        self.forms = {}

        ############################### needs rewrite to make defintion more robust
        for category in ('Interface', 'Editing'):
            vbox = Gtk.VBox()
            index = gtknotebook.append_page(vbox, Gtk.Label(label=_(category)))
            # From GTK Doc: Note that due to historical reasons, GtkNotebook refuses
            # to switch to a page unless the child widget is visible.
            vbox.show()
            if category == default_tab:
                gtknotebook.set_current_page(index)

            fields = []
            values = {}
            sections = {}

            for section, preferences in (('GtkInterface',
                                          interface_preferences),
                                         ('PageView', pageview_preferences)):
                for p in [p for p in preferences if p[2] == category]:
                    # key, type, category, label, default, (check)
                    if len(p) == 5:
                        key, type, cat, label, default = p
                        self.preferences[section].setdefault(key, default)
                        fields.append((key, type, label))
                    else:
                        key, type, cat, label, default, check = p
                        self.preferences[section].setdefault(
                            key, default, check)
                        fields.append((key, type, label, check))

                    values[key] = self.preferences[section][key]
                    sections[key] = section

            form = InputForm(fields, values)
            form.preferences_sections = sections
            vbox.pack_start(form, False, True, 0)
            self.forms[category] = form

            if category == 'Interface':
                self._add_font_selection(form)

        # Styles tab
        #~ gtknotebook.append_page(StylesTab(self), Gtk.Label(label=_('Styles')))

        # Keybindings tab
        #~ gtknotebook.append_page(KeyBindingsTab(self), Gtk.Label(label=_('Key bindings')))

        # Plugins tab
        self.plugins_tab = PluginsTab(self, self.plugins)
        plugins_tab_index = gtknotebook.append_page(
            self.plugins_tab, Gtk.Label(label=_('Plugins')))
        # T: Heading in preferences dialog
        self.plugins_tab.show()
        #~ print default_tab, index
        if default_tab == "Plugins":
            gtknotebook.set_current_page(plugins_tab_index)
            if not select_plugin is None:
                self.plugins_tab.select_plugin(select_plugin)

        # Applications tab
        gtknotebook.append_page(ApplicationsTab(self),
                                Gtk.Label(label=_('Applications')))
Example #59
0
    def __init__(self, parent, tool=None):
        Dialog.__init__(self, parent, _('Edit Custom Tool'))  # T: Dialog title
        self.set_help(':Help:Custom Tools')
        self.vbox.set_spacing(12)

        if tool:
            name = tool.name
            comment = tool.comment
            execcmd = tool.execcmd
            readonly = tool.isreadonly
            toolbar = tool.showintoolbar
            replaceselection = tool.replaceselection
        else:
            name = ''
            comment = ''
            execcmd = ''
            readonly = False
            toolbar = False
            replaceselection = False

        self.add_form(
            (
                ('Name', 'string',
                 _('Name')),  # T: Input in "Edit Custom Tool" dialog
                ('Comment', 'string',
                 _('Description')),  # T: Input in "Edit Custom Tool" dialog
                ('X-Zim-ExecTool', 'string',
                 _('Command')),  # T: Input in "Edit Custom Tool" dialog
            ),
            {
                'Name': name,
                'Comment': comment,
                'X-Zim-ExecTool': execcmd,
            },
            trigger_response=False)

        # FIXME need ui builder to take care of this as well
        self.iconbutton = IconChooserButton(stock=Gtk.STOCK_EXECUTE)
        if tool and tool.icon and tool.icon != Gtk.STOCK_EXECUTE:
            try:
                self.iconbutton.set_file(File(tool.icon))
            except Exception as error:
                logger.exception('Could not load: %s', tool.icon)
        label = Gtk.Label(label=_('Icon') +
                          ':')  # T: Input in "Edit Custom Tool" dialog
        label.set_alignment(0.0, 0.5)
        hbox = Gtk.HBox()
        i = self.form.get_property('n-rows')
        self.form.attach(label, 0, 1, i, i + 1, xoptions=0)
        self.form.attach(hbox, 1, 2, i, i + 1)
        hbox.pack_start(self.iconbutton, False, True, 0)

        self.form.add_inputs((
            ('X-Zim-ReadOnly', 'bool', _('Command does not modify data')
             ),  # T: Input in "Edit Custom Tool" dialog
            ('X-Zim-ReplaceSelection', 'bool',
             _('Output should replace current selection')
             ),  # T: Input in "Edit Custom Tool" dialog
            #('X-Zim-ShowInToolBar', 'bool', _('Show in the toolbar')), # T: Input in "Edit Custom Tool" dialog
        ))
        self.form.update({
            'X-Zim-ReadOnly': readonly,
            'X-Zim-ReplaceSelection': replaceselection,
            #'X-Zim-ShowInToolBar': toolbar,
        })

        self.add_help_text(
            _('''\
The following parameters will be substituted
in the command when it is executed:
<tt>
<b>%f</b> the page source as a temporary file
<b>%d</b> the attachment directory of the current page
<b>%s</b> the real page source file (if any)
<b>%p</b> the page name
<b>%n</b> the notebook location (file or folder)
<b>%D</b> the document root (if any)
<b>%t</b> the selected text or word under cursor
<b>%T</b> the selected text including wiki formatting
</tt>
'''))  # T: Short help text in "Edit Custom Tool" dialog. The "%" is literal - please include the html formatting
Example #60
0
    def __init__(self, window, tasksview, preferences):
        Dialog.__init__(
            self,
            window,
            _('Task List'),  # T: dialog title
            buttons=gtk.BUTTONS_CLOSE,
            help=':Plugins:Task List',
            defaultwindowsize=(550, 400))
        self.preferences = preferences
        self.tasksview = tasksview

        hbox = gtk.HBox(spacing=5)
        self.vbox.pack_start(hbox, False)
        self.hpane = HPaned()
        self.uistate.setdefault('hpane_pos', 75)
        self.hpane.set_position(self.uistate['hpane_pos'])
        self.vbox.add(self.hpane)

        # Task list
        self.uistate.setdefault('only_show_act', False)
        self.uistate.setdefault('show_flatlist', False)
        self.uistate.setdefault('sort_column', 0)
        self.uistate.setdefault('sort_order', int(gtk.SORT_DESCENDING))

        opener = window.get_resource_opener()
        task_labels = _parse_task_labels(preferences['labels'])
        nonactionable_tags = _parse_task_labels(
            preferences['nonactionable_tags'])
        self.task_list = TaskListTreeView(
            self.tasksview,
            opener,
            task_labels,
            nonactionable_tags=nonactionable_tags,
            filter_actionable=self.uistate['only_show_act'],
            tag_by_page=preferences['tag_by_page'],
            use_workweek=preferences['use_workweek'],
            flatlist=self.uistate['show_flatlist'],
            sort_column=self.uistate['sort_column'],
            sort_order=self.uistate['sort_order'])
        self.task_list.set_headers_visible(True)
        self.task_list.connect('populate-popup', self.on_populate_popup)
        self.hpane.add2(ScrolledWindow(self.task_list))

        # Tag list
        self.tag_list = TagListTreeView(self.task_list, task_labels)
        self.hpane.add1(ScrolledWindow(self.tag_list))

        # Filter input
        hbox.pack_start(gtk.Label(_('Filter') + ': '), False)  # T: Input label
        filter_entry = InputEntry()
        filter_entry.set_icon_to_clear()
        hbox.pack_start(filter_entry, False)
        filter_cb = DelayedCallback(
            500, lambda o: self.task_list.set_filter(filter_entry.get_text()))
        filter_entry.connect('changed', filter_cb)

        # TODO: use menu button here and add same options as in context menu
        #       for filtering the list
        def on_show_active_toggle(o):
            active = self.act_toggle.get_active()
            if self.uistate['only_show_act'] != active:
                self.uistate['only_show_act'] = active
                self.task_list.set_filter_actionable(active)

        self.act_toggle = gtk.CheckButton(_('Only Show Active Tasks'))
        # T: Checkbox in task list - this options hides tasks that are not yet started
        self.act_toggle.set_active(self.uistate['only_show_act'])
        self.act_toggle.connect('toggled', on_show_active_toggle)
        self.uistate.connect(
            'changed', lambda o: self.act_toggle.set_active(self.uistate[
                'only_show_act']))
        hbox.pack_start(self.act_toggle, False)

        # Statistics label
        self.statistics_label = gtk.Label()
        hbox.pack_end(self.statistics_label, False)

        def set_statistics():
            total = self.task_list.get_n_tasks()
            text = ngettext('%i open item', '%i open items', total) % total
            # T: Label for task List, %i is the number of tasks
            self.statistics_label.set_text(text)

        set_statistics()

        def on_tasklist_changed(o):
            self.task_list.refresh()
            self.tag_list.refresh(self.task_list)
            set_statistics()

        callback = DelayedCallback(10, on_tasklist_changed)
        # Don't really care about the delay, but want to
        # make it less blocking - should be async preferably
        # now it is at least on idle

        ### XXX HACK to get dependency to connect to
        ###   -- no access to plugin, so can;t use get_extension()
        ##    -- duplicat of this snippet in MainWindowExtension
        for e in window.ui.notebook.__zim_extension_objects__:
            if hasattr(e, 'indexer'
                       ) and e.indexer.__class__.__name__ == 'TasksIndexer':
                self.connectto(e, 'tasklist-changed', callback)
                break
        else:
            raise AssertionError, 'Could not find tasklist notebook extension'