diff options
author | Gene Z. Ragan <gzr@eazel.com> | 2001-02-23 23:54:35 +0000 |
---|---|---|
committer | Gene Ragan <gzr@src.gnome.org> | 2001-02-23 23:54:35 +0000 |
commit | bafd9c3ffbde91da49c403b77da22f4d5d618e02 (patch) | |
tree | 774af94f5dc010c2355ebab346f3776d74d999dd /libnautilus-extensions/nautilus-volume-monitor.c | |
parent | 7d28b6f180e33443634cd2ae7b5adedd81a9465d (diff) | |
download | nautilus-bafd9c3ffbde91da49c403b77da22f4d5d618e02.tar.gz |
reviewed by: Darin Adler <darin@eazel.com>
2001-02-23 Gene Z. Ragan <gzr@eazel.com>
reviewed by: Darin Adler <darin@eazel.com>
Fixed bug 6931, "floppy" and "cdrom" in Disks menu
should be "Floppy" and "CD-ROM"
Fixed bug 5600, Desktop context menu "Disks" options
not translated
* libnautilus-extensions/nautilus-volume-monitor.c:
* libnautilus-extensions/nautilus-volume-monitor.h:
(nautilus_volume_monitor_initialize),
(nautilus_volume_monitor_destroy):
Create a hash table of readable names to represent the
less legible name that is present in /etc/fstab.
* src/file-manager/fm-desktop-icon-view.c:
(update_disks_menu):
Call new nautilus_volume_monitor_get_mount_name_for_display()
function to get a legible name for placement in the mount menu.
Diffstat (limited to 'libnautilus-extensions/nautilus-volume-monitor.c')
-rw-r--r-- | libnautilus-extensions/nautilus-volume-monitor.c | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/libnautilus-extensions/nautilus-volume-monitor.c b/libnautilus-extensions/nautilus-volume-monitor.c index d1cea0439..e56c3a65e 100644 --- a/libnautilus-extensions/nautilus-volume-monitor.c +++ b/libnautilus-extensions/nautilus-volume-monitor.c @@ -139,6 +139,7 @@ struct NautilusVolumeMonitorDetails GList *mounts; GList *removable_volumes; guint mount_volume_timer_id; + GHashTable *readable_mount_point_names; }; static NautilusVolumeMonitor *global_volume_monitor = NULL; @@ -176,7 +177,8 @@ static NautilusVolume *copy_volume (NautilusVolume *volume); static void find_volumes (NautilusVolumeMonitor *monitor); static void free_mount_list (GList *mount_list); static GList *get_removable_volumes (void); - +static GHashTable *create_readable_mount_point_name_table (void); + #ifdef MOUNT_AUDIO_CD static cdrom_drive *open_cdda_device (GnomeVFSURI *uri); static gboolean locate_audio_cd (void); @@ -197,7 +199,8 @@ nautilus_volume_monitor_initialize (NautilusVolumeMonitor *monitor) monitor->details = g_new0 (NautilusVolumeMonitorDetails, 1); monitor->details->mounts = NULL; monitor->details->removable_volumes = NULL; - + monitor->details->readable_mount_point_names = create_readable_mount_point_name_table (); + monitor->details->removable_volumes = get_removable_volumes (); find_volumes (monitor); @@ -247,6 +250,9 @@ nautilus_volume_monitor_destroy (GtkObject *object) free_mount_list (monitor->details->mounts); free_mount_list (monitor->details->removable_volumes); + /* Clean up readable names table */ + g_hash_table_destroy (monitor->details->readable_mount_point_names); + /* Clean up details */ g_free (monitor->details); @@ -596,6 +602,27 @@ nautilus_volume_monitor_get_volume_mount_uri (const NautilusVolume *volume) return volume->mount_path; } + +/* create_readable_mount_point_name_table + * + * Create a table with mapping between the mount point names that are found + * in /etc/fstab and names that are clear and easy to understand. + */ +static GHashTable * +create_readable_mount_point_name_table (void) +{ + GHashTable *table; + + table = g_hash_table_new (g_str_hash, g_str_equal); + + /* Populate table with items we know localized names for. */ + g_hash_table_insert (table, "floppy", _("Floppy")); + g_hash_table_insert (table, "cdrom", _("CD-ROM")); + g_hash_table_insert (table, "zip", _("Zip Drive")); + + return table; +} + static void mount_volume_get_cdrom_name (NautilusVolume *volume) { @@ -1855,6 +1882,30 @@ mount_volume_add_filesystem (NautilusVolume *volume, GList *volume_list) return volume_list; } +char * +nautilus_volume_monitor_get_mount_name_for_display (NautilusVolumeMonitor *monitor, NautilusVolume *volume) +{ + const char *name, *found_name; + + if (monitor == NULL || volume == NULL) { + return NULL; + } + + name = strrchr (volume->mount_path, '/'); + if (name != NULL) { + name = name + 1; + } else { + name = volume->mount_path; + } + + /* Look for a match in out localized mount name list */ + found_name = g_hash_table_lookup (monitor->details->readable_mount_point_names, name); + if (found_name != NULL) { + return g_strdup (found_name); + } else { + return g_strdup (name); + } +} #ifdef MOUNT_AUDIO_CD |