Zim

Merge lp:~r-ubunt3-5/zim/bookmarks into lp:~jaap.karssenberg/zim/pyzim

Proposed by E2rd
Status: Needs review
Proposed branch: lp:~r-ubunt3-5/zim/bookmarks
Merge into: lp:~jaap.karssenberg/zim/pyzim
Diff against target: 82 lines (+58/-0)
1 file modified
zim/plugins/bookmarksbar.py (+58/-0)
To merge this branch: bzr merge lp:~r-ubunt3-5/zim/bookmarks
Reviewer Review Type Date Requested Status
Jaap Karssenberg Pending
Review via email: mp+303932@code.launchpad.net

Description of the change

This enables the shortcut functionality I really missed.

Alt+1 -> open first bookmark
Alt+2 -> open second one

To post a comment you must log in.
Revision history for this message
E2rd (r-ubunt3-5) wrote :

Can I do anything else to help this commit be merged, Jaap?
If you disagree with the idea, feel free to just deny that.

Keen regards,
 Edvard

Unmerged revisions

835. By E2rd <email address hidden>

This enables the shortcut functionality I really missed.

Alt+1 -> open first bookmark
Alt+2 -> open second one

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'zim/plugins/bookmarksbar.py'
2--- zim/plugins/bookmarksbar.py 2015-10-08 18:31:40 +0000
3+++ zim/plugins/bookmarksbar.py 2016-08-25 13:20:23 +0000
4@@ -60,6 +60,19 @@
5 <menuitem action='add_bookmark'/>
6 </placeholder>
7 </menu>
8+ <menu action='tools_menu'>
9+ <placeholder name='plugin_items'>
10+ <menuitem action='bookmark_1'/>
11+ <menuitem action='bookmark_2'/>
12+ <menuitem action='bookmark_3'/>
13+ <menuitem action='bookmark_4'/>
14+ <menuitem action='bookmark_5'/>
15+ <menuitem action='bookmark_6'/>
16+ <menuitem action='bookmark_7'/>
17+ <menuitem action='bookmark_8'/>
18+ <menuitem action='bookmark_9'/>
19+ </placeholder>
20+ </menu>
21 </menubar>
22 <toolbar name='toolbar'>
23 <placeholder name='tools'>
24@@ -119,6 +132,50 @@
25 menu.show_all()
26
27
28+ @action(_('_Run bookmark'), accelerator='<alt>1')
29+ def bookmark_1(self):
30+ self._open_bookmark(1)
31+
32+ @action(_('_Run bookmark'), accelerator='<alt>2')
33+ def bookmark_2(self):
34+ self._open_bookmark(2)
35+
36+ @action(_('_Run bookmark'), accelerator='<alt>3')
37+ def bookmark_3(self):
38+ self._open_bookmark(3)
39+
40+ @action(_('_Run bookmark'), accelerator='<alt>4')
41+ def bookmark_4(self):
42+ self._open_bookmark(4)
43+
44+ @action(_('_Run bookmark'), accelerator='<alt>5')
45+ def bookmark_5(self):
46+ self._open_bookmark(5)
47+
48+ @action(_('_Run bookmark'), accelerator='<alt>6')
49+ def bookmark_6(self):
50+ self._open_bookmark(6)
51+
52+ @action(_('_Run bookmark'), accelerator='<alt>7')
53+ def bookmark_7(self):
54+ self._open_bookmark(7)
55+
56+ @action(_('_Run bookmark'), accelerator='<alt>8')
57+ def bookmark_8(self):
58+ self._open_bookmark(8)
59+
60+ @action(_('_Run bookmark'), accelerator='<alt>9')
61+ def bookmark_9(self):
62+ self._open_bookmark(9)
63+
64+
65+ def _open_bookmark(self, number):
66+ number -= 1
67+ try:
68+ self.window.ui.open_page(Path(self.widget.paths[number]))
69+ except IndexError:
70+ pass
71+
72 @toggle_action(_('Bookmarks'), stock='zim-add-bookmark',
73 tooltip = 'Show/Hide Bookmarks', accelerator = BM_TOGGLE_BAR_KEY) # T: menu item bookmark plugin
74 def toggle_show_bookmarks(self, active):
75@@ -395,6 +452,7 @@
76 main_menu.popup(None, None, None, 3, 0)
77 return True
78
79+
80 def on_bookmark_clicked(self, button):
81 '''Open page if a bookmark is clicked.'''
82 self.ui.open_page(Path(button.zim_path))