[gnome-documents] preview: make sure to create all actions before widgets



commit c1e517cb81d44e4985cb6acc89614a8f6a6173c7
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Mar 29 19:23:40 2017 -0700

    preview: make sure to create all actions before widgets
    
    Or some widgets, such as the toolbar, may reference actions that have
    not been created yet.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780705

 src/evinceview.js |   18 ++++++++++++------
 src/preview.js    |   11 ++++++++---
 2 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/src/evinceview.js b/src/evinceview.js
index 431ebb5..ffbb00e 100644
--- a/src/evinceview.js
+++ b/src/evinceview.js
@@ -55,11 +55,6 @@ const EvinceView = new Lang.Class({
 
         this.parent(overlay, mainWindow);
 
-        let fullscreenAction = new FullscreenAction.FullscreenAction({ window: mainWindow });
-        fullscreenAction.connect('notify::state', Lang.bind(this, this._onFullscreenChanged));
-        this.actionGroup.add_action(fullscreenAction);
-        Application.application.set_accels_for_action('view.fullscreen', ['F11']);
-
         this.getAction('bookmark-page').enabled = false;
 
         let nightModeId = Application.application.connect('action-state-changed::night-mode',
@@ -68,7 +63,7 @@ const EvinceView = new Lang.Class({
         this.connect('destroy', Lang.bind(this,
             function() {
                 Application.application.disconnect(nightModeId);
-                fullscreenAction.change_state(new GLib.Variant('b', false));
+                this._fullscreenAction.change_state(new GLib.Variant('b', false));
             }));
     },
 
@@ -226,6 +221,17 @@ const EvinceView = new Lang.Class({
         return actions;
     },
 
+    createActionGroup: function() {
+        let actionGroup = this.parent();
+
+        this._fullscreenAction = new FullscreenAction.FullscreenAction({ window: this.mainWindow });
+        this._fullscreenAction.connect('notify::state', Lang.bind(this, this._onFullscreenChanged));
+        actionGroup.add_action(this._fullscreenAction);
+        Application.application.set_accels_for_action('view.fullscreen', ['F11']);
+
+        return actionGroup;
+    },
+
     createNavControls: function() {
         return new EvinceViewNavControls(this, this.overlay);
     },
diff --git a/src/preview.js b/src/preview.js
index e6628a3..b2a0de1 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -32,9 +32,7 @@ const Preview = new Lang.Class({
         this.parent({ homogeneous: true,
                       transition_type: Gtk.StackTransitionType.CROSSFADE });
 
-        let actions = this.createActions().concat(this._getDefaultActions());
-        this.actionGroup = new Gio.SimpleActionGroup();
-        Utils.populateActionGroup(this.actionGroup, actions, 'view');
+        this.actionGroup = this.createActionGroup();
 
         this._errorBox = new ErrorBox.ErrorBox();
         this.add_named(this._errorBox, 'error');
@@ -140,6 +138,13 @@ const Preview = new Lang.Class({
         this.parent();
     },
 
+    createActionGroup: function() {
+        let actions = this.createActions().concat(this._getDefaultActions());
+        let actionGroup = new Gio.SimpleActionGroup();
+        Utils.populateActionGroup(actionGroup, actions, 'view');
+        return actionGroup;
+    },
+
     createActions: function() {
         return [];
     },


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