Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/backend
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2007-08-31 20:37:24 (GMT)
committer Carlos Garcia Campos <carlosgc@src.gnome.org>2007-08-31 20:37:24 (GMT)
commit982600bbceb76a22d5c7b3e0cbe6e20421105ad6 (patch)
tree1d233d670a447357a7d41044660881e4475f2658 /backend
parentf76fa765536d1f5875699606d0a78c6f132fce1e (diff)
Add support for double and triple click selections.
2007-08-31 Carlos Garcia Campos <carlosgc@gnome.org> * backend/dvi/dvi-document.c: (dvi_document_document_iface_init): * backend/impress/impress-document.c: (impress_document_document_iface_init): * backend/ps/ps-document.c: (ps_document_document_iface_init): * backend/djvu/djvu-document.c: (djvu_document_document_iface_init), (djvu_selection_get_selected_text), (djvu_selection_iface_init): * backend/tiff/tiff-document.c: (tiff_document_document_iface_init): * backend/pixbuf/pixbuf-document.c: (pixbuf_document_document_iface_init): * backend/comics/comics-document.c: (comics_document_document_iface_init): * backend/pdf/ev-poppler.cc: (pdf_document_document_iface_init), (pdf_selection_render_selection), (pdf_selection_get_selected_text), (pdf_selection_get_selection_region), (pdf_selection_get_selection_map), (pdf_selection_iface_init): * libdocument/ev-selection.[ch]: (ev_selection_get_selected_text), (ev_selection_get_selection_region), (ev_selection_get_selection_map): * libdocument/ev-document.[ch]: * shell/ev-pixbuf-cache.[ch]: (add_job), (ev_pixbuf_cache_get_selection_surface), (update_job_selection): * shell/ev-view-private.h: * shell/ev-jobs.[ch]: (ev_job_render_new), (ev_job_render_new), (ev_job_render_run): * shell/ev-window.c: (ev_window_setup_action_sensitivity): * shell/ev-view.c: (start_selection_for_event), (ev_view_button_press_event), (ev_view_drag_data_get), (ev_view_drag_data_received), (ev_view_button_release_event), (compute_new_selection_text), (compute_selections), (ev_view_select_all), (get_selected_text), (ev_view_copy), (ev_view_primary_get_cb): Add support for double and triple click selections. svn path=/trunk/; revision=2648
Diffstat (limited to 'backend')
-rw-r--r--backend/comics/comics-document.c7
-rw-r--r--backend/djvu/djvu-document.c66
-rw-r--r--backend/dvi/dvi-document.c7
-rw-r--r--backend/impress/impress-document.c7
-rw-r--r--backend/pdf/ev-poppler.cc75
-rw-r--r--backend/pixbuf/pixbuf-document.c7
-rw-r--r--backend/ps/ps-document.c7
-rw-r--r--backend/tiff/tiff-document.c7
8 files changed, 73 insertions, 110 deletions
diff --git a/backend/comics/comics-document.c b/backend/comics/comics-document.c
index 092d8c2..77e6fab 100644
--- a/backend/comics/comics-document.c
+++ b/backend/comics/comics-document.c
@@ -367,12 +367,6 @@ comics_document_class_init (ComicsDocumentClass *klass)
gobject_class->finalize = comics_document_finalize;
}
-static gboolean
-comics_document_can_get_text (EvDocument *document)
-{
- return FALSE;
-}
-
static EvDocumentInfo *
comics_document_get_info (EvDocument *document)
{
@@ -386,7 +380,6 @@ comics_document_document_iface_init (EvDocumentIface *iface)
{
iface->load = comics_document_load;
iface->save = comics_document_save;
- iface->can_get_text = comics_document_can_get_text;
iface->get_n_pages = comics_document_get_n_pages;
iface->get_page_size = comics_document_get_page_size;
iface->render = comics_document_render;
diff --git a/backend/djvu/djvu-document.c b/backend/djvu/djvu-document.c
index 4a7aecc..2b9dee7 100644
--- a/backend/djvu/djvu-document.c
+++ b/backend/djvu/djvu-document.c
@@ -26,6 +26,7 @@
#include "ev-document-misc.h"
#include "ev-document-find.h"
#include "ev-document-links.h"
+#include "ev-selection.h"
#include <gdk-pixbuf/gdk-pixbuf-core.h>
#include <glib/gi18n.h>
@@ -51,6 +52,7 @@ static void djvu_document_document_thumbnails_iface_init (EvDocumentThumbnailsIf
static void djvu_document_file_exporter_iface_init (EvFileExporterIface *iface);
static void djvu_document_find_iface_init (EvDocumentFindIface *iface);
static void djvu_document_document_links_iface_init (EvDocumentLinksIface *iface);
+static void djvu_selection_iface_init (EvSelectionIface *iface);
G_DEFINE_TYPE_WITH_CODE
(DjvuDocument, djvu_document, G_TYPE_OBJECT,
@@ -60,6 +62,7 @@ G_DEFINE_TYPE_WITH_CODE
G_IMPLEMENT_INTERFACE (EV_TYPE_FILE_EXPORTER, djvu_document_file_exporter_iface_init);
G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_FIND, djvu_document_find_iface_init);
G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_LINKS, djvu_document_document_links_iface_init);
+ G_IMPLEMENT_INTERFACE (EV_TYPE_SELECTION, djvu_selection_iface_init);
});
@@ -317,35 +320,6 @@ djvu_document_class_init (DjvuDocumentClass *klass)
gobject_class->finalize = djvu_document_finalize;
}
-static gboolean
-djvu_document_can_get_text (EvDocument *document)
-{
- return TRUE;
-}
-
-
-static char *
-djvu_document_get_text (EvDocument *document, int page, EvRectangle *rect)
-{
- DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
- double width, height;
- EvRectangle rectangle;
- char* text;
-
- djvu_document_get_page_size (document, page, &width, &height);
- rectangle.x1 = rect->x1 / SCALE_FACTOR;
- rectangle.y1 = (height - rect->y2) / SCALE_FACTOR;
- rectangle.x2 = rect->x2 / SCALE_FACTOR;
- rectangle.y2 = (height - rect->y1) / SCALE_FACTOR;
-
- text = djvu_text_copy (djvu_document, page, &rectangle);
-
- if (text == NULL)
- text = g_strdup ("");
-
- return text;
-}
-
static EvDocumentInfo *
djvu_document_get_info (EvDocument *document)
{
@@ -361,14 +335,44 @@ djvu_document_document_iface_init (EvDocumentIface *iface)
{
iface->load = djvu_document_load;
iface->save = djvu_document_save;
- iface->can_get_text = djvu_document_can_get_text;
- iface->get_text = djvu_document_get_text;
iface->get_n_pages = djvu_document_get_n_pages;
iface->get_page_size = djvu_document_get_page_size;
iface->render = djvu_document_render;
iface->get_info = djvu_document_get_info;
}
+static gchar *
+djvu_selection_get_selected_text (EvSelection *selection,
+ EvRenderContext *rc,
+ EvSelectionStyle style,
+ EvRectangle *points)
+{
+ DjvuDocument *djvu_document = DJVU_DOCUMENT (selection);
+ double width, height;
+ EvRectangle rectangle;
+ gchar *text;
+
+ djvu_document_get_page_size (EV_DOCUMENT (djvu_document),
+ rc->page, &width, &height);
+ rectangle.x1 = points->x1 / SCALE_FACTOR;
+ rectangle.y1 = (height - points->y2) / SCALE_FACTOR;
+ rectangle.x2 = points->x2 / SCALE_FACTOR;
+ rectangle.y2 = (height - points->y1) / SCALE_FACTOR;
+
+ text = djvu_text_copy (djvu_document, rc->page, &rectangle);
+
+ if (text == NULL)
+ text = g_strdup ("");
+
+ return text;
+}
+
+static void
+djvu_selection_iface_init (EvSelectionIface *iface)
+{
+ iface->get_selected_text = djvu_selection_get_selected_text;
+}
+
static void
djvu_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
EvRenderContext *rc,
diff --git a/backend/dvi/dvi-document.c b/backend/dvi/dvi-document.c
index b6f8325..73b148b 100644
--- a/backend/dvi/dvi-document.c
+++ b/backend/dvi/dvi-document.c
@@ -250,12 +250,6 @@ dvi_document_class_init (DviDocumentClass *klass)
dvi_context_mutex = g_mutex_new ();
}
-static gboolean
-dvi_document_can_get_text (EvDocument *document)
-{
- return FALSE;
-}
-
static EvDocumentInfo *
dvi_document_get_info (EvDocument *document)
{
@@ -271,7 +265,6 @@ dvi_document_document_iface_init (EvDocumentIface *iface)
{
iface->load = dvi_document_load;
iface->save = dvi_document_save;
- iface->can_get_text = dvi_document_can_get_text;
iface->get_n_pages = dvi_document_get_n_pages;
iface->get_page_size = dvi_document_get_page_size;
iface->render = dvi_document_render;
diff --git a/backend/impress/impress-document.c b/backend/impress/impress-document.c
index 6251fbd..74d335a 100644
--- a/backend/impress/impress-document.c
+++ b/backend/impress/impress-document.c
@@ -458,12 +458,6 @@ impress_document_class_init (ImpressDocumentClass *klass)
gobject_class->finalize = impress_document_finalize;
}
-static gboolean
-impress_document_can_get_text (EvDocument *document)
-{
- return FALSE;
-}
-
static EvDocumentInfo *
impress_document_get_info (EvDocument *document)
{
@@ -480,7 +474,6 @@ impress_document_document_iface_init (EvDocumentIface *iface)
{
iface->load = impress_document_load;
iface->save = impress_document_save;
- iface->can_get_text = impress_document_can_get_text;
iface->get_n_pages = impress_document_get_n_pages;
iface->get_page_size = impress_document_get_page_size;
iface->render = impress_document_render;
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index 815862c..09edfb4 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -568,12 +568,6 @@ pdf_document_set_password (EvDocumentSecurity *document_security,
document->password = g_strdup (password);
}
-static gboolean
-pdf_document_can_get_text (EvDocument *document)
-{
- return TRUE;
-}
-
static EvDocumentInfo *
pdf_document_get_info (EvDocument *document)
{
@@ -719,31 +713,6 @@ pdf_document_get_info (EvDocument *document)
return info;
}
-static char *
-pdf_document_get_text (EvDocument *document, int page, EvRectangle *rect)
-{
- PdfDocument *pdf_document = PDF_DOCUMENT (document);
- PopplerPage *poppler_page;
- PopplerRectangle r;
- double height;
- char *text;
-
- poppler_page = poppler_document_get_page (pdf_document->document, page);
- g_return_val_if_fail (poppler_page != NULL, NULL);
-
- poppler_page_get_size (poppler_page, NULL, &height);
- r.x1 = rect->x1;
- r.y1 = height - rect->y2;
- r.x2 = rect->x2;
- r.y2 = height - rect->y1;
-
- text = poppler_page_get_text (poppler_page, &r);
-
- g_object_unref (poppler_page);
-
- return text;
-}
-
static void
pdf_document_document_iface_init (EvDocumentIface *iface)
{
@@ -755,8 +724,6 @@ pdf_document_document_iface_init (EvDocumentIface *iface)
iface->has_attachments = pdf_document_has_attachments;
iface->get_attachments = pdf_document_get_attachments;
iface->render = pdf_document_render;
- iface->get_text = pdf_document_get_text;
- iface->can_get_text = pdf_document_can_get_text;
iface->get_info = pdf_document_get_info;
};
@@ -1792,6 +1759,7 @@ pdf_selection_render_selection (EvSelection *selection,
cairo_surface_t **surface,
EvRectangle *points,
EvRectangle *old_points,
+ EvSelectionStyle style,
GdkColor *text,
GdkColor *base)
{
@@ -1807,7 +1775,6 @@ pdf_selection_render_selection (EvSelection *selection,
width = (int) ((width_points * rc->scale) + 0.5);
height = (int) ((height_points * rc->scale) + 0.5);
-
#ifdef HAVE_POPPLER_PAGE_RENDER
cairo_t *cr;
@@ -1827,7 +1794,7 @@ pdf_selection_render_selection (EvSelection *selection,
cr,
(PopplerRectangle *)points,
(PopplerRectangle *)old_points,
- POPPLER_SELECTION_NORMAL, /* SelectionStyle */
+ (PopplerSelectionStyle)style,
text,
base);
cairo_destroy (cr);
@@ -1842,7 +1809,7 @@ pdf_selection_render_selection (EvSelection *selection,
rc->scale, rc->rotation, pixbuf,
(PopplerRectangle *)points,
(PopplerRectangle *)old_points,
- POPPLER_SELECTION_NORMAL, /* SelectionStyle */
+ (PopplerSelectionStyle)style,
text,
base);
if (*surface)
@@ -1852,10 +1819,40 @@ pdf_selection_render_selection (EvSelection *selection,
#endif /* HAVE_POPPLER_PAGE_RENDER */
}
+static gchar *
+pdf_selection_get_selected_text (EvSelection *selection,
+ EvRenderContext *rc,
+ EvSelectionStyle style,
+ EvRectangle *points)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (selection);
+ PopplerPage *poppler_page;
+ PopplerRectangle r;
+ double height;
+ char *retval;
+
+ poppler_page = poppler_document_get_page (pdf_document->document, rc->page);
+ g_return_val_if_fail (poppler_page != NULL, NULL);
+
+ poppler_page_get_size (poppler_page, NULL, &height);
+ r.x1 = points->x1;
+ r.y1 = height - points->y2;
+ r.x2 = points->x2;
+ r.y2 = height - points->y1;
+
+ retval = poppler_page_get_text (poppler_page,
+ (PopplerSelectionStyle)style,
+ &r);
+
+ g_object_unref (poppler_page);
+
+ return retval;
+}
static GdkRegion *
pdf_selection_get_selection_region (EvSelection *selection,
EvRenderContext *rc,
+ EvSelectionStyle style,
EvRectangle *points)
{
PdfDocument *pdf_document;
@@ -1867,6 +1864,7 @@ pdf_selection_get_selection_region (EvSelection *selection,
retval = poppler_page_get_selection_region ((PopplerPage *)rc->data,
rc->scale,
+ (PopplerSelectionStyle)style,
(PopplerRectangle *) points);
return retval;
}
@@ -1887,7 +1885,9 @@ pdf_selection_get_selection_map (EvSelection *selection,
points.x1 = 0.0;
points.y1 = 0.0;
poppler_page_get_size (poppler_page, &(points.x2), &(points.y2));
- retval = poppler_page_get_selection_region (poppler_page, 1.0, &points);
+ retval = poppler_page_get_selection_region (poppler_page, 1.0,
+ POPPLER_SELECTION_GLYPH,
+ &points);
g_object_unref (poppler_page);
return retval;
@@ -1897,6 +1897,7 @@ static void
pdf_selection_iface_init (EvSelectionIface *iface)
{
iface->render_selection = pdf_selection_render_selection;
+ iface->get_selected_text = pdf_selection_get_selected_text;
iface->get_selection_region = pdf_selection_get_selection_region;
iface->get_selection_map = pdf_selection_get_selection_map;
}
diff --git a/backend/pixbuf/pixbuf-document.c b/backend/pixbuf/pixbuf-document.c
index 83d2b8a..b9b98a6 100644
--- a/backend/pixbuf/pixbuf-document.c
+++ b/backend/pixbuf/pixbuf-document.c
@@ -143,12 +143,6 @@ pixbuf_document_class_init (PixbufDocumentClass *klass)
gobject_class->finalize = pixbuf_document_finalize;
}
-static gboolean
-pixbuf_document_can_get_text (EvDocument *document)
-{
- return FALSE;
-}
-
static EvDocumentInfo *
pixbuf_document_get_info (EvDocument *document)
{
@@ -165,7 +159,6 @@ pixbuf_document_document_iface_init (EvDocumentIface *iface)
{
iface->load = pixbuf_document_load;
iface->save = pixbuf_document_save;
- iface->can_get_text = pixbuf_document_can_get_text;
iface->get_n_pages = pixbuf_document_get_n_pages;
iface->get_page_size = pixbuf_document_get_page_size;
iface->render = pixbuf_document_render;
diff --git a/backend/ps/ps-document.c b/backend/ps/ps-document.c
index 5e63687..61f07ab 100644
--- a/backend/ps/ps-document.c
+++ b/backend/ps/ps-document.c
@@ -415,12 +415,6 @@ ps_document_get_page_size (EvDocument *document,
}
}
-static gboolean
-ps_document_can_get_text (EvDocument *document)
-{
- return FALSE;
-}
-
static EvDocumentInfo *
ps_document_get_info (EvDocument *document)
{
@@ -454,7 +448,6 @@ ps_document_document_iface_init (EvDocumentIface *iface)
{
iface->load = ps_document_load;
iface->save = ps_document_save;
- iface->can_get_text = ps_document_can_get_text;
iface->get_n_pages = ps_document_get_n_pages;
iface->get_page_size = ps_document_get_page_size;
iface->get_info = ps_document_get_info;
diff --git a/backend/tiff/tiff-document.c b/backend/tiff/tiff-document.c
index c6f4db2..f813c47 100644
--- a/backend/tiff/tiff-document.c
+++ b/backend/tiff/tiff-document.c
@@ -373,12 +373,6 @@ tiff_document_class_init (TiffDocumentClass *klass)
gobject_class->finalize = tiff_document_finalize;
}
-static gboolean
-tiff_document_can_get_text (EvDocument *document)
-{
- return FALSE;
-}
-
static EvDocumentInfo *
tiff_document_get_info (EvDocument *document)
{
@@ -395,7 +389,6 @@ tiff_document_document_iface_init (EvDocumentIface *iface)
{
iface->load = tiff_document_load;
iface->save = tiff_document_save;
- iface->can_get_text = tiff_document_can_get_text;
iface->get_n_pages = tiff_document_get_n_pages;
iface->get_page_size = tiff_document_get_page_size;
iface->render = tiff_document_render;