[gnome-documents] Rename view.js to overview.js



commit 6380ae73339723279843c092bbe1ef5cf5c1c98e
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sun Oct 23 18:53:07 2016 -0700

    Rename view.js to overview.js
    
    Move the old "View" class back to embed.js, since it's conceptually
    where it belongs.
    view.js has always been about the overview, so rename it accordingly.

 src/embed.js                              |  125 ++++++++++++++++++++++++++++-
 src/org.gnome.Books.src.gresource.xml     |    2 +-
 src/org.gnome.Documents.src.gresource.xml |    2 +-
 src/{view.js => overview.js}              |  121 ----------------------------
 4 files changed, 125 insertions(+), 125 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 9425607..dab93f2 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -23,15 +23,136 @@ const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 
 const Application = imports.application;
+const EPUBView = imports.epubview;
+const Edit = imports.edit;
+const EvinceView = imports.evinceview;
+const LOKView = imports.lokview;
 const Search = imports.search;
 const Selections = imports.selections;
-const View = imports.view;
+const Overview = imports.overview;
 const WindowMode = imports.windowMode;
 
 const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
 const _ = imports.gettext.gettext;
 
+const View = new Lang.Class({
+    Name: 'View',
+    Extends: Gtk.Overlay,
+
+    _init: function(window) {
+        this._toolbar = null;
+        this._window = window;
+
+        this.parent();
+
+        this._stack = new Gtk.Stack({ visible: true,
+                                      homogeneous: true,
+                                      transition_type: Gtk.StackTransitionType.CROSSFADE });
+        this.add(this._stack);
+
+        // pack the OSD notification widget
+        this.add_overlay(Application.notificationManager);
+
+        this.show();
+    },
+
+    _clearPreview: function() {
+        if (this._preview) {
+            this._preview.destroy();
+            this._preview = null;
+        }
+    },
+
+    _createPreview: function(mode) {
+        let constructor;
+        switch (mode) {
+        case WindowMode.WindowMode.PREVIEW_EV:
+            constructor = EvinceView.EvinceView;
+            break;
+        case WindowMode.WindowMode.PREVIEW_LOK:
+            constructor = LOKView.LOKView;
+            break;
+        case WindowMode.WindowMode.PREVIEW_EPUB:
+            constructor = EPUBView.EPUBView;
+            break;
+        case WindowMode.WindowMode.EDIT:
+            constructor = Edit.EditView;
+            break;
+        default:
+            return;
+        }
+
+        this._preview = new constructor(this, this._window);
+        this._stack.add_named(this._preview, 'preview');
+    },
+
+    _ensureOverview: function(mode) {
+        if (!this._overview) {
+            this._overview = new Overview.OverviewStack();
+            this._stack.add_named(this._overview, 'overview');
+        }
+
+        this._overview.windowMode = mode;
+    },
+
+    _onActivateResult: function() {
+        this.view.activateResult();
+    },
+
+    set windowMode(mode) {
+        let fromPreview = !!this._preview;
+        this._clearPreview();
+
+        switch (mode) {
+        case WindowMode.WindowMode.COLLECTIONS:
+        case WindowMode.WindowMode.DOCUMENTS:
+        case WindowMode.WindowMode.SEARCH:
+            this._ensureOverview(mode);
+            this._stack.visible_child = this._overview;
+            break;
+        case WindowMode.WindowMode.PREVIEW_EV:
+        case WindowMode.WindowMode.PREVIEW_LOK:
+        case WindowMode.WindowMode.PREVIEW_EPUB:
+        case WindowMode.WindowMode.EDIT:
+            this._createPreview(mode);
+            this._stack.visible_child = this._preview;
+            break;
+        default:
+            return;
+        }
+
+        this._window.insert_action_group('view', this.view.actionGroup);
+
+        let createToolbar = true;
+        if (!this._preview)
+            createToolbar = fromPreview || !this._toolbar;
+
+        if (createToolbar) {
+            if (this._toolbar)
+                this._toolbar.destroy();
+
+            if (this._preview)
+                this._toolbar = this._preview.toolbar;
+            else
+                this._toolbar = this.view.createToolbar(this._stack);
+
+            if (this._toolbar.searchbar)
+                this._toolbar.searchbar.connectJS('activate-result',
+                                                  Lang.bind(this, this._onActivateResult));
+            this._window.get_titlebar().add(this._toolbar);
+        }
+    },
+
+    get toolbar() {
+        return this._toolbar;
+    },
+
+    get view() {
+        return this._stack.visible_child;
+    }
+});
+
 const Embed = new Lang.Class({
     Name: 'Embed',
     Extends: Gtk.Box,
@@ -49,7 +170,7 @@ const Embed = new Lang.Class({
         this._selectionToolbar = new Selections.SelectionToolbar();
         this.pack_end(this._selectionToolbar, false, false, 0);
 
-        this._view = new View.View(mainWindow);
+        this._view = new View(mainWindow);
         this.pack_end(this._view, true, true, 0);
 
         Application.modeController.connect('window-mode-changed',
diff --git a/src/org.gnome.Books.src.gresource.xml b/src/org.gnome.Books.src.gresource.xml
index 03178a4..7c929db 100644
--- a/src/org.gnome.Books.src.gresource.xml
+++ b/src/org.gnome.Books.src.gresource.xml
@@ -16,6 +16,7 @@
     <file>manager.js</file>
     <file>miners.js</file>
     <file>notifications.js</file>
+    <file>overview.js</file>
     <file>password.js</file>
     <file>places.js</file>
     <file>presentation.js</file>
@@ -32,7 +33,6 @@
     <file>trackerController.js</file>
     <file>trackerUtils.js</file>
     <file>utils.js</file>
-    <file>view.js</file>
     <file>windowMode.js</file>
   </gresource>
 </gresources>
diff --git a/src/org.gnome.Documents.src.gresource.xml b/src/org.gnome.Documents.src.gresource.xml
index baa6224..6ec63b7 100644
--- a/src/org.gnome.Documents.src.gresource.xml
+++ b/src/org.gnome.Documents.src.gresource.xml
@@ -16,6 +16,7 @@
     <file>manager.js</file>
     <file>miners.js</file>
     <file>notifications.js</file>
+    <file>overview.js</file>
     <file>password.js</file>
     <file>places.js</file>
     <file>preview.js</file>
@@ -32,7 +33,6 @@
     <file>trackerController.js</file>
     <file>trackerUtils.js</file>
     <file>utils.js</file>
-    <file>view.js</file>
     <file>windowMode.js</file>
   </gresource>
 </gresources>
diff --git a/src/view.js b/src/overview.js
similarity index 88%
rename from src/view.js
rename to src/overview.js
index 2210b19..9cefe28 100644
--- a/src/view.js
+++ b/src/overview.js
@@ -20,9 +20,6 @@
  */
 
 const Cairo = imports.gi.cairo;
-const Edit = imports.edit;
-const EvinceView = imports.evinceview;
-const EPUBView = imports.epubview;
 const Gd = imports.gi.Gd;
 const Gdk = imports.gi.Gdk;
 const Gettext = imports.gettext;
@@ -30,7 +27,6 @@ const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
-const LOKView = imports.lokview;
 const _ = imports.gettext.gettext;
 
 const Lang = imports.lang;
@@ -791,120 +787,3 @@ const OverviewStack = new Lang.Class({
         return new MainToolbar.OverviewToolbar(this);
     },
 });
-
-const View = new Lang.Class({
-    Name: 'View',
-    Extends: Gtk.Overlay,
-
-    _init: function(window) {
-        this._toolbar = null;
-        this._window = window;
-
-        this.parent();
-
-        this._stack = new Gtk.Stack({ visible: true,
-                                      homogeneous: true,
-                                      transition_type: Gtk.StackTransitionType.CROSSFADE });
-        this.add(this._stack);
-
-        // pack the OSD notification widget
-        this.add_overlay(Application.notificationManager);
-
-        this.show();
-    },
-
-    _clearPreview: function() {
-        if (this._preview) {
-            this._preview.destroy();
-            this._preview = null;
-        }
-    },
-
-    _createPreview: function(mode) {
-        let constructor;
-        switch (mode) {
-        case WindowMode.WindowMode.PREVIEW_EV:
-            constructor = EvinceView.EvinceView;
-            break;
-        case WindowMode.WindowMode.PREVIEW_LOK:
-            constructor = LOKView.LOKView;
-            break;
-        case WindowMode.WindowMode.PREVIEW_EPUB:
-            constructor = EPUBView.EPUBView;
-            break;
-        case WindowMode.WindowMode.EDIT:
-            constructor = Edit.EditView;
-            break;
-        default:
-            return;
-        }
-
-        this._preview = new constructor(this, this._window);
-        this._stack.add_named(this._preview, 'preview');
-    },
-
-    _ensureOverview: function(mode) {
-        if (!this._overview) {
-            this._overview = new OverviewStack();
-            this._stack.add_named(this._overview, 'overview');
-        }
-
-        this._overview.windowMode = mode;
-    },
-
-    _onActivateResult: function() {
-        this.view.activateResult();
-    },
-
-    set windowMode(mode) {
-        let fromPreview = !!this._preview;
-        this._clearPreview();
-
-        switch (mode) {
-        case WindowMode.WindowMode.COLLECTIONS:
-        case WindowMode.WindowMode.DOCUMENTS:
-        case WindowMode.WindowMode.SEARCH:
-            this._ensureOverview(mode);
-            this._stack.visible_child = this._overview;
-            break;
-        case WindowMode.WindowMode.PREVIEW_EV:
-        case WindowMode.WindowMode.PREVIEW_LOK:
-        case WindowMode.WindowMode.PREVIEW_EPUB:
-        case WindowMode.WindowMode.EDIT:
-            this._createPreview(mode);
-            this._stack.visible_child = this._preview;
-            break;
-        default:
-            return;
-        }
-
-        this._window.insert_action_group('view', this.view.actionGroup);
-
-        let createToolbar = true;
-        if (!this._preview)
-            createToolbar = fromPreview || !this._toolbar;
-
-        if (createToolbar) {
-            if (this._toolbar)
-                this._toolbar.destroy();
-
-            if (this._preview)
-                this._toolbar = this._preview.toolbar;
-            else
-                this._toolbar = this.view.createToolbar(this._stack);
-
-            if (this._toolbar.searchbar)
-                this._toolbar.searchbar.connectJS('activate-result',
-                                                  Lang.bind(this, this._onActivateResult));
-            this._window.get_titlebar().add(this._toolbar);
-        }
-    },
-
-    get toolbar() {
-        return this._toolbar;
-    },
-
-    get view() {
-        return this._stack.visible_child;
-    }
-});


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