[sushi/wip/cosimoc/no-clutter: 4/50] evince: cleanup renderer state



commit 9c214e15874c20d9def135ce8f5f8434bbdb94d7
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sun Apr 9 15:11:58 2017 -0700

    evince: cleanup renderer state
    
    Don't hold on the pdf loader, and avoid storing the document in a
    private field too.

 src/js/viewers/evince.js        | 21 +++++----------------
 src/libsushi/sushi-pdf-loader.c | 32 ++++----------------------------
 src/libsushi/sushi-pdf-loader.h |  5 -----
 3 files changed, 9 insertions(+), 49 deletions(-)
---
diff --git a/src/js/viewers/evince.js b/src/js/viewers/evince.js
index f6cea9f..181a40a 100644
--- a/src/js/viewers/evince.js
+++ b/src/js/viewers/evince.js
@@ -43,9 +43,6 @@ const EvinceRenderer = new Lang.Class({
     _init : function(args) {
         EvDoc.init();
 
-        this._pdfLoader = null;
-        this._document = null;
-
         this.moveOnClick = false;
         this.canFullScreen = true;
     },
@@ -66,10 +63,8 @@ const EvinceRenderer = new Lang.Class({
     },
 
     _updatePageLabel : function() {
-        let curPage, totPages;
-
-        curPage = this._model.get_page();
-        totPages = this._document.get_n_pages();
+        let curPage = this._model.get_page();
+        let totPages = this._model.document.get_n_pages();
 
         this._toolbarBack.set_sensitive(curPage > 0);
         this._toolbarForward.set_sensitive(curPage < totPages - 1);
@@ -77,17 +72,13 @@ const EvinceRenderer = new Lang.Class({
         this._pageLabel.set_text(_("%d of %d").format(curPage + 1, totPages));
     },
 
-    _onDocumentLoaded : function() {
-        this._document = this._pdfLoader.document;
-        this._model = EvView.DocumentModel.new_with_document(this._document);
+    _onDocumentLoaded : function(pdfLoader) {
+        this._model = EvView.DocumentModel.new_with_document(pdfLoader.document);
 
         this._model.set_sizing_mode(EvView.SizingMode.FIT_WIDTH);
        this._model.set_continuous(true);
 
-        this._model.connect('page-changed',
-                            Lang.bind(this, function() {
-                                this._updatePageLabel();
-                            }));
+        this._model.connect('page-changed', Lang.bind(this, this._updatePageLabel));
 
         this._view = EvView.View.new();
         this._view.show();
@@ -167,8 +158,6 @@ const EvinceRenderer = new Lang.Class({
     },
 
     clear : function() {
-        this._pdfLoader.cleanup_document();
-        this._document = null;
         this._pdfLoader = null;
     }
 });
diff --git a/src/libsushi/sushi-pdf-loader.c b/src/libsushi/sushi-pdf-loader.c
index 16c3221..508f63d 100644
--- a/src/libsushi/sushi-pdf-loader.c
+++ b/src/libsushi/sushi-pdf-loader.c
@@ -390,9 +390,11 @@ sushi_pdf_loader_set_uri (SushiPdfLoader *self,
   start_loading_document (self);
 }
 
-void
-sushi_pdf_loader_cleanup_document (SushiPdfLoader *self)
+static void
+sushi_pdf_loader_dispose (GObject *object)
 {
+  SushiPdfLoader *self = SUSHI_PDF_LOADER (object);
+
   if (self->priv->pdf_path) {
     g_unlink (self->priv->pdf_path);
     g_free (self->priv->pdf_path);
@@ -402,14 +404,6 @@ sushi_pdf_loader_cleanup_document (SushiPdfLoader *self)
     kill (self->priv->libreoffice_pid, SIGKILL);
     self->priv->libreoffice_pid = -1;
   }
-}
-
-static void
-sushi_pdf_loader_dispose (GObject *object)
-{
-  SushiPdfLoader *self = SUSHI_PDF_LOADER (object);
-
-  sushi_pdf_loader_cleanup_document (self);
 
   g_clear_object (&self->priv->document);
   g_free (self->priv->uri);
@@ -504,21 +498,3 @@ sushi_pdf_loader_new (const gchar *uri)
                        "uri", uri,
                        NULL);
 }
-
-/**
- * sushi_pdf_loader_get_max_page_size:
- * @self:
- * @width: (out):
- * @height: (out):
- *
- */
-void
-sushi_pdf_loader_get_max_page_size (SushiPdfLoader *self,
-                                    gdouble *width,
-                                    gdouble *height)
-{
-  if (self->priv->document == NULL)
-    return;
-
-  ev_document_get_max_page_size (self->priv->document, width, height);
-}
diff --git a/src/libsushi/sushi-pdf-loader.h b/src/libsushi/sushi-pdf-loader.h
index c33dab2..3a5fc70 100644
--- a/src/libsushi/sushi-pdf-loader.h
+++ b/src/libsushi/sushi-pdf-loader.h
@@ -56,11 +56,6 @@ struct _SushiPdfLoaderClass
 GType    sushi_pdf_loader_get_type     (void) G_GNUC_CONST;
 
 SushiPdfLoader *sushi_pdf_loader_new (const gchar *uri);
-void sushi_pdf_loader_cleanup_document (SushiPdfLoader *self);
-void sushi_pdf_loader_get_max_page_size (SushiPdfLoader *self,
-                                         gdouble *width,
-                                         gdouble *height);
-
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]