static ObActionsAct *interactive_act = NULL;
static guint interactive_initial_state = 0;
+static gboolean stop_running = FALSE;
struct _ObActionsDefinition {
guint ref;
data->client = client;
}
+void actions_stop_running()
+{
+ stop_running = TRUE;
+}
+
void actions_run_acts(GSList *acts,
ObUserAction uact,
guint state,
{
GSList *it;
+ stop_running = FALSE;
+
/* Don't allow saving the initial state when running things from the
menu */
if (uact == OB_USER_ACTION_MENU_SELECTION)
if (!act->def->run(&data, act->options)) {
if (actions_act_is_interactive(act))
actions_interactive_end_act();
+ else if (stop_running) {
+ stop_running = FALSE;
+ break;
+ }
} else {
/* make sure its interactive if it returned TRUE */
g_assert(act->i_input);
static gpointer setup_func(xmlNodePtr node);
static void free_func(gpointer options);
-static gboolean run_func(ObActionsData *data, gpointer options);
+static gboolean run_func_if(ObActionsData *data, gpointer options);
+static gboolean run_func_continue(ObActionsData *data, gpointer options);
+static gboolean run_func_stop(ObActionsData *data, gpointer options);
+static gboolean run_func_foreach(ObActionsData *data, gpointer options);
+static gboolean run_func_group(ObActionsData *data, gpointer options);
+
+static gboolean foreach_stop;
void action_if_startup(void)
{
- actions_register("If", setup_func, free_func, run_func);
+ actions_register("If", setup_func, free_func, run_func_if);
+ actions_register("Stop", NULL, NULL, run_func_stop);
+ actions_register("Continue", NULL, NULL, run_func_continue);
+ actions_register("ForEach", setup_func, free_func, run_func_foreach);
+ //actions_register("GroupMembers", setup_func, free_func, run_func_group);
}
static gpointer setup_func(xmlNodePtr node)
}
/* Always return FALSE because its not interactive */
-static gboolean run_func(ObActionsData *data, gpointer options)
+static gboolean run_func_if(ObActionsData *data, gpointer options)
{
Options *o = options;
GSList *acts;
return FALSE;
}
+
+/* Always return FALSE because its not interactive */
+static gboolean run_func_foreach(ObActionsData *data, gpointer options)
+{
+ GList *it;
+
+ foreach_stop = FALSE;
+
+ for (it = client_list; it; it = g_list_next(it)) {
+ data->client = it->data;
+ run_func_if(data, options);
+ if (foreach_stop) {
+ foreach_stop = FALSE;
+ break;
+ }
+ }
+
+ return FALSE;
+}
+
+static gboolean run_func_continue(ObActionsData *data, gpointer options)
+{
+ actions_stop_running();
+}
+
+static gboolean run_func_stop(ObActionsData *data, gpointer options)
+{
+ actions_stop_running();
+ foreach_stop = TRUE;
+}
+/*
+static gboolean run_func_group(ObActionsData *data, gpointer acts)
+{
+ GSList *it, *a = acts;
+ ObClient *c = data->client;
+
+ if (a && c)
+ for (it = c->group->members; it; it = g_slist_next(it)) {
+ ObClient *member = it->data;
+ if (actions_run_acts(a, data->uact, data->state,
+ data->x, data->y, data->button,
+ data->context, member))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+*/