add an optional shutdown function which actions can register
authorDana Jansens <danakj@orodu.net>
Thu, 11 Feb 2010 15:25:22 +0000 (10:25 -0500)
committerDana Jansens <danakj@orodu.net>
Thu, 11 Feb 2010 15:31:15 +0000 (10:31 -0500)
openbox/actions.c
openbox/actions.h

index 948ac2c..3e3dbfd 100644 (file)
@@ -47,6 +47,7 @@ struct _ObActionsDefinition {
     ObActionsRunFunc run;
     ObActionsInteractiveInputFunc i_input;
     ObActionsInteractiveCancelFunc i_cancel;
+    ObActionsShutdownFunc shutdown;
 };
 
 struct _ObActionsAct {
@@ -73,7 +74,9 @@ void actions_shutdown(gboolean reconfig)
 
     /* free all the registered actions */
     while (registered) {
-        actions_definition_unref(registered->data);
+        ObActionsDefinition *d = registered->data;
+        if (d->shutdown) d->shutdown();
+        actions_definition_unref(d);
         registered = g_slist_delete_link(registered, registered);
     }
 }
@@ -111,6 +114,22 @@ gboolean actions_register(const gchar *name,
     return TRUE;
 }
 
+gboolean actions_set_shutdown(const gchar *name,
+                              ObActionsShutdownFunc shutdown)
+{
+    GSList *it;
+    ObActionsDefinition *def;
+
+    for (it = registered; it; it = g_slist_next(it)) {
+        def = it->data;
+        if (!g_ascii_strcasecmp(name, def->name)) {
+            def->shutdown = shutdown;
+            return TRUE;
+        }
+    }
+    return FALSE;
+}
+
 static void actions_definition_ref(ObActionsDefinition *def)
 {
     ++def->ref;
index fb9a6a8..7a98aab 100644 (file)
@@ -35,6 +35,7 @@ typedef gpointer (*ObActionsDataSetupFunc)(ObParseInst *i,
 typedef void     (*ObActionsDataFreeFunc)(gpointer options);
 typedef gboolean (*ObActionsRunFunc)(ObActionsData *data,
                                      gpointer options);
+typedef void     (*ObActionsShutdownFunc)(void);
 typedef gboolean (*ObActionsInteractiveInputFunc)(guint initial_state,
                                                   XEvent *e,
                                                   gpointer options,
@@ -64,9 +65,13 @@ gboolean actions_register(const gchar *name,
                           ObActionsInteractiveInputFunc i_input,
                           ObActionsInteractiveCancelFunc i_cancel);
 
+gboolean actions_set_shutdown(const gchar *name,
+                              ObActionsShutdownFunc shutdown);
+
 ObActionsAct* actions_parse(ObParseInst *i,
                             xmlDocPtr doc,
                             xmlNodePtr node);
+
 ObActionsAct* actions_parse_string(const gchar *name);
 
 gboolean actions_act_is_interactive(ObActionsAct *act);