From 6b05feae2e57d126f57a1f40527ff387070e9a73 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 19 Apr 2005 16:40:32 +0000 Subject: [PATCH] Remove get_title from the interface, we can just use document info 2005-04-19 Marco Pesenti Gritti * 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 --- ChangeLog | 14 ++++++++++ backend/ev-document.c | 44 ++++++----------------------- backend/ev-document.h | 59 ++++++++++++++++++--------------------- backend/ev-page-cache.c | 10 ++++++- pdf/ev-poppler.cc | 32 --------------------- pixbuf/pixbuf-document.c | 49 ++++++++------------------------ ps/ps-document.c | 60 ++++++++++------------------------------ 7 files changed, 84 insertions(+), 184 deletions(-) diff --git a/ChangeLog b/ChangeLog index c53b7e81..bf00f2c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2005-04-19 Marco Pesenti Gritti + + * 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 * backend/Makefile.am: diff --git a/backend/ev-document.c b/backend/ev-document.c index 6aa0504c..5df6e69b 100644 --- a/backend/ev-document.c +++ b/backend/ev-document.c @@ -67,12 +67,6 @@ ev_document_error_quark (void) 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" @@ -134,17 +128,6 @@ ev_document_save (EvDocument *document, 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) { @@ -190,6 +173,14 @@ ev_document_can_get_text (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, @@ -236,22 +227,3 @@ ev_document_render_pixbuf (EvDocument *document, 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; - -} diff --git a/backend/ev-document.h b/backend/ev-document.h index d8f8eba0..47a91eef 100644 --- a/backend/ev-document.h +++ b/backend/ev-document.h @@ -92,38 +92,33 @@ struct _EvDocumentIface 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 diff --git a/backend/ev-page-cache.c b/backend/ev-page-cache.c index 491e0742..935347e1 100644 --- a/backend/ev-page-cache.c +++ b/backend/ev-page-cache.c @@ -89,6 +89,7 @@ ev_page_cache_finalize (GObject *object) EvPageCache * _ev_page_cache_new (EvDocument *document) { + EvDocumentInfo *doc_info; EvPageCache *page_cache; EvPageCacheInfo *info; gint i; @@ -102,9 +103,16 @@ _ev_page_cache_new (EvDocument *document) /* 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; diff --git a/pdf/ev-poppler.cc b/pdf/ev-poppler.cc index 95ea00e5..ac70a035 100644 --- a/pdf/ev-poppler.cc +++ b/pdf/ev-poppler.cc @@ -32,13 +32,6 @@ #include "ev-document-security.h" #include "ev-document-thumbnails.h" - -enum { - PROP_0, - PROP_TITLE -}; - - typedef struct { PdfDocument *document; char *text; @@ -94,34 +87,9 @@ G_DEFINE_TYPE_WITH_CODE (PdfDocument, pdf_document, G_TYPE_OBJECT, 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 diff --git a/pixbuf/pixbuf-document.c b/pixbuf/pixbuf-document.c index 0aabb55f..18d357df 100644 --- a/pixbuf/pixbuf-document.c +++ b/pixbuf/pixbuf-document.c @@ -20,11 +20,6 @@ #include "pixbuf-document.h" #include "ev-document-thumbnails.h" -enum { - PROP_0, - PROP_TITLE -}; - struct _PixbufDocumentClass { GObjectClass parent_class; @@ -129,44 +124,12 @@ pixbuf_document_finalize (GObject *object) 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 @@ -175,6 +138,17 @@ pixbuf_document_can_get_text (EvDocument *document) 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) { @@ -184,6 +158,7 @@ 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 * diff --git a/ps/ps-document.c b/ps/ps-document.c index 8f514cff..a794e995 100644 --- a/ps/ps-document.c +++ b/ps/ps-document.c @@ -68,11 +68,6 @@ GCond* pixbuf_cond = NULL; 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; @@ -151,41 +146,6 @@ ps_document_init (PSDocument *gs) 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) { @@ -196,15 +156,11 @@ 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 @@ -1122,8 +1078,6 @@ document_load(PSDocument * gs, const gchar * fname) /* 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]; @@ -1409,6 +1363,19 @@ ps_document_render_pixbuf (EvDocument *document, int page, double scale) 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) { @@ -1418,6 +1385,7 @@ 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 -- 2.43.5