From 6202bf1580c2792a061729aa469b590626551c0d Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 19 Apr 2005 16:03:53 +0000 Subject: [PATCH] Initial support for document info. Based on jrb patch. 2005-04-19 Marco Pesenti Gritti * backend/Makefile.am: * backend/ev-document.c: (ev_document_render_get_info): * backend/ev-document.h: * pdf/ev-poppler.cc: Initial support for document info. Based on jrb patch. --- ChangeLog | 9 ++++ backend/Makefile.am | 1 + backend/ev-document.c | 18 ++++++++ backend/ev-document.h | 4 ++ pdf/ev-poppler.cc | 96 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 128 insertions(+) diff --git a/ChangeLog b/ChangeLog index b42aace2..c53b7e81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-04-19 Marco Pesenti Gritti + + * backend/Makefile.am: + * backend/ev-document.c: (ev_document_render_get_info): + * backend/ev-document.h: + * pdf/ev-poppler.cc: + + Initial support for document info. Based on jrb patch. + 2005-04-19 Paolo Borelli * shell/ev-window.c: (ev_window_state_event), diff --git a/backend/Makefile.am b/backend/Makefile.am index be844588..b85f62d0 100644 --- a/backend/Makefile.am +++ b/backend/Makefile.am @@ -23,6 +23,7 @@ libevbackend_la_SOURCES= \ ev-document-security.h \ ev-document-find.c \ ev-document-find.h \ + ev-document-info.h \ ev-job-queue.h \ ev-job-queue.c \ ev-jobs.h \ diff --git a/backend/ev-document.c b/backend/ev-document.c index 124a6261..6aa0504c 100644 --- a/backend/ev-document.c +++ b/backend/ev-document.c @@ -237,3 +237,21 @@ ev_document_render_pixbuf (EvDocument *document, return retval; } + +EvDocumentInfo * +ev_document_render_get_info (EvDocument *document) +{ + EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); + EvDocumentInfo *retval = NULL; + + LOG ("ev_document_render_pixbuf"); + + if (iface->get_info != NULL) + retval = iface->get_info (document); + + if (retval == NULL) + retval = g_new0 (EvDocumentInfo, 1); + + return retval; + +} diff --git a/backend/ev-document.h b/backend/ev-document.h index 6cdf8d24..d8f8eba0 100644 --- a/backend/ev-document.h +++ b/backend/ev-document.h @@ -27,6 +27,7 @@ #include #include "ev-link.h" +#include "ev-document-info.h" G_BEGIN_DECLS @@ -88,6 +89,7 @@ struct _EvDocumentIface GdkPixbuf * (* render_pixbuf) (EvDocument *document, int page, double scale); + EvDocumentInfo *(* get_info) (EvDocument *document); }; GType ev_document_get_type (void); @@ -96,6 +98,7 @@ EvPageCache *ev_document_get_page_cache (EvDocument *document); GMutex *ev_document_get_doc_mutex (void); +EvDocumentInfo *ev_document_get_info (EvDocument *document); gboolean ev_document_load (EvDocument *document, const char *uri, GError **error); @@ -119,6 +122,7 @@ GList *ev_document_get_links (EvDocument *document, GdkPixbuf *ev_document_render_pixbuf (EvDocument *document, int page, double scale); +EvDocumentInfo *ev_document_render_get_info (EvDocument *document); G_END_DECLS diff --git a/pdf/ev-poppler.cc b/pdf/ev-poppler.cc index 1599f2f2..95ea00e5 100644 --- a/pdf/ev-poppler.cc +++ b/pdf/ev-poppler.cc @@ -330,6 +330,101 @@ pdf_document_can_get_text (EvDocument *document) return TRUE; } +static EvDocumentInfo * +pdf_document_get_info (EvDocument *document) +{ + EvDocumentInfo *info; + PopplerPageLayout layout; + PopplerPageMode mode; + PopplerViewerPreferences view_prefs; + + info = g_new0 (EvDocumentInfo, 1); + + info->fields_mask = EV_DOCUMENT_INFO_TITLE | + EV_DOCUMENT_INFO_FORMAT | + EV_DOCUMENT_INFO_AUTHOR | + EV_DOCUMENT_INFO_SUBJECT | + EV_DOCUMENT_INFO_KEYWORDS | + EV_DOCUMENT_INFO_LAYOUT | + EV_DOCUMENT_INFO_START_MODE | + /* Missing EV_DOCUMENT_INFO_CREATION_DATE | */ + EV_DOCUMENT_INFO_UI_HINTS; + + + g_object_get (PDF_DOCUMENT (document)->document, + "title", &(info->title), + "format", &(info->format), + "author", &(info->author), + "subject", &(info->subject), + "keywords", &(info->keywords), + "page-mode", &mode, + "page-layout", &layout, + "viewer-preferences", &view_prefs, + NULL); + + switch (layout) { + case POPPLER_PAGE_LAYOUT_SINGLE_PAGE: + info->layout = EV_DOCUMENT_LAYOUT_SINGLE_PAGE; + break; + case POPPLER_PAGE_LAYOUT_ONE_COLUMN: + info->layout = EV_DOCUMENT_LAYOUT_ONE_COLUMN; + break; + case POPPLER_PAGE_LAYOUT_TWO_COLUMN_LEFT: + info->layout = EV_DOCUMENT_LAYOUT_TWO_COLUMN_LEFT; + break; + case POPPLER_PAGE_LAYOUT_TWO_COLUMN_RIGHT: + info->layout = EV_DOCUMENT_LAYOUT_TWO_COLUMN_RIGHT; + case POPPLER_PAGE_LAYOUT_TWO_PAGE_LEFT: + info->layout = EV_DOCUMENT_LAYOUT_TWO_PAGE_LEFT; + break; + case POPPLER_PAGE_LAYOUT_TWO_PAGE_RIGHT: + info->layout = EV_DOCUMENT_LAYOUT_TWO_PAGE_RIGHT; + break; + } + + switch (mode) { + case POPPLER_PAGE_MODE_NONE: + info->mode = EV_DOCUMENT_MODE_NONE; + break; + case POPPLER_PAGE_MODE_USE_THUMBS: + info->mode = EV_DOCUMENT_MODE_USE_THUMBS; + break; + case POPPLER_PAGE_MODE_USE_OC: + info->mode = EV_DOCUMENT_MODE_USE_OC; + break; + case POPPLER_PAGE_MODE_FULL_SCREEN: + info->mode = EV_DOCUMENT_MODE_FULL_SCREEN; + break; + case POPPLER_PAGE_MODE_USE_ATTACHMENTS: + info->mode = EV_DOCUMENT_MODE_USE_ATTACHMENTS; + } + + info->ui_hints = 0; + if (view_prefs & POPPLER_VIEWER_PREFERENCES_HIDE_TOOLBAR) { + info->ui_hints |= EV_DOCUMENT_UI_HINT_HIDE_TOOLBAR; + } + if (view_prefs & POPPLER_VIEWER_PREFERENCES_HIDE_MENUBAR) { + info->ui_hints |= EV_DOCUMENT_UI_HINT_HIDE_MENUBAR; + } + if (view_prefs & POPPLER_VIEWER_PREFERENCES_HIDE_WINDOWUI) { + info->ui_hints |= EV_DOCUMENT_UI_HINT_HIDE_WINDOWUI; + } + if (view_prefs & POPPLER_VIEWER_PREFERENCES_FIT_WINDOW) { + info->ui_hints |= EV_DOCUMENT_UI_HINT_FIT_WINDOW; + } + if (view_prefs & POPPLER_VIEWER_PREFERENCES_CENTER_WINDOW) { + info->ui_hints |= EV_DOCUMENT_UI_HINT_CENTER_WINDOW; + } + if (view_prefs & POPPLER_VIEWER_PREFERENCES_DISPLAY_DOC_TITLE) { + info->ui_hints |= EV_DOCUMENT_UI_HINT_DISPLAY_DOC_TITLE; + } + if (view_prefs & POPPLER_VIEWER_PREFERENCES_DIRECTION_RTL) { + info->ui_hints |= EV_DOCUMENT_UI_HINT_DIRECTION_RTL; + } + + return info; +} + static char * pdf_document_get_text (EvDocument *document, int page, EvRectangle *rect) { @@ -362,6 +457,7 @@ pdf_document_document_iface_init (EvDocumentIface *iface) iface->render_pixbuf = pdf_document_render_pixbuf; iface->get_text = pdf_document_get_text; iface->can_get_text = pdf_document_can_get_text; + iface->get_info = pdf_document_get_info; }; static void -- 2.43.5