]> Dogcows Code - chaz/openbox/commitdiff
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 16:01:18 +0000 (11:01 -0500)
openbox/actions.c
openbox/actions.h

index 023fab3ab5c96291ce0508c4527bc035cdfd0c07..35d5cc25f095c23f2acd78806ee00d7d63a31544 100644 (file)
@@ -49,6 +49,7 @@ struct _ObActionsDefinition {
     } setup;
     ObActionsDataFreeFunc free;
     ObActionsRunFunc run;
+    ObActionsShutdownFunc shutdown;
 };
 
 struct _ObActionsAct {
@@ -79,7 +80,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);
     }
 }
@@ -135,6 +138,22 @@ gboolean actions_register(const gchar *name,
     return def != NULL;
 }
 
+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 afcc96b7ed58826631520d752b31125a2937ad7a..a56ece398e8e7ba5937604975aec3c2397fb4989 100644 (file)
@@ -35,6 +35,7 @@ typedef void     (*ObActionsDataFreeFunc)(gpointer options);
 typedef gboolean (*ObActionsRunFunc)(ObActionsData *data,
                                      gpointer options);
 typedef gpointer (*ObActionsDataSetupFunc)(xmlNodePtr node);
+typedef void     (*ObActionsShutdownFunc)(void);
 
 /* functions for interactive actions */
 /* return TRUE if the action is going to be interactive, or false to change
@@ -77,6 +78,9 @@ gboolean actions_register(const gchar *name,
                           ObActionsDataFreeFunc free,
                           ObActionsRunFunc run);
 
+gboolean actions_set_shutdown(const gchar *name,
+                              ObActionsShutdownFunc shutdown);
+
 ObActionsAct* actions_parse(xmlNodePtr node);
 ObActionsAct* actions_parse_string(const gchar *name);
 
This page took 0.028533 seconds and 4 git commands to generate.