]> www.fi.muni.cz Git - evince.git/commitdiff
Some cleanups, stop the interpreter on finalize
authorMarco Pesenti Gritti <marco@gnome.org>
Mon, 7 Feb 2005 21:51:28 +0000 (21:51 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Mon, 7 Feb 2005 21:51:28 +0000 (21:51 +0000)
2005-02-07  Marco Pesenti Gritti  <marco@gnome.org>

        * ps/ps-document.c: (ps_document_finalize),
        (ps_document_get_n_pages), (ps_document_get_page):

        Some cleanups, stop the interpreter on finalize

        * shell/ev-page-view.c: (ev_page_view_dispose),
        (ev_page_view_class_init):

        Release our reference on the document

ChangeLog
ps/ps-document.c
shell/ev-page-view.c

index f789a601cc5b8a7e2fb825776319e28876b413dd..ab79810869f3ab3b2d837683d6ec8a5a7d8099de 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-02-07  Marco Pesenti Gritti  <marco@gnome.org>
+
+       * ps/ps-document.c: (ps_document_finalize),
+       (ps_document_get_n_pages), (ps_document_get_page):
+
+       Some cleanups, stop the interpreter on finalize
+
+       * shell/ev-page-view.c: (ev_page_view_dispose),
+       (ev_page_view_class_init):
+
+       Release our reference on the document
+
 2005-02-07  Marco Pesenti Gritti  <marco@gnome.org>
 
        * Makefile.am:
index 0e4f3693f4e2eb3b45117439d4d2d15931fc53ec..c7263bc1fce04d98826abf54b104a30568ecec1c 100644 (file)
@@ -389,23 +389,26 @@ ps_document_cleanup(PSDocument * gs)
 }
 
 static void
-ps_document_finalize(GObject * object)
+ps_document_finalize (GObject * object)
 {
-  PSDocument *gs;
+       PSDocument *gs;
 
-  g_return_if_fail(object != NULL);
-  g_return_if_fail(GTK_IS_GS(object));
+       g_return_if_fail (object != NULL);
+       g_return_if_fail (GTK_IS_GS (object));
 
-  gs = PS_DOCUMENT(object);
+       LOG ("Finalize")
 
-  ps_document_cleanup(gs);
+       gs = PS_DOCUMENT (object);
 
-  if(gs->input_buffer) {
-    g_free(gs->input_buffer);
-    gs->input_buffer = NULL;
-  }
+       ps_document_cleanup (gs);
+       stop_interpreter (gs);
+
+       if(gs->input_buffer) {
+               g_free(gs->input_buffer);
+               gs->input_buffer = NULL;
+       }
 
-  (*G_OBJECT_CLASS(parent_class)->finalize) (object);
+       (*G_OBJECT_CLASS(parent_class)->finalize) (object);
 }
 
 static void
@@ -1431,31 +1434,6 @@ ps_document_next_page(PSDocument * gs)
   return TRUE;
 }
 
-static gint
-ps_document_get_current_page(PSDocument * gs)
-{
-  g_return_val_if_fail(gs != NULL, -1);
-  g_return_val_if_fail(GTK_IS_GS(gs), -1);
-
-  return gs->current_page;
-}
-
-static gint
-ps_document_get_page_count(PSDocument * gs)
-{
-  if(!gs->gs_filename)
-    return 0;
-
-  if(gs->doc) {
-    if(gs->structured_doc)
-      return gs->doc->numpages;
-    else
-      return G_MAXINT;
-  }
-  else
-    return 0;
-}
-
 static gboolean
 ps_document_goto_page(PSDocument * gs, gint page)
 {
@@ -1732,7 +1710,15 @@ ps_document_save (EvDocument  *document,
 static int
 ps_document_get_n_pages (EvDocument  *document)
 {
-       return ps_document_get_page_count (PS_DOCUMENT (document));
+       PSDocument *ps = PS_DOCUMENT (document);
+
+       g_return_val_if_fail (ps != NULL, -1);
+
+       if (!ps->gs_filename || !ps->doc) {
+               return -1;
+       }
+
+       return ps->structured_doc ? ps->doc->numpages : 1;
 }
 
 static void
@@ -1745,7 +1731,11 @@ ps_document_set_page (EvDocument  *document,
 static int
 ps_document_get_page (EvDocument  *document)
 {
-       return ps_document_get_current_page (PS_DOCUMENT (document));
+       PSDocument *ps = PS_DOCUMENT (document);
+
+       g_return_val_if_fail (ps != NULL, -1);
+
+       return ps->current_page;
 }
 
 static gboolean
index 050e3cc8c76c841e9285cb4c3c66b0f4c99d7c91..4b019c4b651ab027a3dfdf18b547c2a872c3997a 100644 (file)
@@ -97,6 +97,19 @@ ev_page_view_init (EvPageView *page_view)
        page_view->priv->uniform_page_size = FALSE;
 }
 
+static void
+ev_page_view_dispose (GObject *object)
+{
+       EvPageView *view = EV_PAGE_VIEW (object);
+
+       if (view->priv->document) {
+               g_object_unref (view->priv->document);
+               view->priv->document = NULL;
+       }
+
+       G_OBJECT_CLASS (ev_page_view_parent_class)->dispose (object);
+}
+
 static void
 ev_page_view_class_init (EvPageViewClass *klass)
 {
@@ -115,6 +128,8 @@ ev_page_view_class_init (EvPageViewClass *klass)
        widget_class->unrealize = ev_page_view_unrealize;
        widget_class->map = ev_page_view_map;
 
+       o_class->dispose = ev_page_view_dispose;
+
        widget_class->set_scroll_adjustments_signal =
                g_signal_new ("set_scroll_adjustments",
                              G_TYPE_FROM_CLASS (o_class),