all repos — openbox @ 2202f11f239bb33e49c05aa73b51e7418748cb6b

openbox fork - make it a bit more like ryudo

add an optional shutdown function which actions can register
Dana Jansens danakj@orodu.net
commit

2202f11f239bb33e49c05aa73b51e7418748cb6b

parent

c168faee634d3c3f9494b2a4da89b80d10f311ce

2 files changed, 24 insertions(+), 1 deletions(-)

jump to
M openbox/actions.copenbox/actions.c

@@ -49,6 +49,7 @@ ObActionsDataSetupFunc n;

} setup; ObActionsDataFreeFunc free; ObActionsRunFunc run; + ObActionsShutdownFunc shutdown; }; struct _ObActionsAct {

@@ -79,7 +80,9 @@ if (reconfig) return;

/* 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); } }

@@ -133,6 +136,22 @@ def->canbeinteractive = FALSE;

def->setup.n = setup; } 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)
M openbox/actions.hopenbox/actions.h

@@ -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

@@ -76,6 +77,9 @@ gboolean actions_register(const gchar *name,

ObActionsDataSetupFunc setup, 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);