[poppler] poppler/glib: Makefile.am, 1.5, 1.6 poppler-action.h, 1.1, 1.2 poppler-document.cc, 1.7, 1.8 poppler-document.h, 1.7, 1.8 poppler-enums.c, NONE, 1.1 poppler-enums.h, NONE, 1.1 poppler-page.cc, 1.14, 1.15 poppler-page.h, 1.11, 1.12 poppler.h, 1.4, 1.5 test-poppler-glib.c, 1.7, 1.8

Jonathan Blandford jrb at freedesktop.org
Sat Apr 16 11:57:46 PDT 2005


Update of /cvs/poppler/poppler/glib
In directory gabe:/tmp/cvs-serv30513/glib

Modified Files:
	Makefile.am poppler-action.h poppler-document.cc 
	poppler-document.h poppler-page.cc poppler-page.h poppler.h 
	test-poppler-glib.c 
Added Files:
	poppler-enums.c poppler-enums.h 
Log Message:
Sat Apr 16 14:53:15 2005  Jonathan Blandford  <jrb at redhat.com>

        * glib/Makefile.am: Create poppler-enums.[ch]

        * glib/poppler.h:
        * glib/poppler-page.cc:
        * glib/poppler-page.h:
        * glib/poppler-action.h: Try to clean up the headers a bit

        * glib/poppler-document.cc:
        * glib/poppler-document.h: Add support for document data.
        Implemented as a lot of GObject properties.

        * glib/poppler-enums.c:
        * glib/poppler-enums.h: New autogenerated files.

        * glib/test-poppler-glib.c: Test the new document metadata.  Seems
        to work nicely, other than the PDF string and View Prefs.

        * poppler/Catalog.cc:
        * poppler/Catalog.h: Extend to support PageLayout.



Index: Makefile.am
===================================================================
RCS file: /cvs/poppler/poppler/glib/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile.am	5 Apr 2005 17:46:44 -0000	1.5
+++ Makefile.am	16 Apr 2005 18:57:44 -0000	1.6
@@ -17,16 +17,44 @@
 	$(cairo_includes)			\
 	-DDATADIR=\""$(datadir)"\"
 
-poppler_glib_includedir = $(includedir)/poppler/glib
-poppler_glib_include_HEADERS =			\
+
+
+
+poppler-enums.h: poppler-document.h
+	( cd $(srcdir) && glib-mkenums \
+			--fhead "#ifndef __POPPLER_TYPE_ENUMS_H__\n#define __POPPLER_TYPE_ENUMS_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
+			--fprod "/* enumerations from \"@filename@\" */\n" \
+			--vhead "GType @enum_name at _get_type (void) G_GNUC_CONST;\n#define POPPLER_TYPE_ at ENUMSHORT@ (@enum_name at _get_type())\n" \
+			--ftail "G_END_DECLS\n\n#endif /* __POPPLER_TYPE_ENUMS_H__ */" \
+		$(poppler_glib_public_headers) ) > poppler-enums.h
+
+poppler-enums.c: poppler-document.h
+	( cd $(srcdir) && glib-mkenums \
+			--fhead "#include \"poppler-enums.h\"\n#include \"poppler-document.h\"\n" \
+			--ftail "#define __POPPLER_ENUMS_C__\n" \
+			--fprod "\n/* enumerations from \"@filename@\" */" \
+			--vhead "GType\n at enum_name@_get_type (void)\n{\n  static GType etype = 0;\n  if (etype == 0) {\n    static const G at Type@Value values[] = {" \
+			--vprod "      { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
+			--vtail "      { 0, NULL, NULL }\n    };\n    etype = g_ at type@_register_static (\"@EnumName@\", values);\n  }\n  return etype;\n}\n" \
+		$(poppler_glib_public_headers) ) > poppler-enums.c
+
+
+poppler_glib_public_headers =			\
 	poppler-action.h			\
 	poppler-document.h			\
 	poppler-page.h				\
 	poppler.h
 
+poppler_glib_includedir = $(includedir)/poppler/glib
+
+poppler_glib_include_HEADERS =			\
+	$(poppler_glib_public_headers)		\
+	poppler-enums.h
+
 lib_LTLIBRARIES = libpoppler-glib.la
 libpoppler_glib_la_SOURCES =			\
 	poppler-action.cc			\
+	poppler-enums.c				\
 	poppler-document.cc			\
 	poppler-page.cc				\
 	poppler.cc				\

Index: poppler-action.h
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-action.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- poppler-action.h	30 Mar 2005 04:07:57 -0000	1.1
+++ poppler-action.h	16 Apr 2005 18:57:44 -0000	1.2
@@ -27,13 +27,13 @@
 
 typedef enum
 {
-	POPPLER_ACTION_UNKNOWN,		// unknown action
-	POPPLER_ACTION_GOTO_DEST,	// go to destination
-	POPPLER_ACTION_GOTO_REMOTE,	// go to destination in new file
-	POPPLER_ACTION_LAUNCH,		// launch app (or open document)
-	POPPLER_ACTION_URI,		// URI
-	POPPLER_ACTION_NAMED,		// named action
-	POPPLER_ACTION_MOVIE,		// movie action
+	POPPLER_ACTION_UNKNOWN,		/* unknown action */
+	POPPLER_ACTION_GOTO_DEST,	/* go to destination */
+	POPPLER_ACTION_GOTO_REMOTE,	/* go to destination in new file */
+	POPPLER_ACTION_LAUNCH,		/* launch app (or open document) */
+	POPPLER_ACTION_URI,		/* URI */
+	POPPLER_ACTION_NAMED,		/* named action*/
+	POPPLER_ACTION_MOVIE,		/* movie action */
 } PopplerActionType;
 
 typedef enum
@@ -50,7 +50,6 @@
 } PopplerDestType;
 
 /* Define the PopplerAction types */
-typedef union  _PopplerAction           PopplerAction;
 typedef struct _PopplerActionAny        PopplerActionAny;
 typedef struct _PopplerActionGotoDest   PopplerActionGotoDest;
 typedef struct _PopplerActionGotoRemote PopplerActionGotoRemote;

Index: poppler-document.cc
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-document.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- poppler-document.cc	7 Apr 2005 22:01:51 -0000	1.7
+++ poppler-document.cc	16 Apr 2005 18:57:44 -0000	1.8
@@ -29,10 +29,18 @@
 
 #include "poppler.h"
 #include "poppler-private.h"
+#include "poppler-enums.h"
 
 enum {
 	PROP_0,
-	PROP_TITLE
+	PROP_TITLE,
+	PROP_FORMAT,
+	PROP_AUTHOR,
+	PROP_SUBJECT,
+	PROP_KEYWORDS,
+	PROP_PAGE_LAYOUT,
+	PROP_PAGE_MODE,
+	PROP_VIEWER_PREFERENCES,
 };
 
 typedef struct _PopplerDocumentClass PopplerDocumentClass;
@@ -224,24 +232,107 @@
   g_free (result);
 }
 
+static PopplerPageLayout
+convert_page_layout (Catalog::PageLayout pageLayout)
+{
+  switch (pageLayout)
+    {
+    case Catalog::pageLayoutSinglePage:
+      return POPPLER_PAGE_LAYOUT_SINGLE_PAGE;
+    case Catalog::pageLayoutOneColumn:
+      return POPPLER_PAGE_LAYOUT_ONE_COLUMN;
+    case Catalog::pageLayoutTwoColumnLeft:
+      return POPPLER_PAGE_LAYOUT_TWO_COLUMN_LEFT;
+    case Catalog::pageLayoutTwoColumnRight:
+      return POPPLER_PAGE_LAYOUT_TWO_COLUMN_RIGHT;
+    case Catalog::pageLayoutTwoPageLeft:
+      return POPPLER_PAGE_LAYOUT_TWO_PAGE_LEFT;
+    case Catalog::pageLayoutTwoPageRight:
+      return POPPLER_PAGE_LAYOUT_TWO_PAGE_RIGHT;
+    case Catalog::pageLayoutNone:
+    default:
+      return POPPLER_PAGE_LAYOUT_UNSET;
+    }
+}
+
+static PopplerPageMode
+convert_page_mode (Catalog::PageMode pageMode)
+{
+  switch (pageMode)
+    {
+    case Catalog::pageModeOutlines:
+      return POPPLER_PAGE_MODE_USE_OUTLINES;
+    case Catalog::pageModeThumbs:
+      return POPPLER_PAGE_MODE_USE_THUMBS;
+    case Catalog::pageModeFullScreen:
+      return POPPLER_PAGE_MODE_FULL_SCREEN;
+    case Catalog::pageModeOC:
+      return POPPLER_PAGE_MODE_USE_OC;
+    case Catalog::pageModeNone:
+    default:
+      return POPPLER_PAGE_MODE_UNSET;
+    }
+}
+
 static void
-poppler_document_get_property (GObject *object,
-			       guint prop_id,
-			       GValue *value,
+poppler_document_get_property (GObject    *object,
+			       guint       prop_id,
+			       GValue     *value,
 			       GParamSpec *pspec)
 {
   PopplerDocument *document = POPPLER_DOCUMENT (object);
-  Object info;
-
-  document->doc->getDocInfo (&info);
-  if (!info.isDict ())
-    return;
+  Object obj;
+  Catalog *catalog;
+  gchar *str;
 
   switch (prop_id)
     {
     case PROP_TITLE:
-      info_dict_get_string (info.getDict(), "Title", value);
+      document->doc->getDocInfo (&obj);
+      if (obj.isDict ())
+	info_dict_get_string (obj.getDict(), "Title", value);
+      break;
+    case PROP_FORMAT:
+      str = g_strdup_printf ("PDF-%1f", document->doc->getPDFVersion ());
+      g_value_take_string (value, str);
+      break;
+    case PROP_AUTHOR:
+      document->doc->getDocInfo (&obj);
+      if (obj.isDict ())
+	info_dict_get_string (obj.getDict(), "Author", value);
+      break;
+    case PROP_SUBJECT:
+      document->doc->getDocInfo (&obj);
+      if (obj.isDict ())
+	info_dict_get_string (obj.getDict(), "Subject", value);
+      break;
+    case PROP_KEYWORDS:
+      document->doc->getDocInfo (&obj);
+      if (obj.isDict ())
+	info_dict_get_string (obj.getDict(), "Keywords", value);
+      break;
+    case PROP_PAGE_LAYOUT:
+      catalog = document->doc->getCatalog ();
+      if (catalog && catalog->isOk ())
+	{
+	  PopplerPageLayout page_layout = convert_page_layout (catalog->getPageLayout ());
+	  g_value_set_enum (value, page_layout);
+	}
+      break;
+    case PROP_PAGE_MODE:
+      catalog = document->doc->getCatalog ();
+      if (catalog && catalog->isOk ())
+	{
+	  PopplerPageMode page_mode = convert_page_mode (catalog->getPageMode ());
+	  g_value_set_enum (value, page_mode);
+	}
       break;
+    case PROP_VIEWER_PREFERENCES:
+      /* FIXME: write... */
+      g_value_set_flags (value, POPPLER_VIEWER_PREFERENCES_UNSET);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
 }
 
@@ -249,19 +340,84 @@
 poppler_document_class_init (PopplerDocumentClass *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-  GParamSpec *pspec;
 
   gobject_class->finalize = poppler_document_finalize;
   gobject_class->get_property = poppler_document_get_property;
 
-  pspec = g_param_spec_string ("title",
-			       "Document Title",
-			       "The title of the document",
-			       NULL,
-			       G_PARAM_READABLE);
-  g_object_class_install_property (G_OBJECT_CLASS (klass),
-				   PROP_TITLE,
-				   pspec);
+  g_object_class_install_property
+	  (G_OBJECT_CLASS (klass),
+	   PROP_TITLE,
+	   g_param_spec_string ("title",
+				"Document Title",
+				"The title of the document",
+				NULL,
+				G_PARAM_READABLE));
+
+  g_object_class_install_property
+	  (G_OBJECT_CLASS (klass),
+	   PROP_FORMAT,
+	   g_param_spec_string ("format",
+				"PDF Format",
+				"The PDF version of the document",
+				NULL,
+				G_PARAM_READABLE));
+
+  g_object_class_install_property
+	  (G_OBJECT_CLASS (klass),
+	   PROP_AUTHOR,
+	   g_param_spec_string ("author",
+				"Author",
+				"The author of the document",
+				NULL,
+				G_PARAM_READABLE));
+
+  g_object_class_install_property
+	  (G_OBJECT_CLASS (klass),
+	   PROP_SUBJECT,
+	   g_param_spec_string ("subject",
+				"Subject",
+				"Subjects the document touches",
+				NULL,
+				G_PARAM_READABLE));
+
+  g_object_class_install_property
+	  (G_OBJECT_CLASS (klass),
+	   PROP_KEYWORDS,
+	   g_param_spec_string ("keywords",
+				"Keywords",
+				"Keywords",
+				NULL,
+				G_PARAM_READABLE));
+
+  g_object_class_install_property
+	  (G_OBJECT_CLASS (klass),
+	   PROP_PAGE_LAYOUT,
+	   g_param_spec_enum ("page-layout",
+			      "Page Layout",
+			      "Initial Page Layout",
+			      POPPLER_TYPE_PAGE_LAYOUT,
+			      POPPLER_PAGE_LAYOUT_UNSET,
+			      G_PARAM_READABLE));
+
+  g_object_class_install_property
+	  (G_OBJECT_CLASS (klass),
+	   PROP_PAGE_MODE,
+	   g_param_spec_enum ("page-mode",
+			      "Page Mode",
+			      "Page Mode",
+			      POPPLER_TYPE_PAGE_MODE,
+			      POPPLER_PAGE_MODE_UNSET,
+			      G_PARAM_READABLE));
+
+  g_object_class_install_property
+	  (G_OBJECT_CLASS (klass),
+	   PROP_VIEWER_PREFERENCES,
+	   g_param_spec_flags ("viewer-preferences",
+			       "Viewer Preferences",
+			       "Viewer Preferences",
+			       POPPLER_TYPE_VIEWER_PREFERENCES,
+			       POPPLER_VIEWER_PREFERENCES_UNSET,
+			       G_PARAM_READABLE));
 }
 
 static void
@@ -440,3 +596,5 @@
 	g_object_unref (ps_file->document);
 	g_free (ps_file);
 }
+
+

Index: poppler-document.h
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-document.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- poppler-document.h	7 Apr 2005 22:01:51 -0000	1.7
+++ poppler-document.h	16 Apr 2005 18:57:44 -0000	1.8
@@ -21,8 +21,8 @@
 
 #include <glib-object.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
+
 #include "poppler.h"
-#include "poppler-action.h"
 
 G_BEGIN_DECLS
 
@@ -30,10 +30,41 @@
 #define POPPLER_DOCUMENT(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), POPPLER_TYPE_DOCUMENT, PopplerDocument))
 #define POPPLER_IS_DOCUMENT(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POPPLER_TYPE_DOCUMENT))
 
-typedef struct _PopplerDocument PopplerDocument;
-typedef struct _PopplerIndexIter PopplerIndexIter;
-typedef struct _PopplerPage PopplerPage;
-typedef struct _PopplerPSFile PopplerPSFile;
+typedef enum
+{
+  POPPLER_PAGE_LAYOUT_UNSET,
+  POPPLER_PAGE_LAYOUT_SINGLE_PAGE,
+  POPPLER_PAGE_LAYOUT_ONE_COLUMN,
+  POPPLER_PAGE_LAYOUT_TWO_COLUMN_LEFT,
+  POPPLER_PAGE_LAYOUT_TWO_COLUMN_RIGHT,
+  POPPLER_PAGE_LAYOUT_TWO_PAGE_LEFT,
+  POPPLER_PAGE_LAYOUT_TWO_PAGE_RIGHT,
+} PopplerPageLayout;
+
+typedef enum
+{
+  POPPLER_PAGE_MODE_UNSET,
+  POPPLER_PAGE_MODE_NONE,
+  POPPLER_PAGE_MODE_USE_OUTLINES,
+  POPPLER_PAGE_MODE_USE_THUMBS,
+  POPPLER_PAGE_MODE_FULL_SCREEN,
+  POPPLER_PAGE_MODE_USE_OC,
+  POPPLER_PAGE_MODE_USE_ATTACHMENTS,
+} PopplerPageMode;
+
+typedef enum /*< flags >*/
+{
+  POPPLER_VIEWER_PREFERENCES_UNSET = 0,
+  POPPLER_VIEWER_PREFERENCES_HIDE_TOOLBAR = 1 << 0,
+  POPPLER_VIEWER_PREFERENCES_HIDE_MENUBAR = 1 << 1,
+  POPPLER_VIEWER_PREFERENCES_HIDE_WINDOWUI = 1 << 2,
+  POPPLER_VIEWER_PREFERENCES_FIT_WINDOW = 1 << 3,
+  POPPLER_VIEWER_PREFERENCES_CENTER_WINDOW = 1 << 4,
+  POPPLER_VIEWER_PREFERENCES_DISPLAY_DOC_TITLE = 1 << 5,
+  POPPLER_VIEWER_PREFERENCES_DIRECTION_RTL = 1 << 6,
+} PopplerViewerPreferences;
+
+
 
 PopplerDocument *poppler_document_new_from_file     (const char       *uri,
 						     const char       *password,
@@ -47,7 +78,7 @@
 PopplerPage     *poppler_document_get_page_by_label (PopplerDocument  *document,
 						     const char       *label);
 
-GType            poppler_document_get_type          (void) G_GNUC_CONST;
+GType            poppler_document_get_type           (void) G_GNUC_CONST;
 
 /* Interface for getting the Index of a poppler_document */
 PopplerIndexIter *poppler_index_iter_new        (PopplerDocument   *document);

--- NEW FILE: poppler-enums.c ---

/* Generated data (by glib-mkenums) */

#include "poppler-enums.h"
#include "poppler-document.h"

/* enumerations from "poppler-action.h" */
GType
poppler_action_type_get_type (void)
{
  static GType etype = 0;
  if (etype == 0) {
    static const GEnumValue values[] = {
      { POPPLER_ACTION_UNKNOWN, "POPPLER_ACTION_UNKNOWN", "unknown" },
      { POPPLER_ACTION_GOTO_DEST, "POPPLER_ACTION_GOTO_DEST", "goto-dest" },
      { POPPLER_ACTION_GOTO_REMOTE, "POPPLER_ACTION_GOTO_REMOTE", "goto-remote" },
      { POPPLER_ACTION_LAUNCH, "POPPLER_ACTION_LAUNCH", "launch" },
      { POPPLER_ACTION_URI, "POPPLER_ACTION_URI", "uri" },
      { POPPLER_ACTION_NAMED, "POPPLER_ACTION_NAMED", "named" },
      { POPPLER_ACTION_MOVIE, "POPPLER_ACTION_MOVIE", "movie" },
      { 0, NULL, NULL }
    };
    etype = g_enum_register_static ("PopplerActionType", values);
  }
  return etype;
}
GType
poppler_dest_type_get_type (void)
{
  static GType etype = 0;
  if (etype == 0) {
    static const GEnumValue values[] = {
      { POPPLER_DEST_UNKNOWN, "POPPLER_DEST_UNKNOWN", "unknown" },
      { POPPLER_DEST_XYZ, "POPPLER_DEST_XYZ", "xyz" },
      { POPPLER_DEST_FIT, "POPPLER_DEST_FIT", "fit" },
      { POPPLER_DEST_FITH, "POPPLER_DEST_FITH", "fith" },
      { POPPLER_DEST_FITV, "POPPLER_DEST_FITV", "fitv" },
      { POPPLER_DEST_FITR, "POPPLER_DEST_FITR", "fitr" },
      { POPPLER_DEST_FITB, "POPPLER_DEST_FITB", "fitb" },
      { POPPLER_DEST_FITBH, "POPPLER_DEST_FITBH", "fitbh" },
      { POPPLER_DEST_FITBV, "POPPLER_DEST_FITBV", "fitbv" },
      { 0, NULL, NULL }
    };
    etype = g_enum_register_static ("PopplerDestType", values);
  }
  return etype;
}

/* enumerations from "poppler-document.h" */
GType
poppler_page_layout_get_type (void)
{
  static GType etype = 0;
  if (etype == 0) {
    static const GEnumValue values[] = {
      { POPPLER_PAGE_LAYOUT_UNSET, "POPPLER_PAGE_LAYOUT_UNSET", "unset" },
      { POPPLER_PAGE_LAYOUT_SINGLE_PAGE, "POPPLER_PAGE_LAYOUT_SINGLE_PAGE", "single-page" },
      { POPPLER_PAGE_LAYOUT_ONE_COLUMN, "POPPLER_PAGE_LAYOUT_ONE_COLUMN", "one-column" },
      { POPPLER_PAGE_LAYOUT_TWO_COLUMN_LEFT, "POPPLER_PAGE_LAYOUT_TWO_COLUMN_LEFT", "two-column-left" },
      { POPPLER_PAGE_LAYOUT_TWO_COLUMN_RIGHT, "POPPLER_PAGE_LAYOUT_TWO_COLUMN_RIGHT", "two-column-right" },
      { POPPLER_PAGE_LAYOUT_TWO_PAGE_LEFT, "POPPLER_PAGE_LAYOUT_TWO_PAGE_LEFT", "two-page-left" },
      { POPPLER_PAGE_LAYOUT_TWO_PAGE_RIGHT, "POPPLER_PAGE_LAYOUT_TWO_PAGE_RIGHT", "two-page-right" },
      { 0, NULL, NULL }
    };
    etype = g_enum_register_static ("PopplerPageLayout", values);
  }
  return etype;
}
GType
poppler_page_mode_get_type (void)
{
  static GType etype = 0;
  if (etype == 0) {
    static const GEnumValue values[] = {
      { POPPLER_PAGE_MODE_UNSET, "POPPLER_PAGE_MODE_UNSET", "unset" },
      { POPPLER_PAGE_MODE_NONE, "POPPLER_PAGE_MODE_NONE", "none" },
      { POPPLER_PAGE_MODE_USE_OUTLINES, "POPPLER_PAGE_MODE_USE_OUTLINES", "use-outlines" },
      { POPPLER_PAGE_MODE_USE_THUMBS, "POPPLER_PAGE_MODE_USE_THUMBS", "use-thumbs" },
      { POPPLER_PAGE_MODE_FULL_SCREEN, "POPPLER_PAGE_MODE_FULL_SCREEN", "full-screen" },
      { POPPLER_PAGE_MODE_USE_OC, "POPPLER_PAGE_MODE_USE_OC", "use-oc" },
      { POPPLER_PAGE_MODE_USE_ATTACHMENTS, "POPPLER_PAGE_MODE_USE_ATTACHMENTS", "use-attachments" },
      { 0, NULL, NULL }
    };
    etype = g_enum_register_static ("PopplerPageMode", values);
  }
  return etype;
}
GType
poppler_viewer_preferences_get_type (void)
{
  static GType etype = 0;
  if (etype == 0) {
    static const GFlagsValue values[] = {
      { POPPLER_VIEWER_PREFERENCES_UNSET, "POPPLER_VIEWER_PREFERENCES_UNSET", "unset" },
      { POPPLER_VIEWER_PREFERENCES_HIDE_TOOLBAR, "POPPLER_VIEWER_PREFERENCES_HIDE_TOOLBAR", "hide-toolbar" },
      { POPPLER_VIEWER_PREFERENCES_HIDE_MENUBAR, "POPPLER_VIEWER_PREFERENCES_HIDE_MENUBAR", "hide-menubar" },
      { POPPLER_VIEWER_PREFERENCES_HIDE_WINDOWUI, "POPPLER_VIEWER_PREFERENCES_HIDE_WINDOWUI", "hide-windowui" },
      { POPPLER_VIEWER_PREFERENCES_FIT_WINDOW, "POPPLER_VIEWER_PREFERENCES_FIT_WINDOW", "fit-window" },
      { POPPLER_VIEWER_PREFERENCES_CENTER_WINDOW, "POPPLER_VIEWER_PREFERENCES_CENTER_WINDOW", "center-window" },
      { POPPLER_VIEWER_PREFERENCES_DISPLAY_DOC_TITLE, "POPPLER_VIEWER_PREFERENCES_DISPLAY_DOC_TITLE", "display-doc-title" },
      { POPPLER_VIEWER_PREFERENCES_DIRECTION_RTL, "POPPLER_VIEWER_PREFERENCES_DIRECTION_RTL", "direction-rtl" },
      { 0, NULL, NULL }
    };
    etype = g_flags_register_static ("PopplerViewerPreferences", values);
  }
  return etype;
}

/* enumerations from "poppler.h" */
GType
poppler_error_get_type (void)
{
  static GType etype = 0;
  if (etype == 0) {
    static const GEnumValue values[] = {
      { POPPLER_ERROR_INVALID, "POPPLER_ERROR_INVALID", "invalid" },
      { POPPLER_ERROR_ENCRYPTED, "POPPLER_ERROR_ENCRYPTED", "encrypted" },
      { 0, NULL, NULL }
    };
    etype = g_enum_register_static ("PopplerError", values);
  }
  return etype;
}
GType
poppler_orientation_get_type (void)
{
  static GType etype = 0;
  if (etype == 0) {
    static const GEnumValue values[] = {
      { POPPLER_ORIENTATION_DOCUMENT, "POPPLER_ORIENTATION_DOCUMENT", "document" },
      { POPPLER_ORIENTATION_PORTRAIT, "POPPLER_ORIENTATION_PORTRAIT", "portrait" },
      { POPPLER_ORIENTATION_LANDSCAPE, "POPPLER_ORIENTATION_LANDSCAPE", "landscape" },
      { POPPLER_ORIENTATION_UPSIDEDOWN, "POPPLER_ORIENTATION_UPSIDEDOWN", "upsidedown" },
      { POPPLER_ORIENTATION_SEASCAPE, "POPPLER_ORIENTATION_SEASCAPE", "seascape" },
      { 0, NULL, NULL }
    };
    etype = g_enum_register_static ("PopplerOrientation", values);
  }
  return etype;
}
#define __POPPLER_ENUMS_C__

/* Generated data ends here */


--- NEW FILE: poppler-enums.h ---

/* Generated data (by glib-mkenums) */

#ifndef __POPPLER_TYPE_ENUMS_H__
#define __POPPLER_TYPE_ENUMS_H__

#include <glib-object.h>

G_BEGIN_DECLS
/* enumerations from "poppler-action.h" */
GType poppler_action_type_get_type (void) G_GNUC_CONST;
#define POPPLER_TYPE_ACTION_TYPE (poppler_action_type_get_type())
GType poppler_dest_type_get_type (void) G_GNUC_CONST;
#define POPPLER_TYPE_DEST_TYPE (poppler_dest_type_get_type())
/* enumerations from "poppler-document.h" */
GType poppler_page_layout_get_type (void) G_GNUC_CONST;
#define POPPLER_TYPE_PAGE_LAYOUT (poppler_page_layout_get_type())
GType poppler_page_mode_get_type (void) G_GNUC_CONST;
#define POPPLER_TYPE_PAGE_MODE (poppler_page_mode_get_type())
GType poppler_viewer_preferences_get_type (void) G_GNUC_CONST;
#define POPPLER_TYPE_VIEWER_PREFERENCES (poppler_viewer_preferences_get_type())
/* enumerations from "poppler.h" */
GType poppler_error_get_type (void) G_GNUC_CONST;
#define POPPLER_TYPE_ERROR (poppler_error_get_type())
GType poppler_orientation_get_type (void) G_GNUC_CONST;
#define POPPLER_TYPE_ORIENTATION (poppler_orientation_get_type())
G_END_DECLS

#endif /* __POPPLER_TYPE_ENUMS_H__ */

/* Generated data ends here */


Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-page.cc,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- poppler-page.cc	15 Apr 2005 02:25:11 -0000	1.14
+++ poppler-page.cc	16 Apr 2005 18:57:44 -0000	1.15
@@ -243,7 +243,6 @@
   SplashColor white;
   SplashBitmap *bitmap;
   SplashColorPtr color_ptr;
-  SplashRGB8 *src;
   int splash_width, splash_height, splash_rowstride;
   int pixbuf_rowstride, pixbuf_n_channels;
   guchar *pixbuf_data, *dst;
@@ -281,7 +280,6 @@
   for (y = 0; y < splash_height; y++)
     {
       SplashRGB8 *src;
-      SplashRGB8 rgb;
 
       src = (SplashRGB8 *) (color_ptr.rgb8p + y * splash_rowstride);
       dst = pixbuf_data + (dest_y + y) * pixbuf_rowstride +
@@ -427,7 +425,6 @@
   TextOutputDev *output_dev;
   PDFDoc *doc;
   GooString *sel_text = new GooString;
-  PopplerRectangle text_dev_rect;
   double height, y1, y2;
   char *result;
 

Index: poppler-page.h
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler-page.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- poppler-page.h	15 Apr 2005 02:25:11 -0000	1.11
+++ poppler-page.h	16 Apr 2005 18:57:44 -0000	1.12
@@ -21,6 +21,7 @@
 
 #include <glib-object.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
+
 #include "poppler.h"
 
 G_BEGIN_DECLS

Index: poppler.h
===================================================================
RCS file: /cvs/poppler/poppler/glib/poppler.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- poppler.h	15 Apr 2005 02:25:11 -0000	1.4
+++ poppler.h	16 Apr 2005 18:57:44 -0000	1.5
@@ -43,10 +43,17 @@
 	POPPLER_ORIENTATION_SEASCAPE
 } PopplerOrientation;
 
+typedef struct _PopplerDocument  PopplerDocument;
+typedef struct _PopplerIndexIter PopplerIndexIter;
+typedef struct _PopplerPage      PopplerPage;
+typedef struct _PopplerPSFile    PopplerPSFile;
+typedef union  _PopplerAction    PopplerAction;
+
 G_END_DECLS
 
 #include "poppler-document.h"
 #include "poppler-page.h"
 #include "poppler-action.h"
+#include "poppler-enums.h"
 
 #endif /* __POPPLER_GLIB_H__ */

Index: test-poppler-glib.c
===================================================================
RCS file: /cvs/poppler/poppler/glib/test-poppler-glib.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- test-poppler-glib.c	31 Mar 2005 22:45:05 -0000	1.7
+++ test-poppler-glib.c	16 Apr 2005 18:57:44 -0000	1.8
@@ -5,11 +5,53 @@
 #define FAIL(msg) \
 	do { fprintf (stderr, "FAIL: %s\n", msg); exit (-1); } while (0)
 
+
+static void
+print_document_info (PopplerDocument *document)
+{
+  gchar *title, *format, *author, *subject, *keywords;
+  PopplerPageLayout layout;
+  PopplerPageMode mode;
+  PopplerViewerPreferences view_prefs;
+  GEnumValue *enum_value;
+
+  g_object_get (document,
+		"title", &title,
+		"format", &format,
+		"author", &author,
+		"subject", &subject,
+		"keywords", &keywords,
+		"page-mode", &mode,
+		"page-layout", &layout,
+		"viewer-preferences", &view_prefs,
+		NULL);
+
+  printf ("document metadata\n");
+  if (title)  printf   ("\ttitle:\t%s\n", title);
+  if (format) printf   ("\tformat:\t%s\n", format);
+  if (author) printf   ("\tauthor:\t%s\n", author);
+  if (subject) printf  ("\tsubject:\t%s\n", subject);
+  if (keywords) printf ("\tdkeywords:\t%s\n", keywords);
+
+  enum_value = g_enum_get_value ((GEnumClass *) g_type_class_peek (POPPLER_TYPE_PAGE_MODE), mode);
+  g_print ("\tpage mode:\t%s\n", enum_value->value_name);
+  enum_value = g_enum_get_value ((GEnumClass *) g_type_class_peek (POPPLER_TYPE_PAGE_LAYOUT), layout);
+  g_print ("\tpage layout:\t%s\n", enum_value->value_name);
+
+  /* FIXME: print out the view prefs when we support it */
+
+  g_free (title);
+  g_free (format);
+  g_free (author);
+  g_free (subject);
+  g_free (keywords);
+}
+
 int main (int argc, char *argv[])
 {
   PopplerDocument *document;
   PopplerPage *page;
-  char *title, *label;
+  char *label;
   GError *error;
   GdkPixbuf *pixbuf, *thumb;
   double width, height;
@@ -25,9 +67,7 @@
   if (document == NULL)
     FAIL (error->message);
       
-  g_object_get (document, "title", &title, NULL);
-  printf ("document title: %s\n", title);
-  g_free (title);
+  print_document_info (document); 
 
   page = poppler_document_get_page_by_label (document, argv[2]);
   if (page == NULL)



More information about the poppler mailing list