[gnome-documents] embed: move selection toolbar to OverviewStack
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] embed: move selection toolbar to OverviewStack
- Date: Mon, 31 Oct 2016 05:39:09 +0000 (UTC)
commit cfd61c978dd134bdfdbf7ed760a2a012575d4fb8
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sun Oct 30 18:39:16 2016 -0700
embed: move selection toolbar to OverviewStack
Instead of in the embed, since it does not apply to preview.
src/embed.js | 5 -----
src/overview.js | 52 ++++++++++++++++++++++++++++++++--------------------
2 files changed, 32 insertions(+), 25 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 3451aa5..12c60ce 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -28,7 +28,6 @@ const Edit = imports.edit;
const EvinceView = imports.evinceview;
const LOKView = imports.lokview;
const Search = imports.search;
-const Selections = imports.selections;
const Overview = imports.overview;
const WindowMode = imports.windowMode;
@@ -164,10 +163,6 @@ const Embed = new Lang.Class({
let titlebar = new Gtk.Grid({ visible: true });
mainWindow.set_titlebar(titlebar);
- // create the toolbar for selected items, it's hidden by default
- this._selectionToolbar = new Selections.SelectionToolbar();
- this.pack_end(this._selectionToolbar, false, false, 0);
-
this._view = new View(mainWindow);
this.pack_end(this._view, true, true, 0);
diff --git a/src/overview.js b/src/overview.js
index 46bd713..7336612 100644
--- a/src/overview.js
+++ b/src/overview.js
@@ -37,6 +37,7 @@ const ErrorBox = imports.errorBox;
const MainToolbar = imports.mainToolbar;
const Search = imports.search;
const Searchbar = imports.searchbar;
+const Selections = imports.selections;
const WindowMode = imports.windowMode;
const Utils = imports.utils;
@@ -508,7 +509,7 @@ const OverviewToolbar = new Lang.Class({
Name: 'OverviewToolbar',
Extends: MainToolbar.MainToolbar,
- _init: function(stack) {
+ _init: function(view) {
this._collBackButton = null;
this._collectionId = 0;
this._selectionChangedId = 0;
@@ -518,7 +519,7 @@ const OverviewToolbar = new Lang.Class({
this._infoUpdatedId = 0;
this._countChangedId = 0;
- this._view = stack;
+ this._view = view;
this.parent();
@@ -529,7 +530,7 @@ const OverviewToolbar = new Lang.Class({
this._selectionMenu.get_style_context().add_class('selection-menu');
this._stackSwitcher = new Gtk.StackSwitcher({ no_show_all: true,
- stack: this._view });
+ stack: this._view.stack });
this._stackSwitcher.show();
// setup listeners to mode changes that affect the toolbar layout
@@ -1039,10 +1040,18 @@ const ViewContainer = new Lang.Class({
const OverviewStack = new Lang.Class({
Name: 'OverviewStack',
- Extends: Gtk.Stack,
+ Extends: Gtk.Box,
_init: function() {
- this.parent({ visible: true });
+ this.parent({ orientation: Gtk.Orientation.VERTICAL,
+ visible: true });
+
+ this._stack = new Gtk.Stack({ visible: true });
+ this.pack_start(this._stack, true, true, 0);
+
+ // create the toolbar for selected items, it's hidden by default
+ this._selectionToolbar = new Selections.SelectionToolbar();
+ this.pack_end(this._selectionToolbar, false, false, 0);
let actions = this._getDefaultActions();
this.actionGroup = new Gio.SimpleActionGroup();
@@ -1051,16 +1060,16 @@ const OverviewStack = new Lang.Class({
// now create the actual content widgets
this._documents = new ViewContainer(WindowMode.WindowMode.DOCUMENTS);
let label = Application.application.isBooks ? _('Books') : _("Documents");
- this.add_titled(this._documents, 'documents', label);
+ this._stack.add_titled(this._documents, 'documents', label);
this._collections = new ViewContainer(WindowMode.WindowMode.COLLECTIONS);
- this.add_titled(this._collections, 'collections', _("Collections"));
+ this._stack.add_titled(this._collections, 'collections', _("Collections"));
this._search = new ViewContainer(WindowMode.WindowMode.SEARCH);
- this.add_named(this._search, 'search');
+ this._stack.add_named(this._search, 'search');
- this.connect('notify::visible-child',
- Lang.bind(this, this._onVisibleChildChanged));
+ this._stack.connect('notify::visible-child',
+ Lang.bind(this, this._onVisibleChildChanged));
},
_getDefaultActions: function() {
@@ -1098,16 +1107,16 @@ const OverviewStack = new Lang.Class({
_selectAll: function() {
Application.selectionController.setSelectionMode(true);
- this.visible_child.view.select_all();
+ this.view.view.select_all();
},
_selectNone: function() {
- this.visible_child.view.unselect_all();
+ this.view.view.unselect_all();
},
_updateTypeForSettings: function() {
let viewType = Application.settings.get_enum('view-as');
- this.visible_child.view.set_view_type(viewType);
+ this.view.view.set_view_type(viewType);
},
_updateSortForSettings: function() {
@@ -1130,7 +1139,7 @@ const OverviewStack = new Lang.Class({
break;
}
- this.visible_child.model.set_sort_column_id(sortBy, sortType);
+ this.view.model.set_sort_column_id(sortBy, sortType);
},
_initSearchSource: function(action) {
@@ -1167,12 +1176,11 @@ const OverviewStack = new Lang.Class({
},
_onVisibleChildChanged: function() {
- let visibleChild = this.visible_child;
let windowMode;
- if (visibleChild == this._collections)
+ if (this.view == this._collections)
windowMode = WindowMode.WindowMode.COLLECTIONS;
- else if (visibleChild == this._documents)
+ else if (this.view == this._documents)
windowMode = WindowMode.WindowMode.DOCUMENTS;
else
return;
@@ -1197,13 +1205,13 @@ const OverviewStack = new Lang.Class({
return;
}
- this.visible_child = visibleChild;
+ this._stack.visible_child = visibleChild;
this._updateSortForSettings();
this._updateTypeForSettings();
},
activateResult: function() {
- this.visible_child.activateResult();
+ this.view.activateResult();
},
createToolbar: function() {
@@ -1214,7 +1222,11 @@ const OverviewStack = new Lang.Class({
return this.actionGroup.lookup_action(name);
},
+ get stack() {
+ return this._stack;
+ },
+
get view() {
- return this.visible_child;
+ return this._stack.visible_child;
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]