]> Dogcows Code - chaz/openbox/commitdiff
added the debug action
authorDana Jansens <danakj@orodu.net>
Fri, 22 Jun 2007 03:45:53 +0000 (03:45 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 22 Jun 2007 03:45:53 +0000 (03:45 +0000)
Makefile.am
openbox/action.c
openbox/actions.c
openbox/actions/all.c
openbox/actions/all.h
openbox/actions/debug.c [new file with mode: 0644]

index 222eefd3371d1b908b23e66a40f7446867167591..c733558832a830ff7ec4760156111180cb7851e0 100644 (file)
@@ -156,6 +156,7 @@ openbox_openbox_SOURCES = \
        gettext.h \
        openbox/actions/all.c \
        openbox/actions/all.h \
+       openbox/actions/debug.c \
        openbox/actions/execute.c \
        openbox/actions.c \
        openbox/actions.h \
index df3037daba95f377a55dad17152bdf24ff70b437..d706e370e88e69887edc4897f61a5a5c4fe890a4 100644 (file)
@@ -1005,24 +1005,6 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
 
     if (parse_attr_string("name", node, &actname)) {
         if ((act = action_from_string(actname, uact))) {
-            if (act->func == action_execute || act->func == action_restart) {
-                if ((n = parse_find_node("execute", node->xmlChildrenNode))) {
-                    gchar *s = parse_string(doc, n);
-                    act->data.execute.path = parse_expand_tilde(s);
-                    g_free(s);
-                }
-                if ((n = parse_find_node("startupnotify", node->xmlChildrenNode))) {
-                    xmlNodePtr m;
-                    if ((m = parse_find_node("enabled", n->xmlChildrenNode)))
-                        act->data.execute.startupnotify = parse_bool(doc, m);
-                    if ((m = parse_find_node("name", n->xmlChildrenNode)))
-                        act->data.execute.name = parse_string(doc, m);
-                    if ((m = parse_find_node("icon", n->xmlChildrenNode)))
-                        act->data.execute.icon_name = parse_string(doc, m);
-                }
-            } else if (act->func == action_debug) {
-                if ((n = parse_find_node("string", node->xmlChildrenNode)))
-                    act->data.debug.string = parse_string(doc, n);
             } else if (act->func == action_showmenu) {
                 if ((n = parse_find_node("menu", node->xmlChildrenNode)))
                     act->data.showmenu.name = parse_string(doc, n);
index 44a39cb5dd25b955852d2f13b2a94dd8f909541b..9a5d193c4a2b33200416867eff81d769c0d224e2 100644 (file)
@@ -83,14 +83,15 @@ gboolean actions_register(const gchar *name,
     GSList *it;
     ObActionsDefinition *def;
 
+    g_assert(run != NULL);
+    g_assert((i_input == NULL) == (i_cancel == NULL));
+
     for (it = registered; it; it = g_slist_next(it)) {
         def = it->data;
         if (!g_ascii_strcasecmp(name, def->name)) /* already registered */
             return FALSE;
     }
 
-    g_assert((i_input == NULL) == (i_cancel == NULL));
-
     def = g_new(ObActionsDefinition, 1);
     def->ref = 1;
     def->name = g_strdup(name);
@@ -156,7 +157,8 @@ ObActionsAct* actions_parse(ObParseInst *i,
     if (parse_attr_string("name", node, &name)) {
         if ((act = actions_parse_string(name)))
             /* there is more stuff to parse here */
-            act->options = act->def->setup(i, doc, node->xmlChildrenNode);
+            if (act->def->setup)
+                act->options = act->def->setup(i, doc, node->xmlChildrenNode);
 
         g_free(name);
     }
@@ -178,7 +180,8 @@ void actions_act_unref(ObActionsAct *act)
 {
     if (act && --act->ref == 0) {
         /* free the action specific options */
-        act->def->free(act->options);
+        if (act->def->free)
+            act->def->free(act->options);
         /* unref the definition */
         actions_definition_unref(act->def);
         g_free(act);
index 7c0b253e5c3c5535c04e0bd7016b8a5ba8948fd8..09eae59afbaeaf034618641ac4332099c0f42e55 100644 (file)
@@ -3,4 +3,5 @@
 void action_all_startup()
 {
     action_execute_startup();
+    action_debug_startup();
 }
index 599c29fc373a81eb0c92e8c5e1c5e9ade7cf061f..b93f140aa1bb90118ee300d73ef9e3ee4c49275a 100644 (file)
@@ -4,5 +4,6 @@
 void action_all_startup();
 
 void action_execute_startup();
+void action_debug_startup();
 
 #endif
diff --git a/openbox/actions/debug.c b/openbox/actions/debug.c
new file mode 100644 (file)
index 0000000..f219e05
--- /dev/null
@@ -0,0 +1,58 @@
+#include "openbox/actions.h"
+#include <glib.h>
+
+typedef struct {
+    gchar   *str;
+} Options;
+
+static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node);
+static void     free_func(gpointer options);
+static gboolean run_func(ObActionsData *data, gpointer options);
+/*
+static gboolean i_input_func(guint initial_state,
+                             XEvent *e,
+                             gpointer options,
+                             gboolean *used);
+static void     i_cancel_func(gpointer options);
+*/
+
+void action_debug_startup()
+{
+    actions_register("Debug",
+                     setup_func,
+                     free_func,
+                     run_func,
+                     NULL, NULL);
+}
+
+static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node)
+{
+    xmlNodePtr n;
+    Options *o;
+
+    o = g_new0(Options, 1);
+
+    if ((n = parse_find_node("string", node)))
+        o->str = parse_string(doc, n);
+    return o;
+}
+
+static void free_func(gpointer options)
+{
+    Options *o = options;
+
+    if (o) {
+        g_free(o->str);
+        g_free(o);
+    }
+}
+
+/* Always return FALSE because its not interactive */
+static gboolean run_func(ObActionsData *data, gpointer options)
+{
+    Options *o = options;
+
+    if (o->str) g_print("%s\n", o->str);
+
+    return FALSE;
+}
This page took 0.031109 seconds and 4 git commands to generate.