[gnome-documents/gnome-3-10] Protect against spurious view-as signals
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/gnome-3-10] Protect against spurious view-as signals
- Date: Wed, 5 Feb 2014 16:40:02 +0000 (UTC)
commit fc6bd166e447f6ff86c8f7b200442b8022df526b
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Feb 5 17:13:02 2014 +0100
Protect against spurious view-as signals
Do not let the GAction and GSettings unnecessarily change each others
state and value when there has been no change.
Listen to the GAction's state for actually changing the UI, because
someone using dconf-editor will still be able to emit spurious
changed::view-as signals from GSettings.
https://bugzilla.gnome.org/show_bug.cgi?id=723690
src/application.js | 7 +++++--
src/documents.js | 4 ++--
src/view.js | 2 +-
3 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 4911d41..1d68686 100644
--- a/src/application.js
+++ b/src/application.js
@@ -160,7 +160,9 @@ const Application = new Lang.Class({
_viewAsCreateHook: function(action) {
settings.connect('changed::view-as', Lang.bind(this,
function() {
- action.state = settings.get_value('view-as');
+ let state = settings.get_value('view-as');
+ if (state.get_string()[0] != action.state.get_string()[0])
+ action.state = state;
}));
},
@@ -187,7 +189,8 @@ const Application = new Lang.Class({
},
_onActionViewAs: function(action, parameter) {
- settings.set_value('view-as', parameter);
+ if (parameter.get_string()[0] != action.state.get_string()[0])
+ settings.set_value('view-as', parameter);
},
_onActionOpenCurrent: function() {
diff --git a/src/documents.js b/src/documents.js
index aa4e408..edd5396 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -248,8 +248,8 @@ const DocCommon = new Lang.Class({
this.populateFromCursor(cursor);
this._refreshIconId =
- Application.settings.connect('changed::view-as',
- Lang.bind(this, this.refreshIcon));
+ Application.application.connect('action-state-changed::view-as',
+ Lang.bind(this, this.refreshIcon));
this._filterId =
Application.searchCategoryManager.connect('active-changed',
Lang.bind(this, this.refreshIcon));
diff --git a/src/view.js b/src/view.js
index 8eaa6de..a52194a 100644
--- a/src/view.js
+++ b/src/view.js
@@ -206,7 +206,7 @@ const ViewContainer = new Lang.Class({
Lang.bind(this, this._onViewSelectionChanged));
// connect to settings change for list/grid view
- this._viewSettingsId = Application.settings.connect('changed::view-as',
+ this._viewSettingsId = Application.application.connect('action-state-changed::view-as',
Lang.bind(this, this._updateTypeForSettings));
this._updateTypeForSettings();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]