[gnome-control-center] bgo#627861 - [randr] Don't silengly ignore errors when pkexec(1) fails



commit bfb92ffe9ba87c51450630ce1cdf727fa685f784
Author: Kalev Lember <kalev smartlink ee>
Date:   Fri Sep 10 14:46:29 2010 -0500

    bgo#627861 - [randr] Don't silengly ignore errors when pkexec(1) fails
    
    Now we present a proper error dialog if the 'Make Default' configuration
    cannot be set due to a pkexec error.
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 panels/display/xrandr-capplet.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/panels/display/xrandr-capplet.c b/panels/display/xrandr-capplet.c
index 31269a7..5b0a651 100644
--- a/panels/display/xrandr-capplet.c
+++ b/panels/display/xrandr-capplet.c
@@ -2330,12 +2330,20 @@ success_dialog_for_make_default (App *app)
 }
 
 static void
+error_dialog_for_make_default (App *app, const char *error_text)
+{
+    error_message (app, _("Could not set the default configuration for monitors"), error_text);
+}
+
+static void
 make_default (App *app)
 {
     char *command_line;
     char *source_filename;
     char *dest_filename;
     char *dest_basename;
+    char *std_error;
+    gint exit_status;
     GError *error;
 
     if (!sanitize_and_save_configuration (app))
@@ -2355,12 +2363,21 @@ make_default (App *app)
 				    dest_basename);
 
     error = NULL;
-    /* FIXME: pick up stderr and present it nicely in case of error */
-    if (!g_spawn_command_line_sync (command_line, NULL, NULL, NULL, &error))
-	error_message (app, _("Could not set the default configuration for monitors"), error ? error->message : NULL);
+    if (!g_spawn_command_line_sync (command_line, NULL, &std_error, &exit_status, &error))
+    {
+	error_dialog_for_make_default (app, error->message);
+	g_error_free (error);
+    }
+    else if (!WIFEXITED (exit_status) || WEXITSTATUS (exit_status) != 0)
+    {
+	error_dialog_for_make_default (app, std_error);
+    }
     else
+    {
 	success_dialog_for_make_default (app);
+    }
 
+    g_free (std_error);
     g_free (dest_filename);
     g_free (dest_basename);
     g_free (source_filename);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]