summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-12-09 23:51:10 +0100
committerinfirit <[email protected]>2014-12-10 00:54:02 +0100
commita7b9ecdd923ede7aa92f60241fb25b009a4ec895 (patch)
treed8e1a75405fc84bd3af7ac392c608aca326a99f8
parent593ef3a82ff1f74cfa527dfe4a96448408978f70 (diff)
downloadatril-a7b9ecdd923ede7aa92f60241fb25b009a4ec895.tar.bz2
atril-a7b9ecdd923ede7aa92f60241fb25b009a4ec895.tar.xz
Gtk3: libdocument: Port To GtkStyleContext
Taken from evince commit: 478dd74e4201b44b5c921fd0bb69b0c4e43bcd8a From: Carlos Garcia Campos <[email protected]>
-rw-r--r--libdocument/ev-document-misc.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libdocument/ev-document-misc.c b/libdocument/ev-document-misc.c
index e7398dee..a695c050 100644
--- a/libdocument/ev-document-misc.c
+++ b/libdocument/ev-document-misc.c
@@ -140,10 +140,29 @@ ev_document_misc_paint_one_page (cairo_t *cr,
gboolean highlight,
gboolean inverted_colors)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkStyleContext *context = gtk_widget_get_style_context (widget);
+ GtkStateFlags state = gtk_widget_get_state_flags (widget);
+ GdkRGBA fg, bg, shade_bg;
+ GtkSymbolicColor *c1, *c2;
+
+ gtk_style_context_get_background_color (context, state, &bg);
+ gtk_style_context_get_color (context, state, &fg);
+
+ // FIXME: should we cache the shade_bg?
+ c1 = gtk_symbolic_color_new_literal (&bg);
+ c2 = gtk_symbolic_color_new_shade (c1, 0.7);
+ gtk_symbolic_color_resolve (c2, NULL, &shade_bg);
+ gtk_symbolic_color_unref (c1);
+ gtk_symbolic_color_unref (c2);
+
+ gdk_cairo_set_source_rgba (cr, highlight ? &fg : &shade_bg);
+#else
GtkStyle *style = gtk_widget_get_style (widget);
GtkStateType state = gtk_widget_get_state (widget);
gdk_cairo_set_source_color (cr, highlight ? &style->text[state] : &style->dark[state]);
+#endif
gdk_cairo_rectangle (cr, area);
cairo_fill (cr);
@@ -158,7 +177,11 @@ ev_document_misc_paint_one_page (cairo_t *cr,
area->height - (border->top + border->bottom));
cairo_fill (cr);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &bg);
+#else
gdk_cairo_set_source_color (cr, &style->mid[state]);
+#endif
cairo_rectangle (cr,
area->x,
area->y + area->height - (border->bottom - border->top),