Feature - dark mode for PDFs
Evince has an Inverted Colours toggle in the File options with a
shortcut of ctrl+i.
Add the same shortcut to invert colours when viewing a PDF with Read.
Add an invert colours button to the view toolbar.
Use same icons from Terminal.
Co-authored-by: James Cameron <quozl@laptop.org> # switch toolbar
nswarup14 authored 4 years ago
James Cameron committed 4 years ago
0 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
1 | <!-- Created with Inkscape (http://www.inkscape.org/) --> | |
2 | ||
3 | <svg | |
4 | xmlns:dc="http://purl.org/dc/elements/1.1/" | |
5 | xmlns:cc="http://creativecommons.org/ns#" | |
6 | xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |
7 | xmlns:svg="http://www.w3.org/2000/svg" | |
8 | xmlns="http://www.w3.org/2000/svg" | |
9 | xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | |
10 | xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | |
11 | width="32px" | |
12 | height="32px" | |
13 | id="svg2985" | |
14 | version="1.1" | |
15 | inkscape:version="0.48.3.1 r9886" | |
16 | sodipodi:docname="dark-theme.svg"> | |
17 | <defs | |
18 | id="defs2987" /> | |
19 | <sodipodi:namedview | |
20 | id="base" | |
21 | pagecolor="#ffffff" | |
22 | bordercolor="#666666" | |
23 | borderopacity="1.0" | |
24 | inkscape:pageopacity="0.0" | |
25 | inkscape:pageshadow="2" | |
26 | inkscape:zoom="12.219689" | |
27 | inkscape:cx="12.682313" | |
28 | inkscape:cy="14.416406" | |
29 | inkscape:current-layer="layer1" | |
30 | showgrid="true" | |
31 | inkscape:grid-bbox="true" | |
32 | inkscape:document-units="px" | |
33 | inkscape:snap-global="false" | |
34 | objecttolerance="10000" | |
35 | guidetolerance="10000" | |
36 | showguides="false" | |
37 | inkscape:window-width="1360" | |
38 | inkscape:window-height="712" | |
39 | inkscape:window-x="0" | |
40 | inkscape:window-y="27" | |
41 | inkscape:window-maximized="1"> | |
42 | <sodipodi:guide | |
43 | position="0,0" | |
44 | orientation="0,32" | |
45 | id="guide3767" /> | |
46 | <sodipodi:guide | |
47 | position="32,0" | |
48 | orientation="-32,0" | |
49 | id="guide3769" /> | |
50 | <sodipodi:guide | |
51 | position="32,32" | |
52 | orientation="0,-32" | |
53 | id="guide3771" /> | |
54 | <sodipodi:guide | |
55 | position="0,32" | |
56 | orientation="32,0" | |
57 | id="guide3773" /> | |
58 | <inkscape:grid | |
59 | type="xygrid" | |
60 | id="grid3775" | |
61 | empspacing="5" | |
62 | visible="true" | |
63 | enabled="true" | |
64 | snapvisiblegridlinesonly="true" /> | |
65 | <sodipodi:guide | |
66 | position="0,0" | |
67 | orientation="0,32" | |
68 | id="guide3777" /> | |
69 | <sodipodi:guide | |
70 | position="32,0" | |
71 | orientation="-32,0" | |
72 | id="guide3779" /> | |
73 | <sodipodi:guide | |
74 | position="32,32" | |
75 | orientation="0,-32" | |
76 | id="guide3781" /> | |
77 | <sodipodi:guide | |
78 | position="0,32" | |
79 | orientation="32,0" | |
80 | id="guide3783" /> | |
81 | <sodipodi:guide | |
82 | position="0,0" | |
83 | orientation="0,32" | |
84 | id="guide3785" /> | |
85 | <sodipodi:guide | |
86 | position="32,0" | |
87 | orientation="-32,0" | |
88 | id="guide3787" /> | |
89 | <sodipodi:guide | |
90 | position="32,32" | |
91 | orientation="0,-32" | |
92 | id="guide3789" /> | |
93 | <sodipodi:guide | |
94 | position="0,32" | |
95 | orientation="32,0" | |
96 | id="guide3791" /> | |
97 | </sodipodi:namedview> | |
98 | <metadata | |
99 | id="metadata2990"> | |
100 | <rdf:RDF> | |
101 | <cc:Work | |
102 | rdf:about=""> | |
103 | <dc:format>image/svg+xml</dc:format> | |
104 | <dc:type | |
105 | rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | |
106 | <dc:title></dc:title> | |
107 | </cc:Work> | |
108 | </rdf:RDF> | |
109 | </metadata> | |
110 | <g | |
111 | id="layer1" | |
112 | inkscape:label="Layer 1" | |
113 | inkscape:groupmode="layer"> | |
114 | <rect | |
115 | style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none" | |
116 | id="rect2993" | |
117 | width="31.022896" | |
118 | height="31.194761" | |
119 | x="0.66299194" | |
120 | y="0.60228604" | |
121 | ry="2.9258621" /> | |
122 | <text | |
123 | xml:space="preserve" | |
124 | style="font-size:11.23703003px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Sans" | |
125 | x="5.8393445" | |
126 | y="26.455677" | |
127 | id="text3763" | |
128 | sodipodi:linespacing="125%"><tspan | |
129 | sodipodi:role="line" | |
130 | id="tspan3765" | |
131 | x="5.8393445" | |
132 | y="26.455677" | |
133 | style="font-size:30.90183258px;fill:#ffffff;fill-opacity:1">A</tspan></text> | |
134 | </g> | |
135 | </svg> |
0 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
1 | <!-- Created with Inkscape (http://www.inkscape.org/) --> | |
2 | ||
3 | <svg | |
4 | xmlns:dc="http://purl.org/dc/elements/1.1/" | |
5 | xmlns:cc="http://creativecommons.org/ns#" | |
6 | xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |
7 | xmlns:svg="http://www.w3.org/2000/svg" | |
8 | xmlns="http://www.w3.org/2000/svg" | |
9 | xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | |
10 | xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | |
11 | width="32px" | |
12 | height="32px" | |
13 | id="svg2985" | |
14 | version="1.1" | |
15 | inkscape:version="0.48.3.1 r9886" | |
16 | sodipodi:docname="dark-theme.svg"> | |
17 | <defs | |
18 | id="defs2987" /> | |
19 | <sodipodi:namedview | |
20 | id="base" | |
21 | pagecolor="#ffffff" | |
22 | bordercolor="#666666" | |
23 | borderopacity="1.0" | |
24 | inkscape:pageopacity="0.0" | |
25 | inkscape:pageshadow="2" | |
26 | inkscape:zoom="12.219689" | |
27 | inkscape:cx="12.682313" | |
28 | inkscape:cy="14.416406" | |
29 | inkscape:current-layer="layer1" | |
30 | showgrid="true" | |
31 | inkscape:grid-bbox="true" | |
32 | inkscape:document-units="px" | |
33 | inkscape:snap-global="false" | |
34 | objecttolerance="10000" | |
35 | guidetolerance="10000" | |
36 | showguides="false" | |
37 | inkscape:window-width="1360" | |
38 | inkscape:window-height="712" | |
39 | inkscape:window-x="0" | |
40 | inkscape:window-y="27" | |
41 | inkscape:window-maximized="1"> | |
42 | <sodipodi:guide | |
43 | position="0,0" | |
44 | orientation="0,32" | |
45 | id="guide3767" /> | |
46 | <sodipodi:guide | |
47 | position="32,0" | |
48 | orientation="-32,0" | |
49 | id="guide3769" /> | |
50 | <sodipodi:guide | |
51 | position="32,32" | |
52 | orientation="0,-32" | |
53 | id="guide3771" /> | |
54 | <sodipodi:guide | |
55 | position="0,32" | |
56 | orientation="32,0" | |
57 | id="guide3773" /> | |
58 | <inkscape:grid | |
59 | type="xygrid" | |
60 | id="grid3775" | |
61 | empspacing="5" | |
62 | visible="true" | |
63 | enabled="true" | |
64 | snapvisiblegridlinesonly="true" /> | |
65 | <sodipodi:guide | |
66 | position="0,0" | |
67 | orientation="0,32" | |
68 | id="guide3777" /> | |
69 | <sodipodi:guide | |
70 | position="32,0" | |
71 | orientation="-32,0" | |
72 | id="guide3779" /> | |
73 | <sodipodi:guide | |
74 | position="32,32" | |
75 | orientation="0,-32" | |
76 | id="guide3781" /> | |
77 | <sodipodi:guide | |
78 | position="0,32" | |
79 | orientation="32,0" | |
80 | id="guide3783" /> | |
81 | <sodipodi:guide | |
82 | position="0,0" | |
83 | orientation="0,32" | |
84 | id="guide3785" /> | |
85 | <sodipodi:guide | |
86 | position="32,0" | |
87 | orientation="-32,0" | |
88 | id="guide3787" /> | |
89 | <sodipodi:guide | |
90 | position="32,32" | |
91 | orientation="0,-32" | |
92 | id="guide3789" /> | |
93 | <sodipodi:guide | |
94 | position="0,32" | |
95 | orientation="32,0" | |
96 | id="guide3791" /> | |
97 | </sodipodi:namedview> | |
98 | <metadata | |
99 | id="metadata2990"> | |
100 | <rdf:RDF> | |
101 | <cc:Work | |
102 | rdf:about=""> | |
103 | <dc:format>image/svg+xml</dc:format> | |
104 | <dc:type | |
105 | rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | |
106 | <dc:title></dc:title> | |
107 | </cc:Work> | |
108 | </rdf:RDF> | |
109 | </metadata> | |
110 | <g | |
111 | id="layer1" | |
112 | inkscape:label="Layer 1" | |
113 | inkscape:groupmode="layer"> | |
114 | <rect | |
115 | style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" | |
116 | id="rect2993" | |
117 | width="31.022896" | |
118 | height="31.194761" | |
119 | x="0.66299194" | |
120 | y="0.60228604" | |
121 | ry="2.9258621" /> | |
122 | <text | |
123 | xml:space="preserve" | |
124 | style="font-size:11.23703002999999967px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans" | |
125 | x="5.8393445" | |
126 | y="26.455677" | |
127 | id="text3763" | |
128 | sodipodi:linespacing="125%"><tspan | |
129 | sodipodi:role="line" | |
130 | id="tspan3765" | |
131 | x="5.8393445" | |
132 | y="26.455677" | |
133 | style="font-size:30.90183258000000066px;fill:#000000;fill-opacity:1">A</tspan></text> | |
134 | </g> | |
135 | </svg> |
206 | 206 | msgid "Rotate right" |
207 | 207 | msgstr "" |
208 | 208 | |
209 | #: readtoolbar.py:270 readtoolbar.py:348 | |
210 | msgid "Inverted Colors" | |
211 | msgstr "" | |
212 | ||
209 | 213 | #: readtoolbar.py:324 |
210 | 214 | msgid "Show Tray" |
211 | 215 | msgstr "" |
214 | 218 | msgid "Hide Tray" |
215 | 219 | msgstr "" |
216 | 220 | |
221 | #: readtoolbar.py:345 | |
222 | msgid "Normal Colors" | |
223 | msgstr "" | |
224 | ||
217 | 225 | #: speechtoolbar.py:65 |
218 | 226 | msgid "Play / Pause" |
219 | 227 | msgstr "" |
237 | 237 | self.__toogle_navigator_cb) |
238 | 238 | self._view_toolbar.connect('toggle-tray-show', |
239 | 239 | self.__toogle_tray_cb) |
240 | self._view_toolbar.connect('toggle-inverted-colors', | |
241 | self.__toggle_inverted_colors_cb) | |
240 | 242 | view_toolbar_button = ToolbarButton(page=self._view_toolbar, |
241 | 243 | icon_name='toolbar-view') |
242 | 244 | self._view_toolbar.show() |
515 | 517 | else: |
516 | 518 | logging.debug('Hide tray') |
517 | 519 | self.tray.hide() |
520 | ||
521 | def __toggle_inverted_colors_cb(self, button, active): | |
522 | if hasattr(self._view._model, 'set_inverted_colors'): | |
523 | self._view._model.set_inverted_colors(active) | |
518 | 524 | |
519 | 525 | def __num_page_entry_insert_text_cb(self, entry, text, length, position): |
520 | 526 | if not re.match('[0-9]', text): |
993 | 999 | else: |
994 | 1000 | import evinceadapter |
995 | 1001 | self._view = evinceadapter.EvinceViewer() |
1002 | self._view_toolbar.show_inverted_colors_button() | |
996 | 1003 | |
997 | 1004 | self._view.setup(self) |
998 | 1005 | self._view.load_document(filepath) |
1181 | 1188 | return True |
1182 | 1189 | elif keyname == 'KP_End': |
1183 | 1190 | self._view_toolbar.zoom_out() |
1191 | return True | |
1192 | elif keyname == 'i' and event.state & Gdk.ModifierType.CONTROL_MASK: | |
1193 | self._view_toolbar.toggle_inverted_colors() | |
1184 | 1194 | return True |
1185 | 1195 | elif keyname == 'Home': |
1186 | 1196 | self._view.scroll(Gtk.ScrollType.START, False) |
176 | 176 | 'toggle-index-show': (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, |
177 | 177 | ([bool])), |
178 | 178 | 'toggle-tray-show': (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, |
179 | ([bool])), } | |
179 | ([bool])), | |
180 | 'toggle-inverted-colors': (GObject.SignalFlags.RUN_FIRST, | |
181 | GObject.TYPE_NONE, ([bool])), } | |
180 | 182 | |
181 | 183 | def __init__(self): |
182 | 184 | Gtk.Toolbar.__init__(self) |
258 | 260 | self._rotate_right.connect('clicked', self._rotate_right_cb) |
259 | 261 | self.insert(self._rotate_right, -1) |
260 | 262 | self._rotate_right.show() |
263 | ||
264 | spacer = Gtk.SeparatorToolItem() | |
265 | self.insert(spacer, -1) | |
266 | spacer.show() | |
267 | ||
268 | self._inverted_colors = ToggleToolButton(icon_name='dark-theme') | |
269 | self._inverted_colors.set_tooltip(_('Inverted Colors')) | |
270 | self._inverted_colors.set_accelerator('<Ctrl>i') | |
271 | self._inverted_colors.connect( | |
272 | 'toggled', self.__inverted_colors_toggled_cb) | |
273 | self.insert(self._inverted_colors, -1) | |
261 | 274 | |
262 | 275 | def set_view(self, view): |
263 | 276 | self._view = view |
323 | 336 | self.traybutton.set_tooltip(_('Show Tray')) |
324 | 337 | else: |
325 | 338 | self.traybutton.set_tooltip(_('Hide Tray')) |
339 | ||
340 | def __inverted_colors_toggled_cb(self, button): | |
341 | self.emit('toggle-inverted-colors', button.props.active) | |
342 | if button.props.active: | |
343 | button.set_icon_name('light-theme') | |
344 | button.set_tooltip(_('Normal Colors')) | |
345 | else: | |
346 | button.set_icon_name('dark-theme') | |
347 | button.set_tooltip(_('Inverted Colors')) | |
348 | ||
349 | def show_inverted_colors_button(self): | |
350 | self._inverted_colors.show() | |
351 | ||
352 | def toggle_inverted_colors(self): | |
353 | self._inverted_colors.set_active( | |
354 | not self._inverted_colors.get_active()) |