summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--libnautilus-private/nautilus-link-desktop-file.c27
-rw-r--r--libnautilus-private/nautilus-link-desktop-file.h1
-rw-r--r--libnautilus-private/nautilus-link.c13
-rw-r--r--libnautilus-private/nautilus-link.h6
-rw-r--r--src/file-manager/fm-desktop-icon-view.c4
6 files changed, 64 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 75a931fdb..31a098009 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2002-08-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-link-desktop-file.c:
+ * libnautilus-private/nautilus-link-desktop-file.h:
+ New function nautilus_link_desktop_file_local_is_utf8.
+
+ * libnautilus-private/nautilus-link.c:
+ * libnautilus-private/nautilus-link.h:
+ New function nautilus_link_local_is_utf8.
+
+ * src/file-manager/fm-desktop-icon-view.c
+ (update_desktop_directory):
+ Recreate trash and homedir links if they are not in utf8.
+
2002-08-15 Dave Camp <dave@ximian.com>
* libnautilus/nautilus-clipboard.c (select_all_callback): Save the
diff --git a/libnautilus-private/nautilus-link-desktop-file.c b/libnautilus-private/nautilus-link-desktop-file.c
index f8e1915e3..cd315fd12 100644
--- a/libnautilus-private/nautilus-link-desktop-file.c
+++ b/libnautilus-private/nautilus-link-desktop-file.c
@@ -39,6 +39,7 @@
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
#include <eel/eel-xml-extensions.h>
+#include <eel/eel-vfs-extensions.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-util.h>
#include <libgnomevfs/gnome-vfs-utils.h>
@@ -265,6 +266,32 @@ nautilus_link_desktop_file_local_get_link_type (const char *path)
return retval;
}
+gboolean
+nautilus_link_desktop_file_local_is_utf8 (const char *uri)
+{
+ char *contents;
+ int file_size;
+ gboolean retval;
+
+ if (eel_read_entire_file (uri,
+ &file_size,
+ &contents) != GNOME_VFS_OK) {
+ return FALSE;
+ }
+
+ if (g_strstr_len (contents, file_size, "Encoding=UTF-8\n") != NULL) {
+ retval = TRUE;
+ } else {
+ retval = FALSE;
+ }
+
+ g_free (contents);
+
+ return retval;
+}
+
+
+
static char *
nautilus_link_desktop_file_get_link_uri_from_desktop (GnomeDesktopItem *desktop_file)
{
diff --git a/libnautilus-private/nautilus-link-desktop-file.h b/libnautilus-private/nautilus-link-desktop-file.h
index 3c40f38aa..b5ea7e0c7 100644
--- a/libnautilus-private/nautilus-link-desktop-file.h
+++ b/libnautilus-private/nautilus-link-desktop-file.h
@@ -41,6 +41,7 @@ char * nautilus_link_desktop_file_local_get_text (c
char * nautilus_link_desktop_file_local_get_additional_text (const char *uri);
NautilusLinkType nautilus_link_desktop_file_local_get_link_type (const char *uri);
char * nautilus_link_desktop_file_local_get_link_uri (const char *uri);
+gboolean nautilus_link_desktop_file_local_is_utf8 (const char *uri);
char * nautilus_link_desktop_file_get_link_uri_given_file_contents (const char *uri,
const char *link_file_contents,
int link_file_size);
diff --git a/libnautilus-private/nautilus-link.c b/libnautilus-private/nautilus-link.c
index 4ac6b2a2d..eaee2f07a 100644
--- a/libnautilus-private/nautilus-link.c
+++ b/libnautilus-private/nautilus-link.c
@@ -233,6 +233,19 @@ nautilus_link_local_get_link_type (const char *uri, GnomeVFSFileInfo *info)
}
}
+gboolean
+nautilus_link_local_is_utf8 (const char *uri,
+ GnomeVFSFileInfo *info)
+{
+ switch (get_link_style_for_local_file (uri, info)) {
+ case desktop:
+ return nautilus_link_desktop_file_local_is_utf8 (uri);
+ case historical:
+ default:
+ return FALSE;
+ }
+}
+
char *
nautilus_link_get_link_uri_given_file_contents (const char *uri,
const char *file_contents,
diff --git a/libnautilus-private/nautilus-link.h b/libnautilus-private/nautilus-link.h
index 3e4545c16..b5eda7354 100644
--- a/libnautilus-private/nautilus-link.h
+++ b/libnautilus-private/nautilus-link.h
@@ -108,6 +108,12 @@ gboolean nautilus_link_local_is_trash_link (const char
gboolean nautilus_link_local_is_special_link (const char *uri);
+/* Returns TRUE if the link is encoded in utf8
+ * Works only if the file is local and does sync. I/O
+ */
+gboolean nautilus_link_local_is_utf8 (const char *uri,
+ GnomeVFSFileInfo *info);
+
/* Returns the link uri associated with a link file. The first version
* works only if the file is local and does sync. I/O, despite the
* fact that it takes a URI parameter. The second version takes the
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index 101ed132c..5f13c80c6 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -1517,7 +1517,8 @@ update_desktop_directory (UpdateType type)
if (type & UPDATE_HOME_LINK &&
nautilus_link_local_is_home_link (link_path, info)) {
- if (!found_home_link) {
+ if (!found_home_link &&
+ nautilus_link_local_is_utf8 (link_path, info)) {
nautilus_link_local_set_link_uri (link_path, home_uri);
found_home_link = TRUE;
} else {
@@ -1528,6 +1529,7 @@ update_desktop_directory (UpdateType type)
if (type & UPDATE_TRASH_LINK &&
nautilus_link_local_is_trash_link (link_path, info)) {
if (!found_trash_link &&
+ nautilus_link_local_is_utf8 (link_path, info) &&
!strcmp (TRASH_LINK_NAME, info->name)) {
nautilus_link_local_set_link_uri (link_path, EEL_TRASH_URI);
found_trash_link = TRUE;