[evolution/webkit] Bug 644310 - Rework "Set as Background" image option



commit ea702e7cf43a9f954623626c11ffd69d8332e766
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Mar 27 11:13:00 2011 -0400

    Bug 644310 - Rework "Set as Background" image option
    
    This adds a dependency on gsettings-desktop-schemas >= 2.91.92.
    The version was chosen for the change from "picture-filename" to
    "picture-uri" in the "org.gnome.desktop.background" schema.
    
    Also, we now save the background image under ~/Pictures since the old
    directory (~/.gnome2/wallpapers) is presumed deprecated in GNOME 3.

 configure.ac                              |    5 ++-
 widgets/misc/e-attachment-handler-image.c |   43 ++++++++++++-----------------
 2 files changed, 21 insertions(+), 27 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 85f8202..39d2b29 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,6 +43,7 @@ m4_define([gnome_desktop_minimum_version], [2.91.3])
 m4_define([gnome_icon_theme_minimum_version], [2.30.2.1])
 m4_define([pangoft2_minimum_version], [1.0.1])		dnl For libgnomecanvas
 m4_define([webkit_minimum_version], [1.1.15])		dnl XXX Just a Guess
+m4_define([gsettings_desktop_schemas_minimum_version], [2.91.92])
 m4_define([gconf_minimum_version], [2.0.0])		dnl XXX Just a Guess
 m4_define([libsoup_minimum_version], [2.4.0])		dnl XXX Just a Guess
 m4_define([libxml_minimum_version], [2.7.3])
@@ -242,7 +243,8 @@ PKG_CHECK_MODULES([GNOME_PLATFORM],
 	 libxml-2.0 >= libxml_minimum_version
 	 shared-mime-info >= shared_mime_info_minimum_version
 	 gnome-desktop-3.0 >= gnome_desktop_minimum_version
-	 webkit-1.0 >= webkit_minimum_version])
+	 webkit-1.0 >= webkit_minimum_version
+	 gsettings-desktop-schemas >= gsettings_desktop_schemas_minimum_version])
 AC_SUBST(GNOME_PLATFORM_CFLAGS)
 AC_SUBST(GNOME_PLATFORM_LIBS)
 
@@ -254,7 +256,6 @@ PKG_CHECK_MODULES([EVOLUTION_DATA_SERVER],
 	 libegroupwise-1.2 >= eds_minimum_version
 	 libebackend-1.2 >= eds_minimum_version])
 
-
 dnl ******************************
 dnl Canberra / Canberra-GTK Sound
 dnl ******************************
diff --git a/widgets/misc/e-attachment-handler-image.c b/widgets/misc/e-attachment-handler-image.c
index e7e3658..16046b9 100644
--- a/widgets/misc/e-attachment-handler-image.c
+++ b/widgets/misc/e-attachment-handler-image.c
@@ -22,7 +22,7 @@
 #include "e-attachment-handler-image.h"
 
 #include <glib/gi18n.h>
-#include <gconf/gconf-client.h>
+#include <gdesktop-enums.h>
 
 #include <e-util/e-util.h>
 
@@ -49,39 +49,34 @@ action_image_set_as_background_saved_cb (EAttachment *attachment,
                                          GAsyncResult *result,
                                          EAttachmentHandler *handler)
 {
+	GDesktopBackgroundStyle style;
 	EAttachmentView *view;
-	GConfClient *client;
+	GSettings *settings;
 	GtkWidget *dialog;
 	GFile *file;
-	const gchar *key;
 	gpointer parent;
-	gchar *value;
+	gchar *uri;
 	GError *error = NULL;
 
-	client = gconf_client_get_default ();
 	view = e_attachment_handler_get_view (handler);
+	settings = g_settings_new ("org.gnome.desktop.background");
 
 	file = e_attachment_save_finish (attachment, result, &error);
 
 	if (error != NULL)
 		goto error;
 
-	value = g_file_get_path (file);
-	g_object_unref (file);
+	uri = g_file_get_uri (file);
+	g_settings_set_string (settings, "picture-uri", uri);
+	g_free (uri);
 
-	key = "/desktop/gnome/background/picture_filename";
-	gconf_client_set_string (client, key, value, &error);
-	g_free (value);
+	style = g_settings_get_enum (settings, "picture-options");
+	if (style == G_DESKTOP_BACKGROUND_STYLE_NONE)
+		g_settings_set_enum (
+			settings, "picture-options",
+			G_DESKTOP_BACKGROUND_STYLE_WALLPAPER);
 
-	if (error != NULL)
-		goto error;
-
-	/* Ignore errors for this part. */
-	key = "/desktop/gnome/background/picture_options";
-	value = gconf_client_get_string (client, key, NULL);
-	if (g_strcmp0 (value, "none") == 0)
-		gconf_client_set_string (client, key, "wallpaper", NULL);
-	g_free (value);
+	g_object_unref (file);
 
 	goto exit;
 
@@ -104,7 +99,7 @@ error:
 	g_error_free (error);
 
 exit:
-	g_object_unref (client);
+	g_object_unref (settings);
 	g_object_unref (handler);
 }
 
@@ -116,19 +111,17 @@ action_image_set_as_background_cb (GtkAction *action,
 	EAttachment *attachment;
 	GFile *destination;
 	GList *selected;
-	gchar *path;
+	const gchar *path;
 
 	view = e_attachment_handler_get_view (handler);
 	selected = e_attachment_view_get_selected_attachments (view);
 	g_return_if_fail (g_list_length (selected) == 1);
 	attachment = E_ATTACHMENT (selected->data);
 
-	/* Save the image under ~/.gnome2/wallpapers/. */
-	path = g_build_filename (
-		e_get_gnome2_user_dir (), "wallpapers", NULL);
+	/* Save the image under the user's Pictures directory. */
+	path = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
 	destination = g_file_new_for_path (path);
 	g_mkdir_with_parents (path, 0755);
-	g_free (path);
 
 	e_attachment_save_async (
 		attachment, destination, (GAsyncReadyCallback)



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