From a7518223c9116fc5640d1e9853368dc4467ebebe Mon Sep 17 00:00:00 2001 From: Moser Peter Date: Tue, 24 Apr 2018 18:16:13 +0200 Subject: [PATCH 1/7] ev-view: Update EvView style to use CSS node name based on commit f1d24b0a6b799abc4ff948286c121b6a5bb7a909 --- shell/ev-sidebar-thumbnails.c | 3 --- shell/xreader.css | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c index 41d54a71..b0946f09 100644 --- a/shell/ev-sidebar-thumbnails.c +++ b/shell/ev-sidebar-thumbnails.c @@ -904,9 +904,6 @@ ev_sidebar_thumbnails_init (EvSidebarThumbnails *ev_sidebar_thumbnails) priv->thumbnail_width = THUMBNAIL_DEFAULT_WIDTH; - /* We actually don't want GTK_POLICY_AUTOMATIC for horizontal scrollbar here - * it's just a workaround for bug #449462 (GTK2 only) - */ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->swindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->swindow), diff --git a/shell/xreader.css b/shell/xreader.css index 56f3d671..45a02068 100644 --- a/shell/xreader.css +++ b/shell/xreader.css @@ -1,8 +1,8 @@ -EvView { +evview { background-color: @theme_bg_color; } -EvWindow .content-view .view { +.content-view.view { background-color: @theme_selected_bg_color; color: @theme_selected_fg_color; } From 91aed3c66ab723e224355631e7821809c477051a Mon Sep 17 00:00:00 2001 From: Moser Peter Date: Tue, 24 Apr 2018 18:55:49 +0200 Subject: [PATCH 2/7] EVINCE BACKPORTS: libdocument: Allow sidebar thumbnails to be styled with CSS commit 30d1c3f4d71d5f53603076c7c93a5999e65eec5a Author: William Jon McCann Date: Sun Dec 23 13:18:49 2012 +0100 libdocument: Allow sidebar thumbnails to be styled with CSS https://bugzilla.gnome.org/show_bug.cgi?id=653294 ...this commit includes also: commit 16bbee9df797c9498b0be983d1bcde309e281824 Author: Trinh Anh Ngoc Date: Sun Nov 29 09:28:29 2015 +0700 shell: Update sidebar thumbnails CSS nodes Fixes frameless thumbnails with GTK+ 3.20 https://bugzilla.gnome.org/show_bug.cgi?id=758793 --- .../libdocument/libxreaderdocument-docs.xml | 1 - libdocument/ev-document-misc.c | 72 +++++++++++++++++++ libdocument/ev-document-misc.h | 12 ++++ shell/ev-sidebar-thumbnails.c | 17 +++-- shell/xreader.css | 9 +++ 5 files changed, 106 insertions(+), 5 deletions(-) diff --git a/help/reference/libdocument/libxreaderdocument-docs.xml b/help/reference/libdocument/libxreaderdocument-docs.xml index 7b1cdf72..350d9beb 100644 --- a/help/reference/libdocument/libxreaderdocument-docs.xml +++ b/help/reference/libdocument/libxreaderdocument-docs.xml @@ -88,7 +88,6 @@ - diff --git a/libdocument/ev-document-misc.c b/libdocument/ev-document-misc.c index 53429d38..f074345e 100644 --- a/libdocument/ev-document-misc.c +++ b/libdocument/ev-document-misc.c @@ -110,6 +110,78 @@ ev_document_misc_get_loading_thumbnail (int width, return create_thumbnail_frame (width, height, NULL, !inverted_colors); } +static GdkPixbuf * +ev_document_misc_render_thumbnail_frame (GtkWidget *widget, + int width, + int height, + gboolean inverted_colors, + GdkPixbuf *source_pixbuf) +{ + GtkStyleContext *context = gtk_widget_get_style_context (widget); + GtkStateFlags state = gtk_widget_get_state_flags (widget); + int width_r, height_r; + int width_f, height_f; + cairo_surface_t *surface; + cairo_t *cr; + GtkBorder border = {0, }; + GdkPixbuf *retval; + + if (source_pixbuf) { + g_return_val_if_fail (GDK_IS_PIXBUF (source_pixbuf), NULL); + + width_r = gdk_pixbuf_get_width (source_pixbuf); + height_r = gdk_pixbuf_get_height (source_pixbuf); + } else { + width_r = width; + height_r = height; + } + + gtk_style_context_save (context); + + gtk_style_context_add_class (context, "page-thumbnail"); + if (inverted_colors) + gtk_style_context_add_class (context, "inverted"); + + gtk_style_context_get_border (context, state, &border); + width_f = width_r + border.left + border.right; + height_f = height_r + border.top + border.bottom; + + surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, + width_f, height_f); + cr = cairo_create (surface); + if (source_pixbuf) { + gdk_cairo_set_source_pixbuf (cr, source_pixbuf, border.left, border.top); + cairo_paint (cr); + } else { + gtk_render_background (context, cr, 0, 0, width_f, height_f); + } + gtk_render_frame (context, cr, 0, 0, width_f, height_f); + cairo_destroy (cr); + + gtk_style_context_restore (context); + + retval = gdk_pixbuf_get_from_surface (surface, 0, 0, width_f, height_f); + cairo_surface_destroy (surface); + + return retval; +} + +GdkPixbuf * +ev_document_misc_render_loading_thumbnail (GtkWidget *widget, + int width, + int height, + gboolean inverted_colors) +{ + return ev_document_misc_render_thumbnail_frame (widget, width, height, inverted_colors, NULL); +} + +GdkPixbuf * +ev_document_misc_render_thumbnail_with_frame (GtkWidget *widget, + GdkPixbuf *source_pixbuf) +{ + return ev_document_misc_render_thumbnail_frame (widget, -1, -1, FALSE, source_pixbuf); +} + void ev_document_misc_get_page_border_size (gint page_width, gint page_height, diff --git a/libdocument/ev-document-misc.h b/libdocument/ev-document-misc.h index 44f4954e..8efd55c0 100644 --- a/libdocument/ev-document-misc.h +++ b/libdocument/ev-document-misc.h @@ -30,15 +30,27 @@ #include #include +#include "ev-macros.h" G_BEGIN_DECLS +EV_DEPRECATED GdkPixbuf *ev_document_misc_get_thumbnail_frame (int width, int height, GdkPixbuf *source_pixbuf); +EV_DEPRECATED GdkPixbuf *ev_document_misc_get_loading_thumbnail (int width, int height, gboolean inverted_colors); + +GdkPixbuf *ev_document_misc_render_loading_thumbnail (GtkWidget *widget, + int width, + int height, + gboolean inverted_colors); +GdkPixbuf *ev_document_misc_render_thumbnail_with_frame (GtkWidget *widget, + GdkPixbuf *source_pixbuf); + +EV_DEPRECATED void ev_document_misc_get_page_border_size (gint page_width, gint page_height, GtkBorder *border); diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c index b0946f09..e40ea000 100644 --- a/shell/ev-sidebar-thumbnails.c +++ b/shell/ev-sidebar-thumbnails.c @@ -438,6 +438,10 @@ ev_sidebar_thumbnails_class_init (EvSidebarThumbnailsClass *ev_sidebar_thumbnail widget_class->map = ev_sidebar_thumbnails_map; +#if GTK_CHECK_VERSION(3, 20, 0) + gtk_widget_class_set_css_name (widget_class, "evsidebarthumbnails"); +#endif + g_object_class_override_property (g_object_class, PROP_WIDGET, "main-widget"); @@ -480,7 +484,8 @@ ev_sidebar_thumbnails_get_loading_icon (EvSidebarThumbnails *sidebar_thumbnails, gboolean inverted_colors; inverted_colors = ev_document_model_get_inverted_colors (priv->model); - icon = ev_document_misc_get_loading_thumbnail (width, height, inverted_colors); + icon = ev_document_misc_render_loading_thumbnail (GTK_WIDGET (sidebar_thumbnails), + width, height, inverted_colors); g_hash_table_insert (priv->loading_icons, key, icon); } else { g_free (key); @@ -1072,19 +1077,23 @@ thumbnail_job_completed_callback (EvJobThumbnail *job, EvSidebarThumbnails *sidebar_thumbnails) { EvSidebarThumbnailsPrivate *priv = sidebar_thumbnails->priv; - GtkTreeIter *iter; + GtkTreeIter *iter; + GdkPixbuf *pixbuf; + + pixbuf = ev_document_misc_render_thumbnail_with_frame (GTK_WIDGET (sidebar_thumbnails), job->thumbnail); iter = (GtkTreeIter *) g_object_get_data (G_OBJECT (job), "tree_iter"); if (priv->inverted_colors && priv->document->iswebdocument == FALSE) - ev_document_misc_invert_pixbuf (job->thumbnail); + ev_document_misc_invert_pixbuf (pixbuf); gtk_list_store_set (priv->list_store, iter, - COLUMN_PIXBUF, job->thumbnail, + COLUMN_PIXBUF, pixbuf, COLUMN_THUMBNAIL_SET, TRUE, COLUMN_JOB, NULL, -1); gtk_widget_queue_draw (priv->icon_view); + g_object_unref (pixbuf); } static void diff --git a/shell/xreader.css b/shell/xreader.css index 45a02068..789d4007 100644 --- a/shell/xreader.css +++ b/shell/xreader.css @@ -7,3 +7,12 @@ evview { color: @theme_selected_fg_color; } +evsidebarthumbnails.page-thumbnail { + background-color: white; + border: 1px solid black; + padding: 0; +} + +evsidebarthumbnails.page-thumbnail.inverted { + background-color: black; +} From 4b999fd3909a281c78df1e37763014389e77457f Mon Sep 17 00:00:00 2001 From: Peter Moser Date: Tue, 15 May 2018 08:50:02 +0200 Subject: [PATCH 3/7] EVINCE BACKPORTS: view: Use a rendered frame instead of custom border commit 7a6b53a1b4083cf6a3d9660dfc7978bb37c3d9e7 Author: William Jon McCann Date: Sun Dec 23 10:49:58 2012 +0100 view: Use a rendered frame instead of custom border So it can be styled with CSS. https://bugzilla.gnome.org/show_bug.cgi?id=653294 --- libview/ev-view.c | 66 +++++++++++++++++++++++++++-------------------- shell/xreader.css | 18 +++++++++++++ 2 files changed, 56 insertions(+), 28 deletions(-) diff --git a/libview/ev-view.c b/libview/ev-view.c index 129aa064..ce2e612a 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -1,5 +1,5 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ -/* this file is part of xreader, a mate document viewer +/* this file is part of evince, a generic document viewer * * Copyright (C) 2004 Red Hat, Inc * @@ -101,6 +101,8 @@ typedef struct { #define SCROLL_TIME 150 +#define EV_STYLE_CLASS_DOCUMENT_PAGE "document-page" + /*** Scrolling ***/ static void view_update_range_and_current_page (EvView *view); static void add_scroll_binding_keypad (GtkBindingSet *binding_set, @@ -113,8 +115,6 @@ static void ensure_rectangle_is_visible (EvView /*** Geometry computations ***/ static void compute_border (EvView *view, - int width, - int height, GtkBorder *border); static void get_page_y_offset (EvView *view, int page, @@ -1035,9 +1035,16 @@ ensure_rectangle_is_visible (EvView *view, GdkRectangle *rect) /*** Geometry computations ***/ static void -compute_border (EvView *view, int width, int height, GtkBorder *border) +compute_border (EvView *view, GtkBorder *border) { - ev_document_misc_get_page_border_size (width, height, border); + GtkWidget *widget = GTK_WIDGET (view); + GtkStyleContext *context = gtk_widget_get_style_context (widget); + GtkStateFlags state = gtk_widget_get_state_flags (widget); + + gtk_style_context_save (context); + gtk_style_context_add_class (context, EV_STYLE_CLASS_DOCUMENT_PAGE); + gtk_style_context_get_border (context, state, border); + gtk_style_context_restore (context); } void @@ -1098,13 +1105,12 @@ ev_view_get_max_page_size (EvView *view, static void get_page_y_offset (EvView *view, int page, int *y_offset) { - int max_width, offset = 0; + int offset = 0; GtkBorder border; g_return_if_fail (y_offset != NULL); - ev_view_get_max_page_size (view, &max_width, NULL); - compute_border (view, max_width, max_width, &border); + compute_border (view, &border); if (view->dual_page) { ev_view_get_height_to_page (view, page, NULL, &offset); @@ -1134,7 +1140,7 @@ ev_view_get_page_extents (EvView *view, /* Get the size of the page */ ev_view_get_page_size (view, page, &width, &height); - compute_border (view, width, height, border); + compute_border (view, border); page_area->width = width + border->left + border->right; page_area->height = height + border->top + border->bottom; @@ -1180,7 +1186,7 @@ ev_view_get_page_extents (EvView *view, if (height_2 > height) max_height = height_2; } - compute_border (view, max_width, max_height, &overall_border); + compute_border (view, &overall_border); /* Find the offsets */ x = view->spacing; @@ -3186,7 +3192,7 @@ ev_view_size_request_continuous_dual_page (EvView *view, GtkBorder border; ev_view_get_max_page_size (view, &max_width, NULL); - compute_border (view, max_width, max_width, &border); + compute_border (view, &border); requisition->width = (max_width + border.left + border.right) * 2 + (view->spacing * 3); } break; @@ -3215,7 +3221,7 @@ ev_view_size_request_continuous (EvView *view, GtkBorder border; ev_view_get_max_page_size (view, &max_width, NULL); - compute_border (view, max_width, max_width, &border); + compute_border (view, &border); requisition->width = max_width + (view->spacing * 2) + border.left + border.right; } break; @@ -3252,7 +3258,7 @@ ev_view_size_request_dual_page (EvView *view, height = height_2; } } - compute_border (view, width, height, &border); + compute_border (view, &border); requisition->width = view->sizing_mode == EV_SIZING_FIT_WIDTH ? 1 : ((width + border.left + border.right) * 2) + (view->spacing * 3); @@ -3274,7 +3280,7 @@ ev_view_size_request_single_page (EvView *view, } ev_view_get_page_size (view, view->current_page, &width, &height); - compute_border (view, width, height, &border); + compute_border (view, &border); requisition->width = view->sizing_mode == EV_SIZING_FIT_WIDTH ? 1 : width + border.left + border.right + (2 * view->spacing); @@ -4589,10 +4595,10 @@ draw_one_page (EvView *view, GdkRectangle *expose_area, gboolean *page_ready) { - GdkRectangle overlap; - GdkRectangle real_page_area; - gint current_page; - gboolean inverted_colors; + GtkStyleContext *context; + GdkRectangle overlap; + GdkRectangle real_page_area; + gint current_page; g_assert (view->document); @@ -4608,13 +4614,17 @@ draw_one_page (EvView *view, real_page_area.height -= (border->top + border->bottom); *page_ready = TRUE; + context = gtk_widget_get_style_context (GTK_WIDGET (view)); current_page = ev_document_model_get_page (view->model); - inverted_colors = ev_document_model_get_inverted_colors (view->model); - ev_document_misc_paint_one_page (cr, - GTK_WIDGET (view), - page_area, border, - page == current_page, - inverted_colors); + + gtk_style_context_save (context); + gtk_style_context_add_class (context, EV_STYLE_CLASS_DOCUMENT_PAGE); + + if (view->continuous && page == current_page) + gtk_style_context_set_state (context, GTK_STATE_FLAG_ACTIVE); + + gtk_render_frame (context, cr, page_area->x, page_area->y, page_area->width, page_area->height); + gtk_style_context_restore (context); if (gdk_rectangle_intersect (&real_page_area, expose_area, &overlap)) { gint width, height; @@ -6003,7 +6013,7 @@ ev_view_zoom_for_size_continuous_and_dual_page (EvView *view, doc_height = tmp; } - compute_border (view, doc_width, doc_height, &border); + compute_border (view, &border); doc_width *= 2; width -= (2 * (border.left + border.right) + 3 * view->spacing); @@ -6040,7 +6050,7 @@ ev_view_zoom_for_size_continuous (EvView *view, doc_height = tmp; } - compute_border (view, doc_width, doc_height, &border); + compute_border (view, &border); width -= (border.left + border.right + 2 * view->spacing); height -= (border.top + border.bottom + 2 * view->spacing - 1); @@ -6080,7 +6090,7 @@ ev_view_zoom_for_size_dual_page (EvView *view, if (height_2 > doc_height) doc_height = height_2; } - compute_border (view, width, height, &border); + compute_border (view, &border); doc_width = doc_width * 2; width -= ((border.left + border.right)* 2 + 3 * view->spacing); @@ -6111,7 +6121,7 @@ ev_view_zoom_for_size_single_page (EvView *view, get_doc_page_size (view, view->current_page, &doc_width, &doc_height); /* Get an approximate border */ - compute_border (view, width, height, &border); + compute_border (view, &border); width -= (border.left + border.right + 2 * view->spacing); height -= (border.top + border.bottom + 2 * view->spacing); diff --git a/shell/xreader.css b/shell/xreader.css index 789d4007..0ccc8a39 100644 --- a/shell/xreader.css +++ b/shell/xreader.css @@ -16,3 +16,21 @@ evsidebarthumbnails.page-thumbnail { evsidebarthumbnails.page-thumbnail.inverted { background-color: black; } + +evview.document-page { + border-color: black; + border-style: solid; + border-width: 1px; + border-radius: 0px; + border-image: none; + padding: 0; +} + +evview.document-page:active { + border-color: @theme_selected_bg_color; + border-style: solid; + border-width: 1px; + border-radius: 0px; + border-image: none; + padding: 0; +} From 42b3786eb6dd8bef6d92de53607d74e7b1100a0a Mon Sep 17 00:00:00 2001 From: Peter Moser Date: Thu, 6 Sep 2018 08:13:23 +0200 Subject: [PATCH 4/7] EVINCE BACKPORTS: view: Fix page background rendering while loading commit 38528f9f1e225f4d661a1d813c5fae45fd6707d4 Author: Carlos Garcia Campos Date: Sun Dec 23 11:28:46 2012 +0100 view: Fix page background rendering while loading --- libview/ev-view.c | 6 +++++- shell/xreader.css | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libview/ev-view.c b/libview/ev-view.c index ce2e612a..50b07068 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -1,5 +1,5 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ -/* this file is part of evince, a generic document viewer +/* this file is part of xreader, a generic document viewer * * Copyright (C) 2004 Red Hat, Inc * @@ -102,6 +102,7 @@ typedef struct { #define SCROLL_TIME 150 #define EV_STYLE_CLASS_DOCUMENT_PAGE "document-page" +#define EV_STYLE_CLASS_INVERTED "inverted" /*** Scrolling ***/ static void view_update_range_and_current_page (EvView *view); @@ -4619,10 +4620,13 @@ draw_one_page (EvView *view, gtk_style_context_save (context); gtk_style_context_add_class (context, EV_STYLE_CLASS_DOCUMENT_PAGE); + if (ev_document_model_get_inverted_colors (view->model)) + gtk_style_context_add_class (context, EV_STYLE_CLASS_INVERTED); if (view->continuous && page == current_page) gtk_style_context_set_state (context, GTK_STATE_FLAG_ACTIVE); + gtk_render_background (context, cr, page_area->x, page_area->y, page_area->width, page_area->height); gtk_render_frame (context, cr, page_area->x, page_area->y, page_area->width, page_area->height); gtk_style_context_restore (context); diff --git a/shell/xreader.css b/shell/xreader.css index 0ccc8a39..a5178359 100644 --- a/shell/xreader.css +++ b/shell/xreader.css @@ -34,3 +34,7 @@ evview.document-page:active { border-image: none; padding: 0; } + +evview.document-page.inverted { + background-color: black; +} From 810d41aaab3b896dd121047418286de1efc7aec2 Mon Sep 17 00:00:00 2001 From: Peter Moser Date: Fri, 14 Sep 2018 08:19:22 +0200 Subject: [PATCH 5/7] EVINCE BACKPORTS: previewer: Add CSS file for EvView styling commit 48110cb41681d8babe94cc8ee3fb26a533d16671 Author: Carlos Garcia Campos Date: Mon Aug 4 12:50:41 2014 +0200 previewer: Add CSS file for EvView styling EvView CSS used to be shared in adwaita theme, but now that adwaita has been merged into GTK+ and app specific CSS has been removed, we need to add the EvView CSS to all of its users. --- data/thumbnail-frame.png | Bin 0 -> 832 bytes previewer/Makefile.am | 8 +++---- previewer/ev-previewer-window.c | 36 ++++++++++++++++++++++++++++-- previewer/previewer.gresource.xml | 2 ++ previewer/xreader-previewer.css | 14 ++++++++++++ shell/Makefile.am | 4 ++-- shell/xreader.css | 26 +++++---------------- 7 files changed, 61 insertions(+), 29 deletions(-) create mode 100644 data/thumbnail-frame.png create mode 100644 previewer/xreader-previewer.css diff --git a/data/thumbnail-frame.png b/data/thumbnail-frame.png new file mode 100644 index 0000000000000000000000000000000000000000..ba5d7212064dbe06f7d95e7b89045b758f108c5c GIT binary patch literal 832 zcmeAS@N?(olHy`uVBq!ia0vp^EkL}QgAGV7-)G_iq!^2X+?^QKos)S9#skTR$57 z;`^%dQn<-XPP{ERQ6k*nTI+?$Zys9(Y`OQlCvo;Q$*!e_F_ZWBXTRV3J@-(7U(xI* zb|?E)%D?_PS-m5qdhK-;eb0HvFJ6qgz5V69hsz9Xu2rqL?pM~iw5;9sr0U7wN%z@R zZZ4~CTU*w4TxI{ODsx%cDCQ$u%i0?suALV@spgjAv56l8B!Ya6b?YMQe|_5EyZ_Fz$B%7lFK=*O!>V*S=l{>|hsu65 zmqn=GH<|YO%h5UZe*>7D95^@_6%|-o8UzHeaq!6jb>Y+pGZCAaFgdW*1T1KnfWu*M zLp%uhKtTnr6yeoh_P6-X|4w|nb&Ff_yyKSjoJnp4zMta4txrZNJiGbMUF0_7VN+n7 zWKVitmCKx@De&GiF6-FzSwGpkB#)S$jGnYyW&i81yH%d6oUPvJl6-Ex>Eq?IewMOb z4J%&Qq5D|c%1^mUu&>%?;(E*_m(M9El$AB!AFDX(DtT@ bc8WikEzLKv>9wkWk~f2=tDnm{r-UW|J+3%t literal 0 HcmV?d00001 diff --git a/previewer/Makefile.am b/previewer/Makefile.am index de8ac0f0..c761f297 100644 --- a/previewer/Makefile.am +++ b/previewer/Makefile.am @@ -35,16 +35,16 @@ xreader_previewer_LDADD = \ $(top_builddir)/libmisc/libevmisc.la \ $(PREVIEWER_LIBS) \ $(WEBKIT_LIBS) - -ev-previewer-resources.c: previewer.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir) $(srcdir)/previewer.gresource.xml) - $(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(srcdir) --generate-source --c-name ev_previewer $< + +ev-previewer-resources.c: previewer.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir=$(srcdir) --sourcedir=$(top_builddir)/data $(srcdir)/previewer.gresource.xml) + $(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --sourcedir=$(top_builddir)/data --generate-source --c-name ev_previewer $< EXTRA_DIST = \ $(man_MANS) \ previewer.gresource.xml \ previewer-ui.xml \ $(NULL) - + CLEANFILES = \ ev-previewer-resources.c \ $(NULL) diff --git a/previewer/ev-previewer-window.c b/previewer/ev-previewer-window.c index 183476f6..caa07c36 100644 --- a/previewer/ev-previewer-window.c +++ b/previewer/ev-previewer-window.c @@ -513,6 +513,27 @@ ev_previewer_window_set_property (GObject *object, } } +static gboolean +_gtk_css_provider_load_from_resource (GtkCssProvider *provider, + const char *resource_path, + GError **error) +{ + GBytes *data; + gboolean retval; + + data = g_resources_lookup_data (resource_path, 0, error); + if (!data) + return FALSE; + + retval = gtk_css_provider_load_from_data (provider, + g_bytes_get_data (data, NULL), + g_bytes_get_size (data), + error); + g_bytes_unref (data); + + return retval; +} + static GObject * ev_previewer_window_constructor (GType type, guint n_construct_properties, @@ -525,13 +546,14 @@ ev_previewer_window_constructor (GType type, GtkAction *action; GError *error = NULL; gdouble dpi; + GtkCssProvider *css_provider; object = G_OBJECT_CLASS (ev_previewer_window_parent_class)->constructor (type, n_construct_properties, construct_params); window = EV_PREVIEWER_WINDOW (object); - gtk_widget_hide(GTK_WIDGET (window)); - gtk_widget_realize (GTK_WIDGET (window)); + gtk_widget_hide(GTK_WIDGET (window)); + gtk_widget_realize (GTK_WIDGET (window)); dpi = get_screen_dpi (window); ev_document_model_set_min_scale (window->model, MIN_SCALE * dpi / 72.0); @@ -571,6 +593,16 @@ ev_previewer_window_constructor (GType type, window); gtk_action_group_set_sensitive (window->accels_group, FALSE); + css_provider = gtk_css_provider_new (); + _gtk_css_provider_load_from_resource (css_provider, + "/org/x/reader/previewer/ui/xreader-previewer.css", + &error); + g_assert_no_error (error); + gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)), + GTK_STYLE_PROVIDER (css_provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_object_unref (css_provider); + window->ui_manager = gtk_ui_manager_new (); gtk_ui_manager_insert_action_group (window->ui_manager, window->action_group, 0); diff --git a/previewer/previewer.gresource.xml b/previewer/previewer.gresource.xml index 5dd42b8a..6c530763 100644 --- a/previewer/previewer.gresource.xml +++ b/previewer/previewer.gresource.xml @@ -18,5 +18,7 @@ previewer-ui.xml + xreader-previewer.css + thumbnail-frame.png diff --git a/previewer/xreader-previewer.css b/previewer/xreader-previewer.css new file mode 100644 index 00000000..9036d5b7 --- /dev/null +++ b/previewer/xreader-previewer.css @@ -0,0 +1,14 @@ +evview { + background-color: @theme_bg_color; +} + +evview.document-page { + background-color: @theme_bg_color; + border-style: solid; + border-width: 3px 3px 6px 4px; + border-image: url("resource:///org/x/reader/previewer/ui/thumbnail-frame.png") 3 3 6 4; +} + +evview.document-page.inverted { + background-color: black; +} diff --git a/shell/Makefile.am b/shell/Makefile.am index 3bef4bf2..a34342e1 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -173,8 +173,8 @@ ev-marshal.c: $(srcdir)/ev-marshal.list echo '#include "ev-marshal.h"' > ev-marshal.c $(AM_V_GEN)$(GLIB_GENMARSHAL) --prefix=ev_marshal $(srcdir)/ev-marshal.list --body >> ev-marshal.c -ev-resources.c: xreader.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir) $(srcdir)/xreader.gresource.xml) - $(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(srcdir) --generate-source --c-name ev $< +ev-resources.c: xreader.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir=$(srcdir) --sourcedir=$(top_builddir)/data $(srcdir)/xreader.gresource.xml) + $(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir=$(srcdir) --sourcedir=$(top_builddir)/data --generate-source --c-name ev $< ev-gdbus-generated.c ev-gdbus-generated.h: ev-gdbus.xml Makefile $(AM_V_GEN) $(GDBUS_CODEGEN) \ diff --git a/shell/xreader.css b/shell/xreader.css index a5178359..a5c41a32 100644 --- a/shell/xreader.css +++ b/shell/xreader.css @@ -2,37 +2,21 @@ evview { background-color: @theme_bg_color; } -.content-view.view { - background-color: @theme_selected_bg_color; - color: @theme_selected_fg_color; -} - evsidebarthumbnails.page-thumbnail { - background-color: white; + background-color: @theme_bg_color; border: 1px solid black; - padding: 0; } evsidebarthumbnails.page-thumbnail.inverted { background-color: black; + border: 1px solid white; } evview.document-page { - border-color: black; - border-style: solid; - border-width: 1px; - border-radius: 0px; - border-image: none; - padding: 0; -} - -evview.document-page:active { - border-color: @theme_selected_bg_color; + background-color: @theme_bg_color; border-style: solid; - border-width: 1px; - border-radius: 0px; - border-image: none; - padding: 0; + border-width: 3px 3px 6px 4px; + border-image: url("resource:///org/x/reader/shell/ui/thumbnail-frame.png") 3 3 6 4; } evview.document-page.inverted { From 7629615d54c9e13fa6d4d1be56321230a8763824 Mon Sep 17 00:00:00 2001 From: Peter Moser Date: Thu, 18 Oct 2018 23:35:12 +0200 Subject: [PATCH 6/7] libdocument: Do not hardcode thumbnail frames Always draw thumbnail frames styled by CSS (see .page-thumbnail inside shell/xreader.css), and not through hard-coded pixbuf manipulations. --- libdocument/ev-document-misc.c | 52 +++++++++------------------------- shell/ev-recent-view.c | 3 +- shell/xreader.gresource.xml | 1 + 3 files changed, 16 insertions(+), 40 deletions(-) diff --git a/libdocument/ev-document-misc.c b/libdocument/ev-document-misc.c index f074345e..bb38d441 100644 --- a/libdocument/ev-document-misc.c +++ b/libdocument/ev-document-misc.c @@ -27,10 +27,10 @@ #include "ev-document-misc.h" -/* Returns a new GdkPixbuf that is suitable for placing in the thumbnail view. - * It is four pixels wider and taller than the source. If source_pixbuf is not - * NULL, then it will fill the return pixbuf with the contents of - * source_pixbuf. +/** + * Returns a new GdkPixbuf that is suitable for placing in the thumbnail view. + * If source_pixbuf is not NULL, then it will fill the return pixbuf with the + * contents of source_pixbuf. */ static GdkPixbuf * create_thumbnail_frame (int width, @@ -39,57 +39,31 @@ create_thumbnail_frame (int width, gboolean fill_bg) { GdkPixbuf *retval; - guchar *data; - gint rowstride; int i; int width_r, height_r; if (source_pixbuf) g_return_val_if_fail (GDK_IS_PIXBUF (source_pixbuf), NULL); - if (source_pixbuf) { - width_r = gdk_pixbuf_get_width (source_pixbuf); - height_r = gdk_pixbuf_get_height (source_pixbuf); - } else { - width_r = width; - height_r = height; - } + width_r = gdk_pixbuf_get_width (source_pixbuf); + height_r = gdk_pixbuf_get_height (source_pixbuf); /* make sure no one is passing us garbage */ g_return_val_if_fail (width_r >= 0 && height_r >= 0, NULL); retval = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, - width_r + 4, - height_r + 4); - - /* make it black and fill in the middle */ - data = gdk_pixbuf_get_pixels (retval); - rowstride = gdk_pixbuf_get_rowstride (retval); + width_r, + height_r); gdk_pixbuf_fill (retval, 0x000000ff); - if (fill_bg) { - for (i = 1; i < height_r + 1; i++) - memset (data + (rowstride * i) + 4, 0xffffffff, width_r * 4); - } /* copy the source pixbuf */ - if (source_pixbuf) - gdk_pixbuf_copy_area (source_pixbuf, 0, 0, - width_r, - height_r, - retval, - 1, 1); - /* Add the corner */ - data [(width_r + 2) * 4 + 3] = 0; - data [(width_r + 3) * 4 + 3] = 0; - data [(width_r + 2) * 4 + (rowstride * 1) + 3] = 0; - data [(width_r + 3) * 4 + (rowstride * 1) + 3] = 0; - - data [(height_r + 2) * rowstride + 3] = 0; - data [(height_r + 3) * rowstride + 3] = 0; - data [(height_r + 2) * rowstride + 4 + 3] = 0; - data [(height_r + 3) * rowstride + 4 + 3] = 0; + gdk_pixbuf_copy_area (source_pixbuf, 0, 0, + width_r, + height_r, + retval, + 0, 0); return retval; } diff --git a/shell/ev-recent-view.c b/shell/ev-recent-view.c index 64598dc4..b656e3f7 100644 --- a/shell/ev-recent-view.c +++ b/shell/ev-recent-view.c @@ -103,7 +103,8 @@ thumbnail_job_completed_callback (EvJobThumbnail *job, GtkButton *button) { if (!ev_job_is_failed (EV_JOB (job))) { - gtk_button_set_image (button, gtk_image_new_from_pixbuf(job->thumbnail)); + GdkPixbuf *pixbuf = ev_document_misc_render_thumbnail_with_frame(button, job->thumbnail); + gtk_button_set_image (button, gtk_image_new_from_pixbuf(pixbuf)); } } diff --git a/shell/xreader.gresource.xml b/shell/xreader.gresource.xml index 87efc788..c68b65e2 100644 --- a/shell/xreader.gresource.xml +++ b/shell/xreader.gresource.xml @@ -20,5 +20,6 @@ xreader-ui.xml xreader.css ev-preferences-dialog.ui + thumbnail-frame.png From 2515554f5ee28bcbe69de52e9acd5f331879a700 Mon Sep 17 00:00:00 2001 From: Peter Moser Date: Fri, 2 Nov 2018 18:04:46 +0100 Subject: [PATCH 7/7] Improve ratio calculations of sidebar thumbnails The old calculation caused sometimes rounding errors, which could cut off the lower border line. --- shell/ev-sidebar-thumbnails.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c index e40ea000..b6f658e8 100644 --- a/shell/ev-sidebar-thumbnails.c +++ b/shell/ev-sidebar-thumbnails.c @@ -27,6 +27,7 @@ #endif #include +#include #include #include @@ -711,7 +712,7 @@ ev_sidebar_thumbnails_fill_model (EvSidebarThumbnails *sidebar_thumbnails) sidebar_thumbnails->priv->rotation, &width, &height); - height = (gint) (height*priv->thumbnail_width/width); + height = (gint) ceil((double)(height) * priv->thumbnail_width / width); width = priv->thumbnail_width; if (!loading_icon || (width != prev_width && height != prev_height)) {