Add actions for highlighting to viewer chrome

This commit is contained in:
Kovid Goyal 2020-06-26 17:22:30 +05:30
parent 74897b4ec2
commit c9fe151075
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 14 additions and 1 deletions

View File

@ -311,10 +311,18 @@ class MainOverlay: # {{{
if full_screen_actions.length: if full_screen_actions.length:
actions_div.appendChild(E.ul(*full_screen_actions)) actions_div.appendChild(E.ul(*full_screen_actions))
highlight_action = ac(_('Highlight'), _('Highlight text in the book'),
def(): self.overlay.hide(), self.overlay.view.initiate_create_annotation();, 'highlight')
if runtime.is_standalone_viewer: if runtime.is_standalone_viewer:
actions_div.appendChild(E.ul( actions_div.appendChild(E.ul(
ac(_('Lookup/search word'), _('Lookup or search for the currently selected word'), ac(_('Lookup/search word'), _('Lookup or search for the currently selected word'),
def(): self.overlay.hide(), ui_operations.toggle_lookup();, 'library') def(): self.overlay.hide(), ui_operations.toggle_lookup();, 'library')
,
highlight_action,
ac(_('Browse highlights'), _('Browse all highlights'),
def(): self.overlay.hide(), ui_operations.toggle_highlights();, 'image')
,
)) ))
copy_actions = E.ul() copy_actions = E.ul()
if self.overlay.view.currently_showing.selected_text: if self.overlay.view.currently_showing.selected_text:
@ -343,6 +351,8 @@ class MainOverlay: # {{{
ac(_('Quit'), _('Close the viewer'), ac(_('Quit'), _('Close the viewer'),
def(): self.overlay.hide(), ui_operations.quit();, 'remove'), def(): self.overlay.hide(), ui_operations.quit();, 'remove'),
)) ))
else:
actions_div.appendChild(E.ul(highlight_action))
container.appendChild(set_css(E.div(class_=MAIN_OVERLAY_TS_CLASS, # top section container.appendChild(set_css(E.div(class_=MAIN_OVERLAY_TS_CLASS, # top section
onclick=def (evt):evt.stopPropagation();, onclick=def (evt):evt.stopPropagation();,

View File

@ -433,7 +433,7 @@ class View:
elif data.name is 'toggle_highlights': elif data.name is 'toggle_highlights':
ui_operations.toggle_highlights() ui_operations.toggle_highlights()
elif data.name is 'create_annotation': elif data.name is 'create_annotation':
self.iframe_wrapper.send_message('create_annotation') self.initiate_create_annotation()
elif data.name is 'new_bookmark': elif data.name is 'new_bookmark':
ui_operations.new_bookmark() ui_operations.new_bookmark()
elif data.name is 'toggle_inspector': elif data.name is 'toggle_inspector':
@ -1193,6 +1193,9 @@ class View:
else: else:
self.show_name(sr.file_name, initial_position={'type':'search_result', 'search_result':sr, 'replace_history':True}) self.show_name(sr.file_name, initial_position={'type':'search_result', 'search_result':sr, 'replace_history':True})
def initiate_create_annotation(self):
self.iframe_wrapper.send_message('create_annotation')
def highlight_action(self, uuid, which): def highlight_action(self, uuid, which):
if self.create_annotation.is_visible: if self.create_annotation.is_visible:
return return