[gnome-documents/wip/rishi/split-view: 8/11] application: Let some actions be enabled across multiple window modes



commit a5c6fc278587505cc93e87299b1f7db8370ea4b6
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Feb 10 15:57:38 2015 +0100

    application: Let some actions be enabled across multiple window modes
    
    With multiple views, those actions which were only needed in the
    overview will need to work in the documents, collections and search
    views also.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686461

 src/application.js |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 4fc61fa..e5ee0ec 100644
--- a/src/application.js
+++ b/src/application.js
@@ -314,6 +314,20 @@ const Application = new Lang.Class({
                             let action = this.lookup_action(actionEntry.name);
                             action.set_enabled(mode == actionEntry.window_mode);
                         }));
+                } else if (actionEntry.window_modes) {
+                    modeController.connect('window-mode-changed', Lang.bind(this,
+                        function() {
+                            let mode = modeController.getWindowMode();
+                            let action = this.lookup_action(actionEntry.name);
+                            let enable = false;
+                            for (let idx in actionEntry.window_modes) {
+                                if (mode == actionEntry.window_modes[idx]) {
+                                    enable = true;
+                                    break;
+                                }
+                            }
+                            action.set_enabled(enable);
+                        }));
                 }
             }));
     },


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