[evince/wip/gpoo/find-results-css] libview: Allow find results be styled with CSS
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/gpoo/find-results-css] libview: Allow find results be styled with CSS
- Date: Sat, 4 Jul 2020 04:33:58 +0000 (UTC)
commit 37dba7a54693bbda9332c772ddc117fb5e3c1154
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Fri Jul 3 23:29:53 2020 -0400
libview: Allow find results be styled with CSS
libview/ev-view.c | 39 +++++++++++++++------------------------
shell/evince.css | 8 ++++++++
2 files changed, 23 insertions(+), 24 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 4b18b605..049074e6 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -113,6 +113,7 @@ typedef struct {
#define EV_STYLE_CLASS_DOCUMENT_PAGE "document-page"
#define EV_STYLE_CLASS_INVERTED "inverted"
+#define EV_STYLE_CLASS_FIND_RESULTS "find-results"
#define ANNOT_POPUP_WINDOW_DEFAULT_WIDTH 200
#define ANNOT_POPUP_WINDOW_DEFAULT_HEIGHT 150
@@ -7281,29 +7282,23 @@ static void
draw_rubberband (EvView *view,
cairo_t *cr,
const GdkRectangle *rect,
- gdouble alpha)
+ gboolean active)
{
GtkStyleContext *context;
- GdkRGBA color;
context = gtk_widget_get_style_context (GTK_WIDGET (view));
gtk_style_context_save (context);
- gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &color);
- gtk_style_context_restore (context);
- cairo_save (cr);
-
- cairo_set_source_rgba (cr, color.red, color.green, color.blue, alpha);
- cairo_rectangle (cr,
- rect->x - view->scroll_x,
- rect->y - view->scroll_y,
- rect->width, rect->height);
- cairo_fill_preserve (cr);
-
- cairo_set_line_width (cr, 0.5);
- cairo_set_source_rgb (cr, color.red, color.green, color.blue);
- cairo_stroke (cr);
+ gtk_style_context_add_class (context, EV_STYLE_CLASS_FIND_RESULTS);
+ if (active)
+ gtk_style_context_set_state (context, GTK_STATE_FLAG_ACTIVE);
+ else
+ gtk_style_context_set_state (context, GTK_STATE_FLAG_SELECTED);
- cairo_restore (cr);
+ gtk_render_background (context, cr,
+ rect->x - view->scroll_x,
+ rect->y - view->scroll_y,
+ rect->width, rect->height);
+ gtk_style_context_restore (context);
}
@@ -7319,17 +7314,13 @@ highlight_find_results (EvView *view,
for (i = 0; i < n_results; i++) {
EvRectangle *rectangle;
GdkRectangle view_rectangle;
- gdouble alpha;
+ gboolean active;
- if (i == view->find_result && page == view->find_page) {
- alpha = 0.6;
- } else {
- alpha = 0.3;
- }
+ active = i == view->find_result && page == view->find_page;
rectangle = ev_view_find_get_result (view, page, i);
_ev_view_transform_doc_rect_to_view_rect (view, page, rectangle, &view_rectangle);
- draw_rubberband (view, cr, &view_rectangle, alpha);
+ draw_rubberband (view, cr, &view_rectangle, active);
}
}
diff --git a/shell/evince.css b/shell/evince.css
index 02501d26..2f55584a 100644
--- a/shell/evince.css
+++ b/shell/evince.css
@@ -24,6 +24,14 @@ evview:selected {
background-color: @theme_selected_bg_color;
}
+evview.find-results:selected {
+ background-color: alpha (@theme_selected_bg_color, 0.3);
+}
+
+evview.find-results:active {
+ background-color: alpha (@theme_selected_bg_color, 0.6);
+}
+
evview.document-page {
background-color: white;
padding: 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]