[nautilus] Migrate .gnome2 scripts dir to use XDG data dir
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] Migrate .gnome2 scripts dir to use XDG data dir
- Date: Thu, 26 Apr 2012 14:08:36 +0000 (UTC)
commit 05e7b7cc4d70b0c89442241e1a741d63a6c5d24d
Author: William Jon McCann <jmccann redhat com>
Date: Wed Apr 25 20:26:29 2012 -0400
Migrate .gnome2 scripts dir to use XDG data dir
https://bugzilla.gnome.org/show_bug.cgi?id=646584
src/nautilus-view.c | 58 ++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 51 insertions(+), 7 deletions(-)
---
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index f5c3ddf..cbdb208 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -46,6 +46,9 @@
#include <glib/gstdio.h>
#include <gio/gio.h>
#include <math.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gnome-extensions.h>
@@ -2155,6 +2158,7 @@ sort_directories_first_changed_callback (gpointer callback_data)
static gboolean
set_up_scripts_directory_global (void)
{
+ char *old_scripts_directory_path;
char *scripts_directory_path;
const char *override;
@@ -2162,17 +2166,56 @@ set_up_scripts_directory_global (void)
return TRUE;
}
+ scripts_directory_path = g_build_filename (g_get_user_data_dir (),
+ "nautilus",
+ "scripts",
+ NULL);
+
override = g_getenv ("GNOME22_USER_DIR");
if (override) {
- scripts_directory_path = g_build_filename (override,
- "nautilus-scripts",
- NULL);
+ old_scripts_directory_path = g_build_filename (override,
+ "nautilus-scripts",
+ NULL);
} else {
- scripts_directory_path = g_build_filename (g_get_home_dir (),
- ".gnome2",
- "nautilus-scripts",
- NULL);
+ old_scripts_directory_path = g_build_filename (g_get_home_dir (),
+ ".gnome2",
+ "nautilus-scripts",
+ NULL);
+ }
+
+ if (g_file_test (old_scripts_directory_path, G_FILE_TEST_IS_DIR)
+ && !g_file_test (scripts_directory_path, G_FILE_TEST_EXISTS)) {
+ char *updated;
+ const char *message;
+
+ /* test if we already attempted to migrate first */
+ updated = g_build_filename (old_scripts_directory_path, "DEPRECATED-DIRECTORY", NULL);
+ message = _("Nautilus 3.6 deprecated this directory and tried migrating "
+ "this configuration to ~/.local/share/nautilus");
+ if (!g_file_test (updated, G_FILE_TEST_EXISTS)) {
+ char *parent_dir;
+
+ parent_dir = g_path_get_dirname (scripts_directory_path);
+ if (g_mkdir_with_parents (parent_dir, 0755) == 0) {
+ int fd, res;
+
+ /* rename() works fine if the destination directory is
+ * empty.
+ */
+ res = g_rename (old_scripts_directory_path, scripts_directory_path);
+ if (res == -1) {
+ fd = g_creat (updated, 0600);
+ if (fd != -1) {
+ res = write (fd, message, strlen (message));
+ close (fd);
+ }
+ }
+ }
+ g_free (parent_dir);
+ }
+
+ g_free (updated);
}
if (g_mkdir_with_parents (scripts_directory_path, 0755) == 0) {
@@ -2181,6 +2224,7 @@ set_up_scripts_directory_global (void)
}
g_free (scripts_directory_path);
+ g_free (old_scripts_directory_path);
return (scripts_directory_uri != NULL) ? TRUE : FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]