Hi, Here's a small patch to correct the behaviour of the suspend menu command in battstat (kudos to you kevin for fixing it!), as well as showing the device errors in dialogs rather than in the command-line. Some strings changes, but i reckon they're needed... Should I also make gnome-session use g_spawn_* ? Cheers -- /Bastien Nocera http://hadess.net
Index: battstat_applet.c =================================================================== RCS file: /cvs/gnome/gnome-applets/battstat/battstat_applet.c,v retrieving revision 1.31 diff -u -r1.31 battstat_applet.c --- battstat_applet.c 2002/02/16 22:03:08 1.31 +++ battstat_applet.c 2002/02/18 10:55:15 @@ -693,7 +693,7 @@ switch (status) { case 1: - g_error ( + gnome_error_dialog ( /* Displayed if the APM device couldn't be opened. (Used under *BSD)*/ _("Can't open the APM device!\n\n" "Make sure you have read permission to the\n" @@ -701,7 +701,7 @@ exit(1); break; case 2: - g_error ( + gnome_error_dialog ( /* Displayed if the APM system is disabled (Used under *BSD)*/ _("The APM Management subsystem seems to be disabled.\n" "Try executing \"apm -e 1\" (FreeBSD) and see if \n" @@ -739,7 +739,30 @@ ProgressData *battstat = data; if(battstat->suspend_cmd && strlen(battstat->suspend_cmd)>0) { - gnome_execute_shell(NULL, battstat->suspend_cmd); + GError *err = NULL; + gboolean ret; + gint shell_ret = 0; + + ret = g_spawn_command_line_sync(battstat->suspend_cmd, + NULL, NULL, &shell_ret, &err); + if (ret == FALSE || shell_ret != 0) + { + gchar *msg; + + if (err != NULL) + { + msg = g_strdup_printf(_("An error occured while launching the Suspend command: %s\nPlease try to correct this error"), err->message); + } else { + /* Probably because the shell_ret is != 0 */ + msg = g_strdup_printf(_("An error occured while launching the Suspend command, the command returned \"%d\"\nPlease try to correct this error"), shell_ret); + } + gnome_error_dialog(msg); + g_free(msg); + if (err != NULL) + g_error_free(err); + } + } else { + gnome_error_dialog(_("Suspend command wasn't setup correctly in the preferences.\nPlease change the preferences and try again.")); } return;
Attachment:
pgpE4NqFaVCZh.pgp
Description: PGP signature