[gnome-documents] preview, places: Disable bookmarking if metadata is unsupported
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] preview, places: Disable bookmarking if metadata is unsupported
- Date: Fri, 11 Jul 2014 17:36:59 +0000 (UTC)
commit f14758b1c296cf566895c179fe11e0e3e353d0e9
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Jul 11 15:26:17 2014 +0200
preview, places: Disable bookmarking if metadata is unsupported
... without hiding all the navigation controls.
This is often due to the absence of GVfs. The absence of GVfs is
considered to be an example of a broken system, but to make the lives
of those who are building from Git into a separate prefix we try to
accommodate this without getting into elaborate fallback code paths.
https://bugzilla.gnome.org/show_bug.cgi?id=733061
src/places.js | 14 ++++++++------
src/preview.js | 21 +++++++++++++--------
2 files changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/src/places.js b/src/places.js
index e81dcb5..966732f 100644
--- a/src/places.js
+++ b/src/places.js
@@ -70,12 +70,14 @@ const PlacesDialog = new Lang.Class({
}));
this._addPage(this._linksPage);
- this._bookmarksPage = new GdPrivate.PlacesBookmarks({ bookmarks: this._bookmarks });
- this._bookmarksPage.connect('bookmark-activated', Lang.bind(this,
- function(widget, link) {
- this._handleBookmark(link);
- }));
- this._addPage(this._bookmarksPage);
+ if (this._bookmarks) {
+ this._bookmarksPage = new GdPrivate.PlacesBookmarks({ bookmarks: this._bookmarks });
+ this._bookmarksPage.connect('bookmark-activated', Lang.bind(this,
+ function(widget, link) {
+ this._handleBookmark(link);
+ }));
+ this._addPage(this._bookmarksPage);
+ }
},
_handleLink: function(link) {
diff --git a/src/preview.js b/src/preview.js
index e9f7342..91551c4 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -86,6 +86,7 @@ const PreviewView = new Lang.Class({
this.widget.show_all();
this._bookmarkPage = Application.application.lookup_action('bookmark-page');
+ this._bookmarkPage.enabled = false;
this._bookmarkPage.connect('change-state',
Lang.bind(this, this._onActionStateChanged));
this._onActionStateChanged(this._bookmarkPage, this._bookmarkPage.state);
@@ -146,6 +147,7 @@ const PreviewView = new Lang.Class({
},
_onLoadStarted: function() {
+ this._bookmarkPage.enabled = false;
this._showPlaces.enabled = false;
this._copy.enabled = false;
},
@@ -153,13 +155,13 @@ const PreviewView = new Lang.Class({
_onLoadFinished: function(manager, doc, docModel) {
this._showPlaces.enabled = true;
this._togglePresentation.enabled = true;
+ this._navControls.show();
if (!Application.documentManager.metadata)
return;
- this._navControls.show();
-
this._bookmarks = new GdPrivate.Bookmarks({ metadata: Application.documentManager.metadata });
+ this._bookmarkPage.enabled = true;
},
_onLoadError: function(manager, doc, message, exception) {
@@ -196,6 +198,9 @@ const PreviewView = new Lang.Class({
_onPageChanged: function() {
this._pageChanged = true;
+ if (!this._bookmarks)
+ return;
+
let page_number = this._model.page;
let bookmark = new GdPrivate.Bookmark({ page_number: page_number });
let hasBookmark = (this._bookmarks.find_bookmark(bookmark) != null);
@@ -548,6 +553,11 @@ const PreviewView = new Lang.Class({
if (this._model) {
this.view.set_model(this._model);
this._navControls.setModel(model);
+
+ let hasMultiplePages = (this._model.document.get_n_pages() > 1);
+ this._bookmarkPage.enabled = hasMultiplePages && this._bookmarks;
+ this._showPlaces.enabled = hasMultiplePages;
+
this._model.connect('page-changed', Lang.bind(this, this._onPageChanged));
}
},
@@ -732,13 +742,8 @@ const PreviewNavControls = new Lang.Class({
this._model = model;
this.bar_widget.document_model = model;
- if (this._model) {
- let hasMultiplePages = (this._model.document.get_n_pages() > 1);
- Application.application.lookup_action('bookmark-page').enabled = hasMultiplePages;
- Application.application.lookup_action('places').enabled = hasMultiplePages;
-
+ if (this._model)
this._pageChangedId = this._model.connect('page-changed', Lang.bind(this,
this._updateVisibility));
- }
this._updateVisibility();
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]