[gnome-documents/wip/split-view: 12/12] bar
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/split-view: 12/12] bar
- Date: Thu, 16 Oct 2014 11:50:03 +0000 (UTC)
commit b2de12ecf44b43192561ef5febb87b7c23e30a9c
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Oct 6 15:34:19 2014 +0200
bar
src/embed.js | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 64 insertions(+), 9 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index ba00cc6..c652e29 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -28,6 +28,7 @@ const Notifications = imports.notifications;
const Password = imports.password;
const Preview = imports.preview;
const Edit = imports.edit;
+const Search = imports.search;
const Selections = imports.selections;
const View = imports.view;
const WindowMode = imports.windowMode;
@@ -356,12 +357,42 @@ const Embed = new Lang.Class({
},
_onSearchChanged: function() {
+ // Whenever a search constraint is specified we want to switch to
+ // the search mode, and when all constraints have been lifted we
+ // want to go back to the previous mode which can be either
+ // collections or documents.
+ //
+ // However there are some exceptions, which are taken care of
+ // elsewhere:
+ // - when moving from search to preview or collection view
+ // - when in preview or coming out of it
+
+ let doc = Application.documentManager.getActiveItem();
+ let windowMode = Application.modeController.getWindowMode();
+ if (windowMode == WindowMode.WindowMode.SEARCH && doc)
+ return;
+ if (windowMode == WindowMode.WindowMode.PREVIEW)
+ return;
+
+ let searchType = Application.searchTypeManager.getActiveItem();
+ let source = Application.sourceManager.getActiveItem();
+ let str = Application.searchController.getString();
+
+ if (searchType.id == Search.SearchTypeStock.ALL &&
+ source.id == Search.SearchSourceStock.ALL &&
+ (!str || str == '')) {
+ Application.modeController.goBack();
+ } else {
+ Application.modeController.setWindowMode(WindowMode.WindowMode.SEARCH);
+ }
},
_onWindowModeChanged: function(object, newMode, oldMode) {
switch (newMode) {
- case WindowMode.WindowMode.OVERVIEW:
- this._prepareForOverview();
+ case WindowMode.WindowMode.COLLECTIONS:
+ case WindowMode.WindowMode.DOCUMENTS:
+ case WindowMode.WindowMode.SEARCH:
+ this._prepareForOverview(newMode, oldMode);
break;
case WindowMode.WindowMode.PREVIEW:
if (oldMode == WindowMode.WindowMode.EDIT)
@@ -445,20 +476,44 @@ const Embed = new Lang.Class({
}));
},
- _prepareForOverview: function() {
+ _prepareForOverview: function(newMode, oldMode) {
+ let createToolbar = (oldMode != WindowMode.WindowMode.COLLECTIONS &&
+ oldMode != WindowMode.WindowMode.DOCUMENTS &&
+ oldMode != WindowMode.WindowMode.SEARCH);
+
+ let visibleChildName;
+
+ switch (newMode) {
+ case WindowMode.WindowMode.COLLECTIONS:
+ visibleChildName = 'collections';
+ break;
+ case WindowMode.WindowMode.DOCUMENTS:
+ visibleChildName = 'documents';
+ break;
+ case WindowMode.WindowMode.SEARCH:
+ visibleChildName = 'search';
+ break;
+ default:
+ throw(new Error('Not handled'));
+ break;
+ }
+
if (this._preview)
this._preview.setModel(null);
if (this._edit)
this._edit.setUri(null);
- if (this._toolbar)
- this._toolbar.widget.destroy();
- // pack the toolbar
- this._toolbar = new MainToolbar.OverviewToolbar(this._stackOverlay, this._stack);
- this._titlebar.add(this._toolbar.widget);
+ if (createToolbar) {
+ if (this._toolbar)
+ this._toolbar.widget.destroy();
+
+ // pack the toolbar
+ this._toolbar = new MainToolbar.OverviewToolbar(this._stackOverlay, this._stack);
+ this._titlebar.add(this._toolbar.widget);
+ }
this._spinnerBox.stop();
- this._stack.set_visible_child_name('view');
+ this._stack.set_visible_child_name(visibleChildName);
},
_prepareForPreview: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]