nautilus r13620 - in trunk: . libnautilus-private src src/file-manager
- From: alexl svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus r13620 - in trunk: . libnautilus-private src src/file-manager
- Date: Fri, 18 Jan 2008 12:21:44 +0000 (GMT)
Author: alexl
Date: Fri Jan 18 12:21:44 2008
New Revision: 13620
URL: http://svn.gnome.org/viewvc/nautilus?rev=13620&view=rev
Log:
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.
Modified:
trunk/ChangeLog
trunk/libnautilus-private/nautilus-autorun.c
trunk/libnautilus-private/nautilus-autorun.h
trunk/libnautilus-private/nautilus-program-choosing.c
trunk/src/file-manager/fm-directory-view.c
trunk/src/nautilus-window-manage-views.c
Modified: trunk/libnautilus-private/nautilus-autorun.c
==============================================================================
--- trunk/libnautilus-private/nautilus-autorun.c (original)
+++ trunk/libnautilus-private/nautilus-autorun.c Fri Jan 18 12:21:44 2008
@@ -593,10 +593,14 @@
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 @@
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 @@
}
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);
}
Modified: trunk/libnautilus-private/nautilus-autorun.h
==============================================================================
--- trunk/libnautilus-private/nautilus-autorun.h (original)
+++ trunk/libnautilus-private/nautilus-autorun.h Fri Jan 18 12:21:44 2008
@@ -79,10 +79,8 @@
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);
Modified: trunk/libnautilus-private/nautilus-program-choosing.c
==============================================================================
--- trunk/libnautilus-private/nautilus-program-choosing.c (original)
+++ trunk/libnautilus-private/nautilus-program-choosing.c Fri Jan 18 12:21:44 2008
@@ -245,7 +245,6 @@
GList *files,
GtkWindow *parent_window)
{
- char *uri;
char *uri_scheme;
GList *locations, *l;
GFile *location;
@@ -261,37 +260,7 @@
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);
}
Modified: trunk/src/file-manager/fm-directory-view.c
==============================================================================
--- trunk/src/file-manager/fm-directory-view.c (original)
+++ trunk/src/file-manager/fm-directory-view.c Fri Jan 18 12:21:44 2008
@@ -3091,6 +3091,7 @@
NAUTILUS_FILE_ATTRIBUTE_INFO |
NAUTILUS_FILE_ATTRIBUTE_LINK_INFO |
NAUTILUS_FILE_ATTRIBUTE_METADATA |
+ NAUTILUS_FILE_ATTRIBUTE_MOUNT |
NAUTILUS_FILE_ATTRIBUTE_EXTENSION_INFO;
nautilus_directory_file_monitor_add (directory,
@@ -4162,14 +4163,21 @@
static void
add_x_content_apps (NautilusFile *file, GList **applications)
{
+ GMount *mount;
char **x_content_types;
+ unsigned int n;
g_return_if_fail (applications != NULL);
- x_content_types = nautilus_autorun_get_x_content_types_for_file (file, NULL, FALSE, FALSE);
+ mount = nautilus_file_get_mount (file);
+
+ if (mount == NULL) {
+ return;
+ }
+
+ x_content_types = nautilus_autorun_get_x_content_types_for_mount (mount, FALSE);
if (x_content_types != NULL) {
- unsigned int n;
for (n = 0; x_content_types[n] != NULL; n++) {
char *x_content_type = x_content_types[n];
GList *app_info_for_x_content_type;
@@ -4179,6 +4187,8 @@
}
g_strfreev (x_content_types);
}
+
+ g_object_unref (mount);
}
static void
@@ -7570,6 +7580,7 @@
NAUTILUS_FILE_ATTRIBUTE_INFO |
NAUTILUS_FILE_ATTRIBUTE_LINK_INFO |
NAUTILUS_FILE_ATTRIBUTE_METADATA |
+ NAUTILUS_FILE_ATTRIBUTE_MOUNT |
NAUTILUS_FILE_ATTRIBUTE_EXTENSION_INFO;
nautilus_directory_file_monitor_add (view->details->model,
Modified: trunk/src/nautilus-window-manage-views.c
==============================================================================
--- trunk/src/nautilus-window-manage-views.c (original)
+++ trunk/src/nautilus-window-manage-views.c Fri Jan 18 12:21:44 2008
@@ -799,6 +799,7 @@
nautilus_file_call_when_ready (window->details->determine_view_file,
NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_MOUNT |
NAUTILUS_FILE_ATTRIBUTE_METADATA,
got_file_info_for_view_selection_callback,
window);
@@ -1303,8 +1304,9 @@
GAppInfo *default_app;
/* skip blank media; the burn:/// location will provide it's own cluebar */
- if (g_str_has_prefix (x_content_types[n], "x-content/blank-"))
+ if (g_str_has_prefix (x_content_types[n], "x-content/blank-")) {
continue;
+ }
/* only show the cluebar if a default app is available */
default_app = g_app_info_get_default_for_type (x_content_types[n], FALSE);
@@ -1400,9 +1402,12 @@
nautilus_window_show_trash_bar (window);
}
- x_content_types = nautilus_autorun_get_x_content_types_for_file (file, &mount, FALSE, TRUE);
- if (x_content_types != NULL) {
- nautilus_window_show_x_content_bar (window, mount, x_content_types);
+ mount = nautilus_file_get_mount (file);
+ if (mount != NULL) {
+ x_content_types = nautilus_autorun_get_x_content_types_for_mount (mount, FALSE);
+ if (x_content_types != NULL && x_content_types[0] != NULL) {
+ nautilus_window_show_x_content_bar (window, mount, x_content_types);
+ }
g_strfreev (x_content_types);
g_object_unref (mount);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]