diff options
author | Pavel Cisler <pavel@eazel.com> | 2000-10-18 23:07:08 +0000 |
---|---|---|
committer | Pavel Cisler <pce@src.gnome.org> | 2000-10-18 23:07:08 +0000 |
commit | 9e6781100f2a89aa5205545c26c699ba6fb873f9 (patch) | |
tree | 92c23a644a80ba83309814663c68aa2694b03b3b /libnautilus-extensions | |
parent | ee67d06ee5f03b1eb3682387d2533a4402da8ab4 (diff) | |
download | nautilus-9e6781100f2a89aa5205545c26c699ba6fb873f9.tar.gz |
Clean up calls to gnome_vfs_extract_short_name, remove explicit unescaping
2000-10-18 Pavel Cisler <pavel@eazel.com>
* components/tree/nautilus-tree-view.c:
* libnautilus-extensions/nautilus-directory.c:
(nautilus_directory_notify_files_moved),
(nautilus_directory_schedule_metadata_copy),
(nautilus_directory_schedule_metadata_move),
(nautilus_directory_schedule_metadata_remove):
* libnautilus-extensions/nautilus-file-utilities.c:
(nautilus_uri_get_basename):
* libnautilus-extensions/nautilus-file-utilities.h:
* libnautilus-extensions/nautilus-file.c:
(nautilus_file_get_internal):
* src/nautilus-theme-selector.c: (add_theme_to_icons):
Clean up calls to gnome_vfs_extract_short_name, remove explicit
unescaping because gnome_vfs_extract_short_name now does it.
Eliminate some copy-paste technology, creating a new call
nautilus_uri_get_basename.
Diffstat (limited to 'libnautilus-extensions')
-rw-r--r-- | libnautilus-extensions/nautilus-directory.c | 33 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-file-utilities.c | 19 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-file-utilities.h | 1 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-file.c | 6 |
4 files changed, 28 insertions, 31 deletions
diff --git a/libnautilus-extensions/nautilus-directory.c b/libnautilus-extensions/nautilus-directory.c index 904a8f229..b2c544116 100644 --- a/libnautilus-extensions/nautilus-directory.c +++ b/libnautilus-extensions/nautilus-directory.c @@ -691,27 +691,6 @@ uri_get_directory_part (const char *uri) return directory_uri; } -static char * -uri_get_basename (const char *uri) -{ - GnomeVFSURI *vfs_uri; - char *escaped_name, *name; - - /* Make VFS version of URI. */ - vfs_uri = gnome_vfs_uri_new (uri); - if (vfs_uri == NULL) { - return NULL; - } - - /* Extract name part. */ - escaped_name = gnome_vfs_uri_extract_short_path_name (vfs_uri); - gnome_vfs_uri_unref (vfs_uri); - name = gnome_vfs_unescape_string (escaped_name, NULL); - g_free (escaped_name); - - return name; -} - /* Return a directory object for this one's parent. */ static NautilusDirectory * get_parent_directory (const char *uri) @@ -1000,7 +979,7 @@ nautilus_directory_notify_files_moved (GList *uri_pairs) nautilus_directory_remove_file (old_directory, file); /* Update the name. */ - name = uri_get_basename (pair->to_uri); + name = nautilus_uri_get_basename (pair->to_uri); nautilus_file_update_name (file, name); g_free (name); @@ -1053,8 +1032,8 @@ nautilus_directory_schedule_metadata_copy (GList *uri_pairs) source_directory = get_parent_directory (pair->from_uri); destination_directory = get_parent_directory (pair->to_uri); - source_file_name = uri_get_basename (pair->from_uri); - destination_file_name = uri_get_basename (pair->to_uri); + source_file_name = nautilus_uri_get_basename (pair->from_uri); + destination_file_name = nautilus_uri_get_basename (pair->to_uri); nautilus_directory_copy_file_metadata (source_directory, source_file_name, @@ -1083,8 +1062,8 @@ nautilus_directory_schedule_metadata_move (GList *uri_pairs) source_directory = get_parent_directory (pair->from_uri); destination_directory = get_parent_directory (pair->to_uri); - source_file_name = uri_get_basename (pair->from_uri); - destination_file_name = uri_get_basename (pair->to_uri); + source_file_name = nautilus_uri_get_basename (pair->from_uri); + destination_file_name = nautilus_uri_get_basename (pair->to_uri); nautilus_directory_copy_file_metadata (source_directory, source_file_name, @@ -1113,7 +1092,7 @@ nautilus_directory_schedule_metadata_remove (GList *uris) uri = (const char *) p->data; directory = get_parent_directory (uri); - file_name = uri_get_basename (uri); + file_name = nautilus_uri_get_basename (uri); nautilus_directory_remove_file_metadata (directory, file_name); diff --git a/libnautilus-extensions/nautilus-file-utilities.c b/libnautilus-extensions/nautilus-file-utilities.c index b7f94f1ff..9db5469a4 100644 --- a/libnautilus-extensions/nautilus-file-utilities.c +++ b/libnautilus-extensions/nautilus-file-utilities.c @@ -160,6 +160,25 @@ nautilus_make_uri_from_input (const char *location) return toreturn; } +char * +nautilus_uri_get_basename (const char *uri) +{ + GnomeVFSURI *vfs_uri; + char *name; + + /* Make VFS version of URI. */ + vfs_uri = gnome_vfs_uri_new (uri); + if (vfs_uri == NULL) { + return NULL; + } + + /* Extract name part. */ + name = gnome_vfs_uri_extract_short_path_name (vfs_uri); + gnome_vfs_uri_unref (vfs_uri); + + return name; +} + gboolean nautilus_uri_is_trash (const char *uri) { diff --git a/libnautilus-extensions/nautilus-file-utilities.h b/libnautilus-extensions/nautilus-file-utilities.h index 3348c34fe..efbe43bc9 100644 --- a/libnautilus-extensions/nautilus-file-utilities.h +++ b/libnautilus-extensions/nautilus-file-utilities.h @@ -43,6 +43,7 @@ char * nautilus_make_uri_canonical (const char gboolean nautilus_uri_is_canonical_uri (const char *uri); gboolean nautilus_uris_match (const char *uri_1, const char *uri_2); +char * nautilus_uri_get_basename (const char *uri); /* FIXME bugzilla.eazel.com 2424: * This is the same as gnome-libs g_concat_dir_and_file except diff --git a/libnautilus-extensions/nautilus-file.c b/libnautilus-extensions/nautilus-file.c index 69da59daf..c22a22841 100644 --- a/libnautilus-extensions/nautilus-file.c +++ b/libnautilus-extensions/nautilus-file.c @@ -269,7 +269,7 @@ nautilus_file_get_internal (const char *uri, gboolean create) GnomeVFSURI *vfs_uri, *directory_vfs_uri; char *directory_uri; NautilusDirectory *directory; - char *file_name_escaped, *file_name; + char *file_name; NautilusFile *file; g_return_val_if_fail (uri != NULL, NULL); @@ -280,9 +280,7 @@ nautilus_file_get_internal (const char *uri, gboolean create) file_name = NULL; if (vfs_uri != NULL) { - file_name_escaped = gnome_vfs_uri_extract_short_path_name (vfs_uri); - file_name = gnome_vfs_unescape_string (file_name_escaped, NULL); - g_free (file_name_escaped); + file_name = gnome_vfs_uri_extract_short_name (vfs_uri); /* Couldn't parse a name out of the URI: the URI must be bogus, * so we'll treat it like the case where gnome_vfs_uri couldn't |