[gnome-control-center/randr-set-as-default] Actually call pkexec(1) to set the systemwide configuration



commit 518b8879377934116fd80a5be0bb039b622c7211
Author: Federico Mena Quintero <federico novell com>
Date:   Thu Mar 11 17:34:17 2010 -0600

    Actually call pkexec(1) to set the systemwide configuration
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 capplets/display/Makefile.am      |    1 +
 capplets/display/xrandr-capplet.c |   40 +++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/capplets/display/Makefile.am b/capplets/display/Makefile.am
index 3aec54e..ee0c046 100644
--- a/capplets/display/Makefile.am
+++ b/capplets/display/Makefile.am
@@ -53,6 +53,7 @@ desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
 
 INCLUDES   = $(DISPLAY_CAPPLET_CFLAGS) \
              $(GNOMECC_CAPPLETS_CFLAGS) \
+	     -DSBINDIR="\"$(sbindir)\"" \
 	     -DUIDIR="\"$(uidir)\"" \
 	     -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
 	     -DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""
diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c
index ad7c9aa..b3c0f21 100644
--- a/capplets/display/xrandr-capplet.c
+++ b/capplets/display/xrandr-capplet.c
@@ -2296,6 +2296,41 @@ apply_button_clicked_cb (GtkButton *button, gpointer data)
     app->apply_button_clicked_timestamp = gtk_get_current_event_time ();
 }
 
+static void
+make_default (App *app)
+{
+    char *command_line;
+    char *source_filename;
+    char *dest_filename;
+    char *dest_basename;
+    GError *error;
+
+    if (!sanitize_and_save_configuration (app))
+	return;
+
+    dest_filename = gconf_client_get_string (app->client, "/apps/gnome_settings_daemon/xrandr/default_configuration_file", NULL);
+    if (!dest_filename)
+	return; /* FIXME: present an error? */
+
+    dest_basename = g_path_get_basename (dest_filename);
+
+    source_filename = gnome_rr_config_get_intended_filename ();
+
+    command_line = g_strdup_printf ("pkexec %s/gnome-display-properties-install-systemwide %s %s",
+				    SBINDIR,
+				    source_filename,
+				    dest_basename);
+
+    error = NULL;
+    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);
+
+    g_free (dest_filename);
+    g_free (dest_basename);
+    g_free (source_filename);
+    g_free (command_line);
+}
+
 static GtkWidget*
 _gtk_builder_get_widget (GtkBuilder *builder, const gchar *name)
 {
@@ -2447,6 +2482,11 @@ restart:
 	apply (app);
 	goto restart;
 	break;
+
+    case RESPONSE_MAKE_DEFAULT:
+	make_default (app);
+	goto restart;
+	break;
     }
 
     gtk_widget_destroy (app->dialog);



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