[gnome-documents] embed: Allow switching directly between previews
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] embed: Allow switching directly between previews
- Date: Thu, 1 Dec 2011 19:45:28 +0000 (UTC)
commit 95b8ed5daaa7e763d1120bc52ae6913c7dd74673
Author: Florian MÃllner <fmuellner gnome org>
Date: Thu Dec 1 14:54:00 2011 +0100
embed: Allow switching directly between previews
Currently it is only possible to open a preview from the overview.
However, when we allow to open a preview from the command line, we
should switch to the new preview even if we are already in preview
mode.
https://bugzilla.gnome.org/show_bug.cgi?id=665300
src/embed.js | 44 ++++++++++++++++++++++++--------------------
1 files changed, 24 insertions(+), 20 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 054d3af..d088dbb 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -48,7 +48,6 @@ function ViewEmbed() {
ViewEmbed.prototype = {
_init: function() {
- this._activeItemId = 0;
this._adjustmentValueId = 0;
this._adjustmentChangedId = 0;
this._loaderCancellable = null;
@@ -106,6 +105,8 @@ ViewEmbed.prototype = {
Lang.bind(this, this._onFullscreenChanged));
Global.trackerController.connect('query-status-changed',
Lang.bind(this, this._onQueryStatusChanged));
+ Global.documentManager.connect('active-changed',
+ Lang.bind(this, this._onActiveItemChanged));
this._onWindowModeChanged();
this._onQueryStatusChanged();
@@ -201,6 +202,20 @@ ViewEmbed.prototype = {
child.destroy();
},
+ _destroyPreview: function() {
+ if (this._loaderCancellable) {
+ this._loaderCancellable.cancel();
+ this._loaderCancellable = null;
+ }
+
+ if (this._preview) {
+ this._preview.destroy();
+ this._preview = null;
+ }
+
+ this._docModel = null;
+ },
+
_initView: function() {
this._destroyScrollViewChild();
@@ -216,10 +231,17 @@ ViewEmbed.prototype = {
_onActiveItemChanged: function() {
let doc = Global.documentManager.getActiveItem();
+
+ if (!doc)
+ return;
+
+ this._destroyPreview();
+
let collection = Global.collectionManager.getItemById(doc.id);
if (collection) {
Global.collectionManager.setActiveItem(collection);
+ Global.modeController.setWindowMode(WindowMode.WindowMode.OVERVIEW);
return;
}
@@ -278,22 +300,9 @@ ViewEmbed.prototype = {
},
_prepareForOverview: function() {
- if (this._loaderCancellable) {
- this._loaderCancellable.cancel();
- this._loaderCancellable = null;
- }
-
- if (this._preview) {
- this._preview.destroy();
- this._preview = null;
- }
-
- this._docModel = null;
+ this._destroyPreview();
Global.documentManager.setActiveItem(null);
- this._activeItemId =
- Global.documentManager.connect('active-changed',
- Lang.bind(this, this._onActiveItemChanged));
this._viewSettingsId =
Global.settings.connect('changed::list-view',
@@ -381,11 +390,6 @@ ViewEmbed.prototype = {
this._queryErrorId = 0;
}
- if (this._activeItemId != 0) {
- Global.documentManager.disconnect(this._activeItemId);
- this._activeItemId = 0;
- }
-
Global.searchController.setSearchVisible(false);
if (this._adjustmentValueId != 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]