Add a reference mode control to the viewer chrome

This commit is contained in:
Kovid Goyal 2019-12-09 09:49:58 +05:30
parent 7dea54d135
commit f495ffc16c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 69 additions and 1 deletions

63
imgsrc/reference.svg Normal file
View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="128"
height="128"
viewBox="0 0 33.866666 33.866668"
version="1.1"
id="svg840"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
sodipodi:docname="reference.svg">
<defs
id="defs834" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="237.114"
inkscape:cy="236.75119"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:window-width="2560"
inkscape:window-height="1400"
inkscape:window-x="0"
inkscape:window-y="40"
inkscape:window-maximized="0" />
<metadata
id="metadata837">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-263.13332)">
<path
inkscape:connector-curvature="0"
d="M 8.7798497,295.71845 H 1.3855535 v -20.36721 l 9.0289685,-10.48359 a 1.5135715,1.4801752 0 0 1 2.655827,0.73022 v 0 a 7.2651433,7.104841 0 0 1 -1.190691,5.10365 l -2.8253283,3.9866 20.7379663,0.46971 a 2.7647919,2.7037879 0 1 1 0,5.40757 l -12.157027,0.71443 -1.743642,8.71133 a 7.2651433,7.104841 0 0 1 -7.1117773,5.72729 z"
id="path4147"
style="fill:#116def;fill-opacity:1;stroke-width:0.31270596" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -50,7 +50,7 @@ def all_actions():
'previous': Action('previous.png', _('Previous page'), 'previous'),
'toc': Action('toc.png', _('Table of Contents'), 'toggle_toc'),
'bookmarks': Action('bookmarks.png', _('Bookmarks'), 'toggle_bookmarks'),
'reference': Action('lookfeel.png', _('Toggle Reference mode'), 'toggle_reference_mode'),
'reference': Action('reference.png', _('Toggle Reference mode'), 'toggle_reference_mode'),
'lookup': Action('generic-library.png', _('Lookup words'), 'toggle_lookup'),
'chrome': Action('tweaks.png', _('Show viewer controls'), 'show_chrome'),
'mode': Action('scroll.png', _('Toggle paged mode'), 'toggle_paged_mode'),

View File

@ -259,6 +259,7 @@ class MainOverlay: # {{{
if runtime.is_standalone_viewer:
toc_actions.appendChild(bookmarks_action)
toc_actions.appendChild(ac(_('Reference mode'), _('Toggle the Reference mode'), self.overlay.toggle_reference_mode, '🖝', True))
actions_div = E.div( # actions
nav_actions,
@ -607,6 +608,10 @@ class Overlay:
self.panels.push(TOCOverlay(self))
self.show_current_panel()
def toggle_reference_mode(self):
self.hide_current_panel()
self.view.toggle_reference_mode()
def show_bookmarks(self):
self.hide_current_panel()
if runtime.is_standalone_viewer: