]> Dogcows Code - chaz/openbox/commitdiff
allow setting startupnotify per execute action, default to disabled. use like this...
authorMikael Magnusson <mikachu@comhem.se>
Sun, 11 Mar 2007 15:41:47 +0000 (15:41 +0000)
committerMikael Magnusson <mikachu@comhem.se>
Sun, 11 Mar 2007 15:41:47 +0000 (15:41 +0000)
openbox/action.c
openbox/action.h
openbox/startupnotify.c
openbox/startupnotify.h

index 7d41d71262695866648e600b621443eece8f593d..5cd39f3d2b56a970326672b6173058fb2d385a3e 100644 (file)
@@ -929,6 +929,15 @@ ObAction *action_parse(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
                     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_showmenu) {
                 if ((n = parse_find_node("menu", node->xmlChildrenNode)))
                     act->data.showmenu.name = parse_string(doc, n);
@@ -1095,11 +1104,13 @@ void action_execute(union ActionData *data)
                 g_warning("failed to execute '%s': %s",
                           cmd, e->message);
                 g_error_free(e);
-            } else {
+            } else if (data->execute.startupnotify) {
                 gchar **env, *program;
                 
                 program = g_path_get_basename(argv[0]);
                 env = sn_get_spawn_environment(program,
+                                               data->execute.name,
+                                               data->execute.icon_name,
                                                data->execute.any.time);
                 if (!g_spawn_async(NULL, argv, env, G_SPAWN_SEARCH_PATH |
                                    G_SPAWN_DO_NOT_REAP_CHILD,
@@ -1112,6 +1123,16 @@ void action_execute(union ActionData *data)
                 g_strfreev(env);
                 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_warning("failed to execute '%s': %s",
+                              cmd, e->message);
+                    g_error_free(e);
+                }
+                g_strfreev(argv);
             }
             g_free(cmd);
         } else {
index 639db0184352e6cdd5ae8dfa76aa851bdf1d809f..c8e91cfa5b654147c6db67622bb8f516fd9df710 100644 (file)
@@ -72,6 +72,9 @@ struct DirectionalAction{
 struct Execute {
     struct AnyAction any;
     gchar *path;
+    gboolean startupnotify;
+    gchar *name;
+    gchar *icon_name;
 };
 
 struct ClientAction {
index 5db9bd48fd09542f83dcd59fa77a0ff0da5248d0..954b9d4ab1193bc92c9ccc7a7766f00bf1073653 100644 (file)
@@ -32,7 +32,8 @@ Time sn_app_started(const gchar *id, const gchar *wmclass)
     return CurrentTime;
 }
 gboolean sn_get_desktop(gchar *id, guint *desktop) { return FALSE; }
-gchar **sn_get_spawn_environment(char *program, Time time)
+gchar **sn_get_spawn_environment(char *program, char *name,
+                                 char *icon_name, Time time)
 {
     return g_strdupv(environ);
 }
@@ -225,7 +226,8 @@ static gboolean sn_launch_wait_timeout(gpointer data)
     return FALSE; /* don't repeat */
 }
 
-gchar **sn_get_spawn_environment(char *program, Time time)
+gchar **sn_get_spawn_environment(char *program, char *name,
+                                 char *icon_name, Time time)
 {
     gchar **env, *desc;
     guint len;
@@ -238,9 +240,9 @@ gchar **sn_get_spawn_environment(char *program, Time time)
         sn_launcher = sn_launcher_context_new(sn_display, ob_screen);
     }
 
-    sn_launcher_context_set_name(sn_launcher, program);
+    sn_launcher_context_set_name(sn_launcher, name ? name : program);
     sn_launcher_context_set_description(sn_launcher, desc);
-    sn_launcher_context_set_icon_name(sn_launcher, program);
+    sn_launcher_context_set_icon_name(sn_launcher, icon_name ? icon_name : program);
     sn_launcher_context_set_binary_name(sn_launcher, program);
     sn_launcher_context_initiate(sn_launcher, "openbox", program, time);
     id = sn_launcher_context_get_startup_id(sn_launcher);
index 533ff9c6fc701c3292cd023f47a2778d770b5f20..850f39a77aaeaa774e4b35060651bcc2da00e325 100644 (file)
@@ -35,7 +35,8 @@ Time sn_app_started(const gchar *id, const gchar *wmclass);
 gboolean sn_get_desktop(gchar *id, guint *desktop);
 
 /* Get the environment to run the program in, with startup notification */
-gchar **sn_get_spawn_environment(char *program, Time time);
+gchar **sn_get_spawn_environment(char *program, char *name,
+                                 char *icon_name, Time time);
 
 /* Tell startup notification we're not actually running the program we
    told it we were
This page took 0.034024 seconds and 4 git commands to generate.