From: Dana Jansens Date: Thu, 11 Feb 2010 15:25:22 +0000 (-0500) Subject: add an optional shutdown function which actions can register X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=9d848528bdb88c51f7f83ea0c2deb4c9a9a0efbc;p=mikachu%2Fopenbox.git add an optional shutdown function which actions can register --- diff --git a/openbox/actions.c b/openbox/actions.c index 948ac2c0..3e3dbfd7 100644 --- a/openbox/actions.c +++ b/openbox/actions.c @@ -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; diff --git a/openbox/actions.h b/openbox/actions.h index fb9a6a84..7a98aab9 100644 --- a/openbox/actions.h +++ b/openbox/actions.h @@ -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);