[gnome-documents] toolbar: show title and page numbers in the preview toolbar
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] toolbar: show title and page numbers in the preview toolbar
- Date: Wed, 31 Aug 2011 16:29:29 +0000 (UTC)
commit 0c6701636dc771a36a3a5c3e765facb3546cdb27
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Aug 30 23:09:44 2011 -0400
toolbar: show title and page numbers in the preview toolbar
Format title and page numbers as in the mockups.
src/documents.js | 12 ++++++++++++
src/mainToolbar.js | 51 +++++++++++++++++++++++++++++++++++++++++----------
src/mainWindow.js | 5 ++++-
3 files changed, 57 insertions(+), 11 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index c53c9ae..b30bd51 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -451,6 +451,7 @@ function DocumentManager() {
DocumentManager.prototype = {
_init: function() {
this._docs = {};
+ this._activeDocument = null;
this._pixbufFrame = GdkPixbuf.Pixbuf.new_from_file(Path.ICONS_DIR + 'thumbnail-frame.png');
},
@@ -496,6 +497,17 @@ DocumentManager.prototype = {
document = this._docs[urn];
return document;
+ },
+
+ setActiveDocument: function(doc) {
+ if (doc == this._activeDocument)
+ return;
+
+ this._activeDocument = doc;
+ },
+
+ getActiveDocument: function() {
+ return this._activeDocument;
}
};
Signals.addSignalMethods(DocumentManager.prototype);
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index c3f6e28..88a2b30 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -20,6 +20,7 @@
*/
const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
const _ = imports.gettext.gettext;
@@ -138,11 +139,23 @@ MainToolbar.prototype = {
this.emit('back-clicked');
}));
- this._modelLabel = new Gtk.Label();
- let labelItem = new Gtk.ToolItem({ child: this._modelLabel });
+ let grid = new Gtk.Grid({ orientation: Gtk.Orientation.HORIZONTAL,
+ halign: Gtk.Align.CENTER,
+ valign: Gtk.Align.CENTER });
+
+ this._titleLabel = new Gtk.Label();
+ grid.add(this._titleLabel);
+
+ this._pageLabel = new Gtk.Label({ margin_left: 12 });
+ this._pageLabel.get_style_context().add_class('dim-label');
+ grid.add(this._pageLabel);
+
+ let labelItem = new Gtk.ToolItem({ child: grid });
labelItem.set_expand(true);
this.widget.insert(labelItem, 1);
+ this._updateModelLabels();
+
let rightGroup = new Gtk.ToolItem();
this.widget.insert(rightGroup, 2);
@@ -153,13 +166,28 @@ MainToolbar.prototype = {
this.widget.show_all();
},
- _updatePageLabel: function(label, model, document) {
- let curPage, totPages;
+ _updateModelLabels: function() {
+ let pageLabel = null;
+ let doc = Global.documentManager.getActiveDocument();
- curPage = model.get_page();
- totPages = document.get_n_pages();
+ let titleLabel = ('<b>%s</b>').format(GLib.markup_escape_text(doc.title, -1));
+ this._titleLabel.set_markup(titleLabel);
- label.set_text(_("page %d of %d").format(curPage + 1, totPages));
+ if (this._model && this._document) {
+ let curPage, totPages;
+
+ curPage = this._model.get_page();
+ totPages = this._document.get_n_pages();
+
+ pageLabel = _("(%d of %d)").format(curPage + 1, totPages);
+ }
+
+ if (pageLabel) {
+ this._pageLabel.show();
+ this._pageLabel.set_text(pageLabel);
+ } else {
+ this._pageLabel.hide();
+ }
},
setWindowMode: function(windowMode) {
@@ -172,12 +200,15 @@ MainToolbar.prototype = {
},
setModel: function(model, document) {
- model.connect('page-changed', Lang.bind(this,
+ this._model = model;
+ this._document = document;
+
+ this._model.connect('page-changed', Lang.bind(this,
function() {
- this._updatePageLabel(this._modelLabel, model, document);
+ this._updateModelLabels();
}));
- this._updatePageLabel(this._modelLabel, model, document);
+ this._updateModelLabels();
}
};
Signals.addSignalMethods(MainToolbar.prototype);
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 0c2c533..181e311 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -226,6 +226,8 @@ MainWindow.prototype = {
this._docModel = null;
this._document = null;
+ Global.documentManager.setActiveDocument(null);
+
this._setFullscreen(false);
this._refreshViewSettings();
@@ -287,11 +289,12 @@ MainWindow.prototype = {
}
let doc = Global.documentManager.lookupDocument(urn);
- this._loaderCancellable = new Gio.Cancellable();
+ Global.documentManager.setActiveDocument(doc);
this._loaderTimeout = Mainloop.timeout_add(_PDF_LOADER_TIMEOUT,
Lang.bind(this, this._onPdfLoaderTimeout));
+ this._loaderCancellable = new Gio.Cancellable();
doc.loadPreview(this._loaderCancellable, Lang.bind(this, this._onDocumentLoaded));
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]