Blob Blame History Raw
diff -up gnome-control-center-2.28.0/capplets/appearance/appearance-desktop.c.make-default gnome-control-center-2.28.0/capplets/appearance/appearance-desktop.c
--- gnome-control-center-2.28.0/capplets/appearance/appearance-desktop.c.make-default	2009-09-21 06:44:55.000000000 -0400
+++ gnome-control-center-2.28.0/capplets/appearance/appearance-desktop.c	2009-09-23 18:13:49.115396173 -0400
@@ -31,6 +31,8 @@
 #include <libgnomeui/gnome-desktop-thumbnail.h>
 #include <libgnomeui/gnome-bg.h>
 
+#include <dbus/dbus-glib.h>
+
 enum {
   TARGET_URI_LIST,
   TARGET_BGIMAGE
@@ -984,6 +986,100 @@ wp_select_after_realize (GtkWidget *widg
   select_item (data, item, TRUE);
 }
 
+static char *background_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
+};
+
+static void
+set_background (GtkAction *action, gpointer data)
+{
+  AppearanceData *adata = (AppearanceData *)data;
+  DBusGProxy *proxy;
+  DBusGConnection *connection;
+  GError *error;
+
+  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;
+  }
+
+  if (!dbus_g_proxy_call (proxy, "SetSystem",
+                          &error,
+                          G_TYPE_STRV, background_keys,
+                          G_TYPE_STRV, NULL,
+                          G_TYPE_INVALID,
+                          G_TYPE_INVALID)) {
+    g_warning ("error calling SetSystem: %s\n", error->message);
+    g_error_free (error);
+  }
+
+  g_object_unref (proxy);
+}
+
+static void
+check_can_set_background (GtkAction *action)
+{
+  DBusGProxy *proxy;
+  DBusGConnection *connection;
+  GError *error;
+  guint result;
+
+  result = 0;
+
+  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);
+    goto out;
+  }
+
+  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");
+    goto out;
+  }
+
+  if (!dbus_g_proxy_call (proxy, "CanSetSystem",
+                          &error,
+                          G_TYPE_STRV, background_keys,
+                          G_TYPE_INVALID,
+                        G_TYPE_UINT, &result,
+                          G_TYPE_INVALID)) {
+    g_warning ("error calling CanSetSystem: %s\n", error->message);
+    g_error_free (error);
+  }
+
+  g_print ("calling CanSetSystem: %d\n", result);
+  g_object_unref (proxy);
+
+out:
+  gtk_action_set_visible (action, result != 0);
+}
+
 static GdkPixbuf *buttons[3];
 
 static void
@@ -1146,6 +1242,8 @@ desktop_init (AppearanceData *data,
 {
   GtkWidget *add_button, *w;
   GtkCellRenderer *cr;
+  GtkAction *action;
+  GtkWidget *widget, *box, *button;
   char *url;
 
   g_object_set (gtk_settings_get_default (), "gtk-tooltip-timeout", 500, NULL);
@@ -1295,6 +1393,24 @@ desktop_init (AppearanceData *data,
   /* create the file selector later to save time on startup */
   data->wp_filesel = NULL;
 
+  widget = appearance_capplet_get_widget (data, "background_vbox");
+  box = gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_end (GTK_BOX (widget), box, FALSE, FALSE, 0);
+
+  action = gtk_action_new ("set-system",
+                           _("Make Default"),
+                           _("Set the current background as the system-wide default"),
+                           NULL);
+  check_can_set_background (action);
+          
+  button = gtk_button_new ();
+  gtk_activatable_set_related_action (GTK_ACTIVATABLE (button), action);
+  gtk_widget_set_no_show_all (button, TRUE);
+  g_object_unref (action);
+
+  gtk_box_pack_end (GTK_BOX (box), button, FALSE, FALSE, 0);
+
+  g_signal_connect (action, "activate", G_CALLBACK (set_background), data);
 }
 
 void