diff --git a/icons/dark-theme.svg b/icons/dark-theme.svg new file mode 100644 index 0000000..6a44324 --- /dev/null +++ b/icons/dark-theme.svg @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + A + + diff --git a/icons/light-theme.svg b/icons/light-theme.svg new file mode 100644 index 0000000..8dea23f --- /dev/null +++ b/icons/light-theme.svg @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + A + + diff --git a/po/Read.pot b/po/Read.pot index d0e333e..341ceda 100644 --- a/po/Read.pot +++ b/po/Read.pot @@ -207,6 +207,10 @@ msgid "Rotate right" msgstr "" +#: readtoolbar.py:270 readtoolbar.py:348 +msgid "Inverted Colors" +msgstr "" + #: readtoolbar.py:324 msgid "Show Tray" msgstr "" @@ -215,6 +219,10 @@ msgid "Hide Tray" msgstr "" +#: readtoolbar.py:345 +msgid "Normal Colors" +msgstr "" + #: speechtoolbar.py:65 msgid "Play / Pause" msgstr "" diff --git a/readactivity.py b/readactivity.py index 3a63824..75d04fe 100644 --- a/readactivity.py +++ b/readactivity.py @@ -238,6 +238,8 @@ self.__toogle_navigator_cb) self._view_toolbar.connect('toggle-tray-show', self.__toogle_tray_cb) + self._view_toolbar.connect('toggle-inverted-colors', + self.__toggle_inverted_colors_cb) view_toolbar_button = ToolbarButton(page=self._view_toolbar, icon_name='toolbar-view') self._view_toolbar.show() @@ -516,6 +518,10 @@ else: logging.debug('Hide tray') self.tray.hide() + + def __toggle_inverted_colors_cb(self, button, active): + if hasattr(self._view._model, 'set_inverted_colors'): + self._view._model.set_inverted_colors(active) def __num_page_entry_insert_text_cb(self, entry, text, length, position): if not re.match('[0-9]', text): @@ -994,6 +1000,7 @@ else: import evinceadapter self._view = evinceadapter.EvinceViewer() + self._view_toolbar.show_inverted_colors_button() self._view.setup(self) self._view.load_document(filepath) @@ -1182,6 +1189,9 @@ return True elif keyname == 'KP_End': self._view_toolbar.zoom_out() + return True + elif keyname == 'i' and event.state & Gdk.ModifierType.CONTROL_MASK: + self._view_toolbar.toggle_inverted_colors() return True elif keyname == 'Home': self._view.scroll(Gtk.ScrollType.START, False) diff --git a/readtoolbar.py b/readtoolbar.py index 5d0626e..76af110 100644 --- a/readtoolbar.py +++ b/readtoolbar.py @@ -177,7 +177,9 @@ 'toggle-index-show': (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, ([bool])), 'toggle-tray-show': (GObject.SignalFlags.RUN_FIRST, GObject.TYPE_NONE, - ([bool])), } + ([bool])), + 'toggle-inverted-colors': (GObject.SignalFlags.RUN_FIRST, + GObject.TYPE_NONE, ([bool])), } def __init__(self): Gtk.Toolbar.__init__(self) @@ -259,6 +261,17 @@ self._rotate_right.connect('clicked', self._rotate_right_cb) self.insert(self._rotate_right, -1) self._rotate_right.show() + + spacer = Gtk.SeparatorToolItem() + self.insert(spacer, -1) + spacer.show() + + self._inverted_colors = ToggleToolButton(icon_name='dark-theme') + self._inverted_colors.set_tooltip(_('Inverted Colors')) + self._inverted_colors.set_accelerator('i') + self._inverted_colors.connect( + 'toggled', self.__inverted_colors_toggled_cb) + self.insert(self._inverted_colors, -1) def set_view(self, view): self._view = view @@ -324,3 +337,19 @@ self.traybutton.set_tooltip(_('Show Tray')) else: self.traybutton.set_tooltip(_('Hide Tray')) + + def __inverted_colors_toggled_cb(self, button): + self.emit('toggle-inverted-colors', button.props.active) + if button.props.active: + button.set_icon_name('light-theme') + button.set_tooltip(_('Normal Colors')) + else: + button.set_icon_name('dark-theme') + button.set_tooltip(_('Inverted Colors')) + + def show_inverted_colors_button(self): + self._inverted_colors.show() + + def toggle_inverted_colors(self): + self._inverted_colors.set_active( + not self._inverted_colors.get_active())