]> www.fi.muni.cz Git - evince.git/commitdiff
Initial support for document info. Based on jrb patch.
authorMarco Pesenti Gritti <mpg@redhat.com>
Tue, 19 Apr 2005 16:03:53 +0000 (16:03 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Tue, 19 Apr 2005 16:03:53 +0000 (16:03 +0000)
2005-04-19  Marco Pesenti Gritti <mpg@redhat.com>

        * 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
backend/Makefile.am
backend/ev-document.c
backend/ev-document.h
pdf/ev-poppler.cc

index b42aace2a1830a8dc2596a4e2c6460df1408f5c0..c53b7e8144301c58f665fbf6c89b6f6fbeaafc38 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-04-19  Marco Pesenti Gritti <mpg@redhat.com>
+
+       * 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 <pborelli@katamail.com>
 
        * shell/ev-window.c: (ev_window_state_event),
index be844588d3ea92d05cde6bf0c3aee1ddff946784..b85f62d0c7437e66ee958c327ca5769acd681c3a 100644 (file)
@@ -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                               \
index 124a626154f1be0ff0d38ab9aa09cdb3da8465ce..6aa0504cfbca4af500e3fa3dc5d171ae75f8fb2e 100644 (file)
@@ -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;
+
+}
index 6cdf8d24c45559bcc3168c2cdc5639f5607341d6..d8f8eba0d51efe64dc93c2cd16fac506541942d2 100644 (file)
@@ -27,6 +27,7 @@
 #include <gdk/gdk.h>
 
 #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
index 1599f2f24906ad9af5336f45514bb36e5d8757fe..95ea00e5a91d02387bcdb12ab75f4b24b3b535c9 100644 (file)
@@ -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