summaryrefslogtreecommitdiff
path: root/openbox/actions
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2008-03-02 16:11:05 -0500
committerDana Jansens <danakj@orodu.net>2008-03-02 16:13:23 -0500
commitbb557f06a6828a95ee94c7579919dec1ee014484 (patch)
treea1a010bf38eb3ecf7c06b2f939d4f772603d600b /openbox/actions
parent527ecafab95e66a6f0cedd6967fe2c61dfe85101 (diff)
add a cleanup callback to the prompt interface. when the prompt's callback returns TRUE, then the cleanup function is called. likewise when the prompt system is shutdown (openbox is exiting), then the cleanup function is also called. it should unref/destroy the prompt and any memory associated with it
Diffstat (limited to 'openbox/actions')
-rw-r--r--openbox/actions/execute.c9
-rw-r--r--openbox/actions/exit.c9
-rw-r--r--openbox/actions/session.c11
3 files changed, 22 insertions, 7 deletions
diff --git a/openbox/actions/execute.c b/openbox/actions/execute.c
index f87fe00c..636dbebf 100644
--- a/openbox/actions/execute.c
+++ b/openbox/actions/execute.c
@@ -98,11 +98,15 @@ static Options* dup_options(Options *in)
static gboolean run_func(ObActionsData *data, gpointer options);
-static void prompt_cb(ObPrompt *p, gint result, gpointer options)
+static gboolean prompt_cb(ObPrompt *p, gint result, gpointer options)
{
if (result)
run_func(NULL, options);
+ return TRUE; /* call the cleanup func */
+}
+static void prompt_cleanup(ObPrompt *p, gpointer options)
+{
prompt_unref(p);
free_func(options);
}
@@ -126,7 +130,8 @@ static gboolean run_func(ObActionsData *data, gpointer options)
};
ocp = dup_options(options);
- p = prompt_new(o->prompt, answers, 2, 0, 0, prompt_cb, ocp);
+ p = prompt_new(o->prompt, answers, 2, 0, 0,
+ prompt_cb, prompt_cleanup, ocp);
prompt_show(p, NULL, FALSE);
return FALSE;
diff --git a/openbox/actions/exit.c b/openbox/actions/exit.c
index 747514f6..67545cd2 100644
--- a/openbox/actions/exit.c
+++ b/openbox/actions/exit.c
@@ -29,10 +29,15 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o;
}
-static void prompt_cb(ObPrompt *p, gint result, gpointer data)
+static gboolean prompt_cb(ObPrompt *p, gint result, gpointer data)
{
if (result)
ob_exit(0);
+ return TRUE; /* call the cleanup func */
+}
+
+static void prompt_cleanup(ObPrompt *p, gpointer data)
+{
prompt_unref(p);
}
@@ -49,7 +54,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
};
p = prompt_new(_("Are you sure you want to exit Openbox?"),
- answers, 2, 0, 0, prompt_cb, NULL);
+ answers, 2, 0, 0, prompt_cb, prompt_cleanup, NULL);
prompt_show(p, NULL, FALSE);
}
else
diff --git a/openbox/actions/session.c b/openbox/actions/session.c
index fc66d25b..ef1497c1 100644
--- a/openbox/actions/session.c
+++ b/openbox/actions/session.c
@@ -31,7 +31,7 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
return o;
}
-static void prompt_cb(ObPrompt *p, gint result, gpointer data)
+static gboolean prompt_cb(ObPrompt *p, gint result, gpointer data)
{
Options *o = data;
if (result) {
@@ -41,7 +41,12 @@ static void prompt_cb(ObPrompt *p, gint result, gpointer data)
g_message(_("The SessionLogout actions is not available since Openbox was built without session management support"));
#endif
}
- g_free(o);
+ return TRUE; /* call cleanup func */
+}
+
+static void prompt_cleanup(ObPrompt *p, gpointer data)
+{
+ g_free(data);
prompt_unref(p);
}
@@ -60,7 +65,7 @@ static gboolean logout_func(ObActionsData *data, gpointer options)
o2 = g_memdup(o, sizeof(Options));
p = prompt_new(_("Are you sure you want to log out?"),
- answers, 2, 0, 0, prompt_cb, o2);
+ answers, 2, 0, 0, prompt_cb, prompt_cleanup, o2);
prompt_show(p, NULL, FALSE);
}
else