summaryrefslogtreecommitdiff
path: root/libview/ev-pixbuf-cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'libview/ev-pixbuf-cache.c')
-rw-r--r--libview/ev-pixbuf-cache.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/libview/ev-pixbuf-cache.c b/libview/ev-pixbuf-cache.c
index 118d3f33..645904ee 100644
--- a/libview/ev-pixbuf-cache.c
+++ b/libview/ev-pixbuf-cache.c
@@ -602,6 +602,28 @@ ev_pixbuf_cache_clear_job_sizes (EvPixbufCache *pixbuf_cache,
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+get_selection_colors (GtkWidget *widget, GdkColor *text, GdkColor *base)
+{
+ GtkStyleContext *context = gtk_widget_get_style_context (widget);
+ GtkStateFlags state = 0;
+ GdkRGBA fg, bg;
+
+ state |= gtk_widget_has_focus (widget) ? GTK_STATE_FLAG_SELECTED : GTK_STATE_FLAG_ACTIVE;
+
+ gtk_style_context_get_color (context, state, &fg);
+ text->pixel = 0;
+ text->red = CLAMP ((guint) (fg.red * 65535), 0, 65535);
+ text->green = CLAMP ((guint) (fg.green * 65535), 0, 65535);
+ text->blue = CLAMP ((guint) (fg.blue * 65535), 0, 65535);
+
+ gtk_style_context_get_background_color (context, state, &bg);
+ base->pixel = 0;
+ base->red = CLAMP ((guint) (bg.red * 65535), 0, 65535);
+ base->green = CLAMP ((guint) (bg.green * 65535), 0, 65535);
+ base->blue = CLAMP ((guint) (bg.blue * 65535), 0, 65535);
+}
+#else
get_selection_colors (GtkWidget *widget, GdkColor **text, GdkColor **base)
{
GtkStyle *style = gtk_widget_get_style (widget);
@@ -614,6 +636,7 @@ get_selection_colors (GtkWidget *widget, GdkColor **text, GdkColor **base)
*base = &style->base [GTK_STATE_ACTIVE];
}
}
+#endif
static void
add_job (EvPixbufCache *pixbuf_cache,
@@ -637,14 +660,22 @@ add_job (EvPixbufCache *pixbuf_cache,
width, height);
if (new_selection_surface_needed (pixbuf_cache, job_info, page, scale)) {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkColor text, base;
+#else
GdkColor *text, *base;
gtk_widget_ensure_style (pixbuf_cache->view);
+#endif
get_selection_colors (pixbuf_cache->view, &text, &base);
ev_job_render_set_selection_info (EV_JOB_RENDER (job_info->job),
&(job_info->target_points),
job_info->selection_style,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ &text, &base);
+#else
text, base);
+#endif
}
g_signal_connect (job_info->job, "finished",
@@ -952,7 +983,11 @@ ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache,
*/
if (ev_rect_cmp (&(job_info->target_points), &(job_info->selection_points))) {
EvRectangle *old_points;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkColor text, base;
+#else
GdkColor *text, *base;
+#endif
EvRenderContext *rc;
EvPage *ev_page;
@@ -977,7 +1012,9 @@ ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache,
rc, job_info->selection_style,
&(job_info->target_points));
+#if !GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_ensure_style (pixbuf_cache->view);
+#endif
get_selection_colors (pixbuf_cache->view, &text, &base);
@@ -986,7 +1023,11 @@ ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache,
&(job_info->target_points),
old_points,
job_info->selection_style,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ &text, &base);
+#else
text, base);
+#endif
job_info->selection_points = job_info->target_points;
g_object_unref (rc);
ev_document_doc_mutex_unlock ();