[gnome-maps/wip/mlundblad/night-mode: 2/3] utils: Add ability to set a create hook for actions



commit c2ef30a03e1164b081aec10984394c2d2feac7df
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Jun 2 22:34:14 2020 +0200

    utils: Add ability to set a create hook for actions

 src/utils.js | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/src/utils.js b/src/utils.js
index 613e87e1..3c4d33d6 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -110,23 +110,26 @@ function setAccelsForActionMap(actionMap, actionName, accels) {
     app.set_accels_for_action(prefix + '.' + actionName, accels);
 }
 
-function createAction(name, { state, paramType, onActivate, onChangeState }) {
+function createAction(name, { state, paramType, onActivate, onChangeState,
+                              createHook }) {
     let entry = { name: name };
 
-    if(Array.isArray(state)) {
+    if (Array.isArray(state)) {
         let [type, value] = state;
         entry.state = new GLib.Variant.new(type, value);
     }
 
-    if(paramType !== undefined)
+    if (paramType !== undefined)
         entry.parameter_type = GLib.VariantType.new(paramType);
 
     let action = new Gio.SimpleAction(entry);
 
-    if(onActivate)
+    if (onActivate)
         action.connect('activate', onActivate);
-    if(onChangeState)
+    if (onChangeState)
         action.connect('change-state', onChangeState);
+    if (createHook)
+        createHook(action);
 
     return action;
 }


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