[poppler] 6 commits - glib/demo glib/poppler-annot.cc glib/poppler-annot.h glib/poppler-attachment.cc glib/poppler-document.cc glib/poppler.h glib/poppler-page.cc glib/poppler-private.h
Carlos Garcia Campos
carlosgc at kemper.freedesktop.org
Sun Nov 15 08:39:06 PST 2009
glib/demo/annots.c | 72 +++++++++++++++++++++++++++++++++++
glib/demo/utils.c | 31 ++++++++++-----
glib/demo/utils.h | 30 ++++++++------
glib/poppler-annot.cc | 91 +++++++++++++++++++++++++++++++++++++++++++--
glib/poppler-annot.h | 9 ++++
glib/poppler-attachment.cc | 13 ------
glib/poppler-document.cc | 2
glib/poppler-page.cc | 3 +
glib/poppler-private.h | 4 -
glib/poppler.h | 49 ++++++++++++------------
10 files changed, 238 insertions(+), 66 deletions(-)
New commits:
commit 2d30dc605cd984f6c32124af9aa7b877d416d141
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Sun Nov 15 17:31:36 2009 +0100
[glib-demo] Show attachment name in FileAttachment annot properties table
diff --git a/glib/demo/annots.c b/glib/demo/annots.c
index 68d9971..1cdfba8 100644
--- a/glib/demo/annots.c
+++ b/glib/demo/annots.c
@@ -425,6 +425,11 @@ pgd_annot_view_set_annot_file_attachment (GtkWidget *table,
gint *row)
{
GtkWidget *button;
+ gchar *text;
+
+ text = poppler_annot_file_attachment_get_name (annot);
+ pgd_table_add_property (GTK_TABLE (table), "<b>Attachment Name:</b>", text, row);
+ g_free (text);
button = gtk_button_new_with_label ("Save Attachment");
g_signal_connect (G_OBJECT (button), "clicked",
commit 6c8ae140256818401351a331787c83e043fdba09
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Sun Nov 15 17:31:13 2009 +0100
[glib] Add poppler_annot_file_attachment_get_name()
diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc
index 9d8b865..e019eca 100644
--- a/glib/poppler-annot.cc
+++ b/glib/poppler-annot.cc
@@ -821,7 +821,7 @@ poppler_annot_free_text_get_callout_line (PopplerAnnotFreeText *poppler_annot)
/* PopplerAnnotFileAttachment */
/**
* poppler_annot_file_attachment_get_attachment:
- * @annot: a #PopplerAnnotFileAttachment
+ * @poppler_annot: a #PopplerAnnotFileAttachment
*
* Creates a #PopplerAttachment for the file of the file attachment annotation @annot.
* The #PopplerAttachment must be unrefed with g_object_unref by the caller.
@@ -829,23 +829,45 @@ poppler_annot_free_text_get_callout_line (PopplerAnnotFreeText *poppler_annot)
* Return value: @PopplerAttachment
**/
PopplerAttachment *
-poppler_annot_file_attachment_get_attachment (PopplerAnnotFileAttachment *annot)
+poppler_annot_file_attachment_get_attachment (PopplerAnnotFileAttachment *poppler_annot)
{
- AnnotFileAttachment *annot_file_attachment;
+ AnnotFileAttachment *annot;
PopplerAttachment *attachment;
- g_return_val_if_fail (POPPLER_IS_ANNOT_FILE_ATTACHMENT (annot), FALSE);
+ g_return_val_if_fail (POPPLER_IS_ANNOT_FILE_ATTACHMENT (poppler_annot), NULL);
- annot_file_attachment = static_cast<AnnotFileAttachment *>(POPPLER_ANNOT (annot)->annot);
+ annot = static_cast<AnnotFileAttachment *>(POPPLER_ANNOT (poppler_annot)->annot);
- EmbFile *emb_file = new EmbFile (annot_file_attachment->getFile(),
- annot_file_attachment->getContents());
+ EmbFile *emb_file = new EmbFile (annot->getFile(), annot->getContents());
attachment = _poppler_attachment_new (emb_file);
delete emb_file;
return attachment;
}
+/**
+ * poppler_annot_file_attachment_get_name:
+ * @poppler_annot: a #PopplerAnnotFileAttachment
+ *
+ * Retrieves the name of @poppler_annot.
+ *
+ * Return value: a new allocated string with the name of @poppler_annot. It must
+ * be freed with g_free() when done.
+ **/
+gchar *
+poppler_annot_file_attachment_get_name (PopplerAnnotFileAttachment *poppler_annot)
+{
+ AnnotFileAttachment *annot;
+ GooString *name;
+
+ g_return_val_if_fail (POPPLER_IS_ANNOT_FILE_ATTACHMENT (poppler_annot), NULL);
+
+ annot = static_cast<AnnotFileAttachment *>(POPPLER_ANNOT (poppler_annot)->annot);
+ name = annot->getName ();
+
+ return name ? _poppler_goo_string_to_utf8 (name) : NULL;
+}
+
/* PopplerAnnotCalloutLine */
POPPLER_DEFINE_BOXED_TYPE (PopplerAnnotCalloutLine, poppler_annot_callout_line,
poppler_annot_callout_line_copy,
diff --git a/glib/poppler-annot.h b/glib/poppler-annot.h
index ccf906b..7c35307 100644
--- a/glib/poppler-annot.h
+++ b/glib/poppler-annot.h
@@ -172,6 +172,7 @@ PopplerAnnotCalloutLine *poppler_annot_free_text_get_callout_line (
/* PopplerAnnotFileAttachment */
GType poppler_annot_file_attachment_get_type (void) G_GNUC_CONST;
PopplerAttachment *poppler_annot_file_attachment_get_attachment (PopplerAnnotFileAttachment *poppler_annot);
+gchar *poppler_annot_file_attachment_get_name (PopplerAnnotFileAttachment *poppler_annot);
/* PopplerCalloutLine */
GType poppler_annot_callout_line_get_type (void) G_GNUC_CONST;
commit ecf5173eb288187a1f076fd4b116f1212fa9e203
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Sun Nov 15 17:14:29 2009 +0100
[glib-demo] Add properties of FileAttachment annotations
diff --git a/glib/demo/annots.c b/glib/demo/annots.c
index c9aecb3..68d9971 100644
--- a/glib/demo/annots.c
+++ b/glib/demo/annots.c
@@ -372,6 +372,70 @@ pgd_annot_view_set_annot_free_text (GtkWidget *table,
}
static void
+pgd_annots_file_attachment_save_dialog_response (GtkFileChooser *file_chooser,
+ gint response,
+ PopplerAttachment *attachment)
+{
+ gchar *filename;
+ GError *error = NULL;
+
+ if (response != GTK_RESPONSE_ACCEPT) {
+ g_object_unref (attachment);
+ gtk_widget_destroy (GTK_WIDGET (file_chooser));
+ return;
+ }
+
+ filename = gtk_file_chooser_get_filename (file_chooser);
+ if (!poppler_attachment_save (attachment, filename, &error)) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+ g_free (filename);
+ g_object_unref (attachment);
+ gtk_widget_destroy (GTK_WIDGET (file_chooser));
+}
+
+static void
+pgd_annot_save_file_attachment_button_clicked (GtkButton *button,
+ PopplerAnnotFileAttachment *annot)
+{
+ GtkWidget *file_chooser;
+ PopplerAttachment *attachment;
+
+ attachment = poppler_annot_file_attachment_get_attachment (annot);
+ if (!attachment)
+ return;
+
+ file_chooser = gtk_file_chooser_dialog_new ("Save attachment",
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (file_chooser), attachment->name);
+ g_signal_connect (G_OBJECT (file_chooser), "response",
+ G_CALLBACK (pgd_annots_file_attachment_save_dialog_response),
+ (gpointer) attachment);
+ gtk_widget_show (file_chooser);
+}
+
+static void
+pgd_annot_view_set_annot_file_attachment (GtkWidget *table,
+ PopplerAnnotFileAttachment *annot,
+ gint *row)
+{
+ GtkWidget *button;
+
+ button = gtk_button_new_with_label ("Save Attachment");
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (pgd_annot_save_file_attachment_button_clicked),
+ (gpointer)annot);
+ pgd_table_add_property_with_custom_widget (GTK_TABLE (table), "<b>File Attachment:</b>", button, row);
+ gtk_widget_show (button);
+
+}
+
+static void
pgd_annot_view_set_annot (GtkWidget *annot_view,
PopplerAnnot *annot)
{
@@ -430,6 +494,9 @@ pgd_annot_view_set_annot (GtkWidget *annot_view,
case POPPLER_ANNOT_FREE_TEXT:
pgd_annot_view_set_annot_free_text (table, POPPLER_ANNOT_FREE_TEXT (annot), &row);
break;
+ case POPPLER_ANNOT_FILE_ATTACHMENT:
+ pgd_annot_view_set_annot_file_attachment (table, POPPLER_ANNOT_FILE_ATTACHMENT (annot), &row);
+ break;
default:
break;
}
commit 8f4fdd864d79e4fa83951a3eb006ea8287c3a1ba
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Sun Nov 15 17:12:43 2009 +0100
[glib-demo] Add pgd_table_add_property_with_custom_widget()
To be able to add properties to a table that are not labels
diff --git a/glib/demo/utils.c b/glib/demo/utils.c
index 010fab3..6171b38 100644
--- a/glib/demo/utils.c
+++ b/glib/demo/utils.c
@@ -22,11 +22,10 @@
#include "utils.h"
void
-pgd_table_add_property_with_value_widget (GtkTable *table,
- const gchar *markup,
- GtkWidget **value_widget,
- const gchar *value,
- gint *row)
+pgd_table_add_property_with_custom_widget (GtkTable *table,
+ const gchar *markup,
+ GtkWidget *widget,
+ gint *row)
{
GtkWidget *label;
@@ -37,17 +36,29 @@ pgd_table_add_property_with_value_widget (GtkTable *table,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
+ gtk_table_attach (GTK_TABLE (table), widget, 1, 2, *row, *row + 1,
+ GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ gtk_widget_show (widget);
+
+ *row += 1;
+}
+
+void
+pgd_table_add_property_with_value_widget (GtkTable *table,
+ const gchar *markup,
+ GtkWidget **value_widget,
+ const gchar *value,
+ gint *row)
+{
+ GtkWidget *label;
+
*value_widget = label = gtk_label_new (value);
g_object_set (G_OBJECT (label),
"xalign", 0.0,
"selectable", TRUE,
"ellipsize", PANGO_ELLIPSIZE_END,
NULL);
- gtk_table_attach (GTK_TABLE (table), label, 1, 2, *row, *row + 1,
- GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
- gtk_widget_show (label);
-
- *row += 1;
+ pgd_table_add_property_with_custom_widget (table, markup, label, row);
}
void
diff --git a/glib/demo/utils.h b/glib/demo/utils.h
index 72c3ef3..ff6897b 100644
--- a/glib/demo/utils.h
+++ b/glib/demo/utils.h
@@ -24,19 +24,23 @@
G_BEGIN_DECLS
-void pgd_table_add_property (GtkTable *table,
- const gchar *markup,
- const gchar *value,
- gint *row);
-void pgd_table_add_property_with_value_widget (GtkTable *table,
- const gchar *markup,
- GtkWidget **value_widget,
- const gchar *value,
- gint *row);
-GtkWidget *pgd_action_view_new (PopplerDocument *document);
-void pgd_action_view_set_action (GtkWidget *action_view,
- PopplerAction *action);
-gchar *pgd_format_date (time_t utime);
+void pgd_table_add_property (GtkTable *table,
+ const gchar *markup,
+ const gchar *value,
+ gint *row);
+void pgd_table_add_property_with_value_widget (GtkTable *table,
+ const gchar *markup,
+ GtkWidget **value_widget,
+ const gchar *value,
+ gint *row);
+void pgd_table_add_property_with_custom_widget (GtkTable *table,
+ const gchar *markup,
+ GtkWidget *widget,
+ gint *row);
+GtkWidget *pgd_action_view_new (PopplerDocument *document);
+void pgd_action_view_set_action (GtkWidget *action_view,
+ PopplerAction *action);
+gchar *pgd_format_date (time_t utime);
G_END_DECLS
commit 061b85f7a442107cda67e385bd772ec8565a936e
Author: Thomas Viehmann <tv at beamnet.de>
Date: Sun Nov 15 17:11:43 2009 +0100
[glib] Add support for file attachment annotations
diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc
index 29051f9..9d8b865 100644
--- a/glib/poppler-annot.cc
+++ b/glib/poppler-annot.cc
@@ -21,10 +21,11 @@
#include "poppler.h"
#include "poppler-private.h"
-typedef struct _PopplerAnnotClass PopplerAnnotClass;
-typedef struct _PopplerAnnotMarkupClass PopplerAnnotMarkupClass;
-typedef struct _PopplerAnnotFreeTextClass PopplerAnnotFreeTextClass;
-typedef struct _PopplerAnnotTextClass PopplerAnnotTextClass;
+typedef struct _PopplerAnnotClass PopplerAnnotClass;
+typedef struct _PopplerAnnotMarkupClass PopplerAnnotMarkupClass;
+typedef struct _PopplerAnnotFreeTextClass PopplerAnnotFreeTextClass;
+typedef struct _PopplerAnnotTextClass PopplerAnnotTextClass;
+typedef struct _PopplerAnnotFileAttachmentClass PopplerAnnotFileAttachmentClass;
struct _PopplerAnnot
{
@@ -67,10 +68,21 @@ struct _PopplerAnnotFreeTextClass
PopplerAnnotMarkupClass parent_class;
};
+struct _PopplerAnnotFileAttachment
+{
+ PopplerAnnotMarkup parent_instance;
+};
+
+struct _PopplerAnnotFileAttachmentClass
+{
+ PopplerAnnotMarkupClass parent_class;
+};
+
G_DEFINE_TYPE (PopplerAnnot, poppler_annot, G_TYPE_OBJECT)
G_DEFINE_TYPE (PopplerAnnotMarkup, poppler_annot_markup, POPPLER_TYPE_ANNOT)
G_DEFINE_TYPE (PopplerAnnotText, poppler_annot_text, POPPLER_TYPE_ANNOT_MARKUP)
G_DEFINE_TYPE (PopplerAnnotFreeText, poppler_annot_free_text, POPPLER_TYPE_ANNOT_MARKUP)
+G_DEFINE_TYPE (PopplerAnnotFileAttachment, poppler_annot_file_attachment, POPPLER_TYPE_ANNOT_MARKUP)
static void
poppler_annot_finalize (GObject *object)
@@ -158,6 +170,27 @@ _poppler_annot_free_text_new (Annot *annot)
return poppler_annot;
}
+static void
+poppler_annot_file_attachment_init (PopplerAnnotFileAttachment *poppler_annot)
+{
+}
+
+static void
+poppler_annot_file_attachment_class_init (PopplerAnnotFileAttachmentClass *klass)
+{
+}
+
+PopplerAnnot *
+_poppler_annot_file_attachment_new (Annot *annot)
+{
+ PopplerAnnot *poppler_annot;
+
+ poppler_annot = POPPLER_ANNOT (g_object_new (POPPLER_TYPE_ANNOT_FILE_ATTACHMENT, NULL));
+ poppler_annot->annot = annot;
+
+ return poppler_annot;
+}
+
/* Public methods */
/**
* poppler_annot_get_annot_type:
@@ -785,6 +818,34 @@ poppler_annot_free_text_get_callout_line (PopplerAnnotFreeText *poppler_annot)
return NULL;
}
+/* PopplerAnnotFileAttachment */
+/**
+ * poppler_annot_file_attachment_get_attachment:
+ * @annot: a #PopplerAnnotFileAttachment
+ *
+ * Creates a #PopplerAttachment for the file of the file attachment annotation @annot.
+ * The #PopplerAttachment must be unrefed with g_object_unref by the caller.
+ *
+ * Return value: @PopplerAttachment
+ **/
+PopplerAttachment *
+poppler_annot_file_attachment_get_attachment (PopplerAnnotFileAttachment *annot)
+{
+ AnnotFileAttachment *annot_file_attachment;
+ PopplerAttachment *attachment;
+
+ g_return_val_if_fail (POPPLER_IS_ANNOT_FILE_ATTACHMENT (annot), FALSE);
+
+ annot_file_attachment = static_cast<AnnotFileAttachment *>(POPPLER_ANNOT (annot)->annot);
+
+ EmbFile *emb_file = new EmbFile (annot_file_attachment->getFile(),
+ annot_file_attachment->getContents());
+ attachment = _poppler_attachment_new (emb_file);
+ delete emb_file;
+
+ return attachment;
+}
+
/* PopplerAnnotCalloutLine */
POPPLER_DEFINE_BOXED_TYPE (PopplerAnnotCalloutLine, poppler_annot_callout_line,
poppler_annot_callout_line_copy,
diff --git a/glib/poppler-annot.h b/glib/poppler-annot.h
index 4648027..ccf906b 100644
--- a/glib/poppler-annot.h
+++ b/glib/poppler-annot.h
@@ -42,6 +42,10 @@ G_BEGIN_DECLS
#define POPPLER_ANNOT_FREE_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POPPLER_TYPE_ANNOT_FREE_TEXT, PopplerAnnotFreeText))
#define POPPLER_IS_ANNOT_FREE_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POPPLER_TYPE_ANNOT_FREE_TEXT))
+#define POPPLER_TYPE_ANNOT_FILE_ATTACHMENT (poppler_annot_file_attachment_get_type ())
+#define POPPLER_ANNOT_FILE_ATTACHMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POPPLER_TYPE_ANNOT_MARKUP, PopplerAnnotFileAttachment))
+#define POPPLER_IS_ANNOT_FILE_ATTACHMENT(obj)(G_TYPE_CHECK_INSTANCE_TYPE ((obj), POPPLER_TYPE_ANNOT_FILE_ATTACHMENT))
+
#define POPPLER_TYPE_ANNOT_CALLOUT_LINE (poppler_annot_callout_line_get_type ())
typedef enum
@@ -165,6 +169,10 @@ GType poppler_annot_free_text_get_type (
PopplerAnnotFreeTextQuadding poppler_annot_free_text_get_quadding (PopplerAnnotFreeText *poppler_annot);
PopplerAnnotCalloutLine *poppler_annot_free_text_get_callout_line (PopplerAnnotFreeText *poppler_annot);
+/* PopplerAnnotFileAttachment */
+GType poppler_annot_file_attachment_get_type (void) G_GNUC_CONST;
+PopplerAttachment *poppler_annot_file_attachment_get_attachment (PopplerAnnotFileAttachment *poppler_annot);
+
/* PopplerCalloutLine */
GType poppler_annot_callout_line_get_type (void) G_GNUC_CONST;
PopplerAnnotCalloutLine *poppler_annot_callout_line_new (void);
diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc
index 3c0ead1..4514f9c 100644
--- a/glib/poppler-page.cc
+++ b/glib/poppler-page.cc
@@ -1700,6 +1700,9 @@ poppler_page_get_annot_mapping (PopplerPage *page)
case Annot::typeFreeText:
mapping->annot = _poppler_annot_free_text_new (annot);
break;
+ case Annot::typeFileAttachment:
+ mapping->annot = _poppler_annot_file_attachment_new (annot);
+ break;
default:
mapping->annot = _poppler_annot_new (annot);
break;
diff --git a/glib/poppler-private.h b/glib/poppler-private.h
index d2e7017..a41742c 100644
--- a/glib/poppler-private.h
+++ b/glib/poppler-private.h
@@ -107,6 +107,7 @@ PopplerAttachment *_poppler_attachment_new (EmbFile *file);
PopplerAnnot *_poppler_annot_new (Annot *annot);
PopplerAnnot *_poppler_annot_text_new (Annot *annot);
PopplerAnnot *_poppler_annot_free_text_new (Annot *annot);
+PopplerAnnot *_poppler_annot_file_attachment_new (Annot *annot);
char *_poppler_goo_string_to_utf8(GooString *s);
gboolean _poppler_convert_pdf_date_to_gtime (GooString *date,
diff --git a/glib/poppler.h b/glib/poppler.h
index b1a7730..aae6076 100644
--- a/glib/poppler.h
+++ b/glib/poppler.h
@@ -79,30 +79,31 @@ typedef enum
POPPLER_SELECTION_LINE
} PopplerSelectionStyle;
-typedef struct _PopplerDocument PopplerDocument;
-typedef struct _PopplerIndexIter PopplerIndexIter;
-typedef struct _PopplerFontsIter PopplerFontsIter;
-typedef struct _PopplerLayersIter PopplerLayersIter;
-typedef struct _PopplerRectangle PopplerRectangle;
-typedef struct _PopplerColor PopplerColor;
-typedef struct _PopplerLinkMapping PopplerLinkMapping;
-typedef struct _PopplerPageTransition PopplerPageTransition;
-typedef struct _PopplerImageMapping PopplerImageMapping;
-typedef struct _PopplerFormFieldMapping PopplerFormFieldMapping;
-typedef struct _PopplerAnnotMapping PopplerAnnotMapping;
-typedef struct _PopplerPage PopplerPage;
-typedef struct _PopplerFontInfo PopplerFontInfo;
-typedef struct _PopplerLayer PopplerLayer;
-typedef struct _PopplerPSFile PopplerPSFile;
-typedef union _PopplerAction PopplerAction;
-typedef struct _PopplerDest PopplerDest;
-typedef struct _PopplerFormField PopplerFormField;
-typedef struct _PopplerAttachment PopplerAttachment;
-typedef struct _PopplerAnnot PopplerAnnot;
-typedef struct _PopplerAnnotMarkup PopplerAnnotMarkup;
-typedef struct _PopplerAnnotText PopplerAnnotText;
-typedef struct _PopplerAnnotFreeText PopplerAnnotFreeText;
-typedef struct _PopplerAnnotCalloutLine PopplerAnnotCalloutLine;
+typedef struct _PopplerDocument PopplerDocument;
+typedef struct _PopplerIndexIter PopplerIndexIter;
+typedef struct _PopplerFontsIter PopplerFontsIter;
+typedef struct _PopplerLayersIter PopplerLayersIter;
+typedef struct _PopplerRectangle PopplerRectangle;
+typedef struct _PopplerColor PopplerColor;
+typedef struct _PopplerLinkMapping PopplerLinkMapping;
+typedef struct _PopplerPageTransition PopplerPageTransition;
+typedef struct _PopplerImageMapping PopplerImageMapping;
+typedef struct _PopplerFormFieldMapping PopplerFormFieldMapping;
+typedef struct _PopplerAnnotMapping PopplerAnnotMapping;
+typedef struct _PopplerPage PopplerPage;
+typedef struct _PopplerFontInfo PopplerFontInfo;
+typedef struct _PopplerLayer PopplerLayer;
+typedef struct _PopplerPSFile PopplerPSFile;
+typedef union _PopplerAction PopplerAction;
+typedef struct _PopplerDest PopplerDest;
+typedef struct _PopplerFormField PopplerFormField;
+typedef struct _PopplerAttachment PopplerAttachment;
+typedef struct _PopplerAnnot PopplerAnnot;
+typedef struct _PopplerAnnotMarkup PopplerAnnotMarkup;
+typedef struct _PopplerAnnotText PopplerAnnotText;
+typedef struct _PopplerAnnotFreeText PopplerAnnotFreeText;
+typedef struct _PopplerAnnotFileAttachment PopplerAnnotFileAttachment;
+typedef struct _PopplerAnnotCalloutLine PopplerAnnotCalloutLine;
typedef enum
{
commit 189c45332991bce51e40bcaf65da67d2d644045a
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Sun Nov 15 16:42:21 2009 +0100
[glib] Remove PopplerDocument from PopplerAttachment
Since we are duplicating the stream we don't need to hold a reference of
PopplerDocument anymore.
diff --git a/glib/poppler-attachment.cc b/glib/poppler-attachment.cc
index 78bc72f..6a098e1 100644
--- a/glib/poppler-attachment.cc
+++ b/glib/poppler-attachment.cc
@@ -30,7 +30,6 @@ typedef struct _PopplerAttachmentPrivate PopplerAttachmentPrivate;
struct _PopplerAttachmentPrivate
{
Object *obj_stream;
- PopplerDocument *document;
};
#define POPPLER_ATTACHMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), POPPLER_TYPE_ATTACHMENT, PopplerAttachmentPrivate))
@@ -67,12 +66,6 @@ poppler_attachment_dispose (GObject *obj)
priv->obj_stream = NULL;
}
- if (priv->document)
- {
- g_object_unref (priv->document);
- priv->document = NULL;
- }
-
G_OBJECT_CLASS (poppler_attachment_parent_class)->dispose (obj);
}
@@ -101,20 +94,16 @@ poppler_attachment_finalize (GObject *obj)
/* Public functions */
PopplerAttachment *
-_poppler_attachment_new (PopplerDocument *document,
- EmbFile *emb_file)
+_poppler_attachment_new (EmbFile *emb_file)
{
PopplerAttachment *attachment;
PopplerAttachmentPrivate *priv;
- g_assert (document != NULL);
g_assert (emb_file != NULL);
attachment = (PopplerAttachment *) g_object_new (POPPLER_TYPE_ATTACHMENT, NULL);
priv = POPPLER_ATTACHMENT_GET_PRIVATE (attachment);
- priv->document = (PopplerDocument *) g_object_ref (document);
-
if (emb_file->name ())
attachment->name = _poppler_goo_string_to_utf8 (emb_file->name ());
if (emb_file->description ())
diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
index e5b2854..f461efb 100644
--- a/glib/poppler-document.cc
+++ b/glib/poppler-document.cc
@@ -472,7 +472,7 @@ poppler_document_get_attachments (PopplerDocument *document)
delete emb_file;
continue;
}
- attachment = _poppler_attachment_new (document, emb_file);
+ attachment = _poppler_attachment_new (emb_file);
delete emb_file;
retval = g_list_prepend (retval, attachment);
diff --git a/glib/poppler-private.h b/glib/poppler-private.h
index e8ace14..d2e7017 100644
--- a/glib/poppler-private.h
+++ b/glib/poppler-private.h
@@ -103,8 +103,7 @@ PopplerDest *_poppler_dest_new_goto (PopplerDocument *document,
LinkDest *link_dest);
PopplerFormField *_poppler_form_field_new (PopplerDocument *document,
FormWidget *field);
-PopplerAttachment *_poppler_attachment_new (PopplerDocument *document,
- EmbFile *file);
+PopplerAttachment *_poppler_attachment_new (EmbFile *file);
PopplerAnnot *_poppler_annot_new (Annot *annot);
PopplerAnnot *_poppler_annot_text_new (Annot *annot);
PopplerAnnot *_poppler_annot_free_text_new (Annot *annot);
More information about the poppler
mailing list