[gnome-documents/gnome-3-20] preview: Fix bookmark action



commit 406b1dabdffb467a95e91ca22de1aae8f89dca8d
Author: Alessandro Bono <abono gnome org>
Date:   Mon Apr 25 00:42:49 2016 +0200

    preview: Fix bookmark action
    
    If a handler is connected to GSimpleAction::change-state it
    must implement the actual action change. Connect to
    GActionGroup:action-state-changed as done for the other
    stateful actions.
    
    Source: https://developer.gnome.org/gio/stable/GSimpleAction.html#GSimpleAction-change-state
    
    https://bugzilla.gnome.org/show_bug.cgi?id=759366

 src/preview.js |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index c7804bc..3121864 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -94,9 +94,8 @@ const PreviewView = new Lang.Class({
 
         this._bookmarkPage = Application.application.lookup_action('bookmark-page');
         this._bookmarkPage.enabled = false;
-        let bookmarkPageId = this._bookmarkPage.connect('change-state',
+        let bookmarkPageId = Application.application.connect('action-state-changed::bookmark-page',
             Lang.bind(this, this._onActionStateChanged));
-        this._onActionStateChanged(this._bookmarkPage, this._bookmarkPage.state);
 
         this._zoomIn = Application.application.lookup_action('zoom-in');
         let zoomInId = this._zoomIn.connect('activate', Lang.bind(this,
@@ -159,7 +158,6 @@ const PreviewView = new Lang.Class({
 
         this.connect('destroy', Lang.bind(this,
             function() {
-                this._bookmarkPage.disconnect(bookmarkPageId);
                 this._zoomIn.disconnect(zoomInId);
                 this._zoomOut.disconnect(zoomOutId);
                 findPrev.disconnect(findPrevId);
@@ -169,6 +167,7 @@ const PreviewView = new Lang.Class({
                 rotRight.disconnect(rotRightId);
                 this._places.disconnect(placesId);
                 Application.application.disconnect(presentCurrentId);
+                Application.application.disconnect(bookmarkPageId);
                 Application.application.disconnect(nightModeId);
             }));
     },
@@ -189,7 +188,7 @@ const PreviewView = new Lang.Class({
         this._setError(message, exception.message);
     },
 
-    _onActionStateChanged: function(action, state) {
+    _onActionStateChanged: function(source, actionName, state) {
         if (!this._model)
             return;
 
@@ -573,6 +572,7 @@ const PreviewView = new Lang.Class({
             this._places.enabled = hasMultiplePages;
 
             this._model.connect('page-changed', Lang.bind(this, this._onPageChanged));
+            this._onPageChanged();
 
             this._updateNightMode();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]