From da453ec039c78d60ebad64226367780037621197 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 1 Feb 2012 19:33:47 -0600 Subject: better error reporting if g_spawn_command_line_async() fails --- src/indicator-power.c | 19 +++++++++++-------- 1 file 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 @@ -160,15 +160,21 @@ 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 -- cgit v1.2.3