[gnome-documents] window: add a window-mode property
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] window: add a window-mode property
- Date: Wed, 31 Aug 2011 01:12:00 +0000 (UTC)
commit 45b6a837bb3fd7fb3dca82eddff6f747f95cdcee
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Aug 30 20:32:41 2011 -0400
window: add a window-mode property
This will be used later to enable fullscreen on preview.
src/mainToolbar.js | 31 ++++++++++++++++---------------
src/mainWindow.js | 35 +++++++++++++++++++++++++++--------
2 files changed, 43 insertions(+), 23 deletions(-)
---
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index a916860..b679930 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -29,6 +29,7 @@ const Mainloop = imports.mainloop;
const Signals = imports.signals;
const Global = imports.global;
+const MainWindow = imports.mainWindow;
const _SEARCH_ENTRY_TIMEOUT = 200;
@@ -132,8 +133,8 @@ MainToolbar.prototype = {
this.emit('back-clicked');
}));
- let label = new Gtk.Label();
- let labelItem = new Gtk.ToolItem({ child: label });
+ this._modelLabel = new Gtk.Label();
+ let labelItem = new Gtk.ToolItem({ child: this._modelLabel });
labelItem.set_expand(true);
this.widget.insert(labelItem, 1);
@@ -144,14 +145,6 @@ MainToolbar.prototype = {
sizeGroup.add_widget(back);
sizeGroup.add_widget(rightGroup);
- if (model && document) {
- model.connect('page-changed', Lang.bind(this,
- function() {
- this._updatePageLabel(label, model, document);
- }));
- this._updatePageLabel(label, model, document);
- }
-
this.widget.show_all();
},
@@ -164,14 +157,22 @@ MainToolbar.prototype = {
label.set_text(_("page %d of %d").format(curPage + 1, totPages));
},
- setOverview: function() {
+ setWindowMode: function(windowMode) {
this._clearToolbar();
- this._populateForOverview();
+
+ if (windowMode == MainWindow.WindowMode.OVERVIEW)
+ this._populateForOverview();
+ else
+ this._populateForPreview();
},
- setPreview: function(model, document) {
- this._clearToolbar();
- this._populateForPreview(model, document);
+ setModel: function(model, document) {
+ model.connect('page-changed', Lang.bind(this,
+ function() {
+ this._updatePageLabel(this._modelLabel, model, document);
+ }));
+
+ this._updatePageLabel(this._modelLabel, model, document);
}
};
Signals.addSignalMethods(MainToolbar.prototype);
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 1ecc1c4..ca64006 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -48,6 +48,12 @@ const _WINDOW_DEFAULT_HEIGHT = 600;
const _PDF_LOADER_TIMEOUT = 300;
+const WindowMode = {
+ NONE: 0,
+ OVERVIEW: 1,
+ PREVIEW: 2
+};
+
function MainWindow() {
this._init();
}
@@ -59,6 +65,7 @@ MainWindow.prototype = {
this._loaderCancellable = null;
this._loaderTimeout = 0;
this._lastFilter = '';
+ this._windowMode = WindowMode.NONE;
this.window = new Gtk.Window({ type: Gtk.WindowType.TOPLEVEL,
window_position: Gtk.WindowPosition.CENTER,
@@ -105,7 +112,7 @@ MainWindow.prototype = {
this._onAdjustmentChange(this._scrolledWin.vadjustment);
this._grid.show_all();
- this._prepareForOverview();
+ this._setWindowMode(WindowMode.OVERVIEW);
},
_onKeyPressEvent: function(widget, event) {
@@ -171,11 +178,23 @@ MainWindow.prototype = {
this._initView();
},
+ _setWindowMode: function(windowMode) {
+ if (windowMode == this._windowMode)
+ return;
+
+ this._windowMode = windowMode;
+
+ if (this._windowMode == WindowMode.OVERVIEW)
+ this._prepareForOverview();
+ else
+ this._prepareForPreview();
+
+ this._toolbar.setWindowMode(this._windowMode);
+ },
+
_prepareForPreview: function(model, document) {
this._destroyView();
this._sidebar.widget.hide();
-
- this._toolbar.setPreview(model, document);
},
_prepareForOverview: function() {
@@ -195,7 +214,6 @@ MainWindow.prototype = {
this._refreshViewSettings();
this._sidebar.widget.show();
- this._toolbar.setOverview();
},
_onDeleteEvent: function() {
@@ -220,7 +238,7 @@ MainWindow.prototype = {
_onPdfLoaderTimeout: function() {
this._loaderTimeout = 0;
- this._prepareForPreview();
+ this._setWindowMode(WindowMode.PREVIEW);
let spinnerBox = new SpinnerBox.SpinnerBox();
this._scrolledWin.add_with_viewport(spinnerBox.widget);
@@ -237,14 +255,15 @@ MainWindow.prototype = {
this._loaderTimeout = 0;
}
- this._prepareForPreview(model, document);
+ this._setWindowMode(WindowMode.PREVIEW);
this._preview = new Preview.PreviewView(model, document);
+ this._toolbar.setModel(model, document);
this._scrolledWin.add(this._preview.widget);
},
_onToolbarBackClicked: function() {
- this._prepareForOverview();
+ this._setWindowMode(WindowMode.OVERVIEW);
},
_onLoadError: function(manager, message, exception) {
@@ -254,7 +273,7 @@ MainWindow.prototype = {
}
this._loaderCancellable = null;
- this._prepareForPreview();
+ this._setWindowMode(WindowMode.PREVIEW);
let errorBox = new ErrorBox.ErrorBox(message, exception.toString());
this._scrolledWin.add_with_viewport(errorBox.widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]