[poppler] 2 commits - glib/demo glib/poppler-action.cc glib/poppler-action.h

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Wed Mar 30 06:10:02 PDT 2011


 glib/demo/utils.c      |   25 +++++++++++++++++++++++++
 glib/poppler-action.cc |   24 ++++++++++++++++++++++++
 glib/poppler-action.h  |   14 +++++++++++++-
 3 files changed, 62 insertions(+), 1 deletion(-)

New commits:
commit c4774fecfe3d523f32d5980f50e31daa798c9692
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Wed Mar 30 15:08:59 2011 +0200

    glib-demo: show javascript actions in actions view

diff --git a/glib/demo/utils.c b/glib/demo/utils.c
index 14262b9..1e59e10 100644
--- a/glib/demo/utils.c
+++ b/glib/demo/utils.c
@@ -438,6 +438,31 @@ pgd_action_view_set_action (GtkWidget     *action_view,
 		gtk_widget_show (button);
 	}
 		break;
+        case POPPLER_ACTION_JAVASCRIPT: {
+                GtkTextBuffer *buffer;
+                GtkWidget     *textview;
+                GtkWidget     *swindow;
+
+                pgd_table_add_property (GTK_TABLE (table), "<b>Type:</b>", "JavaScript", &row);
+
+                buffer = gtk_text_buffer_new (NULL);
+                if (action->javascript.script)
+                        gtk_text_buffer_set_text (buffer, action->javascript.script, -1);
+
+                textview = gtk_text_view_new_with_buffer (buffer);
+                gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), FALSE);
+                g_object_unref (buffer);
+
+                swindow = gtk_scrolled_window_new (NULL, NULL);
+                gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
+                                                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+                gtk_container_add (GTK_CONTAINER (swindow), textview);
+                gtk_widget_show (textview);
+
+                pgd_table_add_property_with_custom_widget (GTK_TABLE (table), NULL, swindow, &row);
+                gtk_widget_show (swindow);
+        }
+                break;
 	default:
 		g_assert_not_reached ();
 	}
commit 68bbbe1a3f68d242b35027ae41f5751b02a2a700
Author: José Aliste <jaliste at src.gnome.org>
Date:   Tue Mar 29 04:56:37 2011 -0400

    glib: add JavaScript actions

diff --git a/glib/poppler-action.cc b/glib/poppler-action.cc
index ca88ca4..c7ebcdd 100644
--- a/glib/poppler-action.cc
+++ b/glib/poppler-action.cc
@@ -140,6 +140,10 @@ poppler_action_free (PopplerAction *action)
 			g_list_free (action->ocg_state.state_list);
 		}
 		break;
+	case POPPLER_ACTION_JAVASCRIPT:
+		if (action->javascript.script)
+			g_free (action->javascript.script);
+		break;
 	default:
 		break;
 	}
@@ -214,6 +218,10 @@ poppler_action_copy (PopplerAction *action)
 		}
 
 		break;
+	case POPPLER_ACTION_JAVASCRIPT:
+		if (action->javascript.script)
+			new_action->javascript.script = g_strdup (action->javascript.script);
+		break;
 	default:
 		break;
 	}
@@ -514,6 +522,18 @@ build_movie (PopplerDocument *document,
 }
 
 static void
+build_javascript (PopplerAction *action,
+		  LinkJavaScript *link)
+{
+	GooString *script;
+
+	script = link->getScript();
+	if (script)
+		action->javascript.script = _poppler_goo_string_to_utf8 (script);
+
+}
+
+static void
 build_rendition (PopplerAction *action,
 		 LinkRendition *link)
 {
@@ -650,6 +670,10 @@ _poppler_action_new (PopplerDocument *document,
 		action->type = POPPLER_ACTION_OCG_STATE;
 		build_ocg_state (document, action, dynamic_cast<LinkOCGState*> (link));
 		break;
+	case actionJavaScript:
+		action->type = POPPLER_ACTION_JAVASCRIPT;
+		build_javascript (action, dynamic_cast<LinkJavaScript*> (link));
+		break;
 	case actionUnknown:
 	default:
 		action->type = POPPLER_ACTION_UNKNOWN;
diff --git a/glib/poppler-action.h b/glib/poppler-action.h
index 6bb87ba..b3df50b 100644
--- a/glib/poppler-action.h
+++ b/glib/poppler-action.h
@@ -36,6 +36,7 @@ G_BEGIN_DECLS
  * @POPPLER_ACTION_MOVIE: play movies. Since 0.14
  * @POPPLER_ACTION_RENDITION: play multimedia content. Since 0.14
  * @POPPLER_ACTION_OCG_STATE: state of layer. Since 0.14
+ * @POPPLER_ACTION_JAVASCRIPT: Javascript. Since 0.18
  *
  * Action types
  */
@@ -50,7 +51,8 @@ typedef enum
 	POPPLER_ACTION_NAMED,		/* named action*/
 	POPPLER_ACTION_MOVIE,		/* movie action */
 	POPPLER_ACTION_RENDITION,       /* rendition action */
-	POPPLER_ACTION_OCG_STATE        /* Set-OCG-State action */
+	POPPLER_ACTION_OCG_STATE,       /* Set-OCG-State action */
+	POPPLER_ACTION_JAVASCRIPT	/* Javascript action */
 } PopplerActionType;
 
 /**
@@ -145,6 +147,7 @@ typedef struct _PopplerActionNamed      PopplerActionNamed;
 typedef struct _PopplerActionMovie      PopplerActionMovie;
 typedef struct _PopplerActionRendition  PopplerActionRendition;
 typedef struct _PopplerActionOCGState   PopplerActionOCGState;
+typedef struct _PopplerActionJavaScript PopplerActionJavaScript;
 
 /**
  * PopplerDest:
@@ -265,6 +268,14 @@ struct _PopplerActionOCGState
 	GList            *state_list;
 };
 
+struct _PopplerActionJavaScript
+{
+	PopplerActionType  type;
+	gchar 		  *title;
+
+	gchar		  *script;
+};
+
 /**
  * PopplerAction:
  *
@@ -282,6 +293,7 @@ union _PopplerAction
 	PopplerActionMovie movie;
 	PopplerActionRendition rendition;
 	PopplerActionOCGState ocg_state;
+	PopplerActionJavaScript javascript;
 };
 
 #define POPPLER_TYPE_ACTION             (poppler_action_get_type ())


More information about the poppler mailing list