[gnome-documents: 1/2] epub: Implement Night Mode
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents: 1/2] epub: Implement Night Mode
- Date: Sun, 20 Jan 2019 00:49:30 +0000 (UTC)
commit 8ef78fc30b0abc8997690eebeac6a9521e7d118a
Author: Ryan Gonzalez <rymg19 gmail com>
Date: Wed Jan 16 21:23:18 2019 -0600
epub: Implement Night Mode
Night Mode in Books now inverts the colors like Documents does, whereas before it simply set the window's
theme to dark.
Closes #30.
src/epubview.js | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
---
diff --git a/src/epubview.js b/src/epubview.js
index 88b9580c..6f347265 100644
--- a/src/epubview.js
+++ b/src/epubview.js
@@ -28,6 +28,7 @@ const WebKit2 = imports.gi.WebKit2;
const _ = imports.gettext.gettext;
+const Application = imports.application;
const Documents = imports.documents;
const Preview = imports.preview;
const Utils = imports.utils;
@@ -69,6 +70,13 @@ var EPUBView = new Lang.Class({
createView: function() {
let view = new Gepub.Widget();
+ this.invertedStyle = new WebKit2.UserStyleSheet(
+ 'body { background: black; filter: invert(100%); }',
+ WebKit2.UserContentInjectedFrames.ALL_FRAMES,
+ WebKit2.UserStyleLevel.USER,
+ null, null,
+ );
+
let fc = view.get_find_controller();
fc.connect('found-text', Lang.bind(this, function(view, matchCount, data) {
let hasResults = matchCount > 0;
@@ -160,6 +168,15 @@ var EPUBView = new Lang.Class({
return true;
},
+ set nightMode(v) {
+ if (this.view && Application.application.isBooks) {
+ if (v)
+ this.view.get_user_content_manager().add_style_sheet(this.invertedStyle);
+ else
+ this.view.get_user_content_manager().remove_all_style_sheets();
+ }
+ },
+
search: function(str) {
this.parent(str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]