]> www.fi.muni.cz Git - evince.git/commitdiff
Switch to GTK+ 3
authorCarlos Garcia Campos <carlosgc@gnome.org>
Thu, 8 Jul 2010 08:22:11 +0000 (10:22 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Thu, 8 Jul 2010 08:22:11 +0000 (10:22 +0200)
16 files changed:
backend/pdf/ev-poppler.cc
configure.ac
evince-document.pc.in
libdocument/ev-document-text.c
libdocument/ev-document-text.h
libdocument/ev-selection.c
libdocument/ev-selection.h
libview/ev-jobs.c
libview/ev-jobs.h
libview/ev-page-cache.c
libview/ev-page-cache.h
libview/ev-pixbuf-cache.c
libview/ev-pixbuf-cache.h
libview/ev-view.c
shell/ev-utils.c
shell/ev-utils.h

index 6e56423692a5ffc9cf6f4904d409a9bbcf94dd9b..655d5897f8b893668721bca813b0c2ba2225f3e3 100644 (file)
@@ -1925,49 +1925,48 @@ pdf_selection_get_selected_text (EvSelection     *selection,
        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;
@@ -1983,14 +1982,14 @@ pdf_selection_iface_init (EvSelectionInterface *iface)
 
 
 /* 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);
 
@@ -2003,7 +2002,7 @@ pdf_document_text_get_text_mapping (EvDocumentText *document_text,
        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;
index 83ee95fe88538d8e59fd46b7cbe83402cc23c020..5135ecb64f16f213a96c25ad32ade24048c5ee34 100644 (file)
@@ -122,7 +122,7 @@ AM_CONDITIONAL([PLATFORM_HILDON],[test "$with_platform" = "hildon"])
 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])
@@ -140,11 +140,12 @@ dnl Check dependencies
 # 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
@@ -170,13 +171,13 @@ 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],
@@ -202,7 +203,7 @@ if test "$with_smclient" != "no"; then
     *) 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
@@ -239,7 +240,7 @@ AC_ARG_WITH([gtk-unix-print],
 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
 
@@ -371,7 +372,7 @@ AC_ARG_ENABLE([nautilus],
     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])
@@ -410,7 +411,7 @@ AC_ARG_ENABLE([previewer],
     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"])
@@ -732,7 +733,7 @@ AM_CONDITIONAL(ENABLE_HELP, test "x$enable_help" = "xyes")
 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
index 537fb73a0c78bed69a84c5ee9da5eb976edc97c4..b7e3dc0d8ad4fc02b6faaeb4a9d40f4ec3895efe 100644 (file)
@@ -7,6 +7,6 @@ backenddir=@libdir@/evince/@EV_BINARY_VERSION@/backends
 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}
index fac43567145be25d82bfd4e4d3caa501091c3627..56c1a563911df51eb50c453f5978bd826b2c2d47 100644 (file)
@@ -57,7 +57,7 @@ ev_document_text_get_text_layout (EvDocumentText   *document_text,
        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)
 {
index bb6c34b7f50b7bea284df63024efe58f86ca21fa..abf1cc762e18430a870ff9b5bc7044e24f267a7c 100644 (file)
@@ -49,26 +49,26 @@ struct _EvDocumentTextInterface
         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
 
index a34e863b2328aa870e10c2cb7bcdf1bb4e1d8c3c..49e56eb434ae3967e54d5b439571ec557a828a1d 100644 (file)
@@ -62,7 +62,7 @@ ev_selection_get_selected_text (EvSelection      *selection,
        return iface->get_selected_text (selection, page, style, points);
 }
 
-GdkRegion *
+cairo_region_t *
 ev_selection_get_selection_region (EvSelection     *selection,
                                   EvRenderContext *rc,
                                   EvSelectionStyle style,
index 5c9c7180ae6685e75b13b83ef0b1003fc800189a..dff12e0a40235472384a79cfeb43f0859d5f128f 100644 (file)
@@ -52,41 +52,41 @@ struct _EvSelectionInterface
 {
        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
 
index 7e522dfd756496ef57423ec943ea71b5bebfa9ff..abb82fbebac1d10e2b3408d890d26cf68f0464bc 100644 (file)
@@ -462,7 +462,7 @@ ev_job_render_dispose (GObject *object)
        }
 
        if (job->selection_region) {
-               gdk_region_destroy (job->selection_region);
+               cairo_region_destroy (job->selection_region);
                job->selection_region = NULL;
        }
 
index 2e53ff1c911e78d7550db1fb2dbcc6cf3464a7f5..6844520ca89b46901f4e249f11ccd07e1645a806 100644 (file)
@@ -212,7 +212,7 @@ struct _EvJobRender
 
        gboolean include_selection;
        cairo_surface_t *selection;
-       GdkRegion *selection_region;
+       cairo_region_t *selection_region;
        EvRectangle selection_points;
        EvSelectionStyle selection_style;
        GdkColor base;
@@ -247,7 +247,7 @@ struct _EvJobPageData
        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;
index e519217ef675486cbd65ec0d594dc6298e4459ac..a2ae8c5779f9eed8479ea4cb0f75767f48de265a 100644 (file)
 #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 {
@@ -92,7 +92,7 @@ ev_page_cache_data_free (EvPageCacheData *data)
        }
 
        if (data->text_mapping) {
-               gdk_region_destroy (data->text_mapping);
+               cairo_region_destroy (data->text_mapping);
                data->text_mapping = NULL;
        }
 
@@ -340,7 +340,7 @@ ev_page_cache_get_annot_mapping (EvPageCache *cache,
        return data->annot_mapping;
 }
 
-GdkRegion *
+cairo_region_t *
 ev_page_cache_get_text_mapping (EvPageCache *cache,
                                gint         page)
 {
index 0abd7e549604cd1b3e614cf57a2b7318e8de89eb..c6ccfd39f6184129d5bc0c1e9fa140f82c1a4d5d 100644 (file)
@@ -55,7 +55,7 @@ GList             *ev_page_cache_get_form_field_mapping (EvPageCache       *cach
                                                         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);
index 42dd1def5349ccfb22056b5e35140583232212de..4eb5c0e0e06b9dddc66a776136250e56389223fc 100644 (file)
@@ -13,7 +13,7 @@ typedef struct _CacheJobInfo
        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;
@@ -27,7 +27,7 @@ typedef struct _CacheJobInfo
        gboolean         points_set;
        
        cairo_surface_t *selection;
-       GdkRegion *selection_region;
+       cairo_region_t  *selection_region;
 } CacheJobInfo;
 
 struct _EvPixbufCache
@@ -174,7 +174,7 @@ dispose_cache_job_info (CacheJobInfo *job_info,
                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) {
@@ -182,7 +182,7 @@ dispose_cache_job_info (CacheJobInfo *job_info,
                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;
        }
 
@@ -259,12 +259,12 @@ copy_job_to_job_info (EvJobRender   *job_render,
                        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;
@@ -620,21 +620,21 @@ get_selection_colors (GtkWidget *widget, GdkColor **text, GdkColor **base)
 }
 
 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,
@@ -920,10 +920,10 @@ ev_pixbuf_cache_style_changed (EvPixbufCache *pixbuf_cache)
 }
 
 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;
 
@@ -975,7 +975,7 @@ ev_pixbuf_cache_get_selection_surface (EvPixbufCache  *pixbuf_cache,
                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,
@@ -1131,7 +1131,7 @@ ev_pixbuf_cache_get_selection_list (EvPixbufCache *pixbuf_cache)
                        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);
                }
                
@@ -1145,7 +1145,7 @@ ev_pixbuf_cache_get_selection_list (EvPixbufCache *pixbuf_cache)
                        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);
                }
                
@@ -1161,7 +1161,7 @@ ev_pixbuf_cache_get_selection_list (EvPixbufCache *pixbuf_cache)
                        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);
                }
                
@@ -1172,11 +1172,11 @@ ev_pixbuf_cache_get_selection_list (EvPixbufCache *pixbuf_cache)
 }
 
 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;
index a2c190ad8aee917e353fab9488a6b16eba1c0e30..2faf2a7752e22dafbd2c852c3a9cd5f8e898b9e3 100644 (file)
@@ -47,7 +47,7 @@ G_BEGIN_DECLS
 typedef struct {
        int page;
        EvRectangle rect;
-       GdkRegion *covered_region;
+       cairo_region_t *covered_region;
        EvSelectionStyle style;
 } EvViewSelection;
 
@@ -68,18 +68,18 @@ cairo_surface_t *ev_pixbuf_cache_get_surface        (EvPixbufCache *pixbuf_cache
                                                     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);
index a473d0aca902629604a699f28563d5caeb0f65a3..1adf772c346281b9b4c7d4844170cc0c4d71a551 100644 (file)
@@ -189,14 +189,14 @@ static void       show_loading_window                        (EvView
 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,
@@ -803,15 +803,13 @@ compute_scroll_increment (EvView        *view,
 {
        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)
@@ -820,7 +818,7 @@ compute_scroll_increment (EvView        *view,
        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);
@@ -836,37 +834,37 @@ compute_scroll_increment (EvView        *view,
        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;
 
@@ -1363,7 +1361,7 @@ location_in_text (EvView  *view,
                  gdouble  x,
                  gdouble  y)
 {
-       GdkRegion *region;
+       cairo_region_t *region;
        gint page = -1;
        gint x_offset = 0, y_offset = 0;
 
@@ -1375,7 +1373,7 @@ location_in_text (EvView  *view,
        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;
 }
@@ -1399,7 +1397,7 @@ location_in_selected_text (EvView  *view,
                        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;
        }
 
@@ -1921,7 +1919,7 @@ ev_view_get_form_field_at_location (EvView  *view,
                return NULL;
 }
 
-static GdkRegion *
+static cairo_region_t *
 ev_view_form_field_get_region (EvView      *view,
                               EvFormField *field)
 {
@@ -1934,7 +1932,7 @@ ev_view_form_field_get_region (EvView      *view,
                                       forms_mapping,
                                       field, &view_area);
 
-       return gdk_region_rectangle (&view_area);
+       return cairo_region_create_rectangle (&view_area);
 }
 
 static gboolean
@@ -1957,7 +1955,7 @@ ev_view_form_field_button_create_widget (EvView      *view,
                                         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:
@@ -1984,7 +1982,7 @@ ev_view_form_field_button_create_widget (EvView      *view,
                                                                              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;
@@ -1996,8 +1994,8 @@ ev_view_form_field_button_create_widget (EvView      *view,
                                        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),
@@ -2008,7 +2006,7 @@ ev_view_form_field_button_create_widget (EvView      *view,
        }
 
        ev_view_reload_page (view, field->page->index, field_region);
-       gdk_region_destroy (field_region);
+       cairo_region_destroy (field_region);
        
        return NULL;
 }
@@ -2026,7 +2024,7 @@ ev_view_form_field_text_save (EvView    *view,
        
        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);
                
@@ -2034,7 +2032,7 @@ ev_view_form_field_text_save (EvView    *view,
                                                            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);
        }
 }
 
@@ -2134,7 +2132,7 @@ ev_view_form_field_choice_save (EvView    *view,
        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);
 
@@ -2151,7 +2149,7 @@ ev_view_form_field_choice_save (EvView    *view,
                }
                field->changed = FALSE;
                ev_view_reload_page (view, field->page->index, field_region);
-               gdk_region_destroy (field_region);
+               cairo_region_destroy (field_region);
        }
 }
 
@@ -4231,6 +4229,7 @@ draw_one_page (EvView       *view,
                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);
@@ -4510,9 +4509,9 @@ ev_view_change_page (EvView *view,
 }
 
 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;
@@ -4954,9 +4953,9 @@ ev_view_set_model (EvView          *view,
 }
 
 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,
@@ -5549,7 +5548,7 @@ merge_selection_region (EvView *view,
        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;
@@ -5584,42 +5583,67 @@ merge_selection_region (EvView *view,
                /* 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 ();
@@ -5632,19 +5656,12 @@ merge_selection_region (EvView *view,
                        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);
                }
        }
 
@@ -5674,7 +5691,7 @@ static void
 selection_free (EvViewSelection *selection)
 {
        if (selection->covered_region)
-               gdk_region_destroy (selection->covered_region);
+               cairo_region_destroy (selection->covered_region);
        g_free (selection);
 }
 
index 5c5e165f979dec47d06c36d1a787b3d1c22af674..83cfcdbc90b59e6f1a28e083ad0dd8391cbf0dcc 100644 (file)
@@ -187,9 +187,8 @@ ev_pixbuf_add_shadow (GdkPixbuf *src, int size,
  * 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) {
@@ -198,17 +197,19 @@ ev_print_region_contents (GdkRegion *region)
        }
 
        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
index 611ba9bb3ddf3c6ac4c72b0675ffa4bf0a0b751f..81acc4630d8ee3675af35cc228e6edc3ab755419 100644 (file)
@@ -29,7 +29,7 @@ G_BEGIN_DECLS
 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,