]> Dogcows Code - chaz/openbox/commitdiff
the execute action works again.
authorDana Jansens <danakj@orodu.net>
Fri, 22 Jun 2007 03:40:01 +0000 (03:40 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 22 Jun 2007 03:40:01 +0000 (03:40 +0000)
default hardcoded bindings are temporarily offline

Makefile.am
openbox/action.c
openbox/actions.c
openbox/actions.h
openbox/actions/Makefile [new file with mode: 0644]
openbox/actions/all.c [new file with mode: 0644]
openbox/actions/all.h [new file with mode: 0644]
openbox/actions/execute.c [new file with mode: 0644]
openbox/config.c
openbox/openbox.c
po/POTFILES.in

index 0ebc9aadf2555cf5a06eb99bdd69b17516f91ee2..222eefd3371d1b908b23e66a40f7446867167591 100644 (file)
@@ -154,6 +154,9 @@ openbox_openbox_LDADD = \
 openbox_openbox_LDFLAGS = -export-dynamic
 openbox_openbox_SOURCES = \
        gettext.h \
+       openbox/actions/all.c \
+       openbox/actions/all.h \
+       openbox/actions/execute.c \
        openbox/actions.c \
        openbox/actions.h \
        openbox/client.c \
index 4268987f43142738b5557ef8652614b8d4c455a0..df3037daba95f377a55dad17152bdf24ff70b437 100644 (file)
@@ -1248,59 +1248,6 @@ void action_debug(union ActionData *data)
 
 void action_execute(union ActionData *data)
 {
-    GError *e = NULL;
-    gchar *cmd, **argv = 0;
-    if (data->execute.path) {
-        cmd = g_filename_from_utf8(data->execute.path, -1, NULL, NULL, NULL);
-        if (cmd) {
-            /* If there is a keyboard grab going on then we need to cancel
-               it so the application can grab things */
-            event_cancel_all_key_grabs();
-
-            if (!g_shell_parse_argv (cmd, NULL, &argv, &e)) {
-                g_message(_("Failed to execute '%s': %s"),
-                          cmd, e->message);
-                g_error_free(e);
-            } else if (data->execute.startupnotify) {
-                gchar *program;
-                
-                program = g_path_get_basename(argv[0]);
-                /* sets up the environment */
-                sn_setup_spawn_environment(program,
-                                           data->execute.name,
-                                           data->execute.icon_name,
-                                           /* launch it on the current
-                                              desktop */
-                                           screen_desktop,
-                                           data->execute.any.time);
-                if (!g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH |
-                                   G_SPAWN_DO_NOT_REAP_CHILD,
-                                   NULL, NULL, NULL, &e)) {
-                    g_message(_("Failed to execute '%s': %s"),
-                              cmd, e->message);
-                    g_error_free(e);
-                    sn_spawn_cancel();
-                }
-                unsetenv("DESKTOP_STARTUP_ID");
-                g_free(program);
-                g_strfreev(argv);
-            } else {
-                if (!g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH |
-                                   G_SPAWN_DO_NOT_REAP_CHILD,
-                                   NULL, NULL, NULL, &e))
-                {
-                    g_message(_("Failed to execute '%s': %s"),
-                              cmd, e->message);
-                    g_error_free(e);
-                }
-                g_strfreev(argv);
-            }
-            g_free(cmd);
-        } else {
-            g_message(_("Failed to convert the path '%s' from utf8"),
-                      data->execute.path);
-        }
-    }
 }
 
 void action_activate(union ActionData *data)
index 00563a700055aa7b2ebeb7064da415895dc4a30f..44a39cb5dd25b955852d2f13b2a94dd8f909541b 100644 (file)
@@ -21,6 +21,8 @@
 #include "grab.h"
 #include "screen.h"
 
+#include "actions/all.h"
+
 static void     actions_definition_ref(ObActionsDefinition *def);
 static void     actions_definition_unref(ObActionsDefinition *def);
 static gboolean actions_interactive_begin_act(ObActionsAct *act, guint state);
@@ -33,7 +35,6 @@ struct _ObActionsDefinition {
     guint ref;
 
     gchar *name;
-    ObActionsType type;
 
     ObActionsDataSetupFunc setup;
     ObActionsDataFreeFunc free;
@@ -55,6 +56,8 @@ static GSList *registered = NULL;
 void actions_startup(gboolean reconfig)
 {
     if (reconfig) return;
+
+    action_all_startup();
 }
 
 void actions_shutdown(gboolean reconfig)
@@ -71,7 +74,6 @@ void actions_shutdown(gboolean reconfig)
 }
 
 gboolean actions_register(const gchar *name,
-                          ObActionsType type,
                           ObActionsDataSetupFunc setup,
                           ObActionsDataFreeFunc free,
                           ObActionsRunFunc run,
@@ -92,12 +94,14 @@ gboolean actions_register(const gchar *name,
     def = g_new(ObActionsDefinition, 1);
     def->ref = 1;
     def->name = g_strdup(name);
-    def->type = type;
     def->setup = setup;
     def->free = free;
     def->run = run;
     def->i_input = i_input;
     def->i_cancel = i_cancel;
+
+    registered = g_slist_prepend(registered, def);
+
     return TRUE;
 }
 
@@ -117,7 +121,7 @@ static void actions_definition_unref(ObActionsDefinition *def)
 ObActionsAct* actions_parse_string(const gchar *name)
 {
     GSList *it;
-    ObActionsDefinition *def;
+    ObActionsDefinition *def = NULL;
     ObActionsAct *act = NULL;
 
     /* find the requested action */
@@ -152,7 +156,7 @@ 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->children);
+            act->options = act->def->setup(i, doc, node->xmlChildrenNode);
 
         g_free(name);
     }
@@ -186,13 +190,17 @@ static void actions_setup_data(ObActionsData *data,
                                Time time,
                                guint state,
                                gint x,
-                               gint y)
+                               gint y,
+                               ObFrameContext con,
+                               struct _ObClient *client)
 {
-    data->any.uact = uact;
-    data->any.time = time;
-    data->any.state = state;
-    data->any.x = x;
-    data->any.y = y;
+    data->uact = uact;
+    data->time = time;
+    data->state = state;
+    data->x = x;
+    data->y = y;
+    data->context = con;
+    data->client = client;
 }
 
 void actions_run_acts(GSList *acts,
@@ -219,18 +227,7 @@ void actions_run_acts(GSList *acts,
         ObActionsAct *act = it->data;
         gboolean ok = TRUE;
 
-        data.type = act->def->type;
-        actions_setup_data(&data, uact, time, state, x, y);
-        switch (data.type) {
-        case OB_ACTION_TYPE_GLOBAL:
-            break;
-        case OB_ACTION_TYPE_CLIENT:
-            data.client.context = con;
-            data.client.c = client;
-            break;
-        default:
-            g_assert_not_reached();
-        }
+        actions_setup_data(&data, uact, time, state, x, y, con, client);
 
         if (actions_act_is_interactive(act) &&
             (!interactive_act || interactive_act->def != act->def))
@@ -242,8 +239,13 @@ void actions_run_acts(GSList *acts,
         if (ok) {
             if (!act->def->run(&data, act->options))
                 actions_interactive_end_act();
-            else
-                break; /* no actions are run after the interactive one */
+            else {
+                /* make sure its interactive if it returned TRUE */
+                g_assert(act->def->i_cancel && act->def->i_input);
+
+                /* no actions are run after the interactive one */
+                break;
+            }
         }
     }
 }
index df30413099acd108faa13514d9cc9a905b43254b..3db6d7927e0cb33304308c48c1740b8f5ef768d7 100644 (file)
@@ -41,51 +41,23 @@ typedef gboolean (*ObActionsInteractiveInputFunc)(guint initial_state,
                                                   gboolean *used);
 typedef void     (*ObActionsInteractiveCancelFunc)(gpointer options);
 
-typedef enum {
-    OB_ACTION_TYPE_GLOBAL,
-    OB_ACTION_TYPE_CLIENT
-} ObActionsType;
-
-/* These structures are all castable as eachother */
-
-struct _ObActionsAnyData {
+struct _ObActionsData {
     ObUserAction uact;
     Time time;
     guint state;
     gint x;
     gint y;
-};
-
-struct _ObActionsGlobalData {
-    ObActionsType type;
-    ObActionsAnyData any;
-};
 
-struct _ObActionsClientData {
-    ObActionsType type;
-    ObActionsAnyData any;
-
-    struct _ObClient *c;
+    struct _ObClient *client;
     ObFrameContext context;
 };
 
-struct _ObActionsData {
-    ObActionsType type;
-
-    union {
-        ObActionsAnyData      any;
-        ObActionsGlobalData   global;
-        ObActionsClientData   client;
-    };
-};
-
 void actions_startup(gboolean reconfigure);
 void actions_shutdown(gboolean reconfigure);
 
 /*! If the action is interactive, then i_input and i_cancel are not NULL.
   Otherwise, they should both be NULL. */
 gboolean actions_register(const gchar *name,
-                          ObActionsType type,
                           ObActionsDataSetupFunc setup,
                           ObActionsDataFreeFunc free,
                           ObActionsRunFunc run,
diff --git a/openbox/actions/Makefile b/openbox/actions/Makefile
new file mode 100644 (file)
index 0000000..b90edac
--- /dev/null
@@ -0,0 +1,4 @@
+all clean install:
+       $(MAKE) -C .. -$(MAKEFLAGS) $@
+
+.PHONY: all clean install
diff --git a/openbox/actions/all.c b/openbox/actions/all.c
new file mode 100644 (file)
index 0000000..7c0b253
--- /dev/null
@@ -0,0 +1,6 @@
+#include "all.h"
+
+void action_all_startup()
+{
+    action_execute_startup();
+}
diff --git a/openbox/actions/all.h b/openbox/actions/all.h
new file mode 100644 (file)
index 0000000..599c29f
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __actions_all_h
+#define __actions_all_h
+
+void action_all_startup();
+
+void action_execute_startup();
+
+#endif
diff --git a/openbox/actions/execute.c b/openbox/actions/execute.c
new file mode 100644 (file)
index 0000000..606bb15
--- /dev/null
@@ -0,0 +1,130 @@
+#include "openbox/actions.h"
+#include "openbox/event.h"
+#include "openbox/startupnotify.h"
+#include "openbox/screen.h"
+#include "gettext.h"
+
+typedef struct {
+    gchar   *cmd;
+    gboolean sn;
+    gchar   *sn_name;
+    gchar   *sn_icon;
+    gchar   *sn_wmclass;
+} 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_execute_startup()
+{
+    actions_register("Execute",
+                     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("execute", node))) {
+        gchar *s = parse_string(doc, n);
+        o->cmd = parse_expand_tilde(s);
+        g_free(s);
+    }
+
+    if ((n = parse_find_node("startupnotify", node))) {
+        xmlNodePtr m;
+        if ((m = parse_find_node("enabled", n->xmlChildrenNode)))
+            o->sn = parse_bool(doc, m);
+        if ((m = parse_find_node("name", n->xmlChildrenNode)))
+            o->sn_name = parse_string(doc, m);
+        if ((m = parse_find_node("icon", n->xmlChildrenNode)))
+            o->sn_icon = parse_string(doc, m);
+        if ((m = parse_find_node("wmclass", n->xmlChildrenNode)))
+            o->sn_wmclass = parse_string(doc, m);
+    }
+    return o;
+}
+
+static void free_func(gpointer options)
+{
+    Options *o = options;
+
+    if (o) {
+        g_free(o->cmd);
+        g_free(o->sn_name);
+        g_free(o->sn_icon);
+        g_free(o->sn_wmclass);
+        g_free(o);
+    }
+}
+
+/* Always return FALSE because its not interactive */
+static gboolean run_func(ObActionsData *data, gpointer options)
+{
+    GError *e = NULL;
+    gchar **argv = NULL;
+    gchar *cmd;
+    Options *o = options;
+
+    if (!o->cmd) return FALSE;
+    cmd = g_filename_from_utf8(o->cmd, -1, NULL, NULL, NULL);
+    if (!cmd) {
+        g_message(_("Failed to convert the path '%s' from utf8"), o->cmd);
+        return FALSE;
+    }
+
+    /* If there is a keyboard grab going on then we need to cancel
+       it so the application can grab things */
+    event_cancel_all_key_grabs();
+
+    if (!g_shell_parse_argv(cmd, NULL, &argv, &e)) {
+        g_message(_("Failed to execute '%s': %s"), o->cmd, e->message);
+        g_error_free(e);
+    }
+    else {
+        gchar *program = NULL;
+
+        if (o->sn) {
+            program = g_path_get_basename(argv[0]);
+            /* sets up the environment */
+            sn_setup_spawn_environment(program, o->sn_name, o->sn_icon,
+                                       /* launch it on the current desktop */
+                                       screen_desktop,
+                                       data->time);
+        }
+
+        if (!g_spawn_async(NULL, argv, NULL,
+                           G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+                           NULL, NULL, NULL, &e))
+        {
+            g_message(_("Failed to execute '%s': %s"), o->cmd, e->message);
+            g_error_free(e);
+
+            if (o->sn)
+                sn_spawn_cancel();
+        }
+        if (o->sn)
+            unsetenv("DESKTOP_STARTUP_ID");
+
+        g_free(program);
+        g_strfreev(argv);
+    }
+
+    g_free(cmd);
+
+    return FALSE;
+}
index 48df2e799e0c6694586f53751492ad488d5e6949..7f51e7c8a3f04ba843cd2858306e173b27e235e0 100644 (file)
@@ -764,6 +764,7 @@ static void bind_default_keyboard()
 {
     ObDefKeyBind *it;
     ObDefKeyBind binds[] = {
+        { NULL, NULL },
         { "A-Tab", "NextWindow" },
         { "S-A-Tab", "PreviousWindow" },
         { "A-F4", "Close" },
@@ -789,6 +790,7 @@ static void bind_default_mouse()
 {
     ObDefMouseBind *it;
     ObDefMouseBind binds[] = {
+        { NULL, NULL, 0, NULL },
         { "Left", "Client", OB_MOUSE_ACTION_PRESS, "Focus" },
         { "Middle", "Client", OB_MOUSE_ACTION_PRESS, "Focus" },
         { "Right", "Client", OB_MOUSE_ACTION_PRESS, "Focus" },
index db14afb099731a00aabea13e04d544f9215bfa4b..250ca6d07f465753515259a96698131618574f1c 100644 (file)
@@ -240,10 +240,10 @@ gint main(gint argc, gchar **argv)
                    of the rc */
                 i = parse_startup();
 
-                /* start up config which sets up with the parser */
-                config_startup(i);
                 /* register all the available actions */
                 actions_startup(reconfigure);
+                /* start up config which sets up with the parser */
+                config_startup(i);
 
                 /* parse/load user options */
                 if (parse_load_rc(NULL, &doc, &node)) {
@@ -376,8 +376,8 @@ gint main(gint argc, gchar **argv)
             sn_shutdown(reconfigure);
             window_shutdown(reconfigure);
             event_shutdown(reconfigure);
-            actions_shutdown(reconfigure);
             config_shutdown();
+            actions_shutdown(reconfigure);
             modkeys_shutdown(reconfigure);
         } while (reconfigure);
     }
index 46c13af95d9f9e97522145a6b128b40cda0363d9..8146eda914ca3fd8f22459153ae35b86c11a1244 100644 (file)
@@ -1,5 +1,5 @@
 # List of source files containing translatable strings.
-openbox/action.c
+openbox/actions/execute.c
 openbox/client_list_combined_menu.c
 openbox/client_list_menu.c
 openbox/client_menu.c
This page took 0.042905 seconds and 4 git commands to generate.