summaryrefslogtreecommitdiff
path: root/libview
diff options
context:
space:
mode:
authorrootavish <[email protected]>2014-08-14 07:41:35 +0530
committerrootavish <[email protected]>2014-08-14 07:41:35 +0530
commit700637ca1dd675ce18f2e9e56387dab86020a623 (patch)
treec442065088b57266d7d9519b07f3226474c8293d /libview
parent89bf352b3d2725b11328e7641cef5c3cc2a8ea39 (diff)
downloadatril-700637ca1dd675ce18f2e9e56387dab86020a623.tar.bz2
atril-700637ca1dd675ce18f2e9e56387dab86020a623.tar.xz
Inverted colors(night) viewing mode for ePub
Added the capability to view and epub document with inverted colors, yet to test for documents where we write the stylesheet, although the code is there.
Diffstat (limited to 'libview')
-rw-r--r--libview/ev-document-model.c16
-rw-r--r--libview/ev-web-view.c47
2 files changed, 24 insertions, 39 deletions
diff --git a/libview/ev-document-model.c b/libview/ev-document-model.c
index dbf0477f..403df466 100644
--- a/libview/ev-document-model.c
+++ b/libview/ev-document-model.c
@@ -109,12 +109,7 @@ ev_document_model_set_property (GObject *object,
ev_document_model_set_rotation (model, g_value_get_int (value));
break;
case PROP_INVERTED_COLORS:
- if ( model->document->iswebdocument == TRUE ) {
- atril_web_document_set_inverted_colors(model,g_value_get_boolean(value));
- }
- else {
- ev_document_model_set_inverted_colors (model, g_value_get_boolean (value));
- }
+ ev_document_model_set_inverted_colors (model, g_value_get_boolean (value));
break;
case PROP_SCALE:
ev_document_model_set_scale (model, g_value_get_double (value));
@@ -495,15 +490,6 @@ ev_document_model_set_inverted_colors (EvDocumentModel *model,
g_object_notify (G_OBJECT (model), "inverted-colors");
}
-void
-atril_web_document_set_inverted_colors (EvDocumentModel *model,
- gboolean inverted_colors)
-{
- //TODO
- model->inverted_colors = FALSE;
- g_object_notify (G_OBJECT (model), "inverted-colors");
-}
-
gboolean
ev_document_model_get_inverted_colors (EvDocumentModel *model)
{
diff --git a/libview/ev-web-view.c b/libview/ev-web-view.c
index b1fe3b08..5d1f5034 100644
--- a/libview/ev-web-view.c
+++ b/libview/ev-web-view.c
@@ -58,7 +58,7 @@ struct _EvWebView
EvDocument *document;
EvDocumentModel *model;
gint current_page;
- gboolean inverted_colors ;
+ gboolean inverted_stylesheet ;
gboolean fullscreen;
SearchParams *search;
#if GTK_CHECK_VERSION (3, 0, 0)
@@ -157,7 +157,7 @@ ev_web_view_init (EvWebView *webview)
webview->search->search_jump = TRUE ;
webview->fullscreen = FALSE;
-
+ webview->inverted_stylesheet = FALSE;
webview->hlink = NULL;
}
@@ -262,29 +262,28 @@ ev_web_view_inverted_colors_changed_cb (EvDocumentModel *model,
GParamSpec *pspec,
EvWebView *webview)
{
- guint inverted_colors = ev_document_model_get_inverted_colors (model);
- inverted_colors = !inverted_colors;
- /*TODO*/
+ EvDocument *document = ev_document_model_get_document(model);
+
+ if (ev_document_model_get_inverted_colors(model) == TRUE) {
+ if (document == NULL) {
+ ev_document_model_set_inverted_colors(model,FALSE);
+ return;
+ }
+ if (webview->inverted_stylesheet == FALSE) {
+ ev_document_check_add_night_sheet(document);
+ webview->inverted_stylesheet = TRUE;
+ }
+ ev_document_toggle_night_mode(document,TRUE);
+ webkit_web_view_reload(WEBKIT_WEB_VIEW(webview));
+ }
+ else {
+ if (document != NULL) {
+ ev_document_toggle_night_mode(document,FALSE);
+ webkit_web_view_reload(WEBKIT_WEB_VIEW(webview));
+ }
+ }
}
-static void
-ev_web_view_fullscreen_changed_cb (EvDocumentModel *model,
- GParamSpec *pspec,
- EvWebView *webview)
-{
- gboolean fullscreen = ev_document_model_get_fullscreen (model);
-
- webview->fullscreen = fullscreen;
-#if GTK_CHECK_VERSION (3, 0, 0)
- WebKitWindowProperties *window_properties =
- webkit_web_view_get_window_properties (WEBKIT_WEB_VIEW(webview));
-
- webkit_window_properties_get_fullscreen(window_properties);
- /*TODO*/
-#else
- webkit_web_view_set_view_mode(WEBKIT_WEB_VIEW(webview), WEBKIT_WEB_VIEW_VIEW_MODE_FULLSCREEN);
-#endif
-}
void
ev_web_view_set_model (EvWebView *webview,
EvDocumentModel *model)
@@ -309,7 +308,7 @@ ev_web_view_set_model (EvWebView *webview,
/* Initialize webview from model */
webview->fullscreen = ev_document_model_get_fullscreen (webview->model);
webview->document = ev_document_model_get_document(webview->model);
- webview->inverted_colors = ev_document_model_get_inverted_colors(webview->model);
+
ev_web_view_document_changed_cb (webview->model, NULL, webview);
g_signal_connect (webview->model, "notify::document",