61
56
false, true, false,
62
57
Clutter.BoxAlignment.CENTER, Clutter.BoxAlignment.START);
59
this.createSearchbar();
62
createSearchbar: function() {
63
log('Error: MainToolbar subclasses must implement createSearchbar');
66
handleEvent: function(event) {
67
let res = this._searchbar.handleEvent(event);
71
addSearchButton: function() {
73
this.widget.add_toggle('edit-find-symbolic', _("Search"), false);
74
searchButton.action_name = 'app.search';
78
const OverviewToolbar = new Lang.Class({
79
Name: 'OverviewToolbar',
82
_init: function(viewLayout) {
83
this._viewLayout = viewLayout;
84
this._collBackButton = null;
85
this._collectionId = 0;
86
this._selectionChangedId = 0;
64
90
// setup listeners to mode changes that affect the toolbar layout
65
91
this._searchStringId =
66
92
Global.searchController.connect('search-string-changed',
77
103
this._selectionModeId =
78
104
Global.selectionController.connect('selection-mode-changed',
79
105
Lang.bind(this, this._resetToolbarMode));
81
Global.modeController.connect('window-mode-changed',
82
Lang.bind(this, this._resetToolbarMode));
83
106
this._resetToolbarMode();
85
108
this.widget.connect('destroy', Lang.bind(this,
87
110
this._clearStateData();
89
if (this._windowModeId != 0) {
90
Global.modeController.disconnect(this._windowModeId);
91
this._windowModeId = 0;
94
112
if (this._selectionModeId != 0) {
95
113
Global.selectionController.disconnect(this._selectionModeId);
96
114
this._selectionModeId = 0;
121
_clearStateData: function() {
123
this._collBackButton = null;
125
if (this._collectionId != 0) {
126
Global.collectionManager.disconnect(this._collectionId);
127
this._collectionId = 0;
130
if (this._selectionChangedId != 0) {
131
Global.selectionController.disconnect(this._selectionChangedId);
132
this._selectionChangedId = 0;
136
_clearToolbar: function() {
137
this._clearStateData();
139
this.widget.get_style_context().remove_class('documents-selection-mode');
140
this.widget.reset_style();
144
139
_setToolbarTitle: function() {
145
let windowMode = Global.modeController.getWindowMode();
146
140
let selectionMode = Global.selectionController.getSelectionMode();
147
141
let activeCollection = Global.collectionManager.getActiveItem();
148
142
let primary = null;
149
143
let detail = null;
151
if (windowMode == WindowMode.WindowMode.OVERVIEW) {
152
if (!selectionMode) {
153
if (activeCollection) {
154
primary = activeCollection.name;
145
if (!selectionMode) {
146
if (activeCollection) {
147
primary = activeCollection.name;
149
let string = Global.searchController.getString();
152
let searchType = Global.searchTypeManager.getActiveItem();
153
let searchSource = Global.sourceManager.getActiveItem();
155
if (searchType.id != 'all')
156
primary = searchType.name;
158
primary = _("New and Recent");
160
if (searchSource.id != 'all')
161
detail = searchSource.name;
156
let string = Global.searchController.getString();
159
let searchType = Global.searchTypeManager.getActiveItem();
160
let searchSource = Global.sourceManager.getActiveItem();
162
if (searchType.id != 'all')
163
primary = searchType.name;
165
primary = _("New and Recent");
167
if (searchSource.id != 'all')
168
detail = searchSource.name;
170
let searchMatch = Global.searchMatchManager.getActiveItem();
172
primary = _("Results for \"%s\"").format(string);
173
if (searchMatch.id == 'title')
174
detail = _("filtered by title");
175
else if (searchMatch.id == 'author')
176
detail = _("filtered by author");
180
let length = Global.selectionController.getSelection().length;
183
detail = _("Click on items to select them");
185
detail = Gettext.ngettext("%d selected",
187
length).format(length);
189
if (activeCollection) {
190
primary = activeCollection.name;
191
} else if (length != 0) {
163
let searchMatch = Global.searchMatchManager.getActiveItem();
165
primary = _("Results for \"%s\"").format(string);
166
if (searchMatch.id == 'title')
167
detail = _("filtered by title");
168
else if (searchMatch.id == 'author')
169
detail = _("filtered by author");
196
} else if (windowMode == WindowMode.WindowMode.PREVIEW) {
197
let doc = Global.documentManager.getActiveItem();
201
let curPage, totPages;
203
curPage = this._model.get_page();
204
totPages = this._model.get_document().get_n_pages();
206
detail = _("%d of %d").format(curPage + 1, totPages);
173
let length = Global.selectionController.getSelection().length;
176
detail = _("Click on items to select them");
178
detail = Gettext.ngettext("%d selected",
180
length).format(length);
182
if (activeCollection) {
183
primary = activeCollection.name;
184
} else if (length != 0) {
230
212
Lang.bind(this, this._setToolbarTitle));
233
_populateForPreview: function(model) {
235
(this.widget.get_direction() == Gtk.TextDirection.RTL) ?
236
'go-next-symbolic' : 'go-previous-symbolic';
239
this.widget.add_button(iconName, _("Back"), true);
240
backButton.connect('clicked', Lang.bind(this,
242
Global.modeController.setWindowMode(WindowMode.WindowMode.OVERVIEW);
246
_populateForOverview: function() {
247
let selectionButton =
248
this.widget.add_button('emblem-default-symbolic', _("Select Items"), false);
249
selectionButton.connect('clicked', Lang.bind(this,
251
Global.selectionController.setSelectionMode(true);
254
// connect to active collection changes while in this mode
256
Global.collectionManager.connect('active-changed',
257
Lang.bind(this, this._onActiveCollectionChanged));
258
this._onActiveCollectionChanged();
261
215
_onActiveCollectionChanged: function() {
262
216
let item = Global.collectionManager.getActiveItem();
276
230
this._setToolbarTitle();
277
this.searchbar.hide();
231
Global.application.change_action_state('search', GLib.Variant.new('b', false));
234
_populateForOverview: function() {
235
this.addSearchButton();
237
let selectionButton =
238
this.widget.add_button('object-select-symbolic', _("Select Items"), false);
239
selectionButton.connect('clicked', Lang.bind(this,
241
Global.selectionController.setSelectionMode(true);
244
// connect to active collection changes while in this mode
246
Global.collectionManager.connect('active-changed',
247
Lang.bind(this, this._onActiveCollectionChanged));
250
_clearStateData: function() {
251
this._collBackButton = null;
253
if (this._collectionId != 0) {
254
Global.collectionManager.disconnect(this._collectionId);
255
this._collectionId = 0;
258
if (this._selectionChangedId != 0) {
259
Global.selectionController.disconnect(this._selectionChangedId);
260
this._selectionChangedId = 0;
264
_clearToolbar: function() {
265
this._clearStateData();
267
this.widget.get_style_context().remove_class('documents-selection-mode');
268
this.widget.reset_style();
280
272
_resetToolbarMode: function() {
281
273
this._clearToolbar();
283
let windowMode = Global.modeController.getWindowMode();
284
if (windowMode == WindowMode.WindowMode.OVERVIEW) {
285
let selectionMode = Global.selectionController.getSelectionMode();
287
this._populateForSelectionMode();
289
this._populateForOverview();
290
} else if (windowMode == WindowMode.WindowMode.PREVIEW) {
291
this._populateForPreview();
275
let selectionMode = Global.selectionController.getSelectionMode();
277
this._populateForSelectionMode();
279
this._populateForOverview();
294
281
this._setToolbarTitle();
295
282
this.widget.show_all();
298
setModel: function(model) {
303
this._model.connect('page-changed', Lang.bind(this,
305
this._setToolbarTitle();
308
this._setToolbarTitle();
312
const PreviewToolbar = new Lang.Class({
313
Name: 'PreviewToolbar',
314
Extends: MainToolbar,
319
this.actor.y = -(this.widget.get_preferred_height()[1]);
323
Tweener.addTween(this.actor,
326
transition: 'easeInQuad' });
330
Tweener.addTween(this.actor,
331
{ y: -(this.widget.get_preferred_height()[1]),
333
transition: 'easeOutQuad' });
337
const OverviewToolbar = new Lang.Class({
338
Name: 'OverviewToolbar',
339
Extends: MainToolbar,
344
this.searchbar = new Searchbar.Searchbar();
345
this.layout.pack_start = true;
346
this.layout.pack(this.searchbar.actor, false, true, false,
284
if (Global.searchController.getString() != '')
285
Global.application.change_action_state('search', GLib.Variant.new('b', true));
288
createSearchbar: function() {
289
// create the dropdown for the search bar, it's hidden by default
290
let dropdown = new Searchbar.Dropdown();
291
this._viewLayout.add(dropdown.actor,
292
Clutter.BinAlignment.CENTER, Clutter.BinAlignment.FIXED);
294
this._searchbar = new Searchbar.OverviewSearchbar(dropdown);
295
this.layout.pack_start = false;
296
this.layout.pack(this._searchbar.actor, false, true, false,
347
297
Clutter.BoxAlignment.CENTER, Clutter.BoxAlignment.START);
350
_resetToolbarMode: function() {
353
let mode = Global.modeController.getWindowMode();
355
if (mode == WindowMode.WindowMode.PREVIEW)
356
this.searchbar.hide();
357
else if (mode == WindowMode.WindowMode.OVERVIEW &&
358
Global.searchController.getString() != '')
359
this.searchbar.show();