From c4b8cdd48c95fc3d2cafc81403dfc2be23461357 Mon Sep 17 00:00:00 2001 From: Darin Adler Date: Wed, 15 Aug 2001 21:04:01 +0000 Subject: A pass at cleaning up the volume monitor. Made all the details of NautilusVolume private. * libnautilus-private/filesystem-attributes.xml: Changed the "description" string to be named "default_volume_name" and also marked it to be localized. * libnautilus-private/nautilus-file-utilities.h: * libnautilus-private/nautilus-file-utilities.c: (nautilus_get_data_file_path): Added a new utility function to locate a file that's either in the user's directory or in the Nautilus datadir. * src/nautilus-property-browser.c: (read_browser_xml): Use nautilus_get_data_file_path. * libnautilus-private/nautilus-trash-directory.c: (get_trash_volume): * libnautilus-private/nautilus-trash-monitor.c: (add_one_volume_trash): * src/file-manager/fm-desktop-icon-view.c: (volume_in_black_list), (create_unique_volume_name), (create_mount_link), (volume_unmounted_callback), (update_disks_menu): * src/nautilus-application.c: (volume_mounted_callback), (volume_unmounted_callback): * src/nautilus-bookmark-list.c: (nautilus_bookmark_list_get_file_path): Use only calls from the NautilusVolume public API -- no getting at the structure directly. Also fix callers that were using nautilus_volume_monitor_get_volume_mount_uri to correctly understand that they get the mount path, not the mount URI. * libnautilus-private/nautilus-volume-monitor.h: * libnautilus-private/nautilus-volume-monitor.c: (load_file_system_table): Fix storage leaks. Use the new nautilus_get_data_file_path. Translate the default volume names as they are loaded. Check for duplicate entries while loading the table. Don't bother checking the name of the root node, since there are plenty of other things about the file that we don't check and there's no reason we particularly need to check that. Fix some storage leaks. Free the doc, since I'm not seeing a "nautilus --quit" segfault. (nautilus_volume_monitor_initialize): Only initialize stuff that g_new0 won't set up for us. (nautilus_volume_is_removable): Rename so it's a call on NautilusVolume, not the NautilusVolumeMonitor. (volume_is_removable): Fix logic so we don't have to have so many different calls to fclose. (nautilus_volume_get_name): Rename so it's a call on NautilusVolume, not the NautilusVolumeMonitor. (modify_volume_name_for_display): Don't bother supplying a name if passed NULL, since that won't ever be helpful the way this is used. (nautilus_volume_get_target_uri): Rename so it's a call on NautilusVolume, not the NautilusVolumeMonitor. (nautilus_volume_should_integrate_trash): Rename so it's a call on NautilusVolume, not the NautilusVolumeMonitor. Get the information from the file system type, so we don't have to copy it into each NautilusVolume object. (nautilus_volume_get_mount_path): Rename so it's a call on NautilusVolume, and don't call it a URI since it's really a path. (nautilus_volume_get_device_type): New call. (make_volume_name_from_path): Get the default from the file system type rather than passing it in. (free_mount_list): Get rid of some dumb extra code. (copy_volume), (nautilus_volume_free): Update for smaller set of fields. (create_volume), (finish_creating_volume), (finish_creating_volume_and_prepend): Restructure so we don't need to keep so much stuff around in the NautilusVolume object. * src/nautilus-first-time-druid.c: (druid_set_first_time_file_flag): Some tiny tweaking. --- ChangeLog | 75 ++++ libnautilus-private/filesystem-attributes.xml | 49 ++- libnautilus-private/nautilus-file-utilities.c | 25 ++ libnautilus-private/nautilus-file-utilities.h | 4 +- libnautilus-private/nautilus-trash-directory.c | 9 +- libnautilus-private/nautilus-trash-monitor.c | 18 +- libnautilus-private/nautilus-volume-monitor.c | 495 +++++++++++-------------- libnautilus-private/nautilus-volume-monitor.h | 81 ++-- po/ChangeLog | 4 + po/POTFILES.in | 47 +-- src/file-manager/fm-desktop-icon-view.c | 29 +- src/nautilus-application.c | 6 +- src/nautilus-bookmark-list.c | 4 +- src/nautilus-first-time-druid.c | 21 +- src/nautilus-property-browser.c | 33 +- 15 files changed, 433 insertions(+), 467 deletions(-) diff --git a/ChangeLog b/ChangeLog index 50601abed..92d20e567 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,78 @@ +2001-08-15 Darin Adler + + A pass at cleaning up the volume monitor. Made all the details of + NautilusVolume private. + + * libnautilus-private/filesystem-attributes.xml: Changed the + "description" string to be named "default_volume_name" and also + marked it to be localized. + + * libnautilus-private/nautilus-file-utilities.h: + * libnautilus-private/nautilus-file-utilities.c: + (nautilus_get_data_file_path): + Added a new utility function to locate a file that's either in the + user's directory or in the Nautilus datadir. + + * src/nautilus-property-browser.c: (read_browser_xml): Use + nautilus_get_data_file_path. + + * libnautilus-private/nautilus-trash-directory.c: + (get_trash_volume): + * libnautilus-private/nautilus-trash-monitor.c: + (add_one_volume_trash): + * src/file-manager/fm-desktop-icon-view.c: (volume_in_black_list), + (create_unique_volume_name), (create_mount_link), + (volume_unmounted_callback), (update_disks_menu): + * src/nautilus-application.c: (volume_mounted_callback), + (volume_unmounted_callback): + * src/nautilus-bookmark-list.c: + (nautilus_bookmark_list_get_file_path): + Use only calls from the NautilusVolume public API -- no getting at + the structure directly. Also fix callers that were using + nautilus_volume_monitor_get_volume_mount_uri to correctly + understand that they get the mount path, not the mount URI. + + * libnautilus-private/nautilus-volume-monitor.h: + * libnautilus-private/nautilus-volume-monitor.c: + (load_file_system_table): Fix storage leaks. Use the new + nautilus_get_data_file_path. Translate the default volume names as + they are loaded. Check for duplicate entries while loading the + table. Don't bother checking the name of the root node, since + there are plenty of other things about the file that we don't + check and there's no reason we particularly need to check that. + Fix some storage leaks. Free the doc, since I'm not seeing a + "nautilus --quit" segfault. + (nautilus_volume_monitor_initialize): Only initialize stuff that + g_new0 won't set up for us. + (nautilus_volume_is_removable): Rename so it's a call on + NautilusVolume, not the NautilusVolumeMonitor. + (volume_is_removable): Fix logic so we don't have to have so many + different calls to fclose. + (nautilus_volume_get_name): Rename so it's a call on + NautilusVolume, not the NautilusVolumeMonitor. + (modify_volume_name_for_display): Don't bother supplying a name if + passed NULL, since that won't ever be helpful the way this is used. + (nautilus_volume_get_target_uri): Rename so it's a call on + NautilusVolume, not the NautilusVolumeMonitor. + (nautilus_volume_should_integrate_trash): Rename so it's a call on + NautilusVolume, not the NautilusVolumeMonitor. Get the information + from the file system type, so we don't have to copy it into each + NautilusVolume object. + (nautilus_volume_get_mount_path): Rename so it's a call on + NautilusVolume, and don't call it a URI since it's really a path. + (nautilus_volume_get_device_type): New call. + (make_volume_name_from_path): Get the default from the file system + type rather than passing it in. + (free_mount_list): Get rid of some dumb extra code. + (copy_volume), (nautilus_volume_free): Update for smaller set of + fields. + (create_volume), (finish_creating_volume), + (finish_creating_volume_and_prepend): Restructure so we don't need + to keep so much stuff around in the NautilusVolume object. + + * src/nautilus-first-time-druid.c: + (druid_set_first_time_file_flag): Some tiny tweaking. + 2001-08-15 Maciej Stachowiak * components/music/Makefile.am: Revert accidental commit of not diff --git a/libnautilus-private/filesystem-attributes.xml b/libnautilus-private/filesystem-attributes.xml index 9e2907fb4..037aaff78 100644 --- a/libnautilus-private/filesystem-attributes.xml +++ b/libnautilus-private/filesystem-attributes.xml @@ -1,28 +1,27 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c index 5055f7206..66b282b24 100644 --- a/libnautilus-private/nautilus-file-utilities.c +++ b/libnautilus-private/nautilus-file-utilities.c @@ -287,6 +287,31 @@ nautilus_pixmap_file (const char *partial_path) return NULL; } +char * +nautilus_get_data_file_path (const char *partial_path) +{ + char *path; + char *user_directory; + + /* first try the user's home directory */ + user_directory = nautilus_get_user_directory (); + path = nautilus_make_path (user_directory, partial_path); + g_free (user_directory); + if (g_file_exists (path)) { + return path; + } + g_free (path); + + /* next try the shared directory */ + path = nautilus_make_path (NAUTILUS_DATADIR, partial_path); + if (g_file_exists (path)) { + return path; + } + g_free (path); + + return NULL; +} + char * nautilus_unique_temporary_file_name (void) { diff --git a/libnautilus-private/nautilus-file-utilities.h b/libnautilus-private/nautilus-file-utilities.h index 12c656bd6..2d7fa0075 100644 --- a/libnautilus-private/nautilus-file-utilities.h +++ b/libnautilus-private/nautilus-file-utilities.h @@ -47,7 +47,6 @@ char * nautilus_get_desktop_directory (void); char * nautilus_get_gmc_desktop_directory (void); char * nautilus_get_pixmap_directory (void); - /* See if the user_main_directory exists. This should be called before * nautilus_get_user_main_directory, which creates the directory. */ @@ -63,6 +62,9 @@ gboolean nautilus_user_main_directory_exists (void); */ char * nautilus_pixmap_file (const char *partial_path); +/* Locate a file in either the uers directory or the datadir. */ +char * nautilus_get_data_file_path (const char *partial_path); + /* Returns the build time stamp the Nautilus binary. * This is useful to be able to tell builds apart. * A return value of NULL means unknown time stamp. diff --git a/libnautilus-private/nautilus-trash-directory.c b/libnautilus-private/nautilus-trash-directory.c index 0a8e930c9..777dddd0e 100644 --- a/libnautilus-private/nautilus-trash-directory.c +++ b/libnautilus-private/nautilus-trash-directory.c @@ -140,6 +140,8 @@ get_trash_volume (NautilusTrashDirectory *trash, TrashVolume **trash_volume, GnomeVFSURI **volume_mount_uri) { + char *uri_str; + /* Quick out if we already know about this volume. */ *trash_volume = g_hash_table_lookup (trash->details->volumes, volume); @@ -148,12 +150,13 @@ get_trash_volume (NautilusTrashDirectory *trash, return FALSE; } - if (!nautilus_volume_monitor_should_integrate_trash (volume)) { + if (!nautilus_volume_should_integrate_trash (volume)) { return FALSE; } - *volume_mount_uri = gnome_vfs_uri_new - (nautilus_volume_monitor_get_volume_mount_uri (volume)); + uri_str = gnome_vfs_get_uri_from_local_path (nautilus_volume_get_mount_path (volume)); + *volume_mount_uri = gnome_vfs_uri_new (uri_str); + g_free (uri_str); if (*trash_volume == NULL) { /* Make the structure used to track the trash for this volume. */ diff --git a/libnautilus-private/nautilus-trash-monitor.c b/libnautilus-private/nautilus-trash-monitor.c index 83ef5667d..64da6584d 100644 --- a/libnautilus-private/nautilus-trash-monitor.c +++ b/libnautilus-private/nautilus-trash-monitor.c @@ -215,19 +215,21 @@ static gboolean add_one_volume_trash (const NautilusVolume *volume, gpointer callback_data) { + char *uri_str; GnomeVFSURI *volume_mount_point_uri; GnomeVFSURI *trash_uri; GList **result; - result = (GList **)callback_data; + result = (GList **) callback_data; - if (nautilus_volume_monitor_should_integrate_trash (volume)) { + if (nautilus_volume_should_integrate_trash (volume)) { /* Get the uri of the volume mount point as the place * "near" which to look for trash on the given volume. - */ - volume_mount_point_uri = gnome_vfs_uri_new ( - nautilus_volume_monitor_get_volume_mount_uri (volume)); + */ + uri_str = gnome_vfs_get_uri_from_local_path (nautilus_volume_get_mount_path (volume)); + volume_mount_point_uri = gnome_vfs_uri_new (uri_str); + g_free (uri_str); g_assert (volume_mount_point_uri != NULL); @@ -236,9 +238,9 @@ add_one_volume_trash (const NautilusVolume *volume, * already don't know where it is) do not cause any IO. */ if (gnome_vfs_find_directory (volume_mount_point_uri, - GNOME_VFS_DIRECTORY_KIND_TRASH, &trash_uri, - FALSE, FALSE, 0777) == GNOME_VFS_OK) { - + GNOME_VFS_DIRECTORY_KIND_TRASH, &trash_uri, + FALSE, FALSE, 0777) == GNOME_VFS_OK) { + /* found trash, put it on the list */ *result = g_list_prepend (*result, trash_uri); } diff --git a/libnautilus-private/nautilus-volume-monitor.c b/libnautilus-private/nautilus-volume-monitor.c index f91bfa3ee..22327bf93 100644 --- a/libnautilus-private/nautilus-volume-monitor.c +++ b/libnautilus-private/nautilus-volume-monitor.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -122,7 +123,6 @@ #include #define CD_AUDIO_PATH "/dev/cdrom" -#define CDDA_SCHEME "cdda" /* This is here to work around a broken header file. cdda_interface.h * has a statically defined array of chars that is unused. This will @@ -144,8 +144,23 @@ typedef struct statfs MountTableEntry; typedef struct mntent MountTableEntry; #endif -typedef void (* ChangeNautilusVolumeFunction) (NautilusVolumeMonitor *view, - NautilusVolume *volume); +typedef struct { + char *name; + char *default_volume_name; + gboolean can_handle_trash; +} NautilusFileSystemType; + +struct NautilusVolume { + NautilusDeviceType device_type; + NautilusFileSystemType *file_system_type; + + char *device_path; + char *mount_path; + char *volume_name; + + gboolean is_removable; + gboolean is_audio_cd; +}; struct NautilusVolumeMonitorDetails { @@ -153,9 +168,12 @@ struct NautilusVolumeMonitorDetails GList *removable_volumes; guint mount_volume_timer_id; GHashTable *readable_mount_point_names; - GHashTable *filesystem_attribute_table; + GHashTable *file_system_table; }; +typedef void (* ChangeNautilusVolumeFunction) (NautilusVolumeMonitor *view, + NautilusVolume *volume); + static NautilusVolumeMonitor *global_volume_monitor = NULL; static const char *floppy_device_path_prefix; static const char *noauto_string; @@ -178,120 +196,81 @@ static void nautilus_volume_monitor_initialize_class (NautilusVolumeM static void nautilus_volume_monitor_destroy (GtkObject *object); static char * get_iso9660_volume_name (NautilusVolume *volume, int volume_fd); -static GHashTable * load_filesystem_attributes_table (void); +static GHashTable * load_file_system_table (void); static void mount_volume_activate (NautilusVolumeMonitor *view, NautilusVolume *volume); static void mount_volume_deactivate (NautilusVolumeMonitor *monitor, NautilusVolume *volume); static void load_additional_mount_list_info (GList *volume_list); -static GList * mount_volume_prepend_filesystem (GList *volume_list, - NautilusVolume *volume); -static NautilusVolume *create_volume (GHashTable *fs_attribute_table, - const char *device_path, - const char *mount_path, - const char *filesystem); -static NautilusVolume *copy_volume (NautilusVolume *volume); +static NautilusVolume *create_volume (const char *device_path, + const char *mount_path); +static GList * finish_creating_volume_and_prepend (NautilusVolumeMonitor *monitor, + NautilusVolume *volume, + const char *file_system_type_name, + GList *volume_list); +static NautilusVolume *copy_volume (const NautilusVolume *volume); static void find_volumes (NautilusVolumeMonitor *monitor); static void free_mount_list (GList *mount_list); -static GList * get_removable_volumes (GHashTable *fs_attribute_table); +static GList * get_removable_volumes (NautilusVolumeMonitor *monitor); static GHashTable * create_readable_mount_point_name_table (void); static int get_cdrom_type (const char *vol_dev_path, int *fd); +static void nautilus_volume_free (NautilusVolume *volume); #ifdef HAVE_CDDA static gboolean locate_audio_cd (void); #endif EEL_DEFINE_CLASS_BOILERPLATE (NautilusVolumeMonitor, - nautilus_volume_monitor, - GTK_TYPE_OBJECT) -static char* -get_xml_path (const char *file_name) -{ - char *xml_path; - char *user_directory; - - user_directory = nautilus_get_user_directory (); - - /* first try the user's home directory */ - xml_path = nautilus_make_path (user_directory, - file_name); - g_free (user_directory); - if (g_file_exists (xml_path)) { - return xml_path; - } - g_free (xml_path); - - /* next try the shared directory */ - xml_path = nautilus_make_path (NAUTILUS_DATADIR, - file_name); - if (g_file_exists (xml_path)) { - return xml_path; - } - g_free (xml_path); - - return NULL; -} + nautilus_volume_monitor, + GTK_TYPE_OBJECT) static GHashTable * -load_filesystem_attributes_table (void) +load_file_system_table (void) { xmlDocPtr doc; xmlNodePtr node; GHashTable *table; - char *filesystem_attributes_file; - xmlChar *name, *trash_str; - NautilusVolumeInfo *filesystem; - - filesystem_attributes_file = get_xml_path ("filesystem-attributes.xml"); + char *file_system_attributes_file; + xmlChar *name, *default_volume_name, *trash; + NautilusFileSystemType *type; - if (filesystem_attributes_file == NULL) { - return NULL; - } - - doc = xmlParseFile (filesystem_attributes_file); + table = g_hash_table_new (g_str_hash, g_str_equal); - g_free (filesystem_attributes_file); - - if (doc == NULL - || doc->xmlRootNode == NULL - || doc->xmlRootNode->name == NULL - || g_strcasecmp (doc->xmlRootNode->name, "FileSystemAttributes") != 0) { - xmlFreeDoc(doc); - return NULL; + file_system_attributes_file = nautilus_get_data_file_path ("filesystem-attributes.xml"); + if (file_system_attributes_file == NULL) { + return table; + } + doc = xmlParseFile (file_system_attributes_file); + g_free (file_system_attributes_file); + if (doc == NULL) { + return table; } - table = g_hash_table_new (g_str_hash, g_str_equal); - for (node = doc->xmlRootNode->xmlChildrenNode; node != NULL; node = node->next) { name = xmlGetProp (node, "name"); - if (name == NULL) { - continue; - } - filesystem = g_new0 (NautilusVolumeInfo, 1); - filesystem->name = strdup (name); - filesystem->description = strdup (xmlGetProp (node, "description")); + if (name != NULL) { + default_volume_name = eel_xml_get_property_translated (node, "default_volume_name"); + trash = xmlGetProp (node, "trash"); - trash_str = xmlGetProp (node, "trash"); - if (trash_str != NULL && (strcmp (trash_str, "yes") == 0)) { - filesystem->use_trash = TRUE; - } else { - filesystem->use_trash = FALSE; + if (g_hash_table_lookup (table, name) != NULL) { + g_message ("duplicate entry for file system type %s", name); + } + type = g_new (NautilusFileSystemType, 1); + type->name = g_strdup (name); + type->default_volume_name = g_strdup (default_volume_name); + type->can_handle_trash = eel_str_is_equal (trash, "yes"); + g_hash_table_insert (table, type->name, type); + + xmlFree (default_volume_name); + xmlFree (trash); } - g_hash_table_insert (table, filesystem->name, filesystem); - xmlFree (name); - xmlFree (trash_str); - /* printf ("Found filesystem %s (%s), trash support is %d.\n", filesystem->description, filesystem->name, filesystem->use_trash); */ } - /* FIXME: if I do this xmlFreeDoc, then "nautilus --quit" segfaults somewhere in OAF. - Why? It looks like memory trashing, but the xmlFreeDoc here sure looks correct to me. - Leaving it commented out currently, though that will leak a little memory, it should be - a fixed amount since this function should be (and is) only called once */ - /* xmlFreeDoc (doc); */ + xmlFreeDoc (doc); return table; } @@ -301,13 +280,9 @@ nautilus_volume_monitor_initialize (NautilusVolumeMonitor *monitor) { /* Set up details */ 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->filesystem_attribute_table = load_filesystem_attributes_table (); - - monitor->details->removable_volumes = get_removable_volumes (monitor->details->filesystem_attribute_table); - + monitor->details->file_system_table = load_file_system_table (); + monitor->details->removable_volumes = get_removable_volumes (monitor); find_volumes (monitor); } @@ -439,12 +414,11 @@ floppy_sort (const NautilusVolume *volume1, const NautilusVolume *volume2) } gboolean -nautilus_volume_monitor_volume_is_removable (const NautilusVolume *volume) +nautilus_volume_is_removable (const NautilusVolume *volume) { return volume->is_removable; } - /* nautilus_volume_monitor_get_removable_volumes * * Accessor. List and internal data is not to be freed. @@ -489,7 +463,7 @@ has_removable_mntent_options (MountTableEntry *ent) */ static GList * -get_removable_volumes (GHashTable *fs_attribute_table) +get_removable_volumes (NautilusVolumeMonitor *monitor) { FILE *file; GList *volumes; @@ -509,13 +483,11 @@ get_removable_volumes (GHashTable *fs_attribute_table) /* getmentinfo returns a pointer to static data. Do not free. */ for (index = 0; index < count; index++) { if (has_removable_mntent_options (ent + 1)) { - create_volume (fs_attribute_table, - ent[index].f_mntfromname, - ent[index].f_mntoname, - ent[index].f_fstyename); + volume = create_volume (ent[index].f_mntfromname, + ent[index].f_mntoname); volume->is_removable = TRUE; - volume->is_read_only = ((ent[index].f_flags & MNT_RDONLY) != 0); - volumes = mount_volume_prepend_filesystem (volumes, volume); + volumes = finish_creating_volume_and_prepend + (monitor, volume, ent[index].f_fstyename, volumes); } } #endif @@ -528,21 +500,19 @@ get_removable_volumes (GHashTable *fs_attribute_table) #ifdef HAVE_SYS_MNTTAB_H ent = &ent_storage; while (! getmntent (file, ent)) { - /* On Solaris look for /vol/ for determining a removable volume */ if (eel_str_has_prefix (ent->mnt_special, noauto_string)) { - volume = create_volume (fs_attribute_table, ent->mnt_special, - ent->mnt_mountp, ent->mnt_fstype); + volume = create_volume (ent->mnt_special, ent->mnt_mountp); volume->is_removable = TRUE; - volume->is_read_only = hasmntopt (ent, MNTOPT_RO) != NULL; - volumes = mount_volume_prepend_filesystem (volumes, volume); + volumes = finish_creating_volume_and_prepend + (monitor, volume, ent->mnt_fstype, volumes); } } #elif defined (HAVE_MNTENT_H) while ((ent = getmntent (file)) != NULL) { if (has_removable_mntent_options (ent)) { - volume = create_volume (fs_attribute_table, ent->mnt_fsname, - ent->mnt_dir, ent->mnt_type); - volumes = mount_volume_prepend_filesystem (volumes, volume); + volume = create_volume (ent->mnt_fsname, ent->mnt_dir); + volumes = finish_creating_volume_and_prepend + (monitor, volume, ent->mnt_type, volumes); } } #endif @@ -550,8 +520,8 @@ get_removable_volumes (GHashTable *fs_attribute_table) fclose (file); #ifdef HAVE_CDDA - volume = create_volume (NULL, CD_AUDIO_PATH, CD_AUDIO_PATH, CDDA_SCHEME); - volumes = mount_volume_prepend_filesystem (volumes, volume); + volume = create_volume (CD_AUDIO_PATH, CD_AUDIO_PATH); + volumes = finish_creating_volume_and_prepend (monitor, volume, "cdda", volumes); #endif load_additional_mount_list_info (volumes); @@ -565,6 +535,7 @@ get_removable_volumes (GHashTable *fs_attribute_table) static gboolean volume_is_removable (const NautilusVolume *volume) { + gboolean removable; FILE *file; MountTableEntry *ent; #ifdef HAVE_SYS_MNTTAB_H @@ -577,17 +548,17 @@ volume_is_removable (const NautilusVolume *volume) if (file == NULL) { return FALSE; } + + removable = FALSE; /* Search for our device in the fstab */ #ifdef HAVE_SYS_MNTTAB_H ent = &ent_storage; while (!getmntent (file, ent)) { if (strcmp (volume->device_path, ent->mnt_special) == 0) { - /* On Solaris look for /vol/ for determining - a removable volume */ if (eel_str_has_prefix (ent->mnt_special, noauto_string)) { - fclose (file); - return TRUE; + removable = TRUE; + break; } } } @@ -595,73 +566,24 @@ volume_is_removable (const NautilusVolume *volume) while ((ent = getmntent (file)) != NULL) { if (strcmp (volume->device_path, ent->mnt_fsname) == 0 && has_removable_mntent_options (ent)) { - fclose (file); - return TRUE; + removable = TRUE; + break; } } #endif fclose (file); - return FALSE; -} - -static gboolean -volume_is_read_only (const NautilusVolume *volume) -{ - FILE *file; - MountTableEntry *ent; - -#ifdef HAVE_SYS_MNTTAB_H - MountTableEntry ent_storage; - - file = setmntent (MOUNT_TABLE_PATH, "r"); - if (file == NULL) { - return FALSE; - } - - /* Search for our device in the fstab */ - ent = &ent_storage; - while (!getmntent (file, ent)) { - if (strcmp (volume->device_path, ent->mnt_special) == 0) { - if (strstr (ent->mnt_mntopts, MNTOPT_RO) != NULL) { - fclose (file); - return TRUE; - } - } - } -#elif defined (HAVE_MNTENT_H) - file = setmntent (MOUNT_TABLE_PATH, "r"); - if (file == NULL) { - return FALSE; - } - - /* Search for our device in the fstab */ - while ((ent = getmntent (file)) != NULL) { - if (strcmp (volume->device_path, ent->mnt_fsname) == 0) { - if (strstr (ent->mnt_opts, MNTOPT_RO) != NULL) { - fclose (file); - return TRUE; - } - } - } -#else - ent = NULL; - file = NULL; -#endif - - fclose (file); - return FALSE; + return removable; } #endif /* !SOLARIS_MNT */ char * -nautilus_volume_monitor_get_volume_name (const NautilusVolume *volume) +nautilus_volume_get_name (const NautilusVolume *volume) { if (volume->volume_name == NULL) { return g_strdup (_("Unknown")); } - return g_strdup (volume->volume_name); } @@ -678,7 +600,7 @@ modify_volume_name_for_display (const char *unmodified_name) char *name; if (unmodified_name == NULL) { - return g_strdup (_("Unknown")); + return NULL; } name = g_strdup (unmodified_name); @@ -709,11 +631,11 @@ modify_volume_name_for_display (const char *unmodified_name) */ char * -nautilus_volume_monitor_get_target_uri (const NautilusVolume *volume) +nautilus_volume_get_target_uri (const NautilusVolume *volume) { char *uri, *escaped_path; - if (volume->audio_cd) { + if (volume->is_audio_cd) { escaped_path = gnome_vfs_escape_path_string (volume->mount_path); uri = g_strconcat ("cdda://", escaped_path, NULL); g_free (escaped_path); @@ -724,17 +646,27 @@ nautilus_volume_monitor_get_target_uri (const NautilusVolume *volume) } gboolean -nautilus_volume_monitor_should_integrate_trash (const NautilusVolume *volume) +nautilus_volume_should_integrate_trash (const NautilusVolume *volume) { - return volume->use_trash; + g_return_val_if_fail (volume != NULL, FALSE); + return volume->file_system_type != NULL + && volume->file_system_type->can_handle_trash; } const char * -nautilus_volume_monitor_get_volume_mount_uri (const NautilusVolume *volume) +nautilus_volume_get_mount_path (const NautilusVolume *volume) { + g_return_val_if_fail (volume != NULL, NULL); return volume->mount_path; } +const NautilusDeviceType +nautilus_volume_get_device_type (const NautilusVolume *volume) +{ + g_return_val_if_fail (volume != NULL, NAUTILUS_DEVICE_UNKNOWN); + return volume->device_type; +} + /* create_readable_mount_point_name_table * @@ -788,14 +720,17 @@ mount_volume_make_cdrom_name (NautilusVolume *volume) } static char * -make_volume_name_from_path (NautilusVolume *volume, - const char *default_volume_name) +make_volume_name_from_path (NautilusVolume *volume) { const char *name; name = strrchr (volume->mount_path, '/'); if (name == NULL) { - return g_strdup (default_volume_name); + if (volume->file_system_type == NULL) { + return NULL; + } else { + return g_strdup (volume->file_system_type->default_volume_name); + } } if (name[0] == '/' && name[1] == '\0') { return g_strdup (_("Root Volume")); @@ -806,12 +741,12 @@ make_volume_name_from_path (NautilusVolume *volume, static char * mount_volume_make_name (NautilusVolume *volume) { - if (volume->audio_cd) { + if (volume->is_audio_cd) { return g_strdup (_("Audio CD")); } else if (volume->device_type == NAUTILUS_DEVICE_CDROM_DRIVE) { return mount_volume_make_cdrom_name (volume); } else { - return make_volume_name_from_path (volume, volume->description); + return make_volume_name_from_path (volume); } } @@ -866,13 +801,8 @@ mount_volume_deactivate (NautilusVolumeMonitor *monitor, NautilusVolume *volume) static void free_mount_list (GList *mount_list) { - if (mount_list == NULL) { - return; - } - - g_list_foreach (mount_list, (GFunc) nautilus_volume_monitor_free_volume, NULL); + g_list_foreach (mount_list, (GFunc) nautilus_volume_free, NULL); g_list_free (mount_list); - mount_list = NULL; } @@ -918,7 +848,7 @@ build_volume_list_delta (GList *list_one, GList *list_two) #ifdef SOLARIS_MNT static GList * -get_mount_list (GHashTable *fs_attribute_table) +get_mount_list (NautilusVolumeMonitor *monitor) { FILE *fh; GList *volumes; @@ -933,11 +863,10 @@ get_mount_list (GHashTable *fs_attribute_table) } while (! getmntent(fh, &ent)) { - volume = create_volume (fs_attribute_table, ent.mnt_special, - ent.mnt_mountp, ent.mnt_fstype); + volume = create_volume (ent.mnt_special, ent.mnt_mountp); volume->is_removable = has_removable_mntent_options (&ent); - volume->is_read_only = hasmntopt (&ent, MNTOPT_RO) != NULL; - volumes = mount_volume_prepend_filesystem (volumes, volume); + volumes = finish_creating_volume_and_prepend + (monitor, volume, ent.mnt_fstype, volumes); } fclose (fh); @@ -948,7 +877,7 @@ get_mount_list (GHashTable *fs_attribute_table) #else /* !SOLARIS_MNT */ static GList * -get_mount_list (GHashTable *fs_attribute_table) +get_mount_list (NautilusVolumeMonitor *monitor) { GList *volumes; NautilusVolume *volume; @@ -958,7 +887,7 @@ get_mount_list (GHashTable *fs_attribute_table) char line[PATH_MAX * 3]; char device_name[sizeof (line)]; EelStringList *list; - char *device_path, *mount_path, *filesystem; + char *device_path, *mount_path, *file_system_type_name; volumes = NULL; @@ -996,13 +925,13 @@ get_mount_list (GHashTable *fs_attribute_table) if (eel_string_list_get_length (list) >= 3) { device_path = eel_string_list_nth (list, 0); mount_path = eel_string_list_nth (list, 1); - filesystem = eel_string_list_nth (list, 2); - volume = create_volume (fs_attribute_table, device_path, - mount_path, filesystem); + file_system_type_name = eel_string_list_nth (list, 2); + volume = create_volume (device_path, mount_path); + volumes = finish_creating_volume_and_prepend + (monitor, volume, file_system_type_name, volumes); g_free (device_path); g_free (mount_path); - g_free (filesystem); - volumes = mount_volume_prepend_filesystem (volumes, volume); + g_free (file_system_type_name); } eel_string_list_free (list); @@ -1015,21 +944,21 @@ get_mount_list (GHashTable *fs_attribute_table) static GList * -get_current_mount_list (GHashTable *fs_attribute_table) +get_current_mount_list (NautilusVolumeMonitor *monitor) { GList *volumes; #ifdef HAVE_CDDA NautilusVolume *volume; #endif - volumes = get_mount_list (fs_attribute_table); + volumes = get_mount_list (monitor); #ifdef HAVE_CDDA /* CD Audio tricks */ if (locate_audio_cd ()) { - volume = create_volume (NULL, CD_AUDIO_PATH, CD_AUDIO_PATH, CDDA_SCHEME); + volume = create_volume (CD_AUDIO_PATH, CD_AUDIO_PATH); volume->volume_name = mount_volume_make_name (volume); - volumes = mount_volume_prepend_filesystem (volumes, volume); + volumes = finish_creating_volume_and_prepend (monitor, volume, "cdda", volumes); } #endif @@ -1076,7 +1005,7 @@ verify_current_mount_state (NautilusVolumeMonitor *monitor) GList *saved_mount_list, *node; /* Get all current mounts */ - current_mounts = get_current_mount_list (monitor->details->filesystem_attribute_table); + current_mounts = get_current_mount_list (monitor); if (current_mounts == NULL) { return; } @@ -1197,7 +1126,8 @@ mount_volume_auto_add (NautilusVolume *volume) { if (eel_str_has_prefix (volume->device_path, floppy_device_path_prefix)) { volume->device_type = NAUTILUS_DEVICE_FLOPPY_DRIVE; - } /* FIXME: add cdroms to this too */ + } + /* FIXME: add cdroms to this too */ return TRUE; } @@ -1205,7 +1135,7 @@ static gboolean mount_volume_cdda_add (NautilusVolume *volume) { volume->device_type = NAUTILUS_DEVICE_CDROM_DRIVE; - volume->audio_cd = TRUE; + volume->is_audio_cd = TRUE; return TRUE; } @@ -1243,7 +1173,7 @@ find_volumes (NautilusVolumeMonitor *monitor) void nautilus_volume_monitor_each_mounted_volume (NautilusVolumeMonitor *monitor, - NautilusEachVolumeFunction function, + NautilusEachVolumeCallback function, gpointer context) { GList *p; @@ -1585,60 +1515,44 @@ nautilus_volume_monitor_set_volume_name (NautilusVolumeMonitor *monitor, } static NautilusVolume * -create_volume (GHashTable *fs_attribute_table, const char *device_path, - const char *mount_path, const char *filesystem) +create_volume (const char *device_path, const char *mount_path) { NautilusVolume *volume; - NautilusVolumeInfo *info; volume = g_new0 (NautilusVolume, 1); + volume->device_path = g_strdup (device_path); volume->mount_path = g_strdup (mount_path); - volume->filesystem = g_strdup (filesystem); - - if (fs_attribute_table != NULL - && (info = g_hash_table_lookup (fs_attribute_table, filesystem))) { - - volume->use_trash = info->use_trash; - volume->description = g_strdup (info->description); - } else { - volume->use_trash = FALSE; - volume->description = g_strdup ("Unknown Volume Type"); - } - - volume->device_type = NAUTILUS_DEVICE_UNKNOWN; - volume->audio_cd = FALSE; return volume; } static NautilusVolume * -copy_volume (NautilusVolume *volume) +copy_volume (const NautilusVolume *volume) { NautilusVolume *new_volume; - new_volume = g_new0 (NautilusVolume, 1); + new_volume = g_new (NautilusVolume, 1); + + new_volume->device_type = volume->device_type; + new_volume->file_system_type = volume->file_system_type; + new_volume->device_path = g_strdup (volume->device_path); new_volume->mount_path = g_strdup (volume->mount_path); - new_volume->filesystem = g_strdup (volume->filesystem); - new_volume->device_type = volume->device_type; new_volume->volume_name = g_strdup (volume->volume_name); - new_volume->description = g_strdup (volume->description); new_volume->is_removable = volume->is_removable; - new_volume->is_read_only = volume->is_read_only; - new_volume->use_trash = volume->use_trash; + new_volume->is_audio_cd = volume->is_audio_cd; return new_volume; } void -nautilus_volume_monitor_free_volume (NautilusVolume *volume) +nautilus_volume_free (NautilusVolume *volume) { g_free (volume->device_path); g_free (volume->mount_path); g_free (volume->volume_name); - g_free (volume->filesystem); g_free (volume); } @@ -1669,84 +1583,93 @@ load_additional_mount_list_info (GList *volume_list) #ifndef SOLARIS_MNT /* These are set up by get_current_mount_list for Solaris. */ volume->is_removable = volume_is_removable (volume); - volume->is_read_only = volume_is_read_only (volume); #endif volume->volume_name = mount_volume_make_name (volume); } } - -static GList * -mount_volume_prepend_filesystem (GList *volume_list, NautilusVolume *volume) +static gboolean +finish_creating_volume (NautilusVolumeMonitor *monitor, NautilusVolume *volume, + const char *file_system_type_name) { - gboolean added; - char *device_name; - - added = FALSE; - - if (strcmp (volume->filesystem, "auto") == 0) { - added = mount_volume_auto_add (volume); - } else if (strcmp (volume->filesystem, "cdda") == 0) { - added = mount_volume_cdda_add (volume); - } else if (strcmp (volume->filesystem, "iso9660") == 0) { - added = mount_volume_iso9660_add (volume); - } else if (strcmp (volume->filesystem, "nfs") == 0) { - added = mount_volume_nfs_add (volume); + gboolean ok; + const char *name; + + volume->file_system_type = g_hash_table_lookup + (monitor->details->file_system_table, file_system_type_name); + + if (strcmp (file_system_type_name, "auto") == 0) { + ok = mount_volume_auto_add (volume); + } else if (strcmp (file_system_type_name, "cdda") == 0) { + ok = mount_volume_cdda_add (volume); + } else if (strcmp (file_system_type_name, "iso9660") == 0) { + ok = mount_volume_iso9660_add (volume); + } else if (strcmp (file_system_type_name, "nfs") == 0) { + ok = mount_volume_nfs_add (volume); } else { - added = TRUE; + ok = TRUE; + } + + if (!ok) { + return FALSE; } - if (added) { - volume_list = g_list_prepend (volume_list, volume); + /* Identify device type */ + if (eel_str_has_prefix (volume->mount_path, "/mnt/")) { + name = volume->mount_path + strlen ("/mnt/"); - /* Identify device type */ - if (eel_str_has_prefix (volume->mount_path, "/mnt/")) { - device_name = g_strdup (volume->mount_path + 5); - - if (eel_str_has_prefix (device_name, "cdrom")) { - volume->device_type = NAUTILUS_DEVICE_CDROM_DRIVE; - volume->is_removable = TRUE; - } else if (eel_str_has_prefix (device_name, "floppy")) { - volume->device_type = NAUTILUS_DEVICE_FLOPPY_DRIVE; - volume->is_removable = TRUE; - } else if (eel_str_has_prefix (volume->device_path, floppy_device_path_prefix)) { - volume->device_type = NAUTILUS_DEVICE_FLOPPY_DRIVE; - volume->is_removable = TRUE; - } else if (eel_str_has_prefix (device_name, "zip")) { - volume->device_type = NAUTILUS_DEVICE_ZIP_DRIVE; - volume->is_removable = TRUE; - } else if (eel_str_has_prefix (device_name, "jaz")) { - volume->device_type = NAUTILUS_DEVICE_JAZ_DRIVE; - volume->is_removable = TRUE; - } else if (eel_str_has_prefix (device_name, "camera")) { - volume->device_type = NAUTILUS_DEVICE_CAMERA; - volume->is_removable = TRUE; - } else if (eel_str_has_prefix (device_name, "memstick")) { - volume->device_type = NAUTILUS_DEVICE_MEMORY_STICK; + if (eel_str_has_prefix (name, "cdrom")) { + volume->device_type = NAUTILUS_DEVICE_CDROM_DRIVE; + volume->is_removable = TRUE; + } else if (eel_str_has_prefix (name, "floppy")) { + volume->device_type = NAUTILUS_DEVICE_FLOPPY_DRIVE; volume->is_removable = TRUE; - } else { - volume->is_removable = FALSE; - } - - g_free (device_name); + } else if (eel_str_has_prefix (volume->device_path, floppy_device_path_prefix)) { + volume->device_type = NAUTILUS_DEVICE_FLOPPY_DRIVE; + volume->is_removable = TRUE; + } else if (eel_str_has_prefix (name, "zip")) { + volume->device_type = NAUTILUS_DEVICE_ZIP_DRIVE; + volume->is_removable = TRUE; + } else if (eel_str_has_prefix (name, "jaz")) { + volume->device_type = NAUTILUS_DEVICE_JAZ_DRIVE; + volume->is_removable = TRUE; + } else if (eel_str_has_prefix (name, "camera")) { + volume->device_type = NAUTILUS_DEVICE_CAMERA; + volume->is_removable = TRUE; + } else if (eel_str_has_prefix (name, "memstick")) { + volume->device_type = NAUTILUS_DEVICE_MEMORY_STICK; + volume->is_removable = TRUE; + } else { + volume->is_removable = FALSE; } + } + + return TRUE; +} + +static GList * +finish_creating_volume_and_prepend (NautilusVolumeMonitor *monitor, + NautilusVolume *volume, + const char *file_system_type_name, + GList *list) +{ + if (finish_creating_volume (monitor, volume, file_system_type_name)) { + list = g_list_prepend (list, volume); } else { - nautilus_volume_monitor_free_volume (volume); + nautilus_volume_free (volume); } - - return volume_list; + return list; } char * nautilus_volume_monitor_get_mount_name_for_display (NautilusVolumeMonitor *monitor, - NautilusVolume *volume) + const NautilusVolume *volume) { const char *name, *found_name; - - if (monitor == NULL || volume == NULL) { - return NULL; - } + + g_return_val_if_fail (monitor == NULL, NULL); + g_return_val_if_fail (volume == NULL, NULL); name = strrchr (volume->mount_path, '/'); if (name != NULL) { @@ -1755,7 +1678,7 @@ nautilus_volume_monitor_get_mount_name_for_display (NautilusVolumeMonitor *monit name = volume->mount_path; } - /* Look for a match in out localized mount name list */ + /* Look for a match in our 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); diff --git a/libnautilus-private/nautilus-volume-monitor.h b/libnautilus-private/nautilus-volume-monitor.h index 3cc261e41..0a81737ae 100644 --- a/libnautilus-private/nautilus-volume-monitor.h +++ b/libnautilus-private/nautilus-volume-monitor.h @@ -34,7 +34,7 @@ typedef struct NautilusVolumeMonitorDetails NautilusVolumeMonitorDetails; #define NAUTILUS_TYPE_VOLUME_MONITOR (nautilus_volume_monitor_get_type()) #define NAUTILUS_VOLUME_MONITOR(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_VOLUME_MONITOR, NautilusVolumeMonitor)) #define NAUTILUS_VOLUME_MONITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_VOLUME_MONITOR, NautilusVolumeMonitorClass)) -#define IS_NAUTILUS_VOLUME_MONITOR(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VOLUME_MONITOR)) +#define NAUTILUS_IS_VOLUME_MONITOR(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VOLUME_MONITOR)) struct NautilusVolumeMonitor { GtkObject parent; @@ -42,7 +42,6 @@ struct NautilusVolumeMonitor { }; typedef struct NautilusVolume NautilusVolume; -typedef struct NautilusFilesystemType NautilusFilesystemType; struct NautilusVolumeMonitorClass { GtkObjectClass parent_class; @@ -59,6 +58,7 @@ struct NautilusVolumeMonitorClass { }; typedef enum { + NAUTILUS_DEVICE_UNKNOWN, NAUTILUS_DEVICE_AUDIO_CD, NAUTILUS_DEVICE_CAMERA, NAUTILUS_DEVICE_CDROM_DRIVE, @@ -66,57 +66,34 @@ typedef enum { NAUTILUS_DEVICE_JAZ_DRIVE, NAUTILUS_DEVICE_MEMORY_STICK, NAUTILUS_DEVICE_NFS, - NAUTILUS_DEVICE_ZIP_DRIVE, - NAUTILUS_DEVICE_UNKNOWN + NAUTILUS_DEVICE_ZIP_DRIVE } NautilusDeviceType; -typedef struct { - char *name; - char *description; - gboolean use_trash; -} NautilusVolumeInfo; - -struct NautilusVolume { - NautilusDeviceType device_type; - - char *device_path; - char *mount_path; - char *volume_name; - char *filesystem; - - char *description; - - gboolean is_removable; - gboolean is_read_only; - gboolean use_trash; - gboolean audio_cd; -}; +typedef gboolean (* NautilusEachVolumeCallback) (const NautilusVolume *, gpointer callback_data); + +GtkType nautilus_volume_monitor_get_type (void); +NautilusVolumeMonitor *nautilus_volume_monitor_get (void); +void nautilus_volume_monitor_mount_unmount_removable (NautilusVolumeMonitor *monitor, + const char *mount_point, + gboolean should_mount); +gboolean nautilus_volume_monitor_volume_is_mounted (NautilusVolumeMonitor *monitor, + const NautilusVolume *mount_point); +void nautilus_volume_monitor_each_mounted_volume (NautilusVolumeMonitor *monitor, + NautilusEachVolumeCallback callback, + gpointer callback_data); +const GList * nautilus_volume_monitor_get_removable_volumes (NautilusVolumeMonitor *monitor); +char * nautilus_volume_monitor_get_mount_name_for_display (NautilusVolumeMonitor *monitor, + const NautilusVolume *volume); +void nautilus_volume_monitor_set_volume_name (NautilusVolumeMonitor *monitor, + const NautilusVolume *volume, + const char *volume_name); + +/* Volume operations. */ +char * nautilus_volume_get_name (const NautilusVolume *volume); +NautilusDeviceType nautilus_volume_get_device_type (const NautilusVolume *volume); +gboolean nautilus_volume_is_removable (const NautilusVolume *volume); +gboolean nautilus_volume_should_integrate_trash (const NautilusVolume *volume); +const char * nautilus_volume_get_mount_path (const NautilusVolume *volume); +char * nautilus_volume_get_target_uri (const NautilusVolume *volume); -typedef gboolean (* NautilusEachVolumeFunction) (const NautilusVolume *, gpointer); - -GtkType nautilus_volume_monitor_get_type (void); -NautilusVolumeMonitor *nautilus_volume_monitor_get (void); -char *nautilus_volume_monitor_get_volume_name (const NautilusVolume *volume); - -void nautilus_volume_monitor_mount_unmount_removable (NautilusVolumeMonitor *monitor, - const char *mount_point, - gboolean should_mount); -gboolean nautilus_volume_monitor_volume_is_mounted (NautilusVolumeMonitor *monitor, - const NautilusVolume *mount_point); -gboolean nautilus_volume_monitor_volume_is_removable (const NautilusVolume *volume); -gboolean nautilus_volume_monitor_is_volume_link (const char *path); - -gboolean nautilus_volume_monitor_should_integrate_trash (const NautilusVolume *volume); -const char *nautilus_volume_monitor_get_volume_mount_uri (const NautilusVolume *volume); -void nautilus_volume_monitor_each_mounted_volume (NautilusVolumeMonitor *monitor, - NautilusEachVolumeFunction function, - gpointer context); -const GList *nautilus_volume_monitor_get_removable_volumes (NautilusVolumeMonitor *monitor); -void nautilus_volume_monitor_free_volume (NautilusVolume *volume); -char *nautilus_volume_monitor_get_target_uri (const NautilusVolume *volume); -void nautilus_volume_monitor_set_volume_name (NautilusVolumeMonitor *monitor, - const NautilusVolume *volume, - const char *volume_name); -char *nautilus_volume_monitor_get_mount_name_for_display (NautilusVolumeMonitor *monitor, - NautilusVolume *volume); #endif /* NAUTILUS_VOLUME_MONITOR_H */ diff --git a/po/ChangeLog b/po/ChangeLog index d9e39ce58..7e043fbc0 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,7 @@ +2001-08-15 Darin Adler + + * POTFILES.in: Add the file system XML file. + 2001-08-06 Yukihiro Nakai * ja.po: Update Japanese translation. diff --git a/po/POTFILES.in b/po/POTFILES.in index e34c615ce..5a2470905 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,44 +1,44 @@ applets/launcher/nautilus-launcher-applet.c applets/preferences-applet/nautilus-preferences-applet.c components/adapter/Nautilus_ComponentAdapterFactory_std.oaf.in -components/hardware/nautilus-hardware-view.c components/hardware/Nautilus_View_hardware.oaf.in +components/hardware/nautilus-hardware-view.c +components/help/Nautilus_View_help.oaf.in components/help/converters/gnome-db2html2/gdb3html.c components/help/converters/gnome-db2html2/sect-elements.c components/help/converters/gnome-db2html2/toc-elements.c components/help/hyperbola-filefmt.c -components/help/hyperbola-nav-tree.c components/help/hyperbola-nav-index.c +components/help/hyperbola-nav-tree.c components/help/hyperbola-types.h -components/help/Nautilus_View_help.oaf.in -components/history/nautilus-history-view.c components/history/Nautilus_View_history.oaf.in -components/image-viewer/nautilus-image-view.c +components/history/nautilus-history-view.c components/image-viewer/Nautilus_View_image.oaf.in -components/loser/content/nautilus-content-loser.c -components/loser/content/nautilus-content-loser-ui.xml +components/image-viewer/nautilus-image-view.c components/loser/content/Nautilus_View_content-loser.oaf.in -components/loser/sidebar/nautilus-sidebar-loser.c -components/loser/sidebar/nautilus-sidebar-loser-ui.xml +components/loser/content/nautilus-content-loser-ui.xml +components/loser/content/nautilus-content-loser.c components/loser/sidebar/Nautilus_View_sidebar-loser.oaf.in +components/loser/sidebar/nautilus-sidebar-loser-ui.xml +components/loser/sidebar/nautilus-sidebar-loser.c +components/mozilla/Nautilus_View_mozilla.oaf.in components/mozilla/mozilla-preferences.cpp -components/mozilla/nautilus-mozilla-encoding-tables.c components/mozilla/nautilus-mozilla-content-view.c +components/mozilla/nautilus-mozilla-encoding-tables.c components/mozilla/nautilus-mozilla-ui.xml -components/mozilla/Nautilus_View_mozilla.oaf.in +components/music/Nautilus_View_music.oaf.in components/music/mpg123.c components/music/nautilus-music-view.c -components/music/Nautilus_View_music.oaf.in -components/news/nautilus-news.c components/news/Nautilus_View_news.oaf.in -components/notes/nautilus-notes.c +components/news/nautilus-news.c components/notes/Nautilus_View_notes.oaf.in -components/sample/nautilus-sample-content-view.c -components/sample/nautilus-sample-content-view-ui.xml +components/notes/nautilus-notes.c components/sample/Nautilus_View_sample.oaf.in -components/text/nautilus-text-view.c -components/text/nautilus-text-view-ui.xml +components/sample/nautilus-sample-content-view-ui.xml +components/sample/nautilus-sample-content-view.c components/text/Nautilus_View_text.oaf.in +components/text/nautilus-text-view-ui.xml +components/text/nautilus-text-view.c components/text/services/google.xml components/text/services/webster.xml components/throbber/Nautilus_Control_throbber.oaf.in @@ -56,17 +56,18 @@ icons/default.xml icons/gnome/gnome.xml icons/sierra/sierra.xml icons/tahoe/tahoe.xml +libnautilus-private/filesystem-attributes.xml libnautilus-private/nautilus-customization-data.c -libnautilus-private/nautilus-druid.c libnautilus-private/nautilus-druid-page-eazel.c +libnautilus-private/nautilus-druid.c libnautilus-private/nautilus-entry.c -libnautilus-private/nautilus-file.c -libnautilus-private/nautilus-file-operations.c libnautilus-private/nautilus-file-operations-progress.c +libnautilus-private/nautilus-file-operations.c +libnautilus-private/nautilus-file.c libnautilus-private/nautilus-font-factory.c libnautilus-private/nautilus-global-preferences.c -libnautilus-private/nautilus-icon-container.c libnautilus-private/nautilus-icon-canvas-item.c +libnautilus-private/nautilus-icon-container.c libnautilus-private/nautilus-icon-dnd.c libnautilus-private/nautilus-icon-factory.c libnautilus-private/nautilus-icon-text-item.c @@ -80,8 +81,8 @@ libnautilus-private/nautilus-trash-file.c libnautilus-private/nautilus-undo-signal-handlers.c libnautilus-private/nautilus-view-identifier.c libnautilus-private/nautilus-volume-monitor.c -libnautilus/nautilus-clipboard.c libnautilus/nautilus-clipboard-ui.xml +libnautilus/nautilus-clipboard.c nautilus.desktop.in src/Nautilus_shell.oaf.in src/file-manager/fm-desktop-icon-view.c diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c index d992c8b4e..17c9b1462 100644 --- a/src/file-manager/fm-desktop-icon-view.c +++ b/src/file-manager/fm-desktop-icon-view.c @@ -350,7 +350,7 @@ volume_in_black_list (FMDesktopIconView *icon_view, g_return_val_if_fail (FM_IS_DESKTOP_ICON_VIEW (icon_view), TRUE); for (p = icon_view->details->mount_black_list; p != NULL; p = p->next) { - if (strcmp ((char *) p->data, volume->mount_path) == 0) { + if (strcmp ((char *) p->data, nautilus_volume_get_mount_path (volume)) == 0) { return TRUE; } } @@ -374,7 +374,7 @@ create_unique_volume_name (const NautilusVolume *volume) */ index = 1; - volume_name = nautilus_volume_monitor_get_volume_name (volume); + volume_name = nautilus_volume_get_name (volume); uri_path = g_strdup_printf ("%s/%s", desktop_directory, volume_name); uri = gnome_vfs_uri_new (uri_path); @@ -398,7 +398,7 @@ create_unique_volume_name (const NautilusVolume *volume) volume_name = new_name; } - original_volume_name = nautilus_volume_monitor_get_volume_name (volume); + original_volume_name = nautilus_volume_get_name (volume); if (strcmp (volume_name, original_volume_name) != 0) { nautilus_volume_monitor_set_volume_name (nautilus_volume_monitor_get (), volume, volume_name); @@ -423,22 +423,18 @@ create_mount_link (FMDesktopIconView *icon_view, } /* FIXME bugzilla.eazel.com 5412: Design a comprehensive desktop mounting strategy */ - if (!nautilus_volume_monitor_volume_is_removable (volume)) { + if (!nautilus_volume_is_removable (volume)) { return; } /* Get icon type */ - switch (volume->device_type) { + icon_name = "i-blockdev"; + switch (nautilus_volume_get_device_type (volume)) { case NAUTILUS_DEVICE_AUDIO_CD: case NAUTILUS_DEVICE_CDROM_DRIVE: icon_name = "i-cdrom"; break; - case NAUTILUS_DEVICE_CAMERA: - icon_name = "i-blockdev"; - break; - - case NAUTILUS_DEVICE_FLOPPY_DRIVE: icon_name = "i-floppy"; break; @@ -459,15 +455,12 @@ create_mount_link (FMDesktopIconView *icon_view, icon_name = "i-zipdisk"; break; + case NAUTILUS_DEVICE_CAMERA: case NAUTILUS_DEVICE_UNKNOWN: - icon_name = "i-blockdev"; - break; - default: - icon_name = "i-blockdev"; - break; + break; } - target_uri = nautilus_volume_monitor_get_target_uri (volume); + target_uri = nautilus_volume_get_target_uri (volume); volume_name = create_unique_volume_name (volume); @@ -860,7 +853,7 @@ volume_unmounted_callback (NautilusVolumeMonitor *monitor, g_assert (volume != NULL); - volume_name = nautilus_volume_monitor_get_volume_name (volume); + volume_name = nautilus_volume_get_name (volume); if (volume_name == NULL) { return; } @@ -1244,7 +1237,7 @@ update_disks_menu (FMDesktopIconView *view) (view->details->ui, command_name, mount_or_unmount_removable_volume, - mount_parameters_new (view, volume->mount_path), + mount_parameters_new (view, nautilus_volume_get_mount_path (volume)), mount_parameters_free_wrapper); g_free (command_name); diff --git a/src/nautilus-application.c b/src/nautilus-application.c index bf96cd432..f89e79ad8 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -830,10 +830,10 @@ volume_mounted_callback (NautilusVolumeMonitor *monitor, NautilusVolume *volume, } /* Open a window to the CD if the user has set that preference. */ - if (volume->device_type == NAUTILUS_DEVICE_CDROM_DRIVE + if (nautilus_volume_get_device_type (volume) == NAUTILUS_DEVICE_CDROM_DRIVE && gnome_config_get_bool ("/magicdev/Options/do_fileman_window=true")) { window = nautilus_application_create_window (application); - uri = gnome_vfs_get_uri_from_local_path (volume->mount_path); + uri = gnome_vfs_get_uri_from_local_path (nautilus_volume_get_mount_path (volume)); nautilus_window_go_to (window, uri); g_free (uri); } @@ -890,7 +890,7 @@ volume_unmounted_callback (NautilusVolumeMonitor *monitor, NautilusVolume *volum if (window != NULL && window_can_be_closed (window)) { uri = nautilus_window_get_location (window); path = gnome_vfs_get_local_path_from_uri (uri); - if (eel_str_has_prefix (path, volume->mount_path)) { + if (eel_str_has_prefix (path, nautilus_volume_get_mount_path (volume))) { close_list = g_list_prepend (close_list, window); } g_free (path); diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c index 9c72c0e36..9cfb28a13 100644 --- a/src/nautilus-bookmark-list.c +++ b/src/nautilus-bookmark-list.c @@ -338,13 +338,11 @@ nautilus_bookmark_list_get_file_path (NautilusBookmarkList *bookmarks) /* currently hardwired */ static char *file_path = NULL; + char *user_directory; if (file_path == NULL) { - char *user_directory; user_directory = nautilus_get_user_directory (); - file_path = nautilus_make_path (user_directory, "bookmarks.xml"); - g_free (user_directory); } diff --git a/src/nautilus-first-time-druid.c b/src/nautilus-first-time-druid.c index c2d1cb52c..43083068c 100644 --- a/src/nautilus-first-time-druid.c +++ b/src/nautilus-first-time-druid.c @@ -169,25 +169,20 @@ druid_set_first_time_file_flag (void) { FILE *stream; char *user_directory, *druid_flag_file_name; + const char * const blurb = + _("Existence of this file indicates that the Nautilus configuration druid\n" + "has been presented.\n\n" + "You can manually erase this file to present the druid again.\n"); user_directory = nautilus_get_user_directory (); - druid_flag_file_name = g_strdup_printf ("%s/%s", - user_directory, - "first-time-flag"); + druid_flag_file_name = nautilus_make_path (user_directory, "first-time-flag"); g_free (user_directory); - stream = fopen (druid_flag_file_name, "w"); - if (stream) { - const char *blurb = - _("Existence of this file indicates that the Nautilus configuration druid\n" - "has been presented.\n\n" - "You can manually erase this file to present the druid again.\n\n"); - - fwrite (blurb, sizeof (char), strlen (blurb), stream); - fclose (stream); + if (stream != NULL) { + fwrite (blurb, sizeof (char), strlen (blurb), stream); + fclose (stream); } - g_free (druid_flag_file_name); } diff --git a/src/nautilus-property-browser.c b/src/nautilus-property-browser.c index fe538407e..f52dcbc25 100644 --- a/src/nautilus-property-browser.c +++ b/src/nautilus-property-browser.c @@ -747,44 +747,13 @@ category_clicked_callback (GtkWidget *widget, char *category_name) property_browser->details->selected_button = widget; } -/* fetch the path of the xml file. First, try to find it in the home directory, but it - we can't find it there, try the shared directory */ - -static char * -get_xml_path (NautilusPropertyBrowser *property_browser) -{ - char *xml_path; - char *user_directory; - - user_directory = nautilus_get_user_directory (); - - /* first try the user's home directory */ - xml_path = nautilus_make_path (user_directory, - property_browser->details->path); - g_free (user_directory); - if (g_file_exists (xml_path)) { - return xml_path; - } - g_free (xml_path); - - /* next try the shared directory */ - xml_path = nautilus_make_path (NAUTILUS_DATADIR, - property_browser->details->path); - if (g_file_exists (xml_path)) { - return xml_path; - } - g_free (xml_path); - - return NULL; -} - static xmlDocPtr read_browser_xml (NautilusPropertyBrowser *property_browser) { char *path; xmlDocPtr document; - path = get_xml_path (property_browser); + path = nautilus_get_data_file_path (property_browser->details->path); if (path == NULL) { return NULL; } -- cgit v1.2.1