Good evening ZIM users and developers, I would like to share a plugin, which is capable of a fast access to any page through defined bookmarks. The plugin binds page to short cuts Alt+(0-9) and it is also accessible from "Go" in a menu.
Enjoy, best regards, JK! P.S. Great thanks to all developers and contributors, the ZIM simply rocks :D !
# -*- coding: utf-8 -*- # Copyright 2011 NorfCran <norfc...@gmail.com> import gtk import time from zim.notebook import Path from zim.plugins import PluginClass from zim.gui.widgets import ui_environment class BookmarksPlugin(PluginClass): '''FIXME''' plugin_info = { 'name': _('Bookmarks'), # T: plugin name 'description': _('''\ This plugin allows definition of 10 bookmarks. The bookmarks are accessed through Alt+(0-9) and from a menubar (Go). Default plugin values: Bookmark number ==> Page '''), # T: plugin description 'author': 'NorfCran', 'help': 'Plugins:Bookmarks', } plugin_preferences = ( ('bookmark_0', 'string', 'Bookmark 0', ':home'), ('bookmark_1', 'string', 'Bookmark 1', ':home'), ('bookmark_2', 'string', 'Bookmark 2', ':home'), ('bookmark_3', 'string', 'Bookmark 3', ':home'), ('bookmark_4', 'string', 'Bookmark 4', ':home'), ('bookmark_5', 'string', 'Bookmark 5', ':home'), ('bookmark_6', 'string', 'Bookmark 6', ':home'), ('bookmark_7', 'string', 'Bookmark 7', ':home'), ('bookmark_8', 'string', 'Bookmark 8', ':home'), ('bookmark_9', 'string', 'Bookmark 9', ':home'), ) def __init__(self, ui): PluginClass.__init__(self, ui) def generate_ui_xml(self): ui_xml_template = ''' <menubar name='menubar'> <menu action='go_menu'> <placeholder name='plugin_items'> <menuitem action='bookmark_%i'/> </placeholder> </menu> </menubar> ''' ui_xml = "" for i in range(10): ui_xml += ui_xml_template % i ui_xml = "<ui>\n" + ui_xml + "\n</ui>" print ui_xml return ui_xml def generate_ui_actions(self): # in oder to provide dynamic key binding assignment the initiation is made in the plugin class --> DONE ui_actions = () for i in range(10): label = self.preferences['bookmark_%i'%i] ui_actions += ('bookmark_%i'%i, None, _('%s'%label), '<Alt>%i'%i, '', False), print ui_actions return ui_actions def initialize_ui(self, ui): if self.ui.ui_type == 'gtk': ui_actions = self.generate_ui_actions() self.ui.add_actions(ui_actions, self) ui_xml = self.generate_ui_xml() self.ui.add_ui(ui_xml, self) def bookmark_0(self): self.go_to_bookmark(self.preferences['bookmark_0']) def bookmark_1(self): self.go_to_bookmark(self.preferences['bookmark_1']) def bookmark_2(self): self.go_to_bookmark(self.preferences['bookmark_2']) def bookmark_3(self): self.go_to_bookmark(self.preferences['bookmark_3']) def bookmark_4(self): self.go_to_bookmark(self.preferences['bookmark_4']) def bookmark_5(self): self.go_to_bookmark(self.preferences['bookmark_5']) def bookmark_6(self): self.go_to_bookmark(self.preferences['bookmark_6']) def bookmark_7(self): self.go_to_bookmark(self.preferences['bookmark_7']) def bookmark_8(self): self.go_to_bookmark(self.preferences['bookmark_8']) def bookmark_9(self): self.go_to_bookmark(self.preferences['bookmark_9']) def go_to_bookmark(self, page): self.ui.open_page(Path(page))
_______________________________________________ Mailing list: https://launchpad.net/~zim-wiki Post to : zim-wiki@lists.launchpad.net Unsubscribe : https://launchpad.net/~zim-wiki More help : https://help.launchpad.net/ListHelp