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



commit 432e5844b0fa8a46312be5e9bd570ba09950f7d1
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>

 capplets/display/xrandr-capplet.c |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c
index c4aedd8..b386c5f 100644
--- a/capplets/display/xrandr-capplet.c
+++ b/capplets/display/xrandr-capplet.c
@@ -2331,12 +2331,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))
@@ -2356,12 +2364,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]