diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2012-02-01 19:33:47 -0600 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2012-02-01 19:33:47 -0600 |
commit | da453ec039c78d60ebad64226367780037621197 (patch) | |
tree | 094b91d823497c03a02583ec546b792407a348c1 | |
parent | 98a2abe1e732fb0110dbf7785569f3a5c0455dca (diff) | |
download | ayatana-indicator-power-da453ec039c78d60ebad64226367780037621197.tar.gz ayatana-indicator-power-da453ec039c78d60ebad64226367780037621197.tar.bz2 ayatana-indicator-power-da453ec039c78d60ebad64226367780037621197.zip |
better error reporting if g_spawn_command_line_async() fails
-rw-r--r-- | src/indicator-power.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/indicator-power.c b/src/indicator-power.c index 4bf9a6f..dc1007d 100644 --- a/src/indicator-power.c +++ b/src/indicator-power.c @@ -161,14 +161,20 @@ indicator_power_finalize (GObject *object) ***/ static void +spawn_command_line_async (const char * command) +{ + GError * err = NULL; + if (!g_spawn_command_line_async (command, &err)) + g_warning ("Couldn't execute command \"%s\": %s", command, err->message); + g_clear_error (&err); +} + +static void show_info_cb (GtkMenuItem *item, gpointer data) { /*TODO: show the statistics of the specific device*/ - const gchar *command = "gnome-power-statistics"; - - if (g_spawn_command_line_async (command, NULL) == FALSE) - g_warning ("Couldn't execute command: %s", command); + spawn_command_line_async ("gnome-power-statistics"); } static void @@ -191,10 +197,7 @@ static void show_preferences_cb (GtkMenuItem *item, gpointer data) { - const gchar *command = "gnome-control-center power"; - - if (g_spawn_command_line_async (command, NULL) == FALSE) - g_warning ("Couldn't execute command: %s", command); + spawn_command_line_async ("gnome-control-center power"); } static void |