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-10-09 21:43:13.443819939 -0400 +++ gnome-control-center-2.28.0/capplets/appearance/appearance-desktop.c 2009-10-09 21:45:48.428819404 -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,99 @@ 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_object_unref (proxy); + +out: + gtk_action_set_visible (action, result != 0); +} + static GdkPixbuf *buttons[3]; static void @@ -1146,6 +1241,8 @@ desktop_init (AppearanceData *data, { GtkWidget *add_button, *w; GtkCellRenderer *cr; + GtkAction *action; + GtkWidget *widget, *box, *button; char *url; data->wp_update_gconf = TRUE; @@ -1294,6 +1391,21 @@ desktop_init (AppearanceData *data, /* create the file selector later to save time on startup */ data->wp_filesel = NULL; + 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); + + box = appearance_capplet_get_widget (data, "hbox_get_more"); + gtk_box_pack_end (GTK_BOX (box), button, FALSE, FALSE, 6); + + g_signal_connect (action, "activate", G_CALLBACK (set_background), data); } void