Hi all,

          I created new screen annotation in glib. It requires setting the
action, creating LinkRendition, all that are there in other patch.
Please give all your suggestions.

Thanks
--
A Srinivas
Index: poppler-0.16.2/glib/poppler-media.cc
===================================================================
--- poppler-0.16.2/glib/poppler-media.cc	(revision 14)
+++ poppler-0.16.2/glib/poppler-media.cc	(working copy)
@@ -33,16 +33,6 @@
 
 typedef struct _PopplerMediaClass PopplerMediaClass;
 
-struct _PopplerMedia
-{
-  GObject   parent_instance;
-
-  gchar  *filename;
-
-  gchar  *mime_type;
-  Stream *stream;
-};
-
 struct _PopplerMediaClass
 {
   GObjectClass parent_class;
Index: poppler-0.16.2/glib/poppler-action.h
===================================================================
--- poppler-0.16.2/glib/poppler-action.h	(revision 14)
+++ poppler-0.16.2/glib/poppler-action.h	(working copy)
@@ -291,6 +291,12 @@
 
 void           poppler_action_free     (PopplerAction *action);
 PopplerAction *poppler_action_copy     (PopplerAction *action);
+PopplerAction *poppler_action_rendition_new  (PopplerAnnot *annot,
+					      PopplerMedia *media,
+				    	      const gchar  *video_title,
+				    	      guint	    operation);
+PopplerAction *poppler_action_rendition_new_for_javascript  (PopplerAnnot *annot,
+						             const gchar  *js);
 
 
 #define POPPLER_TYPE_DEST              (poppler_dest_get_type ())
Index: poppler-0.16.2/glib/poppler-annot.cc
===================================================================
--- poppler-0.16.2/glib/poppler-annot.cc	(revision 14)
+++ poppler-0.16.2/glib/poppler-annot.cc	(working copy)
@@ -332,7 +332,35 @@
   return poppler_annot;
 }
 
+/**
+ * poppler_annot_screen_new:
+ * @doc: a #PopplerDocument
+ * @rect: a #PopplerRectangle
+ *
+ * Creates a new Screen annotation that will be
+ * located on @rect when added to a page. See
+ * poppler_page_add_annot()
+ *
+ * Return value: A newly created #PopplerAnnotScreen annotation
+ *
+ * Since: 0.18
+ */
+PopplerAnnot *
+poppler_annot_screen_new (PopplerDocument  *doc,
+			  PopplerRectangle *rect)
+{
+  Annot *annot;
 
+  g_return_val_if_fail (doc != NULL, NULL);
+  g_return_val_if_fail (rect != NULL, NULL);
+
+  PDFRectangle pdf_rect(rect->x1, rect->y1,
+			rect->x2, rect->y2);
+
+  annot = new AnnotScreen (doc->doc->getXRef(), &pdf_rect, doc->doc->getCatalog());
+  return _poppler_annot_screen_new (annot);
+}
+
 /* Public methods */
 /**
  * poppler_annot_get_annot_type:
Index: poppler-0.16.2/glib/poppler-private.h
===================================================================
--- poppler-0.16.2/glib/poppler-private.h	(revision 14)
+++ poppler-0.16.2/glib/poppler-private.h	(working copy)
@@ -94,6 +94,16 @@
   gchar *title;
 };
 
+struct _PopplerMedia
+{
+  GObject   parent_instance;
+
+  gchar  *filename;
+
+  gchar  *mime_type;
+  Stream *stream;
+};
+
 GList         *_poppler_document_get_layers (PopplerDocument *document);
 GList         *_poppler_document_get_layer_rbgroup (PopplerDocument *document,
 						    Layer           *layer);
Index: poppler-0.16.2/glib/poppler-action.cc
===================================================================
--- poppler-0.16.2/glib/poppler-action.cc	(revision 14)
+++ poppler-0.16.2/glib/poppler-action.cc	(working copy)
@@ -665,3 +665,94 @@
 {
 	return dest_new_goto (document, link_dest);
 }
+
+/*
+ * poppler_action_rendition_new:
+ * @poppler_annot: a #PopplerAnnot
+ * @video_file: pass the path of the video to be embed
+ * @mimetype: pass the mimetype of the video to put in the Media Clip Dictionary
+ * @video_title: Title of the video to set
+
+ * Set the action for the screen annotation specified @poppler_annot
+ *
+ * Since: 0.18
+ */
+PopplerAction*
+poppler_action_rendition_new (PopplerAnnot *poppler_annot,
+			      PopplerMedia *media,
+			      const gchar  *media_title,
+			      guint         operation)
+{
+  AnnotScreen *annot;
+
+  g_return_val_if_fail (media != NULL, NULL);
+  g_return_val_if_fail (POPPLER_IS_ANNOT (poppler_annot), NULL);
+
+  PopplerAction *action;
+  action = g_slice_new0 (PopplerAction);
+
+  if (media_title) {
+    poppler_annot_set_contents(poppler_annot, media_title);
+    poppler_annot_screen_set_title((PopplerAnnotScreen*)poppler_annot, media_title);
+  }
+
+  XRef *xref = poppler_annot->annot->getXRef();	
+
+  MediaRendition *rendition;
+  LinkRendition *link_rendition;
+
+  rendition = new MediaRendition (xref, media->filename, media->mime_type);
+  link_rendition = new LinkRendition(xref, rendition, operation, poppler_annot->annot);
+  
+  annot = static_cast<AnnotScreen *>(POPPLER_ANNOT (poppler_annot)->annot);
+
+  annot->setAction(link_rendition);
+  
+  action->type = POPPLER_ACTION_RENDITION;
+  action->rendition.op = operation;
+  action->rendition.media = media;
+  
+  return action;
+}
+
+/*
+ * poppler_action_create_rendition_new:
+ * @poppler_annot: a #PopplerAnnot
+ * @js: Javascript to execute
+
+ * Set the action for the screen annotation specified @poppler_annot
+ *
+ * Since: 0.18
+ */
+PopplerAction*
+poppler_action_rendition_new_for_javascript (PopplerAnnot *poppler_annot,
+				             const gchar  *js)
+{
+  AnnotScreen *annot;
+
+  g_return_val_if_fail (js != NULL, NULL);
+  g_return_val_if_fail (POPPLER_IS_ANNOT (poppler_annot), NULL);
+
+  PopplerAction *action;
+  action = g_slice_new0 (PopplerAction);
+
+  XRef *xref = poppler_annot->annot->getXRef();	
+
+  LinkRendition *rendition;
+  Object jsObj, obj1, obj2;
+
+  obj1.initDict(xref);
+  obj1.dictSet("Length", obj2.initInt(strlen(js)));
+
+  MemStream *jsstream = new MemStream(copyString((char*)js), 0, strlen(js), &obj1);
+
+  jsObj.initStream(jsstream);
+  rendition = new LinkRendition(xref, &jsObj);
+  
+  annot = static_cast<AnnotScreen *>(POPPLER_ANNOT (poppler_annot)->annot);
+
+  annot->setAction (rendition);
+
+  action->type = POPPLER_ACTION_RENDITION;
+  return action;
+}
Index: poppler-0.16.2/glib/poppler-annot.h
===================================================================
--- poppler-0.16.2/glib/poppler-annot.h	(revision 14)
+++ poppler-0.16.2/glib/poppler-annot.h	(working copy)
@@ -217,6 +217,8 @@
 
 /* PopplerAnnotScreen */
 GType                         poppler_annot_screen_get_type                    (void) G_GNUC_CONST;
+PopplerAnnot		     *poppler_annot_screen_new			       (PopplerDocument  *doc,
+										PopplerRectangle *rect);
 PopplerAction                *poppler_annot_screen_get_action                  (PopplerAnnotScreen *poppler_annot);
 
 /* PopplerCalloutLine */
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to