From: Dana Jansens Date: Wed, 17 Feb 2010 21:15:08 +0000 (-0500) Subject: move the startup command launching into a helper function X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=2c5d755bd8bfea13fc9830c74b00877e17294e61;p=chaz%2Fopenbox move the startup command launching into a helper function --- diff --git a/openbox/openbox.c b/openbox/openbox.c index 1b39b404..40b614a9 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -109,6 +109,7 @@ static void remove_args(gint *argc, gchar **argv, gint index, gint num); static void parse_env(); static void parse_args(gint *argc, gchar **argv); static Cursor load_cursor(const gchar *name, guint fontval); +static void run_startup_cmd(void); gint main(gint argc, gchar **argv) { @@ -343,28 +344,7 @@ gint main(gint argc, gchar **argv) ob_set_state(OB_STATE_RUNNING); - if (startup_cmd) { - gchar **argv = NULL; - GError *e = NULL; - gboolean ok; - - if (!g_shell_parse_argv(startup_cmd, NULL, &argv, &e)) { - g_message("Error parsing startup command: %s", - e->message); - g_error_free(e); - e = NULL; - } - ok = g_spawn_async(NULL, argv, NULL, - G_SPAWN_SEARCH_PATH | - G_SPAWN_DO_NOT_REAP_CHILD, - NULL, NULL, NULL, &e); - if (!g_shell_parse_argv(startup_cmd, NULL, &argv, &e)) { - g_message("Error launching startup command: %s", - e->message); - g_error_free(e); - e = NULL; - } - } + if (startup_cmd) run_startup_cmd(); /* look for parsing errors */ { @@ -562,6 +542,30 @@ static void remove_args(gint *argc, gchar **argv, gint index, gint num) *argc -= num; } +static void run_startup_cmd(void) +{ + gchar **argv = NULL; + GError *e = NULL; + gboolean ok; + + if (!g_shell_parse_argv(startup_cmd, NULL, &argv, &e)) { + g_message("Error parsing startup command: %s", + e->message); + g_error_free(e); + e = NULL; + } + ok = g_spawn_async(NULL, argv, NULL, + G_SPAWN_SEARCH_PATH | + G_SPAWN_DO_NOT_REAP_CHILD, + NULL, NULL, NULL, &e); + if (!g_shell_parse_argv(startup_cmd, NULL, &argv, &e)) { + g_message("Error launching startup command: %s", + e->message); + g_error_free(e); + e = NULL; + } +} + static void parse_env(void) { const gchar *id;