]> www.fi.muni.cz Git - evince.git/blobdiff - backend/ev-document.c
Check the links info is initialized before using it. Should fix a crash on
[evince.git] / backend / ev-document.c
index 4aea1d11c0fbeaf5afc6261c1b20088f484fc8ad..6f6a687eef0686f4345e88b9661b079f9e70423c 100644 (file)
 #include "config.h"
 
 #include "ev-document.h"
 #include "config.h"
 
 #include "ev-document.h"
-#include "ev-backend-marshal.c"
+#include "ev-backend-marshalers.h"
 
 
-static void ev_document_base_init (gpointer g_class);
+static void ev_document_class_init (gpointer g_class);
+
+enum
+{
+       CHANGED,
+       LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
 
 GType
 ev_document_get_type (void)
 
 GType
 ev_document_get_type (void)
@@ -35,8 +43,9 @@ ev_document_get_type (void)
                static const GTypeInfo our_info =
                {
                        sizeof (EvDocumentIface),
                static const GTypeInfo our_info =
                {
                        sizeof (EvDocumentIface),
-                       ev_document_base_init,
                        NULL,
                        NULL,
+                       NULL,
+                       (GClassInitFunc)ev_document_class_init
                };
 
                type = g_type_register_static (G_TYPE_INTERFACE,
                };
 
                type = g_type_register_static (G_TYPE_INTERFACE,
@@ -47,25 +56,35 @@ ev_document_get_type (void)
        return type;
 }
 
        return type;
 }
 
-static void
-ev_document_base_init (gpointer g_class)
+GQuark
+ev_document_error_quark (void)
 {
 {
-       static gboolean initialized = FALSE;
+  static GQuark q = 0;
+  if (q == 0)
+    q = g_quark_from_static_string ("ev-document-error-quark");
 
 
-       if (!initialized) {
-               g_signal_new ("found",
+  return q;
+}
+
+static void
+ev_document_class_init (gpointer g_class)
+{
+       signals[CHANGED] =
+               g_signal_new ("changed",
                              EV_TYPE_DOCUMENT,
                              G_SIGNAL_RUN_LAST,
                              EV_TYPE_DOCUMENT,
                              G_SIGNAL_RUN_LAST,
-                             G_STRUCT_OFFSET (EvDocumentIface, found),
+                             G_STRUCT_OFFSET (EvDocumentIface, changed),
                              NULL, NULL,
                              NULL, NULL,
-                             _ev_backend_marshal_VOID__POINTER_INT_DOUBLE,
-                             G_TYPE_NONE, 3,
-                             G_TYPE_POINTER,
-                             G_TYPE_INT,
-                             G_TYPE_DOUBLE);
-
-               initialized = TRUE;
-       }
+                             g_cclosure_marshal_VOID__VOID,
+                             G_TYPE_NONE,
+                             0);
+
+       g_object_interface_install_property (g_class,
+                               g_param_spec_string ("title",
+                                                    "Document Title",
+                                                    "The title of the document",
+                                                    NULL,
+                                                    G_PARAM_READABLE));
 }
 
 gboolean
 }
 
 gboolean
@@ -77,6 +96,25 @@ ev_document_load (EvDocument  *document,
        return iface->load (document, uri, error);
 }
 
        return iface->load (document, uri, error);
 }
 
+gboolean
+ev_document_save (EvDocument  *document,
+                 const char  *uri,
+                 GError     **error)
+{
+       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+       return iface->save (document, uri, error);
+}
+
+char *
+ev_document_get_title (EvDocument  *document)
+{
+       char *title;
+
+       g_object_get (document, "title", &title, NULL);
+
+       return title;
+}
+
 int
 ev_document_get_n_pages (EvDocument  *document)
 {
 int
 ev_document_get_n_pages (EvDocument  *document)
 {
@@ -133,6 +171,23 @@ ev_document_get_page_size   (EvDocument   *document,
        iface->get_page_size (document, width, height);
 }
 
        iface->get_page_size (document, width, height);
 }
 
+char *
+ev_document_get_text (EvDocument   *document,
+                     GdkRectangle *rect)
+{
+       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+       return iface->get_text (document, rect);
+}
+
+EvLink *
+ev_document_get_link (EvDocument   *document,
+                     int           x,
+                     int           y)
+{
+       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
+       return iface->get_link (document, x, y);
+}
+
 void
 ev_document_render (EvDocument  *document,
                    int          clip_x,
 void
 ev_document_render (EvDocument  *document,
                    int          clip_x,
@@ -145,17 +200,7 @@ ev_document_render (EvDocument  *document,
 }
 
 void
 }
 
 void
-ev_document_begin_find (EvDocument   *document,
-                       const char   *search_string,
-                       gboolean      case_sensitive)
+ev_document_changed (EvDocument *document)
 {
 {
-       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       iface->begin_find (document, search_string, case_sensitive);
-}
-
-void
-ev_document_end_find (EvDocument   *document)
-{
-       EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document);
-       iface->end_find (document);
-}
+       g_signal_emit (G_OBJECT (document), signals[CHANGED], 0);
+}