diff options
author | Alexander Larsson <alexl@redhat.com> | 2008-01-18 12:21:44 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2008-01-18 12:21:44 +0000 |
commit | 15f536095a726694e28b0202c1b528bad80e09b4 (patch) | |
tree | cca2e672127bd9127805fa6354386322b7d52881 /libnautilus-private | |
parent | d26283080863425d7db14723fd16f29dfdfdc47b (diff) | |
download | nautilus-15f536095a726694e28b0202c1b528bad80e09b4.tar.gz |
Just use get_activation_location instead of all the unnecessary special
2008-01-18 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-program-choosing.c:
Just use get_activation_location instead of all
the unnecessary special casing.
* libnautilus-private/nautilus-autorun.[ch]:
* src/file-manager/fm-directory-view.c:
* src/nautilus-window-manage-views.c:
Use nautilus_file_get_mount() to do the
x-content type detection.
svn path=/trunk/; revision=13620
Diffstat (limited to 'libnautilus-private')
-rw-r--r-- | libnautilus-private/nautilus-autorun.c | 94 | ||||
-rw-r--r-- | libnautilus-private/nautilus-autorun.h | 6 | ||||
-rw-r--r-- | libnautilus-private/nautilus-program-choosing.c | 33 |
3 files changed, 28 insertions, 105 deletions
diff --git a/libnautilus-private/nautilus-autorun.c b/libnautilus-private/nautilus-autorun.c index eaf0bede3..1c515fc2e 100644 --- a/libnautilus-private/nautilus-autorun.c +++ b/libnautilus-private/nautilus-autorun.c @@ -593,10 +593,14 @@ _g_mount_guess_content_type (GMount *mount, GVolume *volume; char *disc_type = NULL; - /* TODO: We can't really sensibly cache anything right now.. - * But when moved to gio this can be done. + /* TODO: This cache handling isn't really threadsafe. + * I think this is ok for nautilus use, but not for general gio use */ - + ret = g_object_get_data (G_OBJECT (mount), "content-type-cache"); + if (ret != NULL) { + return g_strdupv (ret); + } + types = g_ptr_array_new (); root = g_mount_get_root (mount); @@ -719,17 +723,19 @@ _g_mount_guess_content_type (GMount *mount, no_sniff: - if (types->len == 0) { - ret = NULL; - g_ptr_array_free (types, TRUE); - } else { - g_ptr_array_add (types, NULL); - ret = (char **) g_ptr_array_free (types, FALSE); - } + g_ptr_array_add (types, NULL); + ret = (char **) g_ptr_array_free (types, FALSE); - if (volume != NULL) + if (volume != NULL) { g_object_unref (volume); + } g_object_unref (root); + + g_object_set_data_full (G_OBJECT (mount), + "content-type-cache", + g_strdupv (ret), + (GDestroyNotify)g_strfreev); + return ret; } @@ -1232,67 +1238,17 @@ nautilus_autorun (GMount *mount, NautilusAutorunOpenWindow open_window_func, gpo } char ** -nautilus_autorun_get_x_content_types_for_file (NautilusFile *nautilus_file, - GMount **out_mount, - gboolean force_rescan, - gboolean include_child_dirs) +nautilus_autorun_get_x_content_types_for_mount (GMount *mount, + gboolean force_rescan) { - GMount *mount; - char **x_content_types; - - x_content_types = NULL; - - g_return_val_if_fail (nautilus_file != NULL, NULL); - - mount = NULL; - if (g_type_is_a (G_OBJECT_TYPE (nautilus_file), NAUTILUS_TYPE_DESKTOP_ICON_FILE)) { - NautilusDesktopIconFile *desktop_icon_file = NAUTILUS_DESKTOP_ICON_FILE (nautilus_file); - NautilusDesktopLink *desktop_link; - - desktop_link = nautilus_desktop_icon_file_get_link (desktop_icon_file); - if (desktop_link != NULL) { - if (nautilus_desktop_link_get_link_type (desktop_link) == NAUTILUS_DESKTOP_LINK_MOUNT) { - mount = nautilus_desktop_link_get_mount (desktop_link); - } - g_object_unref (desktop_link); - } - } else { - GFile *file; - file = nautilus_file_get_location (nautilus_file); - if (file != NULL) { - mount = g_file_find_enclosing_mount (file, NULL, NULL); - if (mount != NULL) { - GFile *mount_root; - mount_root = g_mount_get_root (mount); - if (!include_child_dirs) { - if (!g_file_equal (mount_root, file)) { - g_object_unref (mount); - mount = NULL; - } - } - g_object_unref (mount_root); - } - g_object_unref (file); - } + if (mount == NULL) { + return NULL; } - - /* TODO: handle files in computer:///. - * - * Also need to handle those in libnautilus-private/nautilus-program-choosing.c:nautilus_launch_application() + /* since we always guess the content type at mount type, we're guaranteed + * to get the cached results * - * These NautilusFile instances are of class NautilusVFSFile.. URI is 'computer:///CompactFlash%20Drive.drive' + * TODO: Really? what if we didn't mount the mount ourself? */ - - if (mount != NULL) { - /* since we always guess the content type at mount type, we're guaranteed - * to get the cached results - */ - x_content_types = _g_mount_guess_content_type (mount, force_rescan, NULL); - if (out_mount != NULL) - *out_mount = g_object_ref (mount); - g_object_unref (mount); - } - - return x_content_types; + return _g_mount_guess_content_type (mount, force_rescan, NULL); } diff --git a/libnautilus-private/nautilus-autorun.h b/libnautilus-private/nautilus-autorun.h index 131a49851..baea78435 100644 --- a/libnautilus-private/nautilus-autorun.h +++ b/libnautilus-private/nautilus-autorun.h @@ -79,10 +79,8 @@ void nautilus_autorun_get_preferences (const char *x_content_type, gboolean *pre void nautilus_autorun (GMount *mount, NautilusAutorunOpenWindow open_window_func, gpointer user_data); -char **nautilus_autorun_get_x_content_types_for_file (NautilusFile *file, - GMount **out_mount, - gboolean force_rescan, - gboolean include_child_dirs); +char **nautilus_autorun_get_x_content_types_for_mount (GMount *mount, + gboolean force_rescan); void nautilus_autorun_launch_for_mount (GMount *mount, GAppInfo *app_info); diff --git a/libnautilus-private/nautilus-program-choosing.c b/libnautilus-private/nautilus-program-choosing.c index 5f675af8f..9b07413f0 100644 --- a/libnautilus-private/nautilus-program-choosing.c +++ b/libnautilus-private/nautilus-program-choosing.c @@ -245,7 +245,6 @@ nautilus_launch_application (GAppInfo *application, GList *files, GtkWindow *parent_window) { - char *uri; char *uri_scheme; GList *locations, *l; GFile *location; @@ -261,37 +260,7 @@ nautilus_launch_application (GAppInfo *application, for (l = files; l != NULL; l = l->next) { file = NAUTILUS_FILE (l->data); - location = NULL; - - if (g_type_is_a (G_OBJECT_TYPE (file), NAUTILUS_TYPE_DESKTOP_ICON_FILE)) { - NautilusDesktopIconFile *desktop_icon_file = NAUTILUS_DESKTOP_ICON_FILE (file); - NautilusDesktopLink *desktop_link; - - desktop_link = nautilus_desktop_icon_file_get_link (desktop_icon_file); - if (desktop_link != NULL) { - if (nautilus_desktop_link_get_link_type (desktop_link) == NAUTILUS_DESKTOP_LINK_MOUNT) { - GMount *mount; - mount = nautilus_desktop_link_get_mount (desktop_link); - if (mount != NULL) { - location = g_mount_get_root (mount); - g_object_unref (mount); - } - } - g_object_unref (desktop_link); - } - } - - if (location == NULL) { - if (nautilus_file_is_nautilus_link (file)) { - uri = nautilus_file_get_activation_uri (file); - location = g_file_new_for_uri (uri); - g_free (uri); - } - } - - if (location == NULL) { - location = nautilus_file_get_location (file); - } + location = nautilus_file_get_activation_location (file); locations = g_list_prepend (locations, location); } |