summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libview/ev-pixbuf-cache.c41
-rw-r--r--libview/ev-view.c46
2 files changed, 80 insertions, 7 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 ();
diff --git a/libview/ev-view.c b/libview/ev-view.c
index e3b4c9f6..13ad9555 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -191,8 +191,12 @@ static gboolean ev_view_enter_notify_event (GtkWidget
GdkEventCrossing *event);
static gboolean ev_view_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void ev_view_style_updated (GtkWidget *widget);
+#else
static void ev_view_style_set (GtkWidget *widget,
GtkStyle *old_style);
+#endif
static void ev_view_remove_all (EvView *view);
static AtkObject *ev_view_get_accessible (GtkWidget *widget);
@@ -4329,13 +4333,21 @@ ev_view_enter_notify_event (GtkWidget *widget, GdkEventCrossing *event)
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+ev_view_style_updated (GtkWidget *widget)
+#else
ev_view_style_set (GtkWidget *widget,
GtkStyle *old_style)
+#endif
{
if (EV_VIEW (widget)->pixbuf_cache)
ev_pixbuf_cache_style_changed (EV_VIEW (widget)->pixbuf_cache);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GTK_WIDGET_CLASS (ev_view_parent_class)->style_updated (widget);
+#else
GTK_WIDGET_CLASS (ev_view_parent_class)->style_set (widget, old_style);
+#endif
}
/*** Drawing ***/
@@ -4346,6 +4358,13 @@ draw_rubberband (EvView *view,
const GdkRectangle *rect,
gdouble alpha)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkStyleContext *context;
+ GdkRGBA color;
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (view));
+ gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &color);
+#else
GtkStyle *style;
GdkColor *fill_color_gdk;
gdouble r, g, b;
@@ -4355,10 +4374,15 @@ draw_rubberband (EvView *view,
r = fill_color_gdk->red / 65535.;
g = fill_color_gdk->green / 65535.;
b = fill_color_gdk->blue / 65535.;
+#endif
cairo_save (cr);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_set_source_rgba (cr, color.red, color.green, color.blue, alpha);
+#else
cairo_set_source_rgba (cr, r, g, b, alpha);
+#endif
cairo_rectangle (cr,
rect->x - view->scroll_x,
rect->y - view->scroll_y,
@@ -4366,12 +4390,18 @@ draw_rubberband (EvView *view,
cairo_fill_preserve (cr);
cairo_set_line_width (cr, 0.5);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_set_source_rgb (cr, color.red, color.green, color.blue);
+#else
cairo_set_source_rgb (cr, r, g, b);
+#endif
cairo_stroke (cr);
cairo_restore (cr);
+#if !GTK_CHECK_VERSION (3, 0, 0)
gdk_color_free (fill_color_gdk);
+#endif
}
@@ -4436,13 +4466,11 @@ focus_annotation (EvView *view,
doc_rect_to_view_rect (view, page, &mapping->area, &rect);
#if GTK_CHECK_VERSION (3, 0, 0)
- gtk_paint_focus (gtk_widget_get_style (widget),
- cr,
- gtk_widget_get_state (widget),
- widget, NULL,
- rect.x - view->scroll_x,
- rect.y - view->scroll_y,
- rect.width + 1, rect.height + 1);
+ gtk_render_focus (gtk_widget_get_style_context (widget),
+ cr,
+ rect.x - view->scroll_x,
+ rect.y - view->scroll_y,
+ rect.width + 1, rect.height + 1);
#else
gtk_paint_focus (gtk_widget_get_style (widget),
gtk_layout_get_bin_window (GTK_LAYOUT (view)),
@@ -4879,7 +4907,11 @@ ev_view_class_init (EvViewClass *class)
widget_class->scroll_event = ev_view_scroll_event;
widget_class->enter_notify_event = ev_view_enter_notify_event;
widget_class->leave_notify_event = ev_view_leave_notify_event;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ widget_class->style_updated = ev_view_style_updated;
+#else
widget_class->style_set = ev_view_style_set;
+#endif
widget_class->drag_data_get = ev_view_drag_data_get;
widget_class->drag_motion = ev_view_drag_motion;
widget_class->popup_menu = ev_view_popup_menu;