+2005-04-19 Marco Pesenti Gritti <mpg@redhat.com>
+
+ * backend/ev-document.c: (ev_document_class_init),
+ (ev_document_get_info), (ev_document_render_pixbuf):
+ * backend/ev-document.h:
+ * backend/ev-page-cache.c: (_ev_page_cache_new):
+ * pdf/ev-poppler.cc:
+ * pixbuf/pixbuf-document.c: (pixbuf_document_class_init),
+ (pixbuf_document_get_info), (pixbuf_document_document_iface_init):
+ * ps/ps-document.c: (ps_document_class_init), (document_load),
+ (ps_document_get_info), (ps_document_document_iface_init):
+
+ Remove get_title from the interface, we can just use document info
+
2005-04-19 Marco Pesenti Gritti <mpg@redhat.com>
* backend/Makefile.am:
static void
ev_document_class_init (gpointer g_class)
{
- g_object_interface_install_property (g_class,
- g_param_spec_string ("title",
- "Document Title",
- "The title of the document",
- NULL,
- G_PARAM_READABLE));
}
#define PAGE_CACHE_STRING "ev-page-cache"
return retval;
}
-char *
-ev_document_get_title (EvDocument *document)
-{
- char *title;
-
- LOG ("ev_document_get_title");
- g_object_get (document, "title", &title, NULL);
-
- return title;
-}
-
int
ev_document_get_n_pages (EvDocument *document)
{
return iface->can_get_text (document);
}
+EvDocumentInfo *
+ev_document_get_info (EvDocument *document)
+{
+ EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+
+ return iface->get_info (document);
+}
+
char *
ev_document_get_text (EvDocument *document,
int page,
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;
-
-}
EvDocumentInfo *(* get_info) (EvDocument *document);
};
-GType ev_document_get_type (void);
-GQuark ev_document_error_quark (void);
-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);
-gboolean ev_document_save (EvDocument *document,
- const char *uri,
- GError **error);
-char *ev_document_get_title (EvDocument *document);
-int ev_document_get_n_pages (EvDocument *document);
-void ev_document_get_page_size (EvDocument *document,
- int page,
- double *width,
- double *height);
-char *ev_document_get_page_label(EvDocument *document,
- int page);
-gboolean ev_document_can_get_text (EvDocument *document);
-char *ev_document_get_text (EvDocument *document,
- int page,
- EvRectangle *rect);
-GList *ev_document_get_links (EvDocument *document,
- int page);
-GdkPixbuf *ev_document_render_pixbuf (EvDocument *document,
- int page,
- double scale);
-EvDocumentInfo *ev_document_render_get_info (EvDocument *document);
-
+GType ev_document_get_type (void);
+GQuark ev_document_error_quark (void);
+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);
+gboolean ev_document_save (EvDocument *document,
+ const char *uri,
+ GError **error);
+int ev_document_get_n_pages (EvDocument *document);
+void ev_document_get_page_size (EvDocument *document,
+ int page,
+ double *width,
+ double *height);
+char *ev_document_get_page_label (EvDocument *document,
+ int page);
+gboolean ev_document_can_get_text (EvDocument *document);
+char *ev_document_get_text (EvDocument *document,
+ int page,
+ EvRectangle *rect);
+GList *ev_document_get_links (EvDocument *document,
+ int page);
+GdkPixbuf *ev_document_render_pixbuf (EvDocument *document,
+ int page,
+ double scale);
G_END_DECLS
EvPageCache *
_ev_page_cache_new (EvDocument *document)
{
+ EvDocumentInfo *doc_info;
EvPageCache *page_cache;
EvPageCacheInfo *info;
gint i;
/* Assume all pages are the same size until proven otherwise */
page_cache->uniform = TRUE;
page_cache->n_pages = ev_document_get_n_pages (document);
- page_cache->title = ev_document_get_title (document);
page_cache->page_labels = g_new0 (char *, page_cache->n_pages);
+ doc_info = ev_document_get_info (document);
+ if (doc_info->fields_mask & EV_DOCUMENT_INFO_TITLE) {
+ page_cache->title = g_strdup (doc_info->title);
+ } else {
+ page_cache->title = NULL;
+ }
+ g_free (doc_info);
+
for (i = 0; i < page_cache->n_pages; i++) {
double page_width = 0;
double page_height = 0;
#include "ev-document-security.h"
#include "ev-document-thumbnails.h"
-
-enum {
- PROP_0,
- PROP_TITLE
-};
-
-
typedef struct {
PdfDocument *document;
char *text;
pdf_document_ps_exporter_iface_init);
});
-
-static void
-pdf_document_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- PdfDocument *pdf_document = PDF_DOCUMENT (object);
-
- switch (prop_id)
- {
- case PROP_TITLE:
- if (pdf_document->document == NULL)
- g_value_set_string (value, NULL);
- else
- g_object_get_property (G_OBJECT (pdf_document->document), "title", value);
- break;
- }
-}
-
static void
pdf_document_class_init (PdfDocumentClass *klass)
{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->get_property = pdf_document_get_property;
-
- g_object_class_override_property (gobject_class, PROP_TITLE, "title");
}
static void
#include "pixbuf-document.h"
#include "ev-document-thumbnails.h"
-enum {
- PROP_0,
- PROP_TITLE
-};
-
struct _PixbufDocumentClass
{
GObjectClass parent_class;
G_OBJECT_CLASS (pixbuf_document_parent_class)->finalize (object);
}
-static void
-pixbuf_document_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id)
- {
- case PROP_TITLE:
- /* read only */
- break;
- }
-}
-
-static void
-pixbuf_document_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id)
- {
- case PROP_TITLE:
- g_value_set_string (value, NULL);
- break;
- }
-}
-
static void
pixbuf_document_class_init (PixbufDocumentClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = pixbuf_document_finalize;
- gobject_class->get_property = pixbuf_document_get_property;
- gobject_class->set_property = pixbuf_document_set_property;
-
- g_object_class_override_property (gobject_class, PROP_TITLE, "title");
}
static gboolean
return FALSE;
}
+static EvDocumentInfo *
+pixbuf_document_get_info (EvDocument *document)
+{
+ EvDocumentInfo *info;
+
+ info = g_new0 (EvDocumentInfo, 1);
+ info->fields_mask = 0;
+
+ return info;
+}
+
static void
pixbuf_document_document_iface_init (EvDocumentIface *iface)
{
iface->get_n_pages = pixbuf_document_get_n_pages;
iface->get_page_size = pixbuf_document_get_page_size;
iface->render_pixbuf = pixbuf_document_render_pixbuf;
+ iface->get_info = pixbuf_document_get_info;
}
static GdkPixbuf *
GMutex* pixbuf_mutex = NULL;
GdkPixbuf *current_pixbuf = NULL;
-enum {
- PROP_0,
- PROP_TITLE
-};
-
/* structure to describe section of file to send to ghostscript */
struct record_list {
FILE *fp;
pixbuf_mutex = g_mutex_new ();
}
-static void
-ps_document_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id)
-
- {
- case PROP_TITLE:
- /* read only */
- break;
- }
-}
-
-static void
-ps_document_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- PSDocument *ps = PS_DOCUMENT (object);
-
- switch (prop_id)
- {
- case PROP_TITLE:
- if (ps->doc) {
- g_value_set_string (value, ps->doc->title);
- } else {
- g_value_set_string (value, NULL);
- }
- break;
- }
-}
-
static void
ps_document_class_init(PSDocumentClass *klass)
{
gs_class = klass;
object_class->finalize = ps_document_finalize;
- object_class->get_property = ps_document_get_property;
- object_class->set_property = ps_document_set_property;
klass->gs_atom = gdk_atom_intern ("GHOSTVIEW", FALSE);
klass->next_atom = gdk_atom_intern ("NEXT", FALSE);
klass->page_atom = gdk_atom_intern ("PAGE", FALSE);
klass->string_atom = gdk_atom_intern ("STRING", FALSE);
-
- g_object_class_override_property (object_class, PROP_TITLE, "title");
}
static void
/* we grab the vital statistics!!! */
gs->doc = psscan(gs->gs_psfile, TRUE, filename);
- g_object_notify (G_OBJECT (gs), "title");
-
if(gs->doc == NULL) {
/* File does not seem to be a Postscript one */
gchar buf[1024];
return pixbuf;
}
+static EvDocumentInfo *
+ps_document_get_info (EvDocument *document)
+{
+ EvDocumentInfo *info;
+ PSDocument *ps = PS_DOCUMENT (document);
+
+ info = g_new0 (EvDocumentInfo, 1);
+ info->fields_mask = EV_DOCUMENT_INFO_TITLE;
+ info->title = ps->doc->title;
+
+ return info;
+}
+
static void
ps_document_document_iface_init (EvDocumentIface *iface)
{
iface->get_n_pages = ps_document_get_n_pages;
iface->get_page_size = ps_document_get_page_size;
iface->render_pixbuf = ps_document_render_pixbuf;
+ iface->get_info = ps_document_get_info;
}
static void