]> www.fi.muni.cz Git - evince.git/commitdiff
Convert EvDocument interface into an abstract class
authorCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 18 Aug 2009 10:08:37 +0000 (12:08 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 15 Sep 2009 13:56:00 +0000 (15:56 +0200)
backend/comics/comics-document.c
backend/djvu/djvu-document-private.h
backend/djvu/djvu-document.c
backend/dvi/dvi-document.c
backend/impress/impress-document.c
backend/pdf/ev-poppler.cc
backend/pixbuf/pixbuf-document.c
backend/ps/ev-spectre.c
backend/tiff/tiff-document.c
libdocument/ev-document.c
libdocument/ev-document.h

index 0c3d37f147c613e587cf36436de0d804bf069de7..3cd6db6b3375a55fa7f2715457e30f086b645509 100644 (file)
 
 struct _ComicsDocumentClass
 {
-       GObjectClass parent_class;
+       EvDocumentClass parent_class;
 };
-typedef enum 
+
+typedef enum
 {
        RARLABS,
        GNAUNRAR,
@@ -49,7 +49,8 @@ typedef enum
 
 struct _ComicsDocument
 {
-       GObject parent_instance;
+       EvDocument parent_instance;
+
        gchar    *archive, *dir;
        GSList   *page_names;
        gint     n_pages;
@@ -80,7 +81,6 @@ struct {
 
 typedef struct    _ComicsDocumentClass ComicsDocumentClass;
 
-static void       comics_document_document_iface_init (EvDocumentIface *iface);
 static void       comics_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface);
 
 static GSList*    get_supported_image_extensions (void);
@@ -721,13 +721,6 @@ comics_document_finalize (GObject *object)
        G_OBJECT_CLASS (comics_document_parent_class)->finalize (object);
 }
 
-static void
-comics_document_class_init (ComicsDocumentClass *klass)
-{
-       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-       gobject_class->finalize = comics_document_finalize;
-}
-
 static EvDocumentInfo *
 comics_document_get_info (EvDocument *document)
 {
@@ -737,14 +730,19 @@ comics_document_get_info (EvDocument *document)
 }
 
 static void
-comics_document_document_iface_init (EvDocumentIface *iface)
+comics_document_class_init (ComicsDocumentClass *klass)
 {
-       iface->load = comics_document_load;
-       iface->save = comics_document_save;
-       iface->get_n_pages = comics_document_get_n_pages;
-       iface->get_page_size = comics_document_get_page_size;
-       iface->render = comics_document_render;
-       iface->get_info = comics_document_get_info;
+       GObjectClass    *gobject_class = G_OBJECT_CLASS (klass);
+       EvDocumentClass *ev_document_class = EV_DOCUMENT_CLASS (klass);
+
+       gobject_class->finalize = comics_document_finalize;
+
+       ev_document_class->load = comics_document_load;
+       ev_document_class->save = comics_document_save;
+       ev_document_class->get_n_pages = comics_document_get_n_pages;
+       ev_document_class->get_page_size = comics_document_get_page_size;
+       ev_document_class->render = comics_document_render;
+       ev_document_class->get_info = comics_document_get_info;
 }
 
 static void
index a110e15e00c8cbf2b036ae115ed8fa1f5ffd1fcb..d1d7ec7cca49b8bf71d801afda74c26637b7b7d8 100644 (file)
@@ -26,7 +26,7 @@
 #include <libdjvu/ddjvuapi.h>
 
 struct _DjvuDocument {
-       GObject           parent_instance;
+       EvDocument        parent_instance;
 
        ddjvu_context_t  *d_context;
        ddjvu_document_t *d_document;
index daf09a5c5b0b2482408508e8cce155ba7c453e92..2bc1f7eade0670f19ffec0cb02fc98f52c6a98f7 100644 (file)
@@ -46,12 +46,11 @@ enum {
 
 struct _DjvuDocumentClass
 {
-       GObjectClass parent_class;
+       EvDocumentClass parent_class;
 };
 
 typedef struct _DjvuDocumentClass DjvuDocumentClass;
 
-static void djvu_document_document_iface_init (EvDocumentIface *iface);
 static void djvu_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface);
 static void djvu_document_file_exporter_iface_init (EvFileExporterIface *iface);
 static void djvu_document_find_iface_init (EvDocumentFindIface *iface);
@@ -387,6 +386,16 @@ djvu_document_render (EvDocument      *document,
        return surface;
 }
 
+static EvDocumentInfo *
+djvu_document_get_info (EvDocument *document)
+{
+       EvDocumentInfo *info;
+
+       info = g_new0 (EvDocumentInfo, 1);
+
+       return info;
+}
+
 static void
 djvu_document_finalize (GObject *object)
 {
@@ -412,30 +421,17 @@ djvu_document_finalize (GObject *object)
 static void
 djvu_document_class_init (DjvuDocumentClass *klass)
 {
-       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+       GObjectClass    *gobject_class = G_OBJECT_CLASS (klass);
+       EvDocumentClass *ev_document_class = EV_DOCUMENT_CLASS (klass);
 
        gobject_class->finalize = djvu_document_finalize;
-}
 
-static EvDocumentInfo *
-djvu_document_get_info (EvDocument *document)
-{
-       EvDocumentInfo *info;
-
-       info = g_new0 (EvDocumentInfo, 1);
-
-       return info;
-}
-
-static void
-djvu_document_document_iface_init (EvDocumentIface *iface)
-{
-       iface->load = djvu_document_load;
-       iface->save = djvu_document_save;
-       iface->get_n_pages = djvu_document_get_n_pages;
-       iface->get_page_size = djvu_document_get_page_size;
-       iface->render = djvu_document_render;
-       iface->get_info = djvu_document_get_info;
+       ev_document_class->load = djvu_document_load;
+       ev_document_class->save = djvu_document_save;
+       ev_document_class->get_n_pages = djvu_document_get_n_pages;
+       ev_document_class->get_page_size = djvu_document_get_page_size;
+       ev_document_class->render = djvu_document_render;
+       ev_document_class->get_info = djvu_document_get_info;
 }
 
 static gchar *
index a1097c94563d4b775db61b9a1108bb6149e94813..7551f80343eeee247b269dee99945b9310c03851 100644 (file)
@@ -44,12 +44,12 @@ enum {
 
 struct _DviDocumentClass
 {
-       GObjectClass parent_class;
+       EvDocumentClass parent_class;
 };
 
 struct _DviDocument
 {
-       GObject parent_instance;
+       EvDocument parent_instance;
 
        DviContext *context;
        DviPageSpec *spec;
@@ -68,7 +68,6 @@ struct _DviDocument
 
 typedef struct _DviDocumentClass DviDocumentClass;
 
-static void dvi_document_document_iface_init            (EvDocumentIface           *iface);
 static void dvi_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface);
 static void dvi_document_file_exporter_iface_init      (EvFileExporterIface       *iface);
 static void dvi_document_do_color_special               (DviContext                *dvi,
@@ -230,11 +229,21 @@ dvi_document_finalize (GObject *object)
        G_OBJECT_CLASS (dvi_document_parent_class)->finalize (object);
 }
 
+static EvDocumentInfo *
+dvi_document_get_info (EvDocument *document)
+{
+       EvDocumentInfo *info;
+
+       info = g_new0 (EvDocumentInfo, 1);
+
+       return info;
+}
 
 static void
 dvi_document_class_init (DviDocumentClass *klass)
 {
-       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+       GObjectClass    *gobject_class = G_OBJECT_CLASS (klass);
+       EvDocumentClass *ev_document_class = EV_DOCUMENT_CLASS (klass);
 
        gobject_class->finalize = dvi_document_finalize;
 
@@ -243,27 +252,13 @@ dvi_document_class_init (DviDocumentClass *klass)
        mdvi_register_fonts ();
 
        dvi_context_mutex = g_mutex_new ();
-}
-
-static EvDocumentInfo *
-dvi_document_get_info (EvDocument *document)
-{
-       EvDocumentInfo *info;
-
-       info = g_new0 (EvDocumentInfo, 1);
 
-       return info;
-}
-
-static void
-dvi_document_document_iface_init (EvDocumentIface *iface)
-{
-       iface->load = dvi_document_load;
-       iface->save = dvi_document_save;
-       iface->get_n_pages = dvi_document_get_n_pages;
-       iface->get_page_size = dvi_document_get_page_size;
-       iface->render = dvi_document_render;
-       iface->get_info = dvi_document_get_info;
+       ev_document_class->load = dvi_document_load;
+       ev_document_class->save = dvi_document_save;
+       ev_document_class->get_n_pages = dvi_document_get_n_pages;
+       ev_document_class->get_page_size = dvi_document_get_page_size;
+       ev_document_class->render = dvi_document_render;
+       ev_document_class->get_info = dvi_document_get_info;
 }
 
 static void
index 72eb8c1fe3cc5c8d1ae932ae2c1e35dc8b29f503..0d58aaf61a344c36095fedceb128c1be19f00abb 100644 (file)
 
 struct _ImpressDocumentClass
 {
-  GObjectClass parent_class;
+  EvDocumentClass parent_class;
 };
 
 struct _ImpressDocument
 {
-  GObject parent_instance;
+  EvDocument parent_instance;
 
   ImpDoc *imp;
   ImpRenderCtx *ctx;
@@ -59,7 +59,6 @@ struct _ImpressDocument
 
 typedef struct _ImpressDocumentClass ImpressDocumentClass;
 
-static void impress_document_document_iface_init (EvDocumentIface *iface);
 static void impress_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface);
 
 EV_BACKEND_REGISTER_WITH_CODE (ImpressDocument, impress_document,
@@ -425,6 +424,17 @@ impress_document_render (EvDocument      *document,
   return scaled_surface;
 }
 
+static EvDocumentInfo *
+impress_document_get_info (EvDocument *document)
+{
+  EvDocumentInfo *info;
+
+  info = g_new0 (EvDocumentInfo, 1);
+  info->fields_mask = 0;
+
+  return info;
+}
+
 static void
 impress_document_finalize (GObject *object)
 {
@@ -454,31 +464,17 @@ impress_document_finalize (GObject *object)
 static void
 impress_document_class_init (ImpressDocumentClass *klass)
 {
-  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+  GObjectClass    *gobject_class = G_OBJECT_CLASS (klass);
+  EvDocumentClass *ev_document_class = EV_DOCUMENT_CLASS (klass);
 
   gobject_class->finalize = impress_document_finalize;
-}
 
-static EvDocumentInfo *
-impress_document_get_info (EvDocument *document)
-{
-  EvDocumentInfo *info;
-
-  info = g_new0 (EvDocumentInfo, 1);
-  info->fields_mask = 0;
-
-  return info;
-}
-
-static void
-impress_document_document_iface_init (EvDocumentIface *iface)
-{
-  iface->load = impress_document_load;
-  iface->save = impress_document_save;
-  iface->get_n_pages = impress_document_get_n_pages;
-  iface->get_page_size = impress_document_get_page_size;
-  iface->render = impress_document_render;
-  iface->get_info = impress_document_get_info;
+  ev_document_class->load = impress_document_load;
+  ev_document_class->save = impress_document_save;
+  ev_document_class->get_n_pages = impress_document_get_n_pages;
+  ev_document_class->get_page_size = impress_document_get_page_size;
+  ev_document_class->render = impress_document_render;
+  ev_document_class->get_info = impress_document_get_info;
 }
 
 static GdkPixbuf *
index 0333d715564810d5209bc9856e0c2386fc8b6733..84314ce9b65f3098733696ffd0164a1564f49e1d 100644 (file)
@@ -92,12 +92,12 @@ typedef struct {
 
 struct _PdfDocumentClass
 {
-       GObjectClass parent_class;
+       EvDocumentClass parent_class;
 };
 
 struct _PdfDocument
 {
-       GObject parent_instance;
+       EvDocument parent_instance;
 
        PopplerDocument *document;
        gchar *password;
@@ -113,7 +113,6 @@ struct _PdfDocument
        GList *layers;
 };
 
-static void pdf_document_document_iface_init             (EvDocumentIface            *iface);
 static void pdf_document_security_iface_init             (EvDocumentSecurityIface    *iface);
 static void pdf_document_document_thumbnails_iface_init  (EvDocumentThumbnailsIface  *iface);
 static void pdf_document_document_links_iface_init       (EvDocumentLinksIface       *iface);
@@ -233,14 +232,6 @@ pdf_document_dispose (GObject *object)
        G_OBJECT_CLASS (pdf_document_parent_class)->dispose (object);
 }
 
-static void
-pdf_document_class_init (PdfDocumentClass *klass)
-{
-       GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
-
-       g_object_class->dispose = pdf_document_dispose;
-}
-
 static void
 pdf_document_init (PdfDocument *pdf_document)
 {
@@ -448,28 +439,6 @@ pdf_document_render (EvDocument      *document,
                                width, height, rc);
 }
 
-/* EvDocumentSecurity */
-
-static gboolean
-pdf_document_has_document_security (EvDocumentSecurity *document_security)
-{
-       /* FIXME: do we really need to have this? */
-       return FALSE;
-}
-
-static void
-pdf_document_set_password (EvDocumentSecurity *document_security,
-                          const char         *password)
-{
-       PdfDocument *document = PDF_DOCUMENT (document_security);
-
-       if (document->password)
-               g_free (document->password);
-
-       document->password = g_strdup (password);
-}
-
-
 /* reference:
 http://www.pdfa.org/lib/exe/fetch.php?id=pdfa%3Aen%3Atechdoc&cache=cache&media=pdfa:techdoc:tn0001_pdfa-1_and_namespaces_2008-03-18.pdf */
 static char *
@@ -721,17 +690,42 @@ pdf_document_get_info (EvDocument *document)
 }
 
 static void
-pdf_document_document_iface_init (EvDocumentIface *iface)
-{
-       iface->save = pdf_document_save;
-       iface->load = pdf_document_load;
-       iface->get_n_pages = pdf_document_get_n_pages;
-       iface->get_page = pdf_document_get_page;
-       iface->get_page_size = pdf_document_get_page_size;
-       iface->get_page_label = pdf_document_get_page_label;
-       iface->render = pdf_document_render;
-       iface->get_info = pdf_document_get_info;
-};
+pdf_document_class_init (PdfDocumentClass *klass)
+{
+       GObjectClass    *g_object_class = G_OBJECT_CLASS (klass);
+       EvDocumentClass *ev_document_class = EV_DOCUMENT_CLASS (klass);
+
+       g_object_class->dispose = pdf_document_dispose;
+
+       ev_document_class->save = pdf_document_save;
+       ev_document_class->load = pdf_document_load;
+       ev_document_class->get_n_pages = pdf_document_get_n_pages;
+       ev_document_class->get_page = pdf_document_get_page;
+       ev_document_class->get_page_size = pdf_document_get_page_size;
+       ev_document_class->get_page_label = pdf_document_get_page_label;
+       ev_document_class->render = pdf_document_render;
+       ev_document_class->get_info = pdf_document_get_info;
+}
+
+/* EvDocumentSecurity */
+static gboolean
+pdf_document_has_document_security (EvDocumentSecurity *document_security)
+{
+       /* FIXME: do we really need to have this? */
+       return FALSE;
+}
+
+static void
+pdf_document_set_password (EvDocumentSecurity *document_security,
+                          const char         *password)
+{
+       PdfDocument *document = PDF_DOCUMENT (document_security);
+
+       if (document->password)
+               g_free (document->password);
+
+       document->password = g_strdup (password);
+}
 
 static void
 pdf_document_security_iface_init (EvDocumentSecurityIface *iface)
index d509b4d4edfe6f41312546c9a340d73e640f96fb..df3af036e6ae7ad4bcaae0256862948d8806c7d1 100644 (file)
 
 struct _PixbufDocumentClass
 {
-       GObjectClass parent_class;
+       EvDocumentClass parent_class;
 };
 
 struct _PixbufDocument
 {
-       GObject parent_instance;
+       EvDocument parent_instance;
 
        GdkPixbuf *pixbuf;
        
@@ -41,7 +41,6 @@ struct _PixbufDocument
 
 typedef struct _PixbufDocumentClass PixbufDocumentClass;
 
-static void pixbuf_document_document_iface_init (EvDocumentIface *iface);
 static void pixbuf_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface);
 
 EV_BACKEND_REGISTER_WITH_CODE (PixbufDocument, pixbuf_document,
@@ -139,14 +138,6 @@ pixbuf_document_finalize (GObject *object)
        G_OBJECT_CLASS (pixbuf_document_parent_class)->finalize (object);
 }
 
-static void
-pixbuf_document_class_init (PixbufDocumentClass *klass)
-{
-       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
-       gobject_class->finalize = pixbuf_document_finalize;
-}
-
 static EvDocumentInfo *
 pixbuf_document_get_info (EvDocument *document)
 {
@@ -159,14 +150,19 @@ pixbuf_document_get_info (EvDocument *document)
 }
 
 static void
-pixbuf_document_document_iface_init (EvDocumentIface *iface)
+pixbuf_document_class_init (PixbufDocumentClass *klass)
 {
-       iface->load = pixbuf_document_load;
-       iface->save = pixbuf_document_save;
-       iface->get_n_pages = pixbuf_document_get_n_pages;
-       iface->get_page_size = pixbuf_document_get_page_size;
-       iface->render = pixbuf_document_render;
-       iface->get_info = pixbuf_document_get_info;
+       GObjectClass    *gobject_class = G_OBJECT_CLASS (klass);
+       EvDocumentClass *ev_document_class = EV_DOCUMENT_CLASS (klass);
+
+       gobject_class->finalize = pixbuf_document_finalize;
+
+       ev_document_class->load = pixbuf_document_load;
+       ev_document_class->save = pixbuf_document_save;
+       ev_document_class->get_n_pages = pixbuf_document_get_n_pages;
+       ev_document_class->get_page_size = pixbuf_document_get_page_size;
+       ev_document_class->render = pixbuf_document_render;
+       ev_document_class->get_info = pixbuf_document_get_info;
 }
 
 static GdkPixbuf *
index 1342c3e9e920155aba4565533364a1bef19e7f8b..8ee1732a118c8cc920f249926d61a3f399094bbd 100644 (file)
 #include "ev-document-misc.h"
 
 struct _PSDocument {
-       GObject object;
+       EvDocument object;
 
        SpectreDocument *doc;
        SpectreExporter *exporter;
 };
 
 struct _PSDocumentClass {
-       GObjectClass parent_class;
+       EvDocumentClass parent_class;
 };
 
-static void ps_document_document_iface_init            (EvDocumentIface           *iface);
 static void ps_document_file_exporter_iface_init       (EvFileExporterIface       *iface);
 static void ps_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface);
 
@@ -77,16 +76,6 @@ ps_document_dispose (GObject *object)
        G_OBJECT_CLASS (ps_document_parent_class)->dispose (object);
 }
 
-static void
-ps_document_class_init (PSDocumentClass *klass)
-{
-       GObjectClass *object_class;
-
-       object_class = G_OBJECT_CLASS (klass);
-
-       object_class->dispose = ps_document_dispose;
-}
-
 /* EvDocumentIface */
 static gboolean
 ps_document_load (EvDocument *document,
@@ -331,16 +320,21 @@ ps_document_render (EvDocument      *document,
 }
 
 static void
-ps_document_document_iface_init (EvDocumentIface *iface)
+ps_document_class_init (PSDocumentClass *klass)
 {
-       iface->load = ps_document_load;
-       iface->save = ps_document_save;
-       iface->get_n_pages = ps_document_get_n_pages;
-       iface->get_page = ps_document_get_page;
-       iface->get_page_size = ps_document_get_page_size;
-       iface->get_page_label = ps_document_get_page_label;
-       iface->get_info = ps_document_get_info;
-       iface->render = ps_document_render;
+       GObjectClass    *object_class = G_OBJECT_CLASS (klass);
+       EvDocumentClass *ev_document_class = EV_DOCUMENT_CLASS (klass);
+
+       object_class->dispose = ps_document_dispose;
+
+       ev_document_class->load = ps_document_load;
+       ev_document_class->save = ps_document_save;
+       ev_document_class->get_n_pages = ps_document_get_n_pages;
+       ev_document_class->get_page = ps_document_get_page;
+       ev_document_class->get_page_size = ps_document_get_page_size;
+       ev_document_class->get_page_label = ps_document_get_page_label;
+       ev_document_class->get_info = ps_document_get_info;
+       ev_document_class->render = ps_document_render;
 }
 
 /* EvDocumentThumbnailsIface */
index 7f10c9ab7496b6edfdbd0e9244eacce26bdbea34..d122ba7a6c17ed052aa57a5b61381cb1d421e4e1 100644 (file)
 
 struct _TiffDocumentClass
 {
-  GObjectClass parent_class;
+  EvDocumentClass parent_class;
 };
 
 struct _TiffDocument
 {
-  GObject parent_instance;
+  EvDocument parent_instance;
 
   TIFF *tiff;
   gint n_pages;
@@ -53,7 +53,6 @@ struct _TiffDocument
 
 typedef struct _TiffDocumentClass TiffDocumentClass;
 
-static void tiff_document_document_iface_init (EvDocumentIface *iface);
 static void tiff_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface);
 static void tiff_document_document_file_exporter_iface_init (EvFileExporterIface *iface);
 
@@ -384,39 +383,18 @@ tiff_document_render_pixbuf (EvDocument      *document,
        return rotated_pixbuf;
 }
 
-static void
-tiff_document_finalize (GObject *object)
-{
-       TiffDocument *tiff_document = TIFF_DOCUMENT (object);
-
-       if (tiff_document->tiff)
-               TIFFClose (tiff_document->tiff);
-       if (tiff_document->uri)
-               g_free (tiff_document->uri);
-
-       G_OBJECT_CLASS (tiff_document_parent_class)->finalize (object);
-}
-
-static void
-tiff_document_class_init (TiffDocumentClass *klass)
-{
-       GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
-       gobject_class->finalize = tiff_document_finalize;
-}
-
 static gchar *
 tiff_document_get_page_label (EvDocument *document,
                              EvPage     *page)
 {
        TiffDocument *tiff_document = TIFF_DOCUMENT (document);
        static gchar *label;
-       
+
        if (TIFFGetField (tiff_document->tiff, TIFFTAG_PAGENAME, &label) &&
            g_utf8_validate (label, -1, NULL)) {
                return g_strdup (label);
        }
-       
+
        return NULL;
 }
 
@@ -432,15 +410,33 @@ tiff_document_get_info (EvDocument *document)
 }
 
 static void
-tiff_document_document_iface_init (EvDocumentIface *iface)
+tiff_document_finalize (GObject *object)
+{
+       TiffDocument *tiff_document = TIFF_DOCUMENT (object);
+
+       if (tiff_document->tiff)
+               TIFFClose (tiff_document->tiff);
+       if (tiff_document->uri)
+               g_free (tiff_document->uri);
+
+       G_OBJECT_CLASS (tiff_document_parent_class)->finalize (object);
+}
+
+static void
+tiff_document_class_init (TiffDocumentClass *klass)
 {
-       iface->load = tiff_document_load;
-       iface->save = tiff_document_save;
-       iface->get_n_pages = tiff_document_get_n_pages;
-       iface->get_page_size = tiff_document_get_page_size;
-       iface->render = tiff_document_render;
-       iface->get_page_label = tiff_document_get_page_label;
-       iface->get_info = tiff_document_get_info;
+       GObjectClass    *gobject_class = G_OBJECT_CLASS (klass);
+       EvDocumentClass *ev_document_class = EV_DOCUMENT_CLASS (klass);
+
+       gobject_class->finalize = tiff_document_finalize;
+
+       ev_document_class->load = tiff_document_load;
+       ev_document_class->save = tiff_document_save;
+       ev_document_class->get_n_pages = tiff_document_get_n_pages;
+       ev_document_class->get_page_size = tiff_document_get_page_size;
+       ev_document_class->render = tiff_document_render;
+       ev_document_class->get_page_label = tiff_document_get_page_label;
+       ev_document_class->get_info = tiff_document_get_info;
 }
 
 static GdkPixbuf *
index 9d1144a1b71997bde47f3915aa5aecbd6c9eb5ff..66d7d46e001da3811abe30455876db00f9f5cae0 100644 (file)
@@ -1,5 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
 /*
+ *  Copyright (C) 2009 Carlos Garcia Campos
  *  Copyright (C) 2004 Marco Pesenti Gritti
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -25,7 +26,7 @@
 GMutex *ev_doc_mutex = NULL;
 GMutex *ev_fc_mutex = NULL;
 
-EV_DEFINE_INTERFACE (EvDocument, ev_document, G_TYPE_OBJECT)
+G_DEFINE_ABSTRACT_TYPE (EvDocument, ev_document, G_TYPE_OBJECT)
 
 GQuark
 ev_document_error_quark (void)
@@ -37,11 +38,24 @@ ev_document_error_quark (void)
   return q;
 }
 
+static EvPage *
+ev_document_impl_get_page (EvDocument *document,
+                          gint        index)
+{
+       return ev_page_new (index);
+}
+
 static void
-ev_document_class_init (EvDocumentIface *klass)
+ev_document_init (EvDocument *document)
 {
 }
 
+static void
+ev_document_class_init (EvDocumentClass *klass)
+{
+       klass->get_page = ev_document_impl_get_page;
+}
+
 GMutex *
 ev_document_get_doc_mutex (void)
 {
@@ -118,16 +132,16 @@ ev_document_load (EvDocument  *document,
                  const char  *uri,
                  GError     **error)
 {
-       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+       EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
        gboolean retval;
        GError *err = NULL;
 
-       retval = iface->load (document, uri, &err);
+       retval = klass->load (document, uri, &err);
        if (!retval) {
                if (err) {
                        g_propagate_error (error, err);
                } else {
-                       g_warning ("%s::EvDocumentIface::load returned FALSE but did not fill in @error; fix the backend!\n",
+                       g_warning ("%s::EvDocument::load returned FALSE but did not fill in @error; fix the backend!\n",
                                   G_OBJECT_TYPE_NAME (document));
 
                        /* So upper layers don't crash */
@@ -156,38 +170,26 @@ ev_document_save (EvDocument  *document,
                  const char  *uri,
                  GError     **error)
 {
-       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       gboolean retval;
-
-       retval = iface->save (document, uri, error);
+       EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
 
-       return retval;
+       return klass->save (document, uri, error);
 }
 
 int
 ev_document_get_n_pages (EvDocument  *document)
 {
-       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       gint retval;
-
-       retval = iface->get_n_pages (document);
+       EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
 
-       return retval;
+       return klass->get_n_pages (document);
 }
 
 EvPage *
 ev_document_get_page (EvDocument *document,
                      gint        index)
 {
-       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       EvPage *retval;
+       EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
 
-       if (iface->get_page)
-               retval = iface->get_page (document, index);
-       else
-               retval = ev_page_new (index);
-
-       return retval;
+       return klass->get_page (document, index);
 }
 
 void
@@ -196,43 +198,36 @@ ev_document_get_page_size (EvDocument *document,
                           double     *width,
                           double     *height)
 {
-       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+       EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
 
-       iface->get_page_size (document, page, width, height);
+       klass->get_page_size (document, page, width, height);
 }
 
-char *
+gchar *
 ev_document_get_page_label (EvDocument *document,
                            EvPage     *page)
 {
-       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+       EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
 
-       if (iface->get_page_label == NULL)
-               return NULL;
-
-       return iface->get_page_label (document, page);
+       return klass->get_page_label ?
+               klass->get_page_label (document, page) : NULL;
 }
 
 EvDocumentInfo *
 ev_document_get_info (EvDocument *document)
 {
-       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+       EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
 
-       return iface->get_info (document);
+       return klass->get_info (document);
 }
 
 cairo_surface_t *
 ev_document_render (EvDocument      *document,
                    EvRenderContext *rc)
 {
-       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       cairo_surface_t *retval;
-
-       g_assert (iface->render);
+       EvDocumentClass *klass = EV_DOCUMENT_GET_CLASS (document);
 
-       retval = iface->render (document, rc);
-
-       return retval;
+       return klass->render (document, rc);
 }
 
 /* EvDocumentInfo */
index e74c49abe6f26184d261905ee9c226ac37b90188..74bd3bb7ebb0268bd652aff046e62ed1463c1742 100644 (file)
@@ -1,5 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
 /*
+ *  Copyright (C) 2009 Carlos Garcia Campos
  *  Copyright (C) 2000-2003 Marco Pesenti Gritti
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -39,13 +40,13 @@ G_BEGIN_DECLS
 
 #define EV_TYPE_DOCUMENT            (ev_document_get_type ())
 #define EV_DOCUMENT(o)              (G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_DOCUMENT, EvDocument))
-#define EV_DOCUMENT_IFACE(k)        (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT, EvDocumentIface))
+#define EV_DOCUMENT_CLASS(k)        (G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_DOCUMENT, EvDocumentClass))
 #define EV_IS_DOCUMENT(o)           (G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_DOCUMENT))
-#define EV_IS_DOCUMENT_IFACE(k)     (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT))
-#define EV_DOCUMENT_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_DOCUMENT, EvDocumentIface))
+#define EV_IS_DOCUMENT_CLASS(k)     (G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_DOCUMENT))
+#define EV_DOCUMENT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), EV_TYPE_DOCUMENT, EvDocumentClass))
 
 typedef struct _EvDocument        EvDocument;
-typedef struct _EvDocumentIface   EvDocumentIface;
+typedef struct _EvDocumentClass   EvDocumentClass;
 typedef struct _EvPageCache       EvPageCache;
 typedef struct _EvPageCacheClass  EvPageCacheClass;
 
@@ -66,29 +67,34 @@ typedef struct {
 
 typedef struct _EvRectangle EvRectangle;
 
-struct _EvDocumentIface
+struct _EvDocument
 {
-        GTypeInterface base_iface;
+       GObject base;
+};
+
+struct _EvDocumentClass
+{
+        GObjectClass base_class;
 
-        /* Methods  */
+        /* Virtual Methods  */
         gboolean          (* load)            (EvDocument      *document,
                                                const char      *uri,
                                                GError         **error);
         gboolean          (* save)            (EvDocument      *document,
                                                const char      *uri,
                                                GError         **error);
-        int               (* get_n_pages)     (EvDocument      *document);
+        gint              (* get_n_pages)     (EvDocument      *document);
        EvPage          * (* get_page)        (EvDocument      *document,
                                               gint             index);
         void              (* get_page_size)   (EvDocument      *document,
                                                EvPage          *page,
                                                double          *width,
                                                double          *height);
-        char            * (* get_page_label)  (EvDocument      *document,
+        gchar           * (* get_page_label)  (EvDocument      *document,
                                                EvPage          *page);
         cairo_surface_t * (* render)          (EvDocument      *document,
                                                EvRenderContext *rc);
-        EvDocumentInfo  (* get_info)        (EvDocument      *document);
+        EvDocumentInfo  * (* get_info)        (EvDocument      *document);
 };
 
 GType            ev_document_get_type         (void) G_GNUC_CONST;
@@ -113,14 +119,14 @@ gboolean         ev_document_load             (EvDocument      *document,
 gboolean         ev_document_save             (EvDocument      *document,
                                                const char      *uri,
                                                GError         **error);
-int              ev_document_get_n_pages      (EvDocument      *document);
+gint             ev_document_get_n_pages      (EvDocument      *document);
 EvPage          *ev_document_get_page         (EvDocument      *document,
                                               gint             index);
 void             ev_document_get_page_size    (EvDocument      *document,
                                                EvPage          *page,
                                                double          *width,
                                                double          *height);
-char            *ev_document_get_page_label   (EvDocument      *document,
+gchar           *ev_document_get_page_label   (EvDocument      *document,
                                                EvPage          *page);
 cairo_surface_t *ev_document_render           (EvDocument      *document,
                                                EvRenderContext *rc);
@@ -187,7 +193,7 @@ static void     backend_name##_class_intern_init (gpointer klass)           \
 G_MODULE_EXPORT GType                                                          \
 register_evince_backend (GTypeModule *module)                                  \
 {                                                                              \
-       const GTypeInfo our_info = {                                    \
+       const GTypeInfo our_info = {                                            \
                sizeof (BackendName##Class),                                    \
                NULL, /* base_init */                                           \
                NULL, /* base_finalize */                                       \
@@ -204,14 +210,11 @@ register_evince_backend (GTypeModule *module)                                     \
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");                     \
                                                                                 \
        g_define_type_id = g_type_module_register_type (module,                 \
-                                           G_TYPE_OBJECT,                      \
-                                           #BackendName,                       \
-                                           &our_info,                          \
-                                          (GTypeFlags)0);                      \
+                                                       EV_TYPE_DOCUMENT,       \
+                                                       #BackendName,           \
+                                                       &our_info,              \
+                                                       (GTypeFlags)0);         \
                                                                                \
-       EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT,                       \
-                               backend_name##_document_iface_init);             \
-                                                                               \
        CODE                                                                    \
                                                                                \
        return g_define_type_id;                                                \