diff options
author | Gaute Lindkvist <lindkvis@src.gnome.org> | 2003-03-24 17:44:09 +0000 |
---|---|---|
committer | Gaute Lindkvist <lindkvis@src.gnome.org> | 2003-03-24 17:44:09 +0000 |
commit | 81e99f4b161363390799f2856cf7bfdf55a7981e (patch) | |
tree | 43bc70b07e54835b57b3b5398311f2c7d46abbce /libnautilus-private | |
parent | 54ae8fa6aa1bc5dcb248a21f9c7497fabb35427e (diff) | |
download | nautilus-81e99f4b161363390799f2856cf7bfdf55a7981e.tar.gz |
Free space and volume name in property window for directories
Diffstat (limited to 'libnautilus-private')
-rw-r--r-- | libnautilus-private/nautilus-file.c | 77 | ||||
-rw-r--r-- | libnautilus-private/nautilus-file.h | 2 |
2 files changed, 77 insertions, 2 deletions
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c index 6dd7735ad..c7995c7a3 100644 --- a/libnautilus-private/nautilus-file.c +++ b/libnautilus-private/nautilus-file.c @@ -40,6 +40,7 @@ #include "nautilus-trash-directory.h" #include "nautilus-trash-file.h" #include "nautilus-vfs-file.h" +#include "nautilus-volume-monitor.h" #include <eel/eel-glib-extensions.h> #include <eel/eel-gtk-extensions.h> #include <eel/eel-vfs-extensions.h> @@ -4126,7 +4127,7 @@ nautilus_file_get_deep_directory_count_as_string (NautilusFile *file) * set includes "name", "type", "mime_type", "size", "deep_size", "deep_directory_count", * "deep_file_count", "deep_total_count", "date_modified", "date_changed", "date_accessed", * "date_permissions", "owner", "group", "permissions", "octal_permissions", "uri", "where", - * "link_target". + * "link_target", "volume", "free_space". * * Returns: Newly allocated string ready to display to the user, or NULL * if the value is unknown or @attribute_name is not supported. @@ -4200,7 +4201,12 @@ nautilus_file_get_string_attribute (NautilusFile *file, const char *attribute_na if (strcmp (attribute_name, "link_target") == 0) { return nautilus_file_get_symbolic_link_target_path (file); } - + if (strcmp (attribute_name, "volume") == 0) { + return nautilus_file_get_volume_name (file); + } + if (strcmp (attribute_name, "free_space") == 0) { + return nautilus_file_get_volume_free_space (file); + } return NULL; } @@ -4568,6 +4574,73 @@ nautilus_file_is_broken_symbolic_link (NautilusFile *file) } /** + * nautilus_file_get_volume_free_space + * Get a nicely formatted char with free space on the file's volume + * @file: NautilusFile representing the file in question. + * + * Returns: newly-allocated copy of file size in a formatted string + */ +char * +nautilus_file_get_volume_free_space (NautilusFile *file) +{ + char * file_uri; + GnomeVFSFileSize free_space; + GnomeVFSResult result; + GnomeVFSURI * vfs_uri; + + file_uri = nautilus_file_get_uri (file); + + if (file_uri == NULL) { + return NULL; + } + + vfs_uri = gnome_vfs_uri_new (file_uri); + result = gnome_vfs_get_volume_free_space (vfs_uri, &free_space); + g_free (file_uri); + gnome_vfs_uri_unref (vfs_uri); + + if (result == GNOME_VFS_OK) { + return gnome_vfs_format_file_size_for_display (free_space); + } else { + return NULL; + } +} + +/** + * nautilus_file_get_volume_name + * Get the path of the volume the file resides on + * @file: NautilusFile representing the file in question. + * + * Returns: newly-allocated copy of the volume name of the target file, + * if the volume name isn't set, it returns the mount path of the volume + */ +char * +nautilus_file_get_volume_name (NautilusFile *file) +{ + char *local_path; + char *file_uri; + char *volume_name; + NautilusVolume *volume; + file_uri = nautilus_file_get_uri (file); + + local_path = gnome_vfs_get_local_path_from_uri (file_uri); + volume = nautilus_volume_monitor_get_volume_for_path (nautilus_volume_monitor_get (), local_path); + + g_free (file_uri); + g_free (local_path); + + if (volume != NULL) { + volume_name = nautilus_volume_get_name (volume); + if (volume_name == NULL) { + return g_strdup (nautilus_volume_get_mount_path (volume)); + } + return volume_name; + } else { + return NULL; + } +} + +/** * nautilus_file_get_symbolic_link_target_path * * Get the file path of the target of a symbolic link. It is an error diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h index 40f28231a..d098981db 100644 --- a/libnautilus-private/nautilus-file.h +++ b/libnautilus-private/nautilus-file.h @@ -136,6 +136,8 @@ char * nautilus_file_get_mime_type (Nautilu gboolean nautilus_file_is_mime_type (NautilusFile *file, const char *mime_type); gboolean nautilus_file_is_symbolic_link (NautilusFile *file); +char * nautilus_file_get_volume_free_space (NautilusFile *file); +char * nautilus_file_get_volume_name (NautilusFile *file); char * nautilus_file_get_symbolic_link_target_path (NautilusFile *file); char * nautilus_file_get_symbolic_link_target_uri (NautilusFile *file); gboolean nautilus_file_is_broken_symbolic_link (NautilusFile *file); |