return retval;
}
-static GdkRegion *
-create_gdk_region_from_poppler_region (GList *region)
+static cairo_region_t *
+create_region_from_poppler_region (GList *region, gdouble scale)
{
GList *l;
- GdkRegion *retval;
-
- retval = gdk_region_new ();
-
+ cairo_region_t *retval;
+
+ retval = cairo_region_create ();
+
for (l = region; l; l = g_list_next (l)) {
- PopplerRectangle *rectangle;
- GdkRectangle rect;
-
+ PopplerRectangle *rectangle;
+ cairo_rectangle_int_t rect;
+
rectangle = (PopplerRectangle *)l->data;
-
- rect.x = (gint) rectangle->x1;
- rect.y = (gint) rectangle->y1;
- rect.width = (gint) (rectangle->x2 - rectangle->x1);
- rect.height = (gint) (rectangle->y2 - rectangle->y1);
- gdk_region_union_with_rect (retval, &rect);
-
+
+ rect.x = (gint) ((rectangle->x1 * scale) + 0.5);
+ rect.y = (gint) ((rectangle->y1 * scale) + 0.5);
+ rect.width = (gint) (((rectangle->x2 - rectangle->x1) * scale) + 0.5);
+ rect.height = (gint) (((rectangle->y2 - rectangle->y1) * scale) + 0.5);
+ cairo_region_union_rectangle (retval, &rect);
+
poppler_rectangle_free (rectangle);
}
return retval;
}
-static GdkRegion *
+static cairo_region_t *
pdf_selection_get_selection_region (EvSelection *selection,
EvRenderContext *rc,
EvSelectionStyle style,
EvRectangle *points)
{
- PopplerPage *poppler_page;
- GdkRegion *retval;
- GList *region;
+ PopplerPage *poppler_page;
+ cairo_region_t *retval;
+ GList *region;
poppler_page = POPPLER_PAGE (rc->page->backend_page);
-
region = poppler_page_get_selection_region (poppler_page,
- rc->scale,
+ 1.0,
(PopplerSelectionStyle)style,
(PopplerRectangle *) points);
- retval = create_gdk_region_from_poppler_region (region);
+ retval = create_region_from_poppler_region (region, rc->scale);
g_list_free (region);
return retval;
/* EvDocumentText */
-static GdkRegion *
+static cairo_region_t *
pdf_document_text_get_text_mapping (EvDocumentText *document_text,
EvPage *page)
{
PopplerPage *poppler_page;
PopplerRectangle points;
GList *region;
- GdkRegion *retval;
+ cairo_region_t *retval;
g_return_val_if_fail (POPPLER_IS_PAGE (page->backend_page), NULL);
region = poppler_page_get_selection_region (poppler_page, 1.0,
POPPLER_SELECTION_GLYPH,
&points);
- retval = create_gdk_region_from_poppler_region (region);
+ retval = create_region_from_poppler_region (region, 1.0);
g_list_free (region);
return retval;
AM_CONDITIONAL([PLATFORM_WIN32],[test "$with_platform" = "win32"])
dnl Specify required versions of dependencies
-GTK_REQUIRED=2.21.2
+GTK_REQUIRED=2.90.4
GLIB_REQUIRED=2.25.9
KEYRING_REQUIRED=2.22.0
AC_SUBST([GLIB_REQUIRED])
# SHELL_CFLAGS for shell implementation.
# SHELL_LIBS
-PKG_CHECK_MODULES(LIBDOCUMENT, gtk+-2.0 >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED)
-PKG_CHECK_MODULES(LIBVIEW, gtk+-2.0 >= $GTK_REQUIRED gail >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED)
-PKG_CHECK_MODULES(BACKEND, gtk+-2.0 >= $GTK_REQUIRED)
-PKG_CHECK_MODULES(FRONTEND_CORE, gtk+-2.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED)
-PKG_CHECK_MODULES(PREVIEWER, gtk+-2.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED)
+
+PKG_CHECK_MODULES(LIBDOCUMENT, gtk+-3.0 >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED)
+PKG_CHECK_MODULES(LIBVIEW, gtk+-3.0 >= $GTK_REQUIRED gail-3.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED)
+PKG_CHECK_MODULES(BACKEND, gtk+-3.0 >= $GTK_REQUIRED)
+PKG_CHECK_MODULES(FRONTEND_CORE, gtk+-3.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED)
+PKG_CHECK_MODULES(PREVIEWER, gtk+-3.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED)
SHELL_PLATFORM_PKGS=
case "$with_platform" in
;;
esac
-PKG_CHECK_MODULES([SHELL_CORE],[libxml-2.0 >= $LIBXML_REQUIRED gtk+-2.0 >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED gthread-2.0 $SHELL_PLATFORM_PKGS])
+PKG_CHECK_MODULES([SHELL_CORE],[libxml-2.0 >= $LIBXML_REQUIRED gtk+-3.0 >= $GTK_REQUIRED gio-2.0 >= $GLIB_REQUIRED gthread-2.0 $SHELL_PLATFORM_PKGS])
# *********
# SM client
# *********
-GDK_TARGET="$($PKG_CONFIG --variable target gdk-2.0)"
+GDK_TARGET="$($PKG_CONFIG --variable target gdk-3.0)"
AC_MSG_CHECKING([which smclient backend to use])
AC_ARG_WITH([smclient],
*) SMCLIENT_PKGS="" ;;
esac
- PKG_CHECK_MODULES([SMCLIENT],[gtk+-2.0 gthread-2.0 $SMCLIENT_PKGS])
+ PKG_CHECK_MODULES([SMCLIENT],[gtk+-3.0 gthread-2.0 $SMCLIENT_PKGS])
AC_SUBST([SMCLIENT_CFLAGS])
AC_SUBST([SMCLIENT_LIBS])
fi
AC_MSG_RESULT([$with_gtk_unix_print])
if test "$with_gtk_unix_print" = "yes"; then
- PKG_CHECK_MODULES(GTKUNIXPRINT, [gtk+-unix-print-2.0 >= $GTK_REQUIRED])
+ PKG_CHECK_MODULES(GTKUNIXPRINT, [gtk+-unix-print-3.0 >= $GTK_REQUIRED])
AC_DEFINE([GTKUNIXPRINT_ENABLED], [1], [Define if gtk+-unix-print is enabled.])
fi
esac])
if test "$enable_nautilus" = "yes" ; then
- PKG_CHECK_MODULES([NAUTILUS],[gtk+-x11-2.0 $MM gthread-2.0 libnautilus-extension],
+ PKG_CHECK_MODULES([NAUTILUS],[gtk+-x11-3.0 $MM gthread-2.0 libnautilus-extension],
[],[AC_MSG_ERROR([libnautilus-extension not found; use --disable-nautilus to disable the nautilus extensions])])
NAUTILUS_EXTENSION_DIR=`$PKG_CONFIG --variable=extensiondir libnautilus-extension`
AC_SUBST([nautilusextensiondir],[$NAUTILUS_EXTENSION_DIR])
esac])
if test x$enable_previewer = "xyes" ; then
- PKG_CHECK_MODULES([PREVIEWER],[gtk+-2.0 >= $GTK_REQUIRED gtk+-unix-print-2.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED])
+ PKG_CHECK_MODULES([PREVIEWER],[gtk+-3.0 >= $GTK_REQUIRED gtk+-unix-print-3.0 >= $GTK_REQUIRED gthread-2.0 gio-2.0 >= $GLIB_REQUIRED])
fi
AM_CONDITIONAL([ENABLE_PREVIEWER],[test "$enable_previewer" = "yes"])
GTK_DOC_CHECK([1.13],[--flavour no-tmpl])
AC_SUBST([GLIB_PREFIX],[$($PKG_CONFIG --variable=prefix glib-2.0)])
-AC_SUBST([GTK_PREFIX],[$($PKG_CONFIG --variable=prefix gtk+-2.0)])
+AC_SUBST([GTK_PREFIX],[$($PKG_CONFIG --variable=prefix gtk+-3.0)])
# ******************
# Backends directory
Name: Evince Document
Description: GNOME document viewer backend library
Version: @VERSION@
-Requires: gio-2.0 >= @GLIB_REQUIRED@ gtk+-2.0 >= @GTK_REQUIRED@
+Requires: gio-2.0 >= @GLIB_REQUIRED@ gtk+-3.0 >= @GTK_REQUIRED@
Libs: -L${libdir} -levdocument
Cflags: -I${includedir}
return iface->get_text_layout (document_text, page, areas, n_areas);
}
-GdkRegion *
+cairo_region_t *
ev_document_text_get_text_mapping (EvDocumentText *document_text,
EvPage *page)
{
GTypeInterface base_iface;
/* Methods */
- GdkRegion *(* get_text_mapping) (EvDocumentText *document_text,
- EvPage *page);
- gchar *(* get_text) (EvDocumentText *document_text,
- EvPage *page);
- gboolean (* get_text_layout) (EvDocumentText *document_text,
- EvPage *page,
- EvRectangle **areas,
- guint *n_areas);
+ cairo_region_t *(* get_text_mapping) (EvDocumentText *document_text,
+ EvPage *page);
+ gchar *(* get_text) (EvDocumentText *document_text,
+ EvPage *page);
+ gboolean (* get_text_layout) (EvDocumentText *document_text,
+ EvPage *page,
+ EvRectangle **areas,
+ guint *n_areas);
};
-GType ev_document_text_get_type (void) G_GNUC_CONST;
+GType ev_document_text_get_type (void) G_GNUC_CONST;
-gchar *ev_document_text_get_text (EvDocumentText *document_text,
- EvPage *page);
-gboolean ev_document_text_get_text_layout (EvDocumentText *document_text,
- EvPage *page,
- EvRectangle **areas,
- guint *n_areas);
-GdkRegion *ev_document_text_get_text_mapping (EvDocumentText *document_text,
- EvPage *page);
+gchar *ev_document_text_get_text (EvDocumentText *document_text,
+ EvPage *page);
+gboolean ev_document_text_get_text_layout (EvDocumentText *document_text,
+ EvPage *page,
+ EvRectangle **areas,
+ guint *n_areas);
+cairo_region_t *ev_document_text_get_text_mapping (EvDocumentText *document_text,
+ EvPage *page);
G_END_DECLS
return iface->get_selected_text (selection, page, style, points);
}
-GdkRegion *
+cairo_region_t *
ev_selection_get_selection_region (EvSelection *selection,
EvRenderContext *rc,
EvSelectionStyle style,
{
GTypeInterface base_iface;
- void (* render_selection) (EvSelection *selection,
- EvRenderContext *rc,
- cairo_surface_t **surface,
- EvRectangle *points,
- EvRectangle *old_points,
- EvSelectionStyle style,
- GdkColor *text,
- GdkColor *base);
- gchar * (* get_selected_text) (EvSelection *selection,
- EvPage *page,
- EvSelectionStyle style,
- EvRectangle *points);
- GdkRegion * (* get_selection_region) (EvSelection *selection,
- EvRenderContext *rc,
- EvSelectionStyle style,
- EvRectangle *points);
+ void (* render_selection) (EvSelection *selection,
+ EvRenderContext *rc,
+ cairo_surface_t **surface,
+ EvRectangle *points,
+ EvRectangle *old_points,
+ EvSelectionStyle style,
+ GdkColor *text,
+ GdkColor *base);
+ gchar * (* get_selected_text) (EvSelection *selection,
+ EvPage *page,
+ EvSelectionStyle style,
+ EvRectangle *points);
+ cairo_region_t * (* get_selection_region) (EvSelection *selection,
+ EvRenderContext *rc,
+ EvSelectionStyle style,
+ EvRectangle *points);
};
-GType ev_selection_get_type (void);
-void ev_selection_render_selection (EvSelection *selection,
- EvRenderContext *rc,
- cairo_surface_t **surface,
- EvRectangle *points,
- EvRectangle *old_points,
- EvSelectionStyle style,
- GdkColor *text,
- GdkColor *base);
-gchar *ev_selection_get_selected_text (EvSelection *selection,
- EvPage *page,
- EvSelectionStyle style,
- EvRectangle *points);
-GdkRegion *ev_selection_get_selection_region (EvSelection *selection,
- EvRenderContext *rc,
- EvSelectionStyle style,
- EvRectangle *points);
+GType ev_selection_get_type (void) G_GNUC_CONST;
+void ev_selection_render_selection (EvSelection *selection,
+ EvRenderContext *rc,
+ cairo_surface_t **surface,
+ EvRectangle *points,
+ EvRectangle *old_points,
+ EvSelectionStyle style,
+ GdkColor *text,
+ GdkColor *base);
+gchar *ev_selection_get_selected_text (EvSelection *selection,
+ EvPage *page,
+ EvSelectionStyle style,
+ EvRectangle *points);
+cairo_region_t *ev_selection_get_selection_region (EvSelection *selection,
+ EvRenderContext *rc,
+ EvSelectionStyle style,
+ EvRectangle *points);
G_END_DECLS
}
if (job->selection_region) {
- gdk_region_destroy (job->selection_region);
+ cairo_region_destroy (job->selection_region);
job->selection_region = NULL;
}
gboolean include_selection;
cairo_surface_t *selection;
- GdkRegion *selection_region;
+ cairo_region_t *selection_region;
EvRectangle selection_points;
EvSelectionStyle selection_style;
GdkColor base;
GList *image_mapping;
GList *form_field_mapping;
GList *annot_mapping;
- GdkRegion *text_mapping;
+ cairo_region_t *text_mapping;
gchar *text;
EvRectangle *text_layout;
guint text_layout_length;
#include "ev-page-cache.h"
typedef struct _EvPageCacheData {
- EvJob *job;
- gboolean done : 1;
-
- GList *link_mapping;
- GList *image_mapping;
- GList *form_field_mapping;
- GList *annot_mapping;
- GdkRegion *text_mapping;
- EvRectangle *text_layout;
- guint text_layout_length;
- gchar *text;
+ EvJob *job;
+ gboolean done : 1;
+
+ GList *link_mapping;
+ GList *image_mapping;
+ GList *form_field_mapping;
+ GList *annot_mapping;
+ cairo_region_t *text_mapping;
+ EvRectangle *text_layout;
+ guint text_layout_length;
+ gchar *text;
} EvPageCacheData;
struct _EvPageCache {
}
if (data->text_mapping) {
- gdk_region_destroy (data->text_mapping);
+ cairo_region_destroy (data->text_mapping);
data->text_mapping = NULL;
}
return data->annot_mapping;
}
-GdkRegion *
+cairo_region_t *
ev_page_cache_get_text_mapping (EvPageCache *cache,
gint page)
{
gint page);
GList *ev_page_cache_get_annot_mapping (EvPageCache *cache,
gint page);
-GdkRegion *ev_page_cache_get_text_mapping (EvPageCache *cache,
+cairo_region_t *ev_page_cache_get_text_mapping (EvPageCache *cache,
gint page);
const gchar *ev_page_cache_get_text (EvPageCache *cache,
gint page);
gboolean page_ready;
/* Region of the page that needs to be drawn */
- GdkRegion *region;
+ cairo_region_t *region;
/* Data we get from rendering */
cairo_surface_t *surface;
gboolean points_set;
cairo_surface_t *selection;
- GdkRegion *selection_region;
+ cairo_region_t *selection_region;
} CacheJobInfo;
struct _EvPixbufCache
job_info->surface = NULL;
}
if (job_info->region) {
- gdk_region_destroy (job_info->region);
+ cairo_region_destroy (job_info->region);
job_info->region = NULL;
}
if (job_info->selection) {
job_info->selection = NULL;
}
if (job_info->selection_region) {
- gdk_region_destroy (job_info->selection_region);
+ cairo_region_destroy (job_info->selection_region);
job_info->selection_region = NULL;
}
job_info->selection = NULL;
}
if (job_info->selection_region) {
- gdk_region_destroy (job_info->selection_region);
+ cairo_region_destroy (job_info->selection_region);
job_info->selection_region = NULL;
}
job_info->selection_points = job_render->selection_points;
- job_info->selection_region = gdk_region_copy (job_render->selection_region);
+ job_info->selection_region = cairo_region_reference (job_render->selection_region);
job_info->selection = cairo_surface_reference (job_render->selection);
g_assert (job_info->selection_points.x1 >= 0);
job_info->points_set = TRUE;
}
static void
-add_job (EvPixbufCache *pixbuf_cache,
- CacheJobInfo *job_info,
- GdkRegion *region,
- gint width,
- gint height,
- gint page,
- gint rotation,
- gfloat scale,
- EvJobPriority priority)
+add_job (EvPixbufCache *pixbuf_cache,
+ CacheJobInfo *job_info,
+ cairo_region_t *region,
+ gint width,
+ gint height,
+ gint page,
+ gint rotation,
+ gfloat scale,
+ EvJobPriority priority)
{
job_info->page_ready = FALSE;
if (job_info->region)
- gdk_region_destroy (job_info->region);
- job_info->region = region ? gdk_region_copy (region) : NULL;
+ cairo_region_destroy (job_info->region);
+ job_info->region = region ? cairo_region_reference (region) : NULL;
job_info->job = ev_job_render_new (pixbuf_cache->document,
page, rotation, scale,
}
cairo_surface_t *
-ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache,
- gint page,
- gfloat scale,
- GdkRegion **region)
+ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache,
+ gint page,
+ gfloat scale,
+ cairo_region_t **region)
{
CacheJobInfo *job_info;
g_object_unref (ev_page);
if (job_info->selection_region)
- gdk_region_destroy (job_info->selection_region);
+ cairo_region_destroy (job_info->selection_region);
job_info->selection_region =
ev_selection_get_selection_region (EV_SELECTION (pixbuf_cache->document),
rc, job_info->selection_style,
selection->page = page;
selection->rect = pixbuf_cache->prev_job[i].selection_points;
if (pixbuf_cache->prev_job[i].selection_region)
- selection->covered_region = gdk_region_copy (pixbuf_cache->prev_job[i].selection_region);
+ selection->covered_region = cairo_region_reference (pixbuf_cache->prev_job[i].selection_region);
retval = g_list_append (retval, selection);
}
selection->page = page;
selection->rect = pixbuf_cache->job_list[i].selection_points;
if (pixbuf_cache->job_list[i].selection_region)
- selection->covered_region = gdk_region_copy (pixbuf_cache->job_list[i].selection_region);
+ selection->covered_region = cairo_region_reference (pixbuf_cache->job_list[i].selection_region);
retval = g_list_append (retval, selection);
}
selection->page = page;
selection->rect = pixbuf_cache->next_job[i].selection_points;
if (pixbuf_cache->next_job[i].selection_region)
- selection->covered_region = gdk_region_copy (pixbuf_cache->next_job[i].selection_region);
+ selection->covered_region = cairo_region_reference (pixbuf_cache->next_job[i].selection_region);
retval = g_list_append (retval, selection);
}
}
void
-ev_pixbuf_cache_reload_page (EvPixbufCache *pixbuf_cache,
- GdkRegion *region,
- gint page,
- gint rotation,
- gdouble scale)
+ev_pixbuf_cache_reload_page (EvPixbufCache *pixbuf_cache,
+ cairo_region_t *region,
+ gint page,
+ gint rotation,
+ gdouble scale)
{
CacheJobInfo *job_info;
gint width, height;
typedef struct {
int page;
EvRectangle rect;
- GdkRegion *covered_region;
+ cairo_region_t *covered_region;
EvSelectionStyle style;
} EvViewSelection;
gint page);
void ev_pixbuf_cache_clear (EvPixbufCache *pixbuf_cache);
void ev_pixbuf_cache_style_changed (EvPixbufCache *pixbuf_cache);
-void ev_pixbuf_cache_reload_page (EvPixbufCache *pixbuf_cache,
- GdkRegion *region,
- gint page,
- gint rotation,
- gdouble scale);
+void ev_pixbuf_cache_reload_page (EvPixbufCache *pixbuf_cache,
+ cairo_region_t *region,
+ gint page,
+ gint rotation,
+ gdouble scale);
void ev_pixbuf_cache_set_inverted_colors (EvPixbufCache *pixbuf_cache,
gboolean inverted_colors);
/* Selection */
-cairo_surface_t *ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache,
- gint page,
- gfloat scale,
- GdkRegion **region);
+cairo_surface_t *ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache,
+ gint page,
+ gfloat scale,
+ cairo_region_t **region);
void ev_pixbuf_cache_set_selection_list (EvPixbufCache *pixbuf_cache,
GList *selection_list);
GList *ev_pixbuf_cache_get_selection_list (EvPixbufCache *pixbuf_cache);
static void hide_loading_window (EvView *view);
static void ev_view_reload_page (EvView *view,
gint page,
- GdkRegion *region);
+ cairo_region_t *region);
static void ev_view_loading_window_move (EvView *view);
/*** Callbacks ***/
static void ev_view_change_page (EvView *view,
gint new_page);
static void job_finished_cb (EvPixbufCache *pixbuf_cache,
- GdkRegion *region,
+ cairo_region_t *region,
EvView *view);
static void ev_view_page_changed_cb (EvDocumentModel *model,
gint old_page,
{
GtkWidget *widget = GTK_WIDGET (view);
GtkAdjustment *adjustment = view->vadjustment;
- GdkRegion *text_region, *region;
+ cairo_region_t *text_region, *region;
GtkAllocation allocation;
gint page;
GdkRectangle rect;
EvRectangle doc_rect;
GdkRectangle page_area;
GtkBorder border;
- GdkRectangle *recs;
- gint n_recs;
gdouble fraction = 1.0;
if (scroll != GTK_SCROLL_PAGE_BACKWARD && scroll != GTK_SCROLL_PAGE_FORWARD)
page = scroll == GTK_SCROLL_PAGE_BACKWARD ? view->start_page : view->end_page;
text_region = ev_page_cache_get_text_mapping (view->page_cache, page);
- if (!text_region || gdk_region_empty (text_region))
+ if (!text_region || cairo_region_is_empty (text_region))
return gtk_adjustment_get_page_size (adjustment);
gtk_widget_get_allocation (widget, &allocation);
rect.y = doc_rect.y1;
rect.width = doc_rect.x2 - doc_rect.x1;
rect.height = MAX (1, doc_rect.y2 - doc_rect.y1);
- region = gdk_region_rectangle (&rect);
+ region = cairo_region_create_rectangle (&rect);
- gdk_region_intersect (region, text_region);
- gdk_region_get_rectangles (region, &recs, &n_recs);
- gdk_region_destroy (region);
- if (n_recs > 0) {
+ cairo_region_intersect (region, text_region);
+ if (cairo_region_num_rectangles (region)) {
EvRenderContext *rc;
EvPage *ev_page;
+ cairo_region_t *sel_region;
+ cairo_region_get_rectangle (region, 0, &rect);
ev_page = ev_document_get_page (view->document, page);
rc = ev_render_context_new (ev_page, view->rotation, view->scale);
g_object_unref (ev_page);
/* Get the selection region to know the height of the line */
- doc_rect.x1 = doc_rect.x2 = recs[0].x + 0.5;
- doc_rect.y1 = doc_rect.y2 = recs[0].y + 0.5;
+ doc_rect.x1 = doc_rect.x2 = rect.x + 0.5;
+ doc_rect.y1 = doc_rect.y2 = rect.y + 0.5;
ev_document_doc_mutex_lock ();
- region = ev_selection_get_selection_region (EV_SELECTION (view->document),
- rc, EV_SELECTION_STYLE_LINE,
- &doc_rect);
+ sel_region = ev_selection_get_selection_region (EV_SELECTION (view->document),
+ rc, EV_SELECTION_STYLE_LINE,
+ &doc_rect);
ev_document_doc_mutex_unlock ();
g_object_unref (rc);
- g_free (recs);
- gdk_region_get_rectangles (region, &recs, &n_recs);
- gdk_region_destroy (region);
- if (n_recs > 0) {
- fraction = 1 - (recs[0].height / gtk_adjustment_get_page_size (adjustment));
+
+ if (cairo_region_num_rectangles (sel_region) > 0) {
+ cairo_region_get_rectangle (sel_region, 0, &rect);
+ fraction = 1 - (rect.height / gtk_adjustment_get_page_size (adjustment));
}
- g_free (recs);
+ cairo_region_destroy (sel_region);
}
+ cairo_region_destroy (region);
return gtk_adjustment_get_page_size (adjustment) * fraction;
gdouble x,
gdouble y)
{
- GdkRegion *region;
+ cairo_region_t *region;
gint page = -1;
gint x_offset = 0, y_offset = 0;
region = ev_page_cache_get_text_mapping (view->page_cache, page);
if (region)
- return gdk_region_point_in (region, x_offset / view->scale, y_offset / view->scale);
+ return cairo_region_contains_point (region, x_offset / view->scale, y_offset / view->scale);
else
return FALSE;
}
continue;
if (selection->covered_region &&
- gdk_region_point_in (selection->covered_region, x_offset, y_offset))
+ cairo_region_contains_point (selection->covered_region, x_offset, y_offset))
return TRUE;
}
return NULL;
}
-static GdkRegion *
+static cairo_region_t *
ev_view_form_field_get_region (EvView *view,
EvFormField *field)
{
forms_mapping,
field, &view_area);
- return gdk_region_rectangle (&view_area);
+ return cairo_region_create_rectangle (&view_area);
}
static gboolean
EvFormField *field)
{
EvFormFieldButton *field_button = EV_FORM_FIELD_BUTTON (field);
- GdkRegion *field_region = NULL;
+ cairo_region_t *field_region = NULL;
switch (field_button->type) {
case EV_FORM_FIELD_BUTTON_PUSH:
field->page->index);
for (l = forms_mapping; l; l = g_list_next (l)) {
EvFormField *button = ((EvMapping *)(l->data))->data;
- GdkRegion *button_region;
+ cairo_region_t *button_region;
if (button->id == field->id)
continue;
continue;
button_region = ev_view_form_field_get_region (view, button);
- gdk_region_union (field_region, button_region);
- gdk_region_destroy (button_region);
+ cairo_region_union (field_region, button_region);
+ cairo_region_destroy (button_region);
}
ev_document_forms_form_field_button_set_state (EV_DOCUMENT_FORMS (view->document),
}
ev_view_reload_page (view, field->page->index, field_region);
- gdk_region_destroy (field_region);
+ cairo_region_destroy (field_region);
return NULL;
}
if (field->changed) {
EvFormFieldText *field_text = EV_FORM_FIELD_TEXT (field);
- GdkRegion *field_region;
+ cairo_region_t *field_region;
field_region = ev_view_form_field_get_region (view, field);
field, field_text->text);
field->changed = FALSE;
ev_view_reload_page (view, field->page->index, field_region);
- gdk_region_destroy (field_region);
+ cairo_region_destroy (field_region);
}
}
if (field->changed) {
GList *l;
EvFormFieldChoice *field_choice = EV_FORM_FIELD_CHOICE (field);
- GdkRegion *field_region;
+ cairo_region_t *field_region;
field_region = ev_view_form_field_get_region (view, field);
}
field->changed = FALSE;
ev_view_reload_page (view, field->page->index, field_region);
- gdk_region_destroy (field_region);
+ cairo_region_destroy (field_region);
}
}
cairo_surface_set_device_offset (selection_surface,
overlap.x - real_page_area.x,
overlap.y - real_page_area.y);
+
cairo_set_source_surface (cr, selection_surface, 0, 0);
cairo_paint (cr);
cairo_restore (cr);
}
static void
-job_finished_cb (EvPixbufCache *pixbuf_cache,
- GdkRegion *region,
- EvView *view)
+job_finished_cb (EvPixbufCache *pixbuf_cache,
+ cairo_region_t *region,
+ EvView *view)
{
if (region) {
GdkWindow *bin_window;
}
static void
-ev_view_reload_page (EvView *view,
- gint page,
- GdkRegion *region)
+ev_view_reload_page (EvView *view,
+ gint page,
+ cairo_region_t *region)
{
ev_pixbuf_cache_reload_page (view->pixbuf_cache,
region,
while (new_list_ptr || old_list_ptr) {
EvViewSelection *old_sel, *new_sel;
int cur_page;
- GdkRegion *region = NULL;
+ cairo_region_t *region = NULL;
new_sel = (new_list_ptr) ? (new_list_ptr->data) : NULL;
old_sel = (old_list_ptr) ? (old_list_ptr->data) : NULL;
/* seed the cache with a new page. We are going to need the new
* region too. */
if (new_sel) {
- GdkRegion *tmp_region = NULL;
+ cairo_region_t *tmp_region = NULL;
ev_pixbuf_cache_get_selection_surface (view->pixbuf_cache,
cur_page,
view->scale,
&tmp_region);
- if (tmp_region && !gdk_region_empty (tmp_region)) {
- new_sel->covered_region = gdk_region_copy (tmp_region);
+ if (tmp_region && !cairo_region_is_empty (tmp_region)) {
+ new_sel->covered_region = cairo_region_reference (tmp_region);
}
}
/* Now we figure out what needs redrawing */
if (old_sel && new_sel) {
if (old_sel->covered_region && new_sel->covered_region) {
+ cairo_region_t *tbr;
+
/* We only want to redraw the areas that have
* changed, so we xor the old and new regions
* and redraw if it's different */
- region = gdk_region_copy (old_sel->covered_region);
- gdk_region_xor (region, new_sel->covered_region);
- if (gdk_region_empty (region)) {
- gdk_region_destroy (region);
+ region = cairo_region_copy (old_sel->covered_region);
+ tbr = cairo_region_copy (new_sel->covered_region);
+
+ /* xor old_sel, new_sel*/
+ cairo_region_subtract (tbr, region);
+ cairo_region_subtract (region, new_sel->covered_region);
+ cairo_region_union (region, tbr);
+ cairo_region_destroy (tbr);
+
+ if (cairo_region_is_empty (region)) {
+ cairo_region_destroy (region);
region = NULL;
+ } else {
+ gint num_rectangles = cairo_region_num_rectangles (region);
+ GdkRectangle r;
+
+ /* We need to make the damage region a little bigger
+ * because the edges of the old selection might change
+ */
+ cairo_region_get_rectangle (region, 0, &r);
+ r.x -= 5;
+ r.width = 5;
+ cairo_region_union_rectangle (region, &r);
+
+ cairo_region_get_rectangle (region, num_rectangles - 1, &r);
+ r.x += r.width;
+ r.width = 5;
+ cairo_region_union_rectangle (region, &r);
}
} else if (old_sel->covered_region) {
- region = gdk_region_copy (old_sel->covered_region);
+ region = cairo_region_copy (old_sel->covered_region);
} else if (new_sel->covered_region) {
- region = gdk_region_copy (new_sel->covered_region);
+ region = cairo_region_copy (new_sel->covered_region);
}
} else if (old_sel && !new_sel) {
- if (old_sel->covered_region && !gdk_region_empty (old_sel->covered_region)) {
- region = gdk_region_copy (old_sel->covered_region);
+ if (old_sel->covered_region && !cairo_region_is_empty (old_sel->covered_region)) {
+ region = cairo_region_copy (old_sel->covered_region);
}
} else if (!old_sel && new_sel) {
- if (new_sel->covered_region && !gdk_region_empty (new_sel->covered_region)) {
- region = gdk_region_copy (new_sel->covered_region);
+ if (new_sel->covered_region && !cairo_region_is_empty (new_sel->covered_region)) {
+ region = cairo_region_copy (new_sel->covered_region);
}
} else {
g_assert_not_reached ();
GtkBorder border;
bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (view));
-
- /* I don't know why but the region is smaller
- * than expected. This hack fixes it, I guess
- * 10 pixels more won't hurt
- */
- gdk_region_shrink (region, -5, -5);
-
ev_view_get_page_extents (view, cur_page, &page_area, &border);
- gdk_region_offset (region,
+ cairo_region_translate (region,
page_area.x + border.left - view->scroll_x,
page_area.y + border.top - view->scroll_y);
gdk_window_invalidate_region (bin_window, region, TRUE);
- gdk_region_destroy (region);
+ cairo_region_destroy (region);
}
}
selection_free (EvViewSelection *selection)
{
if (selection->covered_region)
- gdk_region_destroy (selection->covered_region);
+ cairo_region_destroy (selection->covered_region);
g_free (selection);
}
* the region code.
*/
void
-ev_print_region_contents (GdkRegion *region)
+ev_print_region_contents (cairo_region_t *region)
{
- GdkRectangle *rectangles = NULL;
gint n_rectangles, i;
if (region == NULL) {
}
g_print ("<region %p>\n", region);
- gdk_region_get_rectangles (region, &rectangles, &n_rectangles);
+ n_rectangles = cairo_region_num_rectangles (region);
for (i = 0; i < n_rectangles; i++) {
+ GdkRectangle rect;
+
+ cairo_region_get_rectangle (region, i, &rect);
g_print ("\t(%d %d, %d %d) [%dx%d]\n",
- rectangles[i].x,
- rectangles[i].y,
- rectangles[i].x + rectangles[i].width,
- rectangles[i].y + rectangles[i].height,
- rectangles[i].width,
- rectangles[i].height);
+ rect.x,
+ rect.y,
+ rect.x + rect.width,
+ rect.y + rect.height,
+ rect.width,
+ rect.height);
}
- g_free (rectangles);
}
static void
GdkPixbuf* ev_pixbuf_add_shadow (GdkPixbuf *src, int size,
int x_offset, int y_offset, double opacity);
-void ev_print_region_contents (GdkRegion *region);
+void ev_print_region_contents (cairo_region_t *region);
void ev_gui_menu_position_tree_selection (GtkMenu *menu,
gint *x,