aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/reference/shell/eshell-sections.txt1
-rw-r--r--e-util/e-util.c27
-rw-r--r--e-util/e-util.h1
-rw-r--r--widgets/misc/e-attachment-handler-image.c11
4 files changed, 32 insertions, 8 deletions
diff --git a/doc/reference/shell/eshell-sections.txt b/doc/reference/shell/eshell-sections.txt
index 0fba5ee5b9..8ec35fed16 100644
--- a/doc/reference/shell/eshell-sections.txt
+++ b/doc/reference/shell/eshell-sections.txt
@@ -645,6 +645,7 @@ e_run_signature_script
<FILE>e-util</FILE>
<TITLE>Miscellaneous Utilities</TITLE>
e_get_user_data_dir
+e_get_gnome_user_dir
e_get_accels_filename
e_show_uri
e_display_help
diff --git a/e-util/e-util.c b/e-util/e-util.c
index 46404e6ed6..48f268994b 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -80,6 +80,31 @@ e_get_user_data_dir (void)
}
/**
+ * e_get_gnome2_user_dir:
+ *
+ * Returns the base directory for user data, according to libgnome.
+ * The directory can be overridden by setting the GNOME22_USER_DIR
+ * environment variable. The string is owned by Evolution and must
+ * not be modified or freed.
+ *
+ * Returns: base directory for GNOME user data
+ **/
+const gchar *
+e_get_gnome2_user_dir (void)
+{
+ static gchar *dirname = NULL;
+
+ if (G_UNLIKELY (dirname == NULL)) {
+ dirname = g_strdup (g_getenv ("GNOME22_USER_DIR"));
+ if (dirname == NULL)
+ dirname = g_build_filename (
+ g_get_home_dir (), ".gnome2", NULL);
+ }
+
+ return dirname;
+}
+
+/**
* e_get_accels_filename:
*
* Returns the name of the user data file containing custom keyboard
@@ -99,7 +124,7 @@ e_get_accels_filename (void)
if (G_UNLIKELY (filename == NULL))
filename = g_build_filename (
- g_get_home_dir (), ".gnome2",
+ e_get_gnome2_user_dir (),
"accels", PACKAGE, NULL);
return filename;
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 887cc20ce2..7d58a8a9d8 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -49,6 +49,7 @@ typedef enum {
typedef void (*ETypeFunc) (GType type, gpointer user_data);
const gchar * e_get_user_data_dir (void);
+const gchar * e_get_gnome2_user_dir (void);
const gchar * e_get_accels_filename (void);
void e_show_uri (GtkWindow *parent,
const gchar *uri);
diff --git a/widgets/misc/e-attachment-handler-image.c b/widgets/misc/e-attachment-handler-image.c
index d9d87d991f..770b1c552b 100644
--- a/widgets/misc/e-attachment-handler-image.c
+++ b/widgets/misc/e-attachment-handler-image.c
@@ -24,6 +24,8 @@
#include <glib/gi18n.h>
#include <gconf/gconf-client.h>
+#include <e-util/e-util.h>
+
#define E_ATTACHMENT_HANDLER_IMAGE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_ATTACHMENT_HANDLER_IMAGE, EAttachmentHandlerImagePrivate))
@@ -115,7 +117,6 @@ action_image_set_as_background_cb (GtkAction *action,
EAttachment *attachment;
GFile *destination;
GList *selected;
- const gchar *override;
gchar *path;
view = e_attachment_handler_get_view (handler);
@@ -124,12 +125,8 @@ action_image_set_as_background_cb (GtkAction *action,
attachment = E_ATTACHMENT (selected->data);
/* Save the image under ~/.gnome2/wallpapers/. */
- override = g_getenv ("GNOME22_USER_DIR");
- if (override != NULL)
- path = g_build_filename (override, "wallpapers", NULL);
- else
- path = g_build_filename (
- g_get_home_dir (), ".gnome2", "wallpapers", NULL);
+ path = g_build_filename (
+ e_get_gnome2_user_dir (), "wallpapers", NULL);
destination = g_file_new_for_path (path);
g_mkdir_with_parents (path, 0755);
g_free (path);