Blob Blame History Raw
diff -up gnome-control-center-2.25.1/capplets/appearance/appearance-desktop.c.make-default gnome-control-center-2.25.1/capplets/appearance/appearance-desktop.c
--- gnome-control-center-2.25.1/capplets/appearance/appearance-desktop.c.make-default	2008-11-05 09:21:32.000000000 -0500
+++ gnome-control-center-2.25.1/capplets/appearance/appearance-desktop.c	2008-11-13 14:31:40.000000000 -0500
@@ -32,6 +32,9 @@
 #include <libgnomeui/gnome-desktop-thumbnail.h>
 #include <libgnomeui/gnome-bg.h>
 
+#include <dbus/dbus-glib.h>
+#include <polkit-gnome/polkit-gnome.h>
+
 enum {
   TARGET_URI_LIST,
   TARGET_BGIMAGE
@@ -988,12 +991,61 @@ wp_select_after_realize (GtkWidget *widg
   select_item (data, item, TRUE);
 }
 
+static void
+set_background (GtkAction *action, gpointer data)
+{
+  AppearanceData *adata = (AppearanceData *)data;
+  DBusGProxy *proxy;
+  DBusGConnection *connection;
+  GError *error;
+  char *keys[7] = {
+    "/desktop/gnome/background/picture_filename",
+    "/desktop/gnome/background/picture_opacity",
+    "/desktop/gnome/background/picture_options",
+    "/desktop/gnome/background/color_shading_type",
+    "/desktop/gnome/background/primary_color",
+    "/desktop/gnome/background/secondary_color",
+    NULL
+  };
+
+  gconf_client_suggest_sync (adata->client, NULL);
+
+  error = NULL;
+  connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+  if (error != NULL) {
+    g_warning ("failed to get system bus connection: %s", error->message);
+    g_error_free (error);
+    return;
+  }
+
+  proxy = dbus_g_proxy_new_for_name (connection,
+                                     "org.gnome.GConf.Defaults",
+                                     "/",
+                                     "org.gnome.GConf.Defaults");
+  if (proxy == NULL) {
+    g_warning ("Cannot connect to defaults mechanism");
+    return;
+  }
+
+  dbus_g_proxy_call (proxy, "SetSystem",
+                     &error,
+                     G_TYPE_STRV, keys,
+                     G_TYPE_STRV, NULL,
+                     G_TYPE_INVALID,
+                     G_TYPE_INVALID);
+
+  g_object_unref (proxy);
+}
+
 void
 desktop_init (AppearanceData *data,
 	      const gchar **uris)
 {
   GtkWidget *add_button;
   GtkCellRenderer *cr;
+  PolKitAction *pk_action;
+  PolKitGnomeAction *action;
+  GtkWidget *widget, *box, *button;
 
   g_object_set (gtk_settings_get_default (), "gtk-tooltip-timeout", 500, NULL);
 
@@ -1114,6 +1166,24 @@ desktop_init (AppearanceData *data,
   /* create the file selector later to save time on startup */
   data->wp_filesel = NULL;
 
+  widget = glade_xml_get_widget (data->xml, "background_vbox");
+  box = gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_end (GTK_BOX (widget), box, FALSE, FALSE, 0);
+ 
+  pk_action = polkit_action_new ();
+  polkit_action_set_action_id (pk_action, "org.gnome.gconf.defaults.set-default-background");
+ 
+  action = polkit_gnome_action_new_default ("set-system", 
+                                            pk_action,
+                                            _("Make Default"),
+                                            _("Set the current background as the system-wide default"));
+  g_object_set (action, "no-visible", FALSE, NULL);
+          
+  polkit_action_unref (pk_action);
+  button = polkit_gnome_action_create_button (action);
+  gtk_box_pack_end (GTK_BOX (box), button, FALSE, FALSE, 0);
+
+  g_signal_connect (action, "activate", G_CALLBACK (set_background), data);
 }
 
 void
diff -up gnome-control-center-2.25.1/capplets/appearance/Makefile.am.make-default gnome-control-center-2.25.1/capplets/appearance/Makefile.am
--- gnome-control-center-2.25.1/capplets/appearance/Makefile.am.make-default	2008-11-05 09:21:32.000000000 -0500
+++ gnome-control-center-2.25.1/capplets/appearance/Makefile.am	2008-11-13 14:28:38.000000000 -0500
@@ -42,7 +42,8 @@ gnome_appearance_properties_LDADD = \
 	$(top_builddir)/capplets/common/libcommon.la \
 	$(GNOMECC_CAPPLETS_LIBS) \
 	$(FONT_CAPPLET_LIBS) \
-	$(METACITY_LIBS)
+	$(METACITY_LIBS) \
+	$(POLKIT_GNOME_LIBS) 
 gnome_appearance_properties_LDFLAGS = -export-dynamic
 
 gladedir = $(pkgdatadir)/glade
@@ -53,6 +54,7 @@ INCLUDES = \
 	$(METACITY_CFLAGS) \
 	$(GNOMECC_CAPPLETS_CFLAGS) \
 	$(FONT_CAPPLET_CFLAGS) \
+	$(POLKIT_GNOME_CFLAGS) \
 	-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
 	-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
 	-DGNOMECC_GLADE_DIR="\"$(gladedir)\"" \