[gnome-documents] all: use ev_document_model_get_document() to get the EvDocument



commit a442fc188c60dc4d06b22b05840e91adcd46cdb2
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Oct 25 18:22:09 2011 -0400

    all: use ev_document_model_get_document() to get the EvDocument
    
    Instead of shuffling our reference around, now that the Evince method is
    properly introspected.

 configure.ac       |    5 +++--
 src/embed.js       |   14 +++++---------
 src/mainToolbar.js |   14 +++++---------
 src/preview.js     |    7 +++----
 4 files changed, 16 insertions(+), 24 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b61b2b0..d764347 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,6 +49,7 @@ AC_SUBST(GJS_JS_DIR)
 
 GLIB_GSETTINGS
 
+EVINCE_MIN_VERSION=3.3.0
 GLIB_MIN_VERSION=2.29.90
 GTK_MIN_VERSION=3.1.13
 GOBJECT_INTROSPECTION_MIN_VERSION=0.9.6
@@ -59,8 +60,8 @@ TRACKER_MIN_VERSION=0.12.1
 
 PKG_CHECK_MODULES(DOCUMENTS,
                   clutter-gtk-1.0 >= $CLUTTER_GTK_MIN_VERSION
-                  evince-document-3.0
-                  evince-view-3.0
+                  evince-document-3.0 >= $EVINCE_MIN_VERSION
+                  evince-view-3.0 >= $EVINCE_MIN_VERSION
                   glib-2.0 >= $GLIB_MIN_VERSION
                   gobject-introspection-1.0 >= $GOBJECT_INTROSPECTION_MIN_VERSION
                   gtk+-3.0 >= $GTK_MIN_VERSION
diff --git a/src/embed.js b/src/embed.js
index 60e00f6..cc295f6 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -83,7 +83,7 @@ ViewEmbed.prototype  = {
 
     _createFullscreenToolbar: function() {
         this._fsToolbar = new MainToolbar.FullscreenToolbar();
-        this._fsToolbar.setModel(this._docModel, this._document);
+        this._fsToolbar.setModel(this._docModel);
 
         this._stage.add_actor(this._fsToolbar.actor);
 
@@ -175,7 +175,7 @@ ViewEmbed.prototype  = {
 
     _onDocumentLoaded: function(document) {
         this._loaderCancellable = null;
-        let model = EvView.DocumentModel.new_with_document(document);
+        this._docModel = EvView.DocumentModel.new_with_document(document);
 
         if (this._loaderTimeout) {
             Mainloop.source_remove(this._loaderTimeout);
@@ -185,15 +185,12 @@ ViewEmbed.prototype  = {
         Global.modeController.setWindowMode(WindowMode.WindowMode.PREVIEW);
         Global.modeController.setCanFullscreen(true);
 
-        this._preview = new Preview.PreviewView(model, document);
+        this._preview = new Preview.PreviewView(this._docModel);
 
         if (this._fsToolbar)
-            this._fsToolbar.setModel(model, document);
+            this._fsToolbar.setModel(this._docModel);
 
-        this._toolbar.setModel(model, document);
-
-        this._docModel = model;
-        this._document = document;
+        this._toolbar.setModel(this._docModel);
 
         this._preview.widget.connect('motion-notify-event',
                                      Lang.bind(this, this._fullscreenMotionHandler));
@@ -245,7 +242,6 @@ ViewEmbed.prototype  = {
         this._actor = null;
         this._clutterEmbed = null;
         this._docModel = null;
-        this._document = null;
         this._stage = null;
 
         Global.documentManager.setActiveItem(null);
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index 83138fd..fdee33e 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -42,7 +42,6 @@ function MainToolbar() {
 MainToolbar.prototype = {
     _init: function() {
         this._model = null;
-        this._document = null;
         this._searchFocusId = 0;
         this._searchEntryTimeout = 0;
 
@@ -66,7 +65,6 @@ MainToolbar.prototype = {
         }));
 
         this._model = null;
-        this._document = null;
     },
 
     _populateForOverview: function() {
@@ -148,7 +146,7 @@ MainToolbar.prototype = {
         this._searchEntry.set_text(Global.searchFilterController.getFilter());
     },
 
-    _populateForPreview: function(model, document) {
+    _populateForPreview: function(model) {
         let back = new Gtk.ToolButton({ icon_name: 'go-previous-symbolic' });
         back.get_style_context().add_class('raised');
         this.widget.insert(back, 0);
@@ -192,11 +190,11 @@ MainToolbar.prototype = {
         let titleLabel = ('<b>%s</b>').format(GLib.markup_escape_text(doc.title, -1));
         this._titleLabel.set_markup(titleLabel);
 
-        if (this._model && this._document) {
+        if (this._model) {
             let curPage, totPages;
 
             curPage = this._model.get_page();
-            totPages = this._document.get_n_pages();
+            totPages = this._model.get_document().get_n_pages();
 
             pageLabel = _("(%d of %d)").format(curPage + 1, totPages);
         }
@@ -220,13 +218,11 @@ MainToolbar.prototype = {
             this._populateForPreview();
     },
 
-    setModel: function(model, document) {
-        if (!model || !document)
+    setModel: function(model) {
+        if (!model)
             return;
 
         this._model = model;
-        this._document = document;
-
         this._model.connect('page-changed', Lang.bind(this,
             function() {
                 this._updateModelLabels();
diff --git a/src/preview.js b/src/preview.js
index 49e0ff3..dea5985 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -27,14 +27,13 @@ const Lang = imports.lang;
 const Global = imports.global;
 const View = imports.view;
 
-function PreviewView(model, document) {
-    this._init(model, document);
+function PreviewView(model) {
+    this._init(model);
 }
 
 PreviewView.prototype = {
-    _init: function(model, document) {
+    _init: function(model) {
         this._model = model;
-        this._document = document;
 
         this.widget = EvView.View.new();
         this.widget.set_model(this._model);



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