diff options
author | Maciej Stachowiak <mstachow@src.gnome.org> | 2000-10-17 23:06:47 +0000 |
---|---|---|
committer | Maciej Stachowiak <mstachow@src.gnome.org> | 2000-10-17 23:06:47 +0000 |
commit | 3a1df85362acedda3f5f93d7fdb9a0256be5d125 (patch) | |
tree | ac692e68c9bba819a02ebea123cd82c3cfc2b555 | |
parent | c84664c3c35c10f9e151a991683abc8cc0832e7b (diff) | |
download | nautilus-3a1df85362acedda3f5f93d7fdb9a0256be5d125.tar.gz |
Fix assorted bugs which made NautilusFile think the list was never
* libnautilus-extensions/nautilus-directory-async.c:
(cancel_mime_list, set_up_request_by_file_attributes,
lacks_mime_list, nautilus_directory_invalidate_counts,
mime_list_callback, mime_list_start): Fix assorted bugs which made
NautilusFile think the list was never complete.
* libnautilus-extensions/nautilus-wait-until-ready.h: Include
<libnautilus-extensions/nautilus-directory.h> and
<libnautilus-extensions/nautilus-file.h>.
* libnautilus-extensions/nautilus-file-attributes.h: Rename
MIME_LIST attroibute to DIRECTORY_ITEM_MIME_TYPES.
* libnautilus-extensions/nautilus-file.h,
libnautilus-extensions/nautilus-file.c:
(nautilus_file_get_directory_item_mime_types): Renamed from
nautilus_file_get_mime_list.
* libnautilus-extensions/nautilus-mime-actions.h,
libnautilus-extensions/nautilus-mime-actions.c
(nautilus_file_wait_for_metadata,
nautilus_file_wait_for_mime_action_attributes,
nautilus_mime_get_default_action_type_for_uri,
nautilus_mime_get_default_action_for_uri,
nautilus_mime_get_default_application_for_uri_internal,
nautilus_mime_get_default_application_for_uri,
nautilus_mime_is_default_application_for_uri_user_chosen,
nautilus_mime_get_default_component_for_uri_internal,
nautilus_mime_get_default_component_for_uri,
nautilus_mime_is_default_component_for_uri_user_chosen,
nautilus_mime_get_short_list_applications_for_uri,
nautilus_mime_get_short_list_components_for_uri,
nautilus_mime_get_short_list_methods_for_uri,
nautilus_mime_get_all_applications_for_uri,
nautilus_mime_has_any_applications_for_uri,
nautilus_mime_get_all_components_for_uri,
nautilus_mime_has_any_components_for_uri,
nautilus_mime_set_default_action_type_for_uri,
nautilus_mime_set_default_application_for_uri,
nautilus_mime_set_default_component_for_uri,
nautilus_mime_set_short_list_applications_for_uri,
nautilus_mime_set_short_list_components_for_uri,
nautilus_mime_add_application_to_short_list_for_uri,
nautilus_mime_remove_application_from_short_list_for_uri,
nautilus_mime_add_component_to_short_list_for_uri,
nautilus_mime_remove_component_from_short_list_for_uri,
nautilus_mime_extend_all_applications_for_uri,
nautilus_mime_remove_from_all_applications_for_uri,
mime_type_list_to_hash_table, nautilus_do_component_query): Use
all the new NautilusFile APIs and stop using NautilusDirectory. No
longer take NautilusDirectory as a parameter in addition to
NautilusFile.
* libnautilus-extensions/nautilus-program-chooser.c:
(repopulate_program_list, is_application_default_for_uri,
is_component_default_for_uri, is_component_in_short_list_for_uri,
is_application_in_short_list_for_uri,
program_file_pair_is_default_for_file, add_to_short_list_for_file,
remove_from_short_list_for_file, remove_default_for_item,
set_default_for_item): Stop passing NautilusDirectory to
nautilus-mime-actions functions.
* libnautilus-extensions/nautilus-program-choosing.c:
(any_programs_available_for_file): Likewise.
* src/file-manager/fm-directory-view.c (switch_location_and_view,
files_added_callback, files_changed_callback,
create_open_with_gtk_menu, reset_bonobo_open_with_menu,
activate_callback): Likewise.
* src/nautilus-applicable-views.c (got_file_info_callback): Likewise.
* src/nautilus-sidebar.c (nautilus_sidebar_update_buttons): Likewise.
* src/nautilus-window-manage-views.c
(nautilus_window_set_content_view): Likewise.
* src/nautilus-window.c (nautilus_window_load_content_view_menu):
Likewise.
* test/test-nautilus-mime-actions-set.c (main): Likewise.
* test/test-nautilus-mime-actions.c (main): Likewise.
30 files changed, 511 insertions, 714 deletions
@@ -1,3 +1,81 @@ +2000-10-17 Maciej Stachowiak <mjs@eazel.com> + + * libnautilus-extensions/nautilus-directory-async.c: + (cancel_mime_list, set_up_request_by_file_attributes, + lacks_mime_list, nautilus_directory_invalidate_counts, + mime_list_callback, mime_list_start): Fix assorted bugs which made + NautilusFile think the list was never complete. + + * libnautilus-extensions/nautilus-wait-until-ready.h: Include + <libnautilus-extensions/nautilus-directory.h> and + <libnautilus-extensions/nautilus-file.h>. + + * libnautilus-extensions/nautilus-file-attributes.h: Rename + MIME_LIST attroibute to DIRECTORY_ITEM_MIME_TYPES. + + * libnautilus-extensions/nautilus-file.h, + libnautilus-extensions/nautilus-file.c: + (nautilus_file_get_directory_item_mime_types): Renamed from + nautilus_file_get_mime_list. + + * libnautilus-extensions/nautilus-mime-actions.h, + libnautilus-extensions/nautilus-mime-actions.c + (nautilus_file_wait_for_metadata, + nautilus_file_wait_for_mime_action_attributes, + nautilus_mime_get_default_action_type_for_uri, + nautilus_mime_get_default_action_for_uri, + nautilus_mime_get_default_application_for_uri_internal, + nautilus_mime_get_default_application_for_uri, + nautilus_mime_is_default_application_for_uri_user_chosen, + nautilus_mime_get_default_component_for_uri_internal, + nautilus_mime_get_default_component_for_uri, + nautilus_mime_is_default_component_for_uri_user_chosen, + nautilus_mime_get_short_list_applications_for_uri, + nautilus_mime_get_short_list_components_for_uri, + nautilus_mime_get_short_list_methods_for_uri, + nautilus_mime_get_all_applications_for_uri, + nautilus_mime_has_any_applications_for_uri, + nautilus_mime_get_all_components_for_uri, + nautilus_mime_has_any_components_for_uri, + nautilus_mime_set_default_action_type_for_uri, + nautilus_mime_set_default_application_for_uri, + nautilus_mime_set_default_component_for_uri, + nautilus_mime_set_short_list_applications_for_uri, + nautilus_mime_set_short_list_components_for_uri, + nautilus_mime_add_application_to_short_list_for_uri, + nautilus_mime_remove_application_from_short_list_for_uri, + nautilus_mime_add_component_to_short_list_for_uri, + nautilus_mime_remove_component_from_short_list_for_uri, + nautilus_mime_extend_all_applications_for_uri, + nautilus_mime_remove_from_all_applications_for_uri, + mime_type_list_to_hash_table, nautilus_do_component_query): Use + all the new NautilusFile APIs and stop using NautilusDirectory. No + longer take NautilusDirectory as a parameter in addition to + NautilusFile. + + * libnautilus-extensions/nautilus-program-chooser.c: + (repopulate_program_list, is_application_default_for_uri, + is_component_default_for_uri, is_component_in_short_list_for_uri, + is_application_in_short_list_for_uri, + program_file_pair_is_default_for_file, add_to_short_list_for_file, + remove_from_short_list_for_file, remove_default_for_item, + set_default_for_item): Stop passing NautilusDirectory to + nautilus-mime-actions functions. + * libnautilus-extensions/nautilus-program-choosing.c: + (any_programs_available_for_file): Likewise. + * src/file-manager/fm-directory-view.c (switch_location_and_view, + files_added_callback, files_changed_callback, + create_open_with_gtk_menu, reset_bonobo_open_with_menu, + activate_callback): Likewise. + * src/nautilus-applicable-views.c (got_file_info_callback): Likewise. + * src/nautilus-sidebar.c (nautilus_sidebar_update_buttons): Likewise. + * src/nautilus-window-manage-views.c + (nautilus_window_set_content_view): Likewise. + * src/nautilus-window.c (nautilus_window_load_content_view_menu): + Likewise. + * test/test-nautilus-mime-actions-set.c (main): Likewise. + * test/test-nautilus-mime-actions.c (main): Likewise. + 2000-10-17 Robey Pointer <robey@eazel.com> * components/services/install/lib/eazel-install-logic.c: diff --git a/libnautilus-extensions/nautilus-directory-async.c b/libnautilus-extensions/nautilus-directory-async.c index faf42b1f1..951afa47d 100644 --- a/libnautilus-extensions/nautilus-directory-async.c +++ b/libnautilus-extensions/nautilus-directory-async.c @@ -243,8 +243,6 @@ mime_list_cancel (NautilusDirectory *directory) gnome_vfs_async_cancel (directory->details->mime_list_in_progress); - directory->details->mime_list_file->details->mime_list_status = NAUTILUS_REQUEST_NOT_STARTED; - directory->details->mime_list_file = NULL; directory->details->mime_list_in_progress = NULL; g_free (directory->details->mime_list_uri); @@ -877,7 +875,7 @@ set_up_request_by_file_attributes (Request *request, nautilus_str_compare) != NULL; request->mime_list = g_list_find_custom (file_attributes, - NAUTILUS_FILE_ATTRIBUTE_MIME_LIST, + NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES, nautilus_str_compare) != NULL; request->top_left_text = g_list_find_custom (file_attributes, @@ -1662,7 +1660,7 @@ static gboolean lacks_mime_list (NautilusFile *file) { return nautilus_file_is_directory (file) - && file->details->mime_list_status != NAUTILUS_REQUEST_DONE; + && file->details->got_mime_list == FALSE; } static gboolean @@ -1928,7 +1926,6 @@ nautilus_directory_invalidate_counts (NautilusDirectory *directory) file->details->deep_counts_status = NAUTILUS_REQUEST_NOT_STARTED; file->details->got_mime_list = FALSE; file->details->mime_list_failed = FALSE; - file->details->mime_list_status = NAUTILUS_REQUEST_NOT_STARTED; if (parent_directory != directory) { nautilus_directory_async_state_changed (parent_directory); @@ -2357,7 +2354,6 @@ mime_list_callback (GnomeVFSAsyncHandle *handle, NautilusDirectory *directory; NautilusFile *file; GnomeVFSDirectoryListPosition last_handled, p; - gboolean done; directory = NAUTILUS_DIRECTORY (callback_data); g_assert (directory->details->mime_list_in_progress == handle); @@ -2378,23 +2374,33 @@ mime_list_callback (GnomeVFSAsyncHandle *handle, } directory->details->mime_list_last_handled = last_handled; - done = FALSE; - if (result != GNOME_VFS_OK) { - directory->details->mime_list_in_progress = NULL; - g_free (directory->details->mime_list_uri); - directory->details->mime_list_uri = NULL; + if (result == GNOME_VFS_OK) { + return; + } - file->details->mime_list_status = NAUTILUS_REQUEST_DONE; - directory->details->mime_list_file = NULL; - done = TRUE; + /* Record either a failure or success. */ + if (result != GNOME_VFS_ERROR_EOF) { + file->details->directory_count_failed = TRUE; + nautilus_g_list_free_deep (file->details->mime_list); + file->details->mime_list = NULL; + } else { + file->details->got_mime_list = TRUE; } + g_free (directory->details->mime_list_uri); + directory->details->mime_list_uri = NULL; + directory->details->mime_list_in_progress = NULL; + directory->details->mime_list_file = NULL; + + /* Send file-changed even if getting the item type list + * failed, so interested parties can distinguish between + * unknowable and not-yet-known cases. */ + nautilus_file_changed (file); - if (done) { - async_job_end (); - nautilus_directory_async_state_changed (directory); - } + /* Start up the next one. */ + async_job_end (); + nautilus_directory_async_state_changed (directory); } static void @@ -2461,6 +2467,7 @@ mime_list_start (NautilusDirectory *directory) /* Start counting. */ file->details->mime_list_status = NAUTILUS_REQUEST_IN_PROGRESS; + /* FIXME: clear out mime_list_whatever */ directory->details->mime_list_file = file; uri = nautilus_file_get_uri (file); diff --git a/libnautilus-extensions/nautilus-file-attributes.h b/libnautilus-extensions/nautilus-file-attributes.h index 5c52960be..a165e0884 100644 --- a/libnautilus-extensions/nautilus-file-attributes.h +++ b/libnautilus-extensions/nautilus-file-attributes.h @@ -29,17 +29,17 @@ * in changes to the attributes. */ -#define NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI "activation URI" -#define NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON "custom icon" -#define NAUTILUS_FILE_ATTRIBUTE_DEEP_COUNTS "deep counts" -#define NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT "directory item count" -#define NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE "MIME type" -#define NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE "MIME type" -#define NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT "top left text" -#define NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY "is directory" -#define NAUTILUS_FILE_ATTRIBUTE_FILE_TYPE "file type" -#define NAUTILUS_FILE_ATTRIBUTE_MIME_LIST "MIME list" -#define NAUTILUS_FILE_ATTRIBUTE_METADATA "metadata" +#define NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI "activation URI" +#define NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON "custom icon" +#define NAUTILUS_FILE_ATTRIBUTE_DEEP_COUNTS "deep counts" +#define NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT "directory item count" +#define NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE "MIME type" +#define NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE "MIME type" +#define NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT "top left text" +#define NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY "is directory" +#define NAUTILUS_FILE_ATTRIBUTE_FILE_TYPE "file type" +#define NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES "directory item MIME types" +#define NAUTILUS_FILE_ATTRIBUTE_METADATA "metadata" #endif /* NAUTILUS_FILE_ATTRIBUTES_H */ diff --git a/libnautilus-extensions/nautilus-file.c b/libnautilus-extensions/nautilus-file.c index caf5b34d4..28435c20d 100644 --- a/libnautilus-extensions/nautilus-file.c +++ b/libnautilus-extensions/nautilus-file.c @@ -2051,7 +2051,7 @@ nautilus_file_recompute_deep_counts (NautilusFile *file) } /** - * nautilus_file_get_mime_list + * nautilus_file_get_directory_item_mime_types * * Get the list of mime-types present in a directory. * @file: NautilusFile representing a directory. It is an error to @@ -2062,14 +2062,14 @@ nautilus_file_recompute_deep_counts (NautilusFile *file) * **/ gboolean -nautilus_file_get_mime_list (NautilusFile *file, - GList **mime_list) +nautilus_file_get_directory_item_mime_types (NautilusFile *file, + GList **mime_list) { g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE); - g_return_val_if_fail (nautilus_file_is_directory (file), FALSE); g_return_val_if_fail (mime_list != NULL, FALSE); - if (! file->details->got_mime_list) { + if (! nautilus_file_is_directory (file) || ! file->details->got_mime_list) { + *mime_list = NULL; return FALSE; } diff --git a/libnautilus-extensions/nautilus-file.h b/libnautilus-extensions/nautilus-file.h index 6825d72f2..a2d625d00 100644 --- a/libnautilus-extensions/nautilus-file.h +++ b/libnautilus-extensions/nautilus-file.h @@ -146,8 +146,8 @@ void nautilus_file_set_keywords (NautilusFile GList *keywords); GList * nautilus_file_get_emblem_names (NautilusFile *file); char * nautilus_file_get_top_left_text (NautilusFile *file); -gboolean nautilus_file_get_mime_list (NautilusFile *file, - GList **mime_list); +gboolean nautilus_file_get_directory_item_mime_types (NautilusFile *file, + GList **mime_list); /* Permissions. */ diff --git a/libnautilus-extensions/nautilus-mime-actions.c b/libnautilus-extensions/nautilus-mime-actions.c index 2533a9ac1..125647a2a 100644 --- a/libnautilus-extensions/nautilus-mime-actions.c +++ b/libnautilus-extensions/nautilus-mime-actions.c @@ -30,7 +30,6 @@ #include <libgnomevfs/gnome-vfs-mime-info.h> #include <libgnomevfs/gnome-vfs-application-registry.h> #include "nautilus-lib-self-check-functions.h" -#include "nautilus-directory.h" #include "nautilus-file.h" #include "nautilus-file-attributes.h" #include "nautilus-glib-extensions.h" @@ -62,7 +61,7 @@ static char *make_oaf_query_with_known_mime_type (const char static char *make_oaf_query_with_uri_scheme_only (const char *uri_scheme, GList *explicit_iids, const char *extra_requirements); -static GHashTable *file_list_to_mime_type_hash_table (GList *files); +static GHashTable *mime_type_list_to_hash_table (GList *files); static void free_key (gpointer key, gpointer value, gpointer user_data); @@ -79,7 +78,6 @@ static GList *nautilus_do_component_query (const char CORBA_Environment *ev); static GList *str_list_difference (GList *a, GList *b); -static char *get_mime_type_from_file (NautilusFile *file); static int strv_length (char **a); static char **strv_concat (char **a, char **b); @@ -103,20 +101,33 @@ nautilus_file_wait_for_metadata (NautilusFile *file) { GList *attributes; - /* When nautilus_directory_wait_until_ready is called this way, it - * currently returns NULL. So theoretically we don't have to free - * the result. But there's no guarantee that this behavior won't - * change, so it's safer to free the result. - */ + attributes = NULL; + attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_METADATA); + attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE); + nautilus_file_wait_until_ready (file, attributes); + g_list_free (attributes); +} + + - attributes = g_list_append (NULL, NAUTILUS_FILE_ATTRIBUTE_METADATA); +static void +nautilus_file_wait_for_mime_action_attributes (NautilusFile *file) +{ + GList *attributes; + + attributes = NULL; + attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_METADATA); + attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE); + attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES); nautilus_file_wait_until_ready (file, attributes); g_list_free (attributes); } + + + GnomeVFSMimeActionType -nautilus_mime_get_default_action_type_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_default_action_type_for_uri (NautilusFile *file) { char *mime_type; char *action_type_string; @@ -128,7 +139,7 @@ nautilus_mime_get_default_action_type_for_uri (NautilusDirectory *directory, (file, NAUTILUS_METADATA_KEY_DEFAULT_ACTION_TYPE, NULL); if (action_type_string == NULL) { - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); action_type = gnome_vfs_mime_get_default_action_type (mime_type); g_free (mime_type); return action_type; @@ -144,19 +155,18 @@ nautilus_mime_get_default_action_type_for_uri (NautilusDirectory *directory, } GnomeVFSMimeAction * -nautilus_mime_get_default_action_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_default_action_for_uri (NautilusFile *file) { GnomeVFSMimeAction *action; action = g_new0 (GnomeVFSMimeAction, 1); - action->action_type = nautilus_mime_get_default_action_type_for_uri (directory, file); + action->action_type = nautilus_mime_get_default_action_type_for_uri (file); switch (action->action_type) { case GNOME_VFS_MIME_ACTION_TYPE_APPLICATION: action->action.application = - nautilus_mime_get_default_application_for_uri (directory, file); + nautilus_mime_get_default_application_for_uri (file); if (action->action.application == NULL) { g_free (action); action = NULL; @@ -164,7 +174,7 @@ nautilus_mime_get_default_action_for_uri (NautilusDirectory *directory, break; case GNOME_VFS_MIME_ACTION_TYPE_COMPONENT: action->action.component = - nautilus_mime_get_default_component_for_uri (directory, file); + nautilus_mime_get_default_component_for_uri (file); if (action->action.component == NULL) { g_free (action); action = NULL; @@ -182,8 +192,7 @@ nautilus_mime_get_default_action_for_uri (NautilusDirectory *directory, static GnomeVFSMimeApplication * -nautilus_mime_get_default_application_for_uri_internal (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_get_default_application_for_uri_internal (NautilusFile *file, gboolean *user_chosen) { char *mime_type; @@ -198,7 +207,7 @@ nautilus_mime_get_default_application_for_uri_internal (NautilusDirectory *direc (file, NAUTILUS_METADATA_KEY_DEFAULT_APPLICATION, NULL); if (default_application_string == NULL) { - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); result = gnome_vfs_mime_get_default_application (mime_type); g_free (mime_type); used_user_chosen_info = FALSE; @@ -214,20 +223,18 @@ nautilus_mime_get_default_application_for_uri_internal (NautilusDirectory *direc } GnomeVFSMimeApplication * -nautilus_mime_get_default_application_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_default_application_for_uri (NautilusFile *file) { - return nautilus_mime_get_default_application_for_uri_internal (directory, file, NULL); + return nautilus_mime_get_default_application_for_uri_internal (file, NULL); } gboolean -nautilus_mime_is_default_application_for_uri_user_chosen (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_is_default_application_for_uri_user_chosen (NautilusFile *file) { GnomeVFSMimeApplication *application; gboolean user_chosen; - application = nautilus_mime_get_default_application_for_uri_internal (directory, file, &user_chosen); + application = nautilus_mime_get_default_application_for_uri_internal (file, &user_chosen); /* Doesn't count as user chosen if the user-specified data is bogus and doesn't * result in an actual application. @@ -243,8 +250,7 @@ nautilus_mime_is_default_application_for_uri_user_chosen (NautilusDirectory *dir static OAF_ServerInfo * -nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_get_default_component_for_uri_internal (NautilusFile *file, gboolean *user_chosen) { GList *info_list; @@ -253,8 +259,7 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo char *uri; char *mime_type; char *uri_scheme; - GList *files; - GList *attributes; + GList *item_mime_types; GList *explicit_iids; CORBA_Environment ev; OAF_ServerInfo *server; @@ -269,7 +274,7 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo CORBA_exception_init (&ev); - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); uri = nautilus_file_get_uri (file); @@ -277,14 +282,9 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo g_free (uri); - nautilus_file_wait_for_metadata (file); + nautilus_file_wait_for_mime_action_attributes (file); explicit_iids = get_explicit_content_view_iids_from_metafile (file); - - /* Arrange for all the file attributes we will need. */ - attributes = NULL; - attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE); - files = nautilus_directory_wait_until_ready (directory, attributes); - g_list_free (attributes); + nautilus_file_get_directory_item_mime_types (file, &item_mime_types); default_component_string = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_DEFAULT_COMPONENT, NULL); @@ -318,7 +318,7 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo /* Prefer something from the short list */ - short_list = nautilus_mime_get_short_list_components_for_uri (directory, file); + short_list = nautilus_mime_get_short_list_components_for_uri (file); if (short_list != NULL) { sort_conditions[1] = g_strdup ("has (['"); @@ -358,7 +358,7 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo sort_conditions[4] = NULL; - info_list = nautilus_do_component_query (mime_type, uri_scheme, files, explicit_iids, + info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, explicit_iids, sort_conditions, NULL, &ev); if (ev._major == CORBA_NO_EXCEPTION && info_list != NULL) { @@ -374,7 +374,6 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo return NULL; } - nautilus_file_list_free (files); g_free (sort_conditions[0]); g_free (sort_conditions[1]); g_free (sort_conditions[2]); @@ -395,20 +394,18 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo OAF_ServerInfo * -nautilus_mime_get_default_component_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_default_component_for_uri (NautilusFile *file) { - return nautilus_mime_get_default_component_for_uri_internal (directory, file, NULL); + return nautilus_mime_get_default_component_for_uri_internal (file, NULL); } gboolean -nautilus_mime_is_default_component_for_uri_user_chosen (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_is_default_component_for_uri_user_chosen (NautilusFile *file) { OAF_ServerInfo *component; gboolean user_chosen; - component = nautilus_mime_get_default_component_for_uri_internal (directory, file, &user_chosen); + component = nautilus_mime_get_default_component_for_uri_internal (file, &user_chosen); /* Doesn't count as user chosen if the user-specified data is bogus and doesn't * result in an actual component. @@ -424,8 +421,7 @@ nautilus_mime_is_default_component_for_uri_user_chosen (NautilusDirectory *direc GList * -nautilus_mime_get_short_list_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_short_list_applications_for_uri (NautilusFile *file) { char *mime_type; GList *result; @@ -448,7 +444,7 @@ nautilus_mime_get_short_list_applications_for_uri (NautilusDirectory *directory, NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID); - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); result = gnome_vfs_mime_get_short_list_applications (mime_type); g_free (mime_type); @@ -478,12 +474,12 @@ nautilus_mime_get_short_list_applications_for_uri (NautilusDirectory *directory, } GList * -nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_short_list_components_for_uri (NautilusFile *file) { char *uri; char *mime_type; char *uri_scheme; + GList *item_mime_types; GList *servers; GList *iids; GList *result; @@ -492,8 +488,6 @@ nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, GList *metadata_component_remove_ids; GList *p; OAF_ServerInfo *component; - GList *attributes; - GList *files; GList *explicit_iids; CORBA_Environment ev; char *extra_requirements; @@ -507,15 +501,9 @@ nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, g_free (uri); - nautilus_file_wait_for_metadata (file); + nautilus_file_wait_for_mime_action_attributes (file); explicit_iids = get_explicit_content_view_iids_from_metafile (file); - - /* Arrange for all the file attributes we will need. */ - attributes = NULL; - attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE); - files = nautilus_directory_wait_until_ready (directory, attributes); - g_list_free (attributes); - + nautilus_file_get_directory_item_mime_types (file, &item_mime_types); metadata_component_add_ids = nautilus_file_get_metadata_list (file, @@ -526,7 +514,7 @@ nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_REMOVE, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID); - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); servers = gnome_vfs_mime_get_short_list_components (mime_type); iids = NULL; @@ -571,11 +559,10 @@ nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, } - result = nautilus_do_component_query (mime_type, uri_scheme, files, explicit_iids, NULL, extra_requirements, &ev); + result = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, explicit_iids, NULL, extra_requirements, &ev); g_free (extra_requirements); } - nautilus_file_list_free (files); gnome_vfs_mime_component_list_free (servers); g_list_free (iids); g_free (uri_scheme); @@ -587,21 +574,20 @@ nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, /* FIXME: we should disable this for 1.0 I think */ char * -nautilus_mime_get_short_list_methods_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_short_list_methods_for_uri (NautilusFile *file) { char *mime_type; const char *method; - mime_type = get_mime_type_from_file (file); + nautilus_file_wait_for_metadata (file); + mime_type = nautilus_file_get_slow_mime_type (file); method = gnome_vfs_mime_get_value (mime_type, "vfs-method"); g_free (mime_type); return g_strdup (method); } GList * -nautilus_mime_get_all_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_all_applications_for_uri (NautilusFile *file) { char *mime_type; GList *result; @@ -615,7 +601,7 @@ nautilus_mime_get_all_applications_for_uri (NautilusDirectory *directory, NAUTILUS_METADATA_KEY_EXPLICIT_APPLICATION, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID); - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); result = gnome_vfs_mime_get_all_applications (mime_type); @@ -636,13 +622,12 @@ nautilus_mime_get_all_applications_for_uri (NautilusDirectory *directory, } gboolean -nautilus_mime_has_any_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_has_any_applications_for_uri (NautilusFile *file) { GList *list; gboolean result; - list = nautilus_mime_get_all_applications_for_uri (directory, file); + list = nautilus_mime_get_all_applications_for_uri (file); result = list != NULL; gnome_vfs_mime_application_list_free (list); @@ -650,39 +635,30 @@ nautilus_mime_has_any_applications_for_uri (NautilusDirectory *directory, } GList * -nautilus_mime_get_all_components_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_all_components_for_uri (NautilusFile *file) { char *uri; char *mime_type; char *uri_scheme; - GList *files; - GList *attributes; + GList *item_mime_types; GList *info_list; GList *explicit_iids; CORBA_Environment ev; CORBA_exception_init (&ev); - mime_type = get_mime_type_from_file (file); - uri = nautilus_file_get_uri (file); uri_scheme = uri_string_get_scheme (uri); g_free (uri); - nautilus_file_wait_for_metadata (file); - explicit_iids = get_explicit_content_view_iids_from_metafile (file); - - /* Arrange for all the file attributes we will need. */ - attributes = NULL; - attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE); + nautilus_file_wait_for_mime_action_attributes (file); - files = nautilus_directory_wait_until_ready (directory, attributes); - g_list_free (attributes); + mime_type = nautilus_file_get_slow_mime_type (file); + explicit_iids = get_explicit_content_view_iids_from_metafile (file); + nautilus_file_get_directory_item_mime_types (file, &item_mime_types); - info_list = nautilus_do_component_query (mime_type, uri_scheme, files, explicit_iids, NULL, NULL, &ev); + info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, explicit_iids, NULL, NULL, &ev); - nautilus_file_list_free (files); g_free (uri_scheme); g_free (mime_type); CORBA_exception_free (&ev); @@ -691,13 +667,12 @@ nautilus_mime_get_all_components_for_uri (NautilusDirectory *directory, } gboolean -nautilus_mime_has_any_components_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_has_any_components_for_uri (NautilusFile *file) { GList *list; gboolean result; - list = nautilus_mime_get_all_components_for_uri (directory, file); + list = nautilus_mime_get_all_components_for_uri (file); result = list != NULL; gnome_vfs_mime_component_list_free (list); @@ -705,8 +680,7 @@ nautilus_mime_has_any_components_for_uri (NautilusDirectory *directory, } GnomeVFSResult -nautilus_mime_set_default_action_type_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_set_default_action_type_for_uri (NautilusFile *file, GnomeVFSMimeActionType action_type) { const char *action_string; @@ -731,8 +705,7 @@ nautilus_mime_set_default_action_type_for_uri (NautilusDirectory *directory } GnomeVFSResult -nautilus_mime_set_default_application_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_set_default_application_for_uri (NautilusFile *file, const char *application_id) { nautilus_file_wait_for_metadata (file); @@ -741,16 +714,15 @@ nautilus_mime_set_default_application_for_uri (NautilusDirectory *directory, /* If there's no default action type, set it to match this. */ if (application_id != NULL && - nautilus_mime_get_default_action_type_for_uri (directory, file) == GNOME_VFS_MIME_ACTION_TYPE_NONE) { - return nautilus_mime_set_default_action_type_for_uri (directory, file, GNOME_VFS_MIME_ACTION_TYPE_APPLICATION); + nautilus_mime_get_default_action_type_for_uri (file) == GNOME_VFS_MIME_ACTION_TYPE_NONE) { + return nautilus_mime_set_default_action_type_for_uri (file, GNOME_VFS_MIME_ACTION_TYPE_APPLICATION); } return GNOME_VFS_OK; } GnomeVFSResult -nautilus_mime_set_default_component_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_set_default_component_for_uri (NautilusFile *file, const char *component_iid) { nautilus_file_wait_for_metadata (file); @@ -759,16 +731,15 @@ nautilus_mime_set_default_component_for_uri (NautilusDirectory *directory, /* If there's no default action type, set it to match this. */ if (component_iid != NULL && - nautilus_mime_get_default_action_type_for_uri (directory, file) == GNOME_VFS_MIME_ACTION_TYPE_NONE) { - return nautilus_mime_set_default_action_type_for_uri (directory, file, GNOME_VFS_MIME_ACTION_TYPE_COMPONENT); + nautilus_mime_get_default_action_type_for_uri (file) == GNOME_VFS_MIME_ACTION_TYPE_NONE) { + return nautilus_mime_set_default_action_type_for_uri (file, GNOME_VFS_MIME_ACTION_TYPE_COMPONENT); } return GNOME_VFS_OK; } GnomeVFSResult -nautilus_mime_set_short_list_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_set_short_list_applications_for_uri (NautilusFile *file, GList *applications) { GList *add_list; @@ -780,7 +751,7 @@ nautilus_mime_set_short_list_applications_for_uri (NautilusDirectory *directory, /* get per-mime short list */ - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); normal_short_list = gnome_vfs_mime_get_short_list_applications (mime_type); g_free (mime_type); @@ -814,8 +785,7 @@ nautilus_mime_set_short_list_applications_for_uri (NautilusDirectory *directory, } GnomeVFSResult -nautilus_mime_set_short_list_components_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_set_short_list_components_for_uri (NautilusFile *file, GList *components) { GList *add_list; @@ -827,7 +797,7 @@ nautilus_mime_set_short_list_components_for_uri (NautilusDirectory *directory, /* get per-mime short list */ - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); normal_short_list = gnome_vfs_mime_get_short_list_components (mime_type); g_free (mime_type); @@ -861,8 +831,7 @@ nautilus_mime_set_short_list_components_for_uri (NautilusDirectory *directory, } GnomeVFSResult -nautilus_mime_add_application_to_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_add_application_to_short_list_for_uri (NautilusFile *file, const char *application_id) { GList *old_list, *new_list; @@ -870,12 +839,12 @@ nautilus_mime_add_application_to_short_list_for_uri (NautilusDirectory *director result = GNOME_VFS_OK; - old_list = nautilus_mime_get_short_list_applications_for_uri (directory, file); + old_list = nautilus_mime_get_short_list_applications_for_uri (file); if (!gnome_vfs_mime_id_in_application_list (application_id, old_list)) { new_list = g_list_append (gnome_vfs_mime_id_list_from_application_list (old_list), g_strdup (application_id)); - result = nautilus_mime_set_short_list_applications_for_uri (directory, file, new_list); + result = nautilus_mime_set_short_list_applications_for_uri (file, new_list); nautilus_g_list_free_deep (new_list); } @@ -885,15 +854,14 @@ nautilus_mime_add_application_to_short_list_for_uri (NautilusDirectory *director } GnomeVFSResult -nautilus_mime_remove_application_from_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_remove_application_from_short_list_for_uri (NautilusFile *file, const char *application_id) { GList *old_list, *new_list; gboolean was_in_list; GnomeVFSResult result; - old_list = nautilus_mime_get_short_list_applications_for_uri (directory, file); + old_list = nautilus_mime_get_short_list_applications_for_uri (file); old_list = gnome_vfs_mime_remove_application_from_list (old_list, application_id, &was_in_list); @@ -901,7 +869,7 @@ nautilus_mime_remove_application_from_short_list_for_uri (NautilusDirectory *dir result = GNOME_VFS_OK; } else { new_list = gnome_vfs_mime_id_list_from_application_list (old_list); - result = nautilus_mime_set_short_list_applications_for_uri (directory, file, new_list); + result = nautilus_mime_set_short_list_applications_for_uri (file, new_list); nautilus_g_list_free_deep (new_list); } @@ -911,21 +879,20 @@ nautilus_mime_remove_application_from_short_list_for_uri (NautilusDirectory *dir } GnomeVFSResult -nautilus_mime_add_component_to_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_add_component_to_short_list_for_uri (NautilusFile *file, const char *iid) { GList *old_list, *new_list; GnomeVFSResult result; - old_list = nautilus_mime_get_short_list_components_for_uri (directory, file); + old_list = nautilus_mime_get_short_list_components_for_uri (file); if (gnome_vfs_mime_id_in_component_list (iid, old_list)) { result = GNOME_VFS_OK; } else { new_list = g_list_append (gnome_vfs_mime_id_list_from_component_list (old_list), g_strdup (iid)); - result = nautilus_mime_set_short_list_components_for_uri (directory, file, new_list); + result = nautilus_mime_set_short_list_components_for_uri (file, new_list); nautilus_g_list_free_deep (new_list); } @@ -935,15 +902,14 @@ nautilus_mime_add_component_to_short_list_for_uri (NautilusDirectory *directory, } GnomeVFSResult -nautilus_mime_remove_component_from_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_remove_component_from_short_list_for_uri (NautilusFile *file, const char *iid) { GList *old_list, *new_list; gboolean was_in_list; GnomeVFSResult result; - old_list = nautilus_mime_get_short_list_components_for_uri (directory, file); + old_list = nautilus_mime_get_short_list_components_for_uri (file); old_list = gnome_vfs_mime_remove_component_from_list (old_list, iid, &was_in_list); @@ -951,7 +917,7 @@ nautilus_mime_remove_component_from_short_list_for_uri (NautilusDirectory *direc result = GNOME_VFS_OK; } else { new_list = gnome_vfs_mime_id_list_from_component_list (old_list); - result = nautilus_mime_set_short_list_components_for_uri (directory, file, new_list); + result = nautilus_mime_set_short_list_components_for_uri (file, new_list); nautilus_g_list_free_deep (new_list); } @@ -961,8 +927,7 @@ nautilus_mime_remove_component_from_short_list_for_uri (NautilusDirectory *direc } GnomeVFSResult -nautilus_mime_extend_all_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_extend_all_applications_for_uri (NautilusFile *file, GList *applications) { GList *metadata_application_ids; @@ -990,8 +955,7 @@ nautilus_mime_extend_all_applications_for_uri (NautilusDirectory *directory, } GnomeVFSResult -nautilus_mime_remove_from_all_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_remove_from_all_applications_for_uri (NautilusFile *file, GList *applications) { GList *metadata_application_ids; @@ -1089,7 +1053,7 @@ uri_string_get_scheme (const char *uri_string) * The following routine uses metadata associated with the current url * to add content view components specified in the metadata. The * content views are specified in the string as <EXPLICIT_CONTENT_VIEW - * IID="iid"/> elements inside the appropriate <DIRECTORY> or <FILE> element. + * IID="iid"/> elements inside the appropriate <FILE> element. */ static GList * @@ -1316,7 +1280,7 @@ make_oaf_query_with_uri_scheme_only (const char *uri_scheme, static GHashTable * -file_list_to_mime_type_hash_table (GList *files) +mime_type_list_to_hash_table (GList *types) { GHashTable *result; GList *p; @@ -1324,20 +1288,16 @@ file_list_to_mime_type_hash_table (GList *files) result = g_hash_table_new (g_str_hash, g_str_equal); - for (p = files; p != NULL; p = p->next) { + for (p = types; p != NULL; p = p->next) { if (p->data != NULL) { - mime_type = nautilus_file_get_mime_type ((NautilusFile *) p->data); + mime_type = (char *) (p->data); - if (NULL != mime_type) { - if (g_hash_table_lookup (result, mime_type) == NULL) { + if (g_hash_table_lookup (result, mime_type) == NULL) { #ifdef DEBUG_MJS - printf ("XXX content mime type: %s\n", mime_type); + printf ("XXX content mime type: %s\n", mime_type); #endif - g_hash_table_insert (result, mime_type, mime_type); - } else { - g_free (mime_type); - } - } + g_hash_table_insert (result, g_strdup (mime_type), mime_type); + } } } @@ -1415,7 +1375,7 @@ static char *nautilus_sort_criteria[] = { static GList * nautilus_do_component_query (const char *mime_type, const char *uri_scheme, - GList *files, + GList *item_mime_types, GList *explicit_iids, char **extra_sort_criteria, char *extra_requirements, @@ -1452,7 +1412,7 @@ nautilus_do_component_query (const char *mime_type, GHashTable *content_types; int i; - content_types = file_list_to_mime_type_hash_table (files); + content_types = mime_type_list_to_hash_table (item_mime_types); for (i = 0; i < oaf_result->_length; i++) { OAF_ServerInfo *server; @@ -1495,34 +1455,6 @@ str_list_difference (GList *a, } -static char * -get_mime_type_from_file (NautilusFile *file) -{ - char *type; - GList *file_attributes; - - type = NULL; - - /* FIXME bugzilla.eazel.com 1263: - A better way would be to get this info using - NautilusFile or NautilusDirectory or something, having - previously ensured that the info has been computed - async. */ - - if (file != NULL) { - file_attributes = g_list_append (NULL, NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE); - - nautilus_file_wait_until_ready (file, - file_attributes); - - g_list_free (file_attributes); - - type = nautilus_file_get_slow_mime_type (file); - } - - return type == NULL ? g_strdup ("application/octet-stream") : type; -} - static int strv_length (char **a) { diff --git a/libnautilus-extensions/nautilus-mime-actions.h b/libnautilus-extensions/nautilus-mime-actions.h index e6dc87cd5..b24a6c14f 100644 --- a/libnautilus-extensions/nautilus-mime-actions.h +++ b/libnautilus-extensions/nautilus-mime-actions.h @@ -27,76 +27,48 @@ #include <libgnomevfs/gnome-vfs-mime-handlers.h> -#include <libnautilus-extensions/nautilus-directory.h> #include <libnautilus-extensions/nautilus-file.h> -/* FIXME: This API requires passing both a NautilusDirectory and a - NautilusFile for the same URI, because it requires both the mime type - and the metadata for the location. */ -GnomeVFSMimeActionType nautilus_mime_get_default_action_type_for_uri (NautilusDirectory *directory, - NautilusFile *file); -GnomeVFSMimeAction * nautilus_mime_get_default_action_for_uri (NautilusDirectory *directory, - NautilusFile *file); -GnomeVFSMimeApplication *nautilus_mime_get_default_application_for_uri (NautilusDirectory *directory, - NautilusFile *file); -gboolean nautilus_mime_is_default_application_for_uri_user_chosen (NautilusDirectory *directory, - NautilusFile *file); -OAF_ServerInfo * nautilus_mime_get_default_component_for_uri (NautilusDirectory *directory, - NautilusFile *file); -gboolean nautilus_mime_is_default_component_for_uri_user_chosen (NautilusDirectory *directory, - NautilusFile *file); -GList * nautilus_mime_get_short_list_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file); -GList * nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, - NautilusFile *file); -gchar * nautilus_mime_get_short_list_methods_for_uri (NautilusDirectory *directory, - NautilusFile *file); -GList * nautilus_mime_get_all_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file); -GList * nautilus_mime_get_all_components_for_uri (NautilusDirectory *directory, - NautilusFile *file); -gboolean nautilus_mime_has_any_components_for_uri (NautilusDirectory *directory, - NautilusFile *file); -gboolean nautilus_mime_has_any_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file); -GnomeVFSResult nautilus_mime_set_default_action_type_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSMimeActionType nautilus_mime_get_default_action_type_for_uri (NautilusFile *file); +GnomeVFSMimeAction * nautilus_mime_get_default_action_for_uri (NautilusFile *file); +GnomeVFSMimeApplication *nautilus_mime_get_default_application_for_uri (NautilusFile *file); +gboolean nautilus_mime_is_default_application_for_uri_user_chosen (NautilusFile *file); +OAF_ServerInfo * nautilus_mime_get_default_component_for_uri (NautilusFile *file); +gboolean nautilus_mime_is_default_component_for_uri_user_chosen (NautilusFile *file); +GList * nautilus_mime_get_short_list_applications_for_uri (NautilusFile *file); +GList * nautilus_mime_get_short_list_components_for_uri (NautilusFile *file); +gchar * nautilus_mime_get_short_list_methods_for_uri (NautilusFile *file); +GList * nautilus_mime_get_all_applications_for_uri (NautilusFile *file); +GList * nautilus_mime_get_all_components_for_uri (NautilusFile *file); +gboolean nautilus_mime_has_any_components_for_uri (NautilusFile *file); +gboolean nautilus_mime_has_any_applications_for_uri (NautilusFile *file); +GnomeVFSResult nautilus_mime_set_default_action_type_for_uri (NautilusFile *file, GnomeVFSMimeActionType action_type); -GnomeVFSResult nautilus_mime_set_default_application_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_set_default_application_for_uri (NautilusFile *file, const char *application_id); -GnomeVFSResult nautilus_mime_set_default_component_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_set_default_component_for_uri (NautilusFile *file, const char *component_iid); /* Stored as delta to current user level */ -GnomeVFSResult nautilus_mime_set_short_list_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file, - GList *applications); -GnomeVFSResult nautilus_mime_set_short_list_components_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_set_short_list_applications_for_uri (NautilusFile *file, GList *components); -GnomeVFSResult nautilus_mime_add_application_to_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_add_application_to_short_list_for_uri (NautilusFile *file, const char *application_id); -GnomeVFSResult nautilus_mime_remove_application_from_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_remove_application_from_short_list_for_uri (NautilusFile *file, const char *application_id); -GnomeVFSResult nautilus_mime_add_component_to_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_set_short_list_components_for_uri (NautilusFile *file, + GList *components); +GnomeVFSResult nautilus_mime_add_component_to_short_list_for_uri (NautilusFile *file, const char *iid); -GnomeVFSResult nautilus_mime_remove_component_from_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_remove_component_from_short_list_for_uri (NautilusFile *file, const char *iid); /* No way to override system list; can only add. */ -GnomeVFSResult nautilus_mime_extend_all_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_extend_all_applications_for_uri (NautilusFile *file, GList *applications); /* Only "user" entries may be removed. */ -GnomeVFSResult nautilus_mime_remove_from_all_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_remove_from_all_applications_for_uri (NautilusFile *file, GList *applications); /* No way to add to all components; oafinfo database assumed trusted in this regard. */ diff --git a/libnautilus-extensions/nautilus-program-chooser.c b/libnautilus-extensions/nautilus-program-chooser.c index 48fe6a5b7..f00b1db67 100644 --- a/libnautilus-extensions/nautilus-program-chooser.c +++ b/libnautilus-extensions/nautilus-program-chooser.c @@ -311,7 +311,6 @@ repopulate_program_list (GnomeDialog *program_chooser, { char **text; char *uri; - NautilusDirectory *directory; GList *programs, *program; ProgramFilePair *pair; int new_row; @@ -323,13 +322,11 @@ repopulate_program_list (GnomeDialog *program_chooser, || type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION); uri = nautilus_file_get_uri (file); - directory = nautilus_directory_get (uri); g_free (uri); programs = type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT - ? nautilus_mime_get_all_components_for_uri (directory, file) - : nautilus_mime_get_all_applications_for_uri (directory, file); - nautilus_directory_unref (directory); + ? nautilus_mime_get_all_components_for_uri (file) + : nautilus_mime_get_all_applications_for_uri (file); gtk_clist_clear (clist); @@ -489,16 +486,13 @@ is_application_default_for_uri (GnomeVFSMimeApplication *application, const char GnomeVFSMimeApplication *default_application; gboolean result; NautilusFile *file; - NautilusDirectory *directory; g_assert (application != NULL); file = nautilus_file_get (uri); - directory = nautilus_directory_get (uri); - default_application = nautilus_mime_get_default_application_for_uri (directory, file); + default_application = nautilus_mime_get_default_application_for_uri (file); result = (default_application != NULL && strcmp (default_application->id, application->id) == 0); - nautilus_directory_unref (directory); nautilus_file_unref (file); gnome_vfs_mime_application_free (default_application); @@ -511,18 +505,15 @@ is_component_default_for_uri (NautilusViewIdentifier *identifier, const char *ur { OAF_ServerInfo *default_component; gboolean result; - NautilusDirectory *directory; NautilusFile *file; g_assert (identifier != NULL); - directory = nautilus_directory_get (uri); file = nautilus_file_get (uri); - default_component = nautilus_mime_get_default_component_for_uri (directory, file); + default_component = nautilus_mime_get_default_component_for_uri (file); result = (default_component != NULL && strcmp (default_component->iid, identifier->iid) == 0); - nautilus_directory_unref (directory); nautilus_file_unref (file); CORBA_free (default_component); @@ -551,13 +542,11 @@ is_component_in_short_list_for_uri (NautilusViewIdentifier *identifier, const ch { GList *list; gboolean result; - NautilusDirectory *directory; NautilusFile *file; - directory = nautilus_directory_get (uri); file = nautilus_file_get (uri); - list = nautilus_mime_get_short_list_components_for_uri (directory, file); + list = nautilus_mime_get_short_list_components_for_uri (file); result = g_list_find_custom (list, identifier, (GCompareFunc)compare_component_with_view) @@ -565,7 +554,6 @@ is_component_in_short_list_for_uri (NautilusViewIdentifier *identifier, const ch gnome_vfs_mime_component_list_free (list); nautilus_file_unref (file); - nautilus_directory_unref (directory); return result; } @@ -591,14 +579,12 @@ is_application_in_short_list_for_uri (GnomeVFSMimeApplication *application, cons { GList *list; gboolean result; - NautilusDirectory *directory; NautilusFile *file; - directory = nautilus_directory_get (uri); file = nautilus_file_get (uri); - list = nautilus_mime_get_short_list_applications_for_uri (directory, file); + list = nautilus_mime_get_short_list_applications_for_uri (file); result = g_list_find_custom (list, application, (GCompareFunc)compare_mime_applications) @@ -606,7 +592,6 @@ is_application_in_short_list_for_uri (GnomeVFSMimeApplication *application, cons gnome_vfs_mime_application_list_free (list); - nautilus_directory_unref (directory); nautilus_file_unref (file); return result; @@ -643,20 +628,16 @@ program_file_pair_is_default_for_file (ProgramFilePair *pair) { char *uri; gboolean result; - NautilusDirectory *directory; g_assert (pair != NULL); g_assert (NAUTILUS_IS_FILE (pair->file)); uri = nautilus_file_get_uri (pair->file); - directory = nautilus_directory_get (uri); - if (pair->action_type != nautilus_mime_get_default_action_type_for_uri (directory, pair->file)) { + if (pair->action_type != nautilus_mime_get_default_action_type_for_uri (pair->file)) { return FALSE; } - nautilus_directory_unref (directory); - if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT) { result = is_component_default_for_uri (pair->view_identifier, uri); } else { @@ -819,18 +800,15 @@ static void add_to_short_list_for_file (ProgramFilePair *pair) { char *uri; - NautilusDirectory *directory; uri = nautilus_file_get_uri (pair->file); - directory = nautilus_directory_get (uri); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { - nautilus_mime_add_application_to_short_list_for_uri (directory, pair->file, pair->application->id); + nautilus_mime_add_application_to_short_list_for_uri (pair->file, pair->application->id); } else { - nautilus_mime_add_component_to_short_list_for_uri (directory, pair->file, pair->view_identifier->iid); + nautilus_mime_add_component_to_short_list_for_uri (pair->file, pair->view_identifier->iid); } - nautilus_directory_unref (directory); g_free (uri); } @@ -838,18 +816,15 @@ static void remove_from_short_list_for_file (ProgramFilePair *pair) { char *uri; - NautilusDirectory *directory; uri = nautilus_file_get_uri (pair->file); - directory = nautilus_directory_get (uri); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { - nautilus_mime_remove_application_from_short_list_for_uri (directory, pair->file, pair->application->id); + nautilus_mime_remove_application_from_short_list_for_uri (pair->file, pair->application->id); } else { - nautilus_mime_remove_component_from_short_list_for_uri (directory, pair->file, pair->view_identifier->iid); + nautilus_mime_remove_component_from_short_list_for_uri (pair->file, pair->view_identifier->iid); } - nautilus_directory_unref (directory); g_free (uri); } @@ -909,32 +884,29 @@ static void remove_default_for_item (ProgramFilePair *pair) { char *uri; - NautilusDirectory *directory; uri = nautilus_file_get_uri (pair->file); - directory = nautilus_directory_get (uri); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { /* If the default is just falling through to the default for this type, * don't do anything here. */ - if (nautilus_mime_is_default_application_for_uri_user_chosen (directory, pair->file)) { + if (nautilus_mime_is_default_application_for_uri_user_chosen (pair->file)) { if (is_application_default_for_uri (pair->application, uri)) { - nautilus_mime_set_default_application_for_uri (directory, pair->file, NULL); + nautilus_mime_set_default_application_for_uri (pair->file, NULL); } } } else { /* If the default is just falling through to the default for this type, * don't do anything here. */ - if (nautilus_mime_is_default_component_for_uri_user_chosen (directory, pair->file)) { + if (nautilus_mime_is_default_component_for_uri_user_chosen (pair->file)) { if (is_component_default_for_uri (pair->view_identifier, uri)) { - nautilus_mime_set_default_component_for_uri (directory, pair->file, NULL); + nautilus_mime_set_default_component_for_uri (pair->file, NULL); } } } - nautilus_directory_unref (directory); g_free (uri); } @@ -960,22 +932,19 @@ static void set_default_for_item (ProgramFilePair *pair) { char *uri; - NautilusDirectory *directory; uri = nautilus_file_get_uri (pair->file); - directory = nautilus_directory_get (uri); uri = nautilus_file_get_uri (pair->file); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { - nautilus_mime_set_default_application_for_uri (directory, pair->file, pair->application->id); + nautilus_mime_set_default_application_for_uri (pair->file, pair->application->id); } else { - nautilus_mime_set_default_component_for_uri (directory, pair->file, pair->view_identifier->iid); + nautilus_mime_set_default_component_for_uri (pair->file, pair->view_identifier->iid); } - nautilus_mime_set_default_action_type_for_uri (directory, pair->file, pair->action_type); + nautilus_mime_set_default_action_type_for_uri (pair->file, pair->action_type); - nautilus_directory_unref (directory); g_free (uri); } diff --git a/libnautilus-extensions/nautilus-program-choosing.c b/libnautilus-extensions/nautilus-program-choosing.c index d77694e74..d3c4f3ddc 100644 --- a/libnautilus-extensions/nautilus-program-choosing.c +++ b/libnautilus-extensions/nautilus-program-choosing.c @@ -41,19 +41,16 @@ any_programs_available_for_file (GnomeVFSMimeActionType action_type, NautilusFil { gboolean result; char *uri; - NautilusDirectory *directory; uri = nautilus_file_get_uri (file); - directory = nautilus_directory_get (uri); if (action_type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT) { - result = nautilus_mime_has_any_components_for_uri (directory, file); + result = nautilus_mime_has_any_components_for_uri (file); } else { g_assert (action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION); - result = nautilus_mime_has_any_applications_for_uri (directory, file); + result = nautilus_mime_has_any_applications_for_uri (file); } - nautilus_directory_unref (directory); g_free (uri); return result; diff --git a/libnautilus-extensions/nautilus-wait-until-ready.h b/libnautilus-extensions/nautilus-wait-until-ready.h index e6fe2610b..640e6c6b1 100644 --- a/libnautilus-extensions/nautilus-wait-until-ready.h +++ b/libnautilus-extensions/nautilus-wait-until-ready.h @@ -23,6 +23,11 @@ * Authors: Maciej Stachowiak */ +#include <glib.h> +#include <libnautilus-extensions/nautilus-file.h> +#include <libnautilus-extensions/nautilus-directory.h> + + /* nautilus-wait-until-ready.h: I'm adding this file as a temporary * measure in the process of eliminating the wait_until_ready calls. It * is deprecated! Do not use these calls in new code! diff --git a/libnautilus-private/nautilus-directory-async.c b/libnautilus-private/nautilus-directory-async.c index faf42b1f1..951afa47d 100644 --- a/libnautilus-private/nautilus-directory-async.c +++ b/libnautilus-private/nautilus-directory-async.c @@ -243,8 +243,6 @@ mime_list_cancel (NautilusDirectory *directory) gnome_vfs_async_cancel (directory->details->mime_list_in_progress); - directory->details->mime_list_file->details->mime_list_status = NAUTILUS_REQUEST_NOT_STARTED; - directory->details->mime_list_file = NULL; directory->details->mime_list_in_progress = NULL; g_free (directory->details->mime_list_uri); @@ -877,7 +875,7 @@ set_up_request_by_file_attributes (Request *request, nautilus_str_compare) != NULL; request->mime_list = g_list_find_custom (file_attributes, - NAUTILUS_FILE_ATTRIBUTE_MIME_LIST, + NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES, nautilus_str_compare) != NULL; request->top_left_text = g_list_find_custom (file_attributes, @@ -1662,7 +1660,7 @@ static gboolean lacks_mime_list (NautilusFile *file) { return nautilus_file_is_directory (file) - && file->details->mime_list_status != NAUTILUS_REQUEST_DONE; + && file->details->got_mime_list == FALSE; } static gboolean @@ -1928,7 +1926,6 @@ nautilus_directory_invalidate_counts (NautilusDirectory *directory) file->details->deep_counts_status = NAUTILUS_REQUEST_NOT_STARTED; file->details->got_mime_list = FALSE; file->details->mime_list_failed = FALSE; - file->details->mime_list_status = NAUTILUS_REQUEST_NOT_STARTED; if (parent_directory != directory) { nautilus_directory_async_state_changed (parent_directory); @@ -2357,7 +2354,6 @@ mime_list_callback (GnomeVFSAsyncHandle *handle, NautilusDirectory *directory; NautilusFile *file; GnomeVFSDirectoryListPosition last_handled, p; - gboolean done; directory = NAUTILUS_DIRECTORY (callback_data); g_assert (directory->details->mime_list_in_progress == handle); @@ -2378,23 +2374,33 @@ mime_list_callback (GnomeVFSAsyncHandle *handle, } directory->details->mime_list_last_handled = last_handled; - done = FALSE; - if (result != GNOME_VFS_OK) { - directory->details->mime_list_in_progress = NULL; - g_free (directory->details->mime_list_uri); - directory->details->mime_list_uri = NULL; + if (result == GNOME_VFS_OK) { + return; + } - file->details->mime_list_status = NAUTILUS_REQUEST_DONE; - directory->details->mime_list_file = NULL; - done = TRUE; + /* Record either a failure or success. */ + if (result != GNOME_VFS_ERROR_EOF) { + file->details->directory_count_failed = TRUE; + nautilus_g_list_free_deep (file->details->mime_list); + file->details->mime_list = NULL; + } else { + file->details->got_mime_list = TRUE; } + g_free (directory->details->mime_list_uri); + directory->details->mime_list_uri = NULL; + directory->details->mime_list_in_progress = NULL; + directory->details->mime_list_file = NULL; + + /* Send file-changed even if getting the item type list + * failed, so interested parties can distinguish between + * unknowable and not-yet-known cases. */ + nautilus_file_changed (file); - if (done) { - async_job_end (); - nautilus_directory_async_state_changed (directory); - } + /* Start up the next one. */ + async_job_end (); + nautilus_directory_async_state_changed (directory); } static void @@ -2461,6 +2467,7 @@ mime_list_start (NautilusDirectory *directory) /* Start counting. */ file->details->mime_list_status = NAUTILUS_REQUEST_IN_PROGRESS; + /* FIXME: clear out mime_list_whatever */ directory->details->mime_list_file = file; uri = nautilus_file_get_uri (file); diff --git a/libnautilus-private/nautilus-file-attributes.h b/libnautilus-private/nautilus-file-attributes.h index 5c52960be..a165e0884 100644 --- a/libnautilus-private/nautilus-file-attributes.h +++ b/libnautilus-private/nautilus-file-attributes.h @@ -29,17 +29,17 @@ * in changes to the attributes. */ -#define NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI "activation URI" -#define NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON "custom icon" -#define NAUTILUS_FILE_ATTRIBUTE_DEEP_COUNTS "deep counts" -#define NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT "directory item count" -#define NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE "MIME type" -#define NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE "MIME type" -#define NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT "top left text" -#define NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY "is directory" -#define NAUTILUS_FILE_ATTRIBUTE_FILE_TYPE "file type" -#define NAUTILUS_FILE_ATTRIBUTE_MIME_LIST "MIME list" -#define NAUTILUS_FILE_ATTRIBUTE_METADATA "metadata" +#define NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI "activation URI" +#define NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON "custom icon" +#define NAUTILUS_FILE_ATTRIBUTE_DEEP_COUNTS "deep counts" +#define NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT "directory item count" +#define NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE "MIME type" +#define NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE "MIME type" +#define NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT "top left text" +#define NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY "is directory" +#define NAUTILUS_FILE_ATTRIBUTE_FILE_TYPE "file type" +#define NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES "directory item MIME types" +#define NAUTILUS_FILE_ATTRIBUTE_METADATA "metadata" #endif /* NAUTILUS_FILE_ATTRIBUTES_H */ diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c index caf5b34d4..28435c20d 100644 --- a/libnautilus-private/nautilus-file.c +++ b/libnautilus-private/nautilus-file.c @@ -2051,7 +2051,7 @@ nautilus_file_recompute_deep_counts (NautilusFile *file) } /** - * nautilus_file_get_mime_list + * nautilus_file_get_directory_item_mime_types * * Get the list of mime-types present in a directory. * @file: NautilusFile representing a directory. It is an error to @@ -2062,14 +2062,14 @@ nautilus_file_recompute_deep_counts (NautilusFile *file) * **/ gboolean -nautilus_file_get_mime_list (NautilusFile *file, - GList **mime_list) +nautilus_file_get_directory_item_mime_types (NautilusFile *file, + GList **mime_list) { g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE); - g_return_val_if_fail (nautilus_file_is_directory (file), FALSE); g_return_val_if_fail (mime_list != NULL, FALSE); - if (! file->details->got_mime_list) { + if (! nautilus_file_is_directory (file) || ! file->details->got_mime_list) { + *mime_list = NULL; return FALSE; } diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h index 6825d72f2..a2d625d00 100644 --- a/libnautilus-private/nautilus-file.h +++ b/libnautilus-private/nautilus-file.h @@ -146,8 +146,8 @@ void nautilus_file_set_keywords (NautilusFile GList *keywords); GList * nautilus_file_get_emblem_names (NautilusFile *file); char * nautilus_file_get_top_left_text (NautilusFile *file); -gboolean nautilus_file_get_mime_list (NautilusFile *file, - GList **mime_list); +gboolean nautilus_file_get_directory_item_mime_types (NautilusFile *file, + GList **mime_list); /* Permissions. */ diff --git a/libnautilus-private/nautilus-mime-actions.c b/libnautilus-private/nautilus-mime-actions.c index 2533a9ac1..125647a2a 100644 --- a/libnautilus-private/nautilus-mime-actions.c +++ b/libnautilus-private/nautilus-mime-actions.c @@ -30,7 +30,6 @@ #include <libgnomevfs/gnome-vfs-mime-info.h> #include <libgnomevfs/gnome-vfs-application-registry.h> #include "nautilus-lib-self-check-functions.h" -#include "nautilus-directory.h" #include "nautilus-file.h" #include "nautilus-file-attributes.h" #include "nautilus-glib-extensions.h" @@ -62,7 +61,7 @@ static char *make_oaf_query_with_known_mime_type (const char static char *make_oaf_query_with_uri_scheme_only (const char *uri_scheme, GList *explicit_iids, const char *extra_requirements); -static GHashTable *file_list_to_mime_type_hash_table (GList *files); +static GHashTable *mime_type_list_to_hash_table (GList *files); static void free_key (gpointer key, gpointer value, gpointer user_data); @@ -79,7 +78,6 @@ static GList *nautilus_do_component_query (const char CORBA_Environment *ev); static GList *str_list_difference (GList *a, GList *b); -static char *get_mime_type_from_file (NautilusFile *file); static int strv_length (char **a); static char **strv_concat (char **a, char **b); @@ -103,20 +101,33 @@ nautilus_file_wait_for_metadata (NautilusFile *file) { GList *attributes; - /* When nautilus_directory_wait_until_ready is called this way, it - * currently returns NULL. So theoretically we don't have to free - * the result. But there's no guarantee that this behavior won't - * change, so it's safer to free the result. - */ + attributes = NULL; + attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_METADATA); + attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE); + nautilus_file_wait_until_ready (file, attributes); + g_list_free (attributes); +} + + - attributes = g_list_append (NULL, NAUTILUS_FILE_ATTRIBUTE_METADATA); +static void +nautilus_file_wait_for_mime_action_attributes (NautilusFile *file) +{ + GList *attributes; + + attributes = NULL; + attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_METADATA); + attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE); + attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES); nautilus_file_wait_until_ready (file, attributes); g_list_free (attributes); } + + + GnomeVFSMimeActionType -nautilus_mime_get_default_action_type_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_default_action_type_for_uri (NautilusFile *file) { char *mime_type; char *action_type_string; @@ -128,7 +139,7 @@ nautilus_mime_get_default_action_type_for_uri (NautilusDirectory *directory, (file, NAUTILUS_METADATA_KEY_DEFAULT_ACTION_TYPE, NULL); if (action_type_string == NULL) { - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); action_type = gnome_vfs_mime_get_default_action_type (mime_type); g_free (mime_type); return action_type; @@ -144,19 +155,18 @@ nautilus_mime_get_default_action_type_for_uri (NautilusDirectory *directory, } GnomeVFSMimeAction * -nautilus_mime_get_default_action_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_default_action_for_uri (NautilusFile *file) { GnomeVFSMimeAction *action; action = g_new0 (GnomeVFSMimeAction, 1); - action->action_type = nautilus_mime_get_default_action_type_for_uri (directory, file); + action->action_type = nautilus_mime_get_default_action_type_for_uri (file); switch (action->action_type) { case GNOME_VFS_MIME_ACTION_TYPE_APPLICATION: action->action.application = - nautilus_mime_get_default_application_for_uri (directory, file); + nautilus_mime_get_default_application_for_uri (file); if (action->action.application == NULL) { g_free (action); action = NULL; @@ -164,7 +174,7 @@ nautilus_mime_get_default_action_for_uri (NautilusDirectory *directory, break; case GNOME_VFS_MIME_ACTION_TYPE_COMPONENT: action->action.component = - nautilus_mime_get_default_component_for_uri (directory, file); + nautilus_mime_get_default_component_for_uri (file); if (action->action.component == NULL) { g_free (action); action = NULL; @@ -182,8 +192,7 @@ nautilus_mime_get_default_action_for_uri (NautilusDirectory *directory, static GnomeVFSMimeApplication * -nautilus_mime_get_default_application_for_uri_internal (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_get_default_application_for_uri_internal (NautilusFile *file, gboolean *user_chosen) { char *mime_type; @@ -198,7 +207,7 @@ nautilus_mime_get_default_application_for_uri_internal (NautilusDirectory *direc (file, NAUTILUS_METADATA_KEY_DEFAULT_APPLICATION, NULL); if (default_application_string == NULL) { - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); result = gnome_vfs_mime_get_default_application (mime_type); g_free (mime_type); used_user_chosen_info = FALSE; @@ -214,20 +223,18 @@ nautilus_mime_get_default_application_for_uri_internal (NautilusDirectory *direc } GnomeVFSMimeApplication * -nautilus_mime_get_default_application_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_default_application_for_uri (NautilusFile *file) { - return nautilus_mime_get_default_application_for_uri_internal (directory, file, NULL); + return nautilus_mime_get_default_application_for_uri_internal (file, NULL); } gboolean -nautilus_mime_is_default_application_for_uri_user_chosen (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_is_default_application_for_uri_user_chosen (NautilusFile *file) { GnomeVFSMimeApplication *application; gboolean user_chosen; - application = nautilus_mime_get_default_application_for_uri_internal (directory, file, &user_chosen); + application = nautilus_mime_get_default_application_for_uri_internal (file, &user_chosen); /* Doesn't count as user chosen if the user-specified data is bogus and doesn't * result in an actual application. @@ -243,8 +250,7 @@ nautilus_mime_is_default_application_for_uri_user_chosen (NautilusDirectory *dir static OAF_ServerInfo * -nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_get_default_component_for_uri_internal (NautilusFile *file, gboolean *user_chosen) { GList *info_list; @@ -253,8 +259,7 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo char *uri; char *mime_type; char *uri_scheme; - GList *files; - GList *attributes; + GList *item_mime_types; GList *explicit_iids; CORBA_Environment ev; OAF_ServerInfo *server; @@ -269,7 +274,7 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo CORBA_exception_init (&ev); - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); uri = nautilus_file_get_uri (file); @@ -277,14 +282,9 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo g_free (uri); - nautilus_file_wait_for_metadata (file); + nautilus_file_wait_for_mime_action_attributes (file); explicit_iids = get_explicit_content_view_iids_from_metafile (file); - - /* Arrange for all the file attributes we will need. */ - attributes = NULL; - attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE); - files = nautilus_directory_wait_until_ready (directory, attributes); - g_list_free (attributes); + nautilus_file_get_directory_item_mime_types (file, &item_mime_types); default_component_string = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_DEFAULT_COMPONENT, NULL); @@ -318,7 +318,7 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo /* Prefer something from the short list */ - short_list = nautilus_mime_get_short_list_components_for_uri (directory, file); + short_list = nautilus_mime_get_short_list_components_for_uri (file); if (short_list != NULL) { sort_conditions[1] = g_strdup ("has (['"); @@ -358,7 +358,7 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo sort_conditions[4] = NULL; - info_list = nautilus_do_component_query (mime_type, uri_scheme, files, explicit_iids, + info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, explicit_iids, sort_conditions, NULL, &ev); if (ev._major == CORBA_NO_EXCEPTION && info_list != NULL) { @@ -374,7 +374,6 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo return NULL; } - nautilus_file_list_free (files); g_free (sort_conditions[0]); g_free (sort_conditions[1]); g_free (sort_conditions[2]); @@ -395,20 +394,18 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo OAF_ServerInfo * -nautilus_mime_get_default_component_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_default_component_for_uri (NautilusFile *file) { - return nautilus_mime_get_default_component_for_uri_internal (directory, file, NULL); + return nautilus_mime_get_default_component_for_uri_internal (file, NULL); } gboolean -nautilus_mime_is_default_component_for_uri_user_chosen (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_is_default_component_for_uri_user_chosen (NautilusFile *file) { OAF_ServerInfo *component; gboolean user_chosen; - component = nautilus_mime_get_default_component_for_uri_internal (directory, file, &user_chosen); + component = nautilus_mime_get_default_component_for_uri_internal (file, &user_chosen); /* Doesn't count as user chosen if the user-specified data is bogus and doesn't * result in an actual component. @@ -424,8 +421,7 @@ nautilus_mime_is_default_component_for_uri_user_chosen (NautilusDirectory *direc GList * -nautilus_mime_get_short_list_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_short_list_applications_for_uri (NautilusFile *file) { char *mime_type; GList *result; @@ -448,7 +444,7 @@ nautilus_mime_get_short_list_applications_for_uri (NautilusDirectory *directory, NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID); - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); result = gnome_vfs_mime_get_short_list_applications (mime_type); g_free (mime_type); @@ -478,12 +474,12 @@ nautilus_mime_get_short_list_applications_for_uri (NautilusDirectory *directory, } GList * -nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_short_list_components_for_uri (NautilusFile *file) { char *uri; char *mime_type; char *uri_scheme; + GList *item_mime_types; GList *servers; GList *iids; GList *result; @@ -492,8 +488,6 @@ nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, GList *metadata_component_remove_ids; GList *p; OAF_ServerInfo *component; - GList *attributes; - GList *files; GList *explicit_iids; CORBA_Environment ev; char *extra_requirements; @@ -507,15 +501,9 @@ nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, g_free (uri); - nautilus_file_wait_for_metadata (file); + nautilus_file_wait_for_mime_action_attributes (file); explicit_iids = get_explicit_content_view_iids_from_metafile (file); - - /* Arrange for all the file attributes we will need. */ - attributes = NULL; - attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE); - files = nautilus_directory_wait_until_ready (directory, attributes); - g_list_free (attributes); - + nautilus_file_get_directory_item_mime_types (file, &item_mime_types); metadata_component_add_ids = nautilus_file_get_metadata_list (file, @@ -526,7 +514,7 @@ nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_REMOVE, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID); - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); servers = gnome_vfs_mime_get_short_list_components (mime_type); iids = NULL; @@ -571,11 +559,10 @@ nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, } - result = nautilus_do_component_query (mime_type, uri_scheme, files, explicit_iids, NULL, extra_requirements, &ev); + result = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, explicit_iids, NULL, extra_requirements, &ev); g_free (extra_requirements); } - nautilus_file_list_free (files); gnome_vfs_mime_component_list_free (servers); g_list_free (iids); g_free (uri_scheme); @@ -587,21 +574,20 @@ nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, /* FIXME: we should disable this for 1.0 I think */ char * -nautilus_mime_get_short_list_methods_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_short_list_methods_for_uri (NautilusFile *file) { char *mime_type; const char *method; - mime_type = get_mime_type_from_file (file); + nautilus_file_wait_for_metadata (file); + mime_type = nautilus_file_get_slow_mime_type (file); method = gnome_vfs_mime_get_value (mime_type, "vfs-method"); g_free (mime_type); return g_strdup (method); } GList * -nautilus_mime_get_all_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_all_applications_for_uri (NautilusFile *file) { char *mime_type; GList *result; @@ -615,7 +601,7 @@ nautilus_mime_get_all_applications_for_uri (NautilusDirectory *directory, NAUTILUS_METADATA_KEY_EXPLICIT_APPLICATION, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID); - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); result = gnome_vfs_mime_get_all_applications (mime_type); @@ -636,13 +622,12 @@ nautilus_mime_get_all_applications_for_uri (NautilusDirectory *directory, } gboolean -nautilus_mime_has_any_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_has_any_applications_for_uri (NautilusFile *file) { GList *list; gboolean result; - list = nautilus_mime_get_all_applications_for_uri (directory, file); + list = nautilus_mime_get_all_applications_for_uri (file); result = list != NULL; gnome_vfs_mime_application_list_free (list); @@ -650,39 +635,30 @@ nautilus_mime_has_any_applications_for_uri (NautilusDirectory *directory, } GList * -nautilus_mime_get_all_components_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_get_all_components_for_uri (NautilusFile *file) { char *uri; char *mime_type; char *uri_scheme; - GList *files; - GList *attributes; + GList *item_mime_types; GList *info_list; GList *explicit_iids; CORBA_Environment ev; CORBA_exception_init (&ev); - mime_type = get_mime_type_from_file (file); - uri = nautilus_file_get_uri (file); uri_scheme = uri_string_get_scheme (uri); g_free (uri); - nautilus_file_wait_for_metadata (file); - explicit_iids = get_explicit_content_view_iids_from_metafile (file); - - /* Arrange for all the file attributes we will need. */ - attributes = NULL; - attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE); + nautilus_file_wait_for_mime_action_attributes (file); - files = nautilus_directory_wait_until_ready (directory, attributes); - g_list_free (attributes); + mime_type = nautilus_file_get_slow_mime_type (file); + explicit_iids = get_explicit_content_view_iids_from_metafile (file); + nautilus_file_get_directory_item_mime_types (file, &item_mime_types); - info_list = nautilus_do_component_query (mime_type, uri_scheme, files, explicit_iids, NULL, NULL, &ev); + info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, explicit_iids, NULL, NULL, &ev); - nautilus_file_list_free (files); g_free (uri_scheme); g_free (mime_type); CORBA_exception_free (&ev); @@ -691,13 +667,12 @@ nautilus_mime_get_all_components_for_uri (NautilusDirectory *directory, } gboolean -nautilus_mime_has_any_components_for_uri (NautilusDirectory *directory, - NautilusFile *file) +nautilus_mime_has_any_components_for_uri (NautilusFile *file) { GList *list; gboolean result; - list = nautilus_mime_get_all_components_for_uri (directory, file); + list = nautilus_mime_get_all_components_for_uri (file); result = list != NULL; gnome_vfs_mime_component_list_free (list); @@ -705,8 +680,7 @@ nautilus_mime_has_any_components_for_uri (NautilusDirectory *directory, } GnomeVFSResult -nautilus_mime_set_default_action_type_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_set_default_action_type_for_uri (NautilusFile *file, GnomeVFSMimeActionType action_type) { const char *action_string; @@ -731,8 +705,7 @@ nautilus_mime_set_default_action_type_for_uri (NautilusDirectory *directory } GnomeVFSResult -nautilus_mime_set_default_application_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_set_default_application_for_uri (NautilusFile *file, const char *application_id) { nautilus_file_wait_for_metadata (file); @@ -741,16 +714,15 @@ nautilus_mime_set_default_application_for_uri (NautilusDirectory *directory, /* If there's no default action type, set it to match this. */ if (application_id != NULL && - nautilus_mime_get_default_action_type_for_uri (directory, file) == GNOME_VFS_MIME_ACTION_TYPE_NONE) { - return nautilus_mime_set_default_action_type_for_uri (directory, file, GNOME_VFS_MIME_ACTION_TYPE_APPLICATION); + nautilus_mime_get_default_action_type_for_uri (file) == GNOME_VFS_MIME_ACTION_TYPE_NONE) { + return nautilus_mime_set_default_action_type_for_uri (file, GNOME_VFS_MIME_ACTION_TYPE_APPLICATION); } return GNOME_VFS_OK; } GnomeVFSResult -nautilus_mime_set_default_component_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_set_default_component_for_uri (NautilusFile *file, const char *component_iid) { nautilus_file_wait_for_metadata (file); @@ -759,16 +731,15 @@ nautilus_mime_set_default_component_for_uri (NautilusDirectory *directory, /* If there's no default action type, set it to match this. */ if (component_iid != NULL && - nautilus_mime_get_default_action_type_for_uri (directory, file) == GNOME_VFS_MIME_ACTION_TYPE_NONE) { - return nautilus_mime_set_default_action_type_for_uri (directory, file, GNOME_VFS_MIME_ACTION_TYPE_COMPONENT); + nautilus_mime_get_default_action_type_for_uri (file) == GNOME_VFS_MIME_ACTION_TYPE_NONE) { + return nautilus_mime_set_default_action_type_for_uri (file, GNOME_VFS_MIME_ACTION_TYPE_COMPONENT); } return GNOME_VFS_OK; } GnomeVFSResult -nautilus_mime_set_short_list_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_set_short_list_applications_for_uri (NautilusFile *file, GList *applications) { GList *add_list; @@ -780,7 +751,7 @@ nautilus_mime_set_short_list_applications_for_uri (NautilusDirectory *directory, /* get per-mime short list */ - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); normal_short_list = gnome_vfs_mime_get_short_list_applications (mime_type); g_free (mime_type); @@ -814,8 +785,7 @@ nautilus_mime_set_short_list_applications_for_uri (NautilusDirectory *directory, } GnomeVFSResult -nautilus_mime_set_short_list_components_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_set_short_list_components_for_uri (NautilusFile *file, GList *components) { GList *add_list; @@ -827,7 +797,7 @@ nautilus_mime_set_short_list_components_for_uri (NautilusDirectory *directory, /* get per-mime short list */ - mime_type = get_mime_type_from_file (file); + mime_type = nautilus_file_get_slow_mime_type (file); normal_short_list = gnome_vfs_mime_get_short_list_components (mime_type); g_free (mime_type); @@ -861,8 +831,7 @@ nautilus_mime_set_short_list_components_for_uri (NautilusDirectory *directory, } GnomeVFSResult -nautilus_mime_add_application_to_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_add_application_to_short_list_for_uri (NautilusFile *file, const char *application_id) { GList *old_list, *new_list; @@ -870,12 +839,12 @@ nautilus_mime_add_application_to_short_list_for_uri (NautilusDirectory *director result = GNOME_VFS_OK; - old_list = nautilus_mime_get_short_list_applications_for_uri (directory, file); + old_list = nautilus_mime_get_short_list_applications_for_uri (file); if (!gnome_vfs_mime_id_in_application_list (application_id, old_list)) { new_list = g_list_append (gnome_vfs_mime_id_list_from_application_list (old_list), g_strdup (application_id)); - result = nautilus_mime_set_short_list_applications_for_uri (directory, file, new_list); + result = nautilus_mime_set_short_list_applications_for_uri (file, new_list); nautilus_g_list_free_deep (new_list); } @@ -885,15 +854,14 @@ nautilus_mime_add_application_to_short_list_for_uri (NautilusDirectory *director } GnomeVFSResult -nautilus_mime_remove_application_from_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_remove_application_from_short_list_for_uri (NautilusFile *file, const char *application_id) { GList *old_list, *new_list; gboolean was_in_list; GnomeVFSResult result; - old_list = nautilus_mime_get_short_list_applications_for_uri (directory, file); + old_list = nautilus_mime_get_short_list_applications_for_uri (file); old_list = gnome_vfs_mime_remove_application_from_list (old_list, application_id, &was_in_list); @@ -901,7 +869,7 @@ nautilus_mime_remove_application_from_short_list_for_uri (NautilusDirectory *dir result = GNOME_VFS_OK; } else { new_list = gnome_vfs_mime_id_list_from_application_list (old_list); - result = nautilus_mime_set_short_list_applications_for_uri (directory, file, new_list); + result = nautilus_mime_set_short_list_applications_for_uri (file, new_list); nautilus_g_list_free_deep (new_list); } @@ -911,21 +879,20 @@ nautilus_mime_remove_application_from_short_list_for_uri (NautilusDirectory *dir } GnomeVFSResult -nautilus_mime_add_component_to_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_add_component_to_short_list_for_uri (NautilusFile *file, const char *iid) { GList *old_list, *new_list; GnomeVFSResult result; - old_list = nautilus_mime_get_short_list_components_for_uri (directory, file); + old_list = nautilus_mime_get_short_list_components_for_uri (file); if (gnome_vfs_mime_id_in_component_list (iid, old_list)) { result = GNOME_VFS_OK; } else { new_list = g_list_append (gnome_vfs_mime_id_list_from_component_list (old_list), g_strdup (iid)); - result = nautilus_mime_set_short_list_components_for_uri (directory, file, new_list); + result = nautilus_mime_set_short_list_components_for_uri (file, new_list); nautilus_g_list_free_deep (new_list); } @@ -935,15 +902,14 @@ nautilus_mime_add_component_to_short_list_for_uri (NautilusDirectory *directory, } GnomeVFSResult -nautilus_mime_remove_component_from_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_remove_component_from_short_list_for_uri (NautilusFile *file, const char *iid) { GList *old_list, *new_list; gboolean was_in_list; GnomeVFSResult result; - old_list = nautilus_mime_get_short_list_components_for_uri (directory, file); + old_list = nautilus_mime_get_short_list_components_for_uri (file); old_list = gnome_vfs_mime_remove_component_from_list (old_list, iid, &was_in_list); @@ -951,7 +917,7 @@ nautilus_mime_remove_component_from_short_list_for_uri (NautilusDirectory *direc result = GNOME_VFS_OK; } else { new_list = gnome_vfs_mime_id_list_from_component_list (old_list); - result = nautilus_mime_set_short_list_components_for_uri (directory, file, new_list); + result = nautilus_mime_set_short_list_components_for_uri (file, new_list); nautilus_g_list_free_deep (new_list); } @@ -961,8 +927,7 @@ nautilus_mime_remove_component_from_short_list_for_uri (NautilusDirectory *direc } GnomeVFSResult -nautilus_mime_extend_all_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_extend_all_applications_for_uri (NautilusFile *file, GList *applications) { GList *metadata_application_ids; @@ -990,8 +955,7 @@ nautilus_mime_extend_all_applications_for_uri (NautilusDirectory *directory, } GnomeVFSResult -nautilus_mime_remove_from_all_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file, +nautilus_mime_remove_from_all_applications_for_uri (NautilusFile *file, GList *applications) { GList *metadata_application_ids; @@ -1089,7 +1053,7 @@ uri_string_get_scheme (const char *uri_string) * The following routine uses metadata associated with the current url * to add content view components specified in the metadata. The * content views are specified in the string as <EXPLICIT_CONTENT_VIEW - * IID="iid"/> elements inside the appropriate <DIRECTORY> or <FILE> element. + * IID="iid"/> elements inside the appropriate <FILE> element. */ static GList * @@ -1316,7 +1280,7 @@ make_oaf_query_with_uri_scheme_only (const char *uri_scheme, static GHashTable * -file_list_to_mime_type_hash_table (GList *files) +mime_type_list_to_hash_table (GList *types) { GHashTable *result; GList *p; @@ -1324,20 +1288,16 @@ file_list_to_mime_type_hash_table (GList *files) result = g_hash_table_new (g_str_hash, g_str_equal); - for (p = files; p != NULL; p = p->next) { + for (p = types; p != NULL; p = p->next) { if (p->data != NULL) { - mime_type = nautilus_file_get_mime_type ((NautilusFile *) p->data); + mime_type = (char *) (p->data); - if (NULL != mime_type) { - if (g_hash_table_lookup (result, mime_type) == NULL) { + if (g_hash_table_lookup (result, mime_type) == NULL) { #ifdef DEBUG_MJS - printf ("XXX content mime type: %s\n", mime_type); + printf ("XXX content mime type: %s\n", mime_type); #endif - g_hash_table_insert (result, mime_type, mime_type); - } else { - g_free (mime_type); - } - } + g_hash_table_insert (result, g_strdup (mime_type), mime_type); + } } } @@ -1415,7 +1375,7 @@ static char *nautilus_sort_criteria[] = { static GList * nautilus_do_component_query (const char *mime_type, const char *uri_scheme, - GList *files, + GList *item_mime_types, GList *explicit_iids, char **extra_sort_criteria, char *extra_requirements, @@ -1452,7 +1412,7 @@ nautilus_do_component_query (const char *mime_type, GHashTable *content_types; int i; - content_types = file_list_to_mime_type_hash_table (files); + content_types = mime_type_list_to_hash_table (item_mime_types); for (i = 0; i < oaf_result->_length; i++) { OAF_ServerInfo *server; @@ -1495,34 +1455,6 @@ str_list_difference (GList *a, } -static char * -get_mime_type_from_file (NautilusFile *file) -{ - char *type; - GList *file_attributes; - - type = NULL; - - /* FIXME bugzilla.eazel.com 1263: - A better way would be to get this info using - NautilusFile or NautilusDirectory or something, having - previously ensured that the info has been computed - async. */ - - if (file != NULL) { - file_attributes = g_list_append (NULL, NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE); - - nautilus_file_wait_until_ready (file, - file_attributes); - - g_list_free (file_attributes); - - type = nautilus_file_get_slow_mime_type (file); - } - - return type == NULL ? g_strdup ("application/octet-stream") : type; -} - static int strv_length (char **a) { diff --git a/libnautilus-private/nautilus-mime-actions.h b/libnautilus-private/nautilus-mime-actions.h index e6dc87cd5..b24a6c14f 100644 --- a/libnautilus-private/nautilus-mime-actions.h +++ b/libnautilus-private/nautilus-mime-actions.h @@ -27,76 +27,48 @@ #include <libgnomevfs/gnome-vfs-mime-handlers.h> -#include <libnautilus-extensions/nautilus-directory.h> #include <libnautilus-extensions/nautilus-file.h> -/* FIXME: This API requires passing both a NautilusDirectory and a - NautilusFile for the same URI, because it requires both the mime type - and the metadata for the location. */ -GnomeVFSMimeActionType nautilus_mime_get_default_action_type_for_uri (NautilusDirectory *directory, - NautilusFile *file); -GnomeVFSMimeAction * nautilus_mime_get_default_action_for_uri (NautilusDirectory *directory, - NautilusFile *file); -GnomeVFSMimeApplication *nautilus_mime_get_default_application_for_uri (NautilusDirectory *directory, - NautilusFile *file); -gboolean nautilus_mime_is_default_application_for_uri_user_chosen (NautilusDirectory *directory, - NautilusFile *file); -OAF_ServerInfo * nautilus_mime_get_default_component_for_uri (NautilusDirectory *directory, - NautilusFile *file); -gboolean nautilus_mime_is_default_component_for_uri_user_chosen (NautilusDirectory *directory, - NautilusFile *file); -GList * nautilus_mime_get_short_list_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file); -GList * nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, - NautilusFile *file); -gchar * nautilus_mime_get_short_list_methods_for_uri (NautilusDirectory *directory, - NautilusFile *file); -GList * nautilus_mime_get_all_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file); -GList * nautilus_mime_get_all_components_for_uri (NautilusDirectory *directory, - NautilusFile *file); -gboolean nautilus_mime_has_any_components_for_uri (NautilusDirectory *directory, - NautilusFile *file); -gboolean nautilus_mime_has_any_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file); -GnomeVFSResult nautilus_mime_set_default_action_type_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSMimeActionType nautilus_mime_get_default_action_type_for_uri (NautilusFile *file); +GnomeVFSMimeAction * nautilus_mime_get_default_action_for_uri (NautilusFile *file); +GnomeVFSMimeApplication *nautilus_mime_get_default_application_for_uri (NautilusFile *file); +gboolean nautilus_mime_is_default_application_for_uri_user_chosen (NautilusFile *file); +OAF_ServerInfo * nautilus_mime_get_default_component_for_uri (NautilusFile *file); +gboolean nautilus_mime_is_default_component_for_uri_user_chosen (NautilusFile *file); +GList * nautilus_mime_get_short_list_applications_for_uri (NautilusFile *file); +GList * nautilus_mime_get_short_list_components_for_uri (NautilusFile *file); +gchar * nautilus_mime_get_short_list_methods_for_uri (NautilusFile *file); +GList * nautilus_mime_get_all_applications_for_uri (NautilusFile *file); +GList * nautilus_mime_get_all_components_for_uri (NautilusFile *file); +gboolean nautilus_mime_has_any_components_for_uri (NautilusFile *file); +gboolean nautilus_mime_has_any_applications_for_uri (NautilusFile *file); +GnomeVFSResult nautilus_mime_set_default_action_type_for_uri (NautilusFile *file, GnomeVFSMimeActionType action_type); -GnomeVFSResult nautilus_mime_set_default_application_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_set_default_application_for_uri (NautilusFile *file, const char *application_id); -GnomeVFSResult nautilus_mime_set_default_component_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_set_default_component_for_uri (NautilusFile *file, const char *component_iid); /* Stored as delta to current user level */ -GnomeVFSResult nautilus_mime_set_short_list_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file, - GList *applications); -GnomeVFSResult nautilus_mime_set_short_list_components_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_set_short_list_applications_for_uri (NautilusFile *file, GList *components); -GnomeVFSResult nautilus_mime_add_application_to_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_add_application_to_short_list_for_uri (NautilusFile *file, const char *application_id); -GnomeVFSResult nautilus_mime_remove_application_from_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_remove_application_from_short_list_for_uri (NautilusFile *file, const char *application_id); -GnomeVFSResult nautilus_mime_add_component_to_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_set_short_list_components_for_uri (NautilusFile *file, + GList *components); +GnomeVFSResult nautilus_mime_add_component_to_short_list_for_uri (NautilusFile *file, const char *iid); -GnomeVFSResult nautilus_mime_remove_component_from_short_list_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_remove_component_from_short_list_for_uri (NautilusFile *file, const char *iid); /* No way to override system list; can only add. */ -GnomeVFSResult nautilus_mime_extend_all_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_extend_all_applications_for_uri (NautilusFile *file, GList *applications); /* Only "user" entries may be removed. */ -GnomeVFSResult nautilus_mime_remove_from_all_applications_for_uri (NautilusDirectory *directory, - NautilusFile *file, +GnomeVFSResult nautilus_mime_remove_from_all_applications_for_uri (NautilusFile *file, GList *applications); /* No way to add to all components; oafinfo database assumed trusted in this regard. */ diff --git a/libnautilus-private/nautilus-program-chooser.c b/libnautilus-private/nautilus-program-chooser.c index 48fe6a5b7..f00b1db67 100644 --- a/libnautilus-private/nautilus-program-chooser.c +++ b/libnautilus-private/nautilus-program-chooser.c @@ -311,7 +311,6 @@ repopulate_program_list (GnomeDialog *program_chooser, { char **text; char *uri; - NautilusDirectory *directory; GList *programs, *program; ProgramFilePair *pair; int new_row; @@ -323,13 +322,11 @@ repopulate_program_list (GnomeDialog *program_chooser, || type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION); uri = nautilus_file_get_uri (file); - directory = nautilus_directory_get (uri); g_free (uri); programs = type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT - ? nautilus_mime_get_all_components_for_uri (directory, file) - : nautilus_mime_get_all_applications_for_uri (directory, file); - nautilus_directory_unref (directory); + ? nautilus_mime_get_all_components_for_uri (file) + : nautilus_mime_get_all_applications_for_uri (file); gtk_clist_clear (clist); @@ -489,16 +486,13 @@ is_application_default_for_uri (GnomeVFSMimeApplication *application, const char GnomeVFSMimeApplication *default_application; gboolean result; NautilusFile *file; - NautilusDirectory *directory; g_assert (application != NULL); file = nautilus_file_get (uri); - directory = nautilus_directory_get (uri); - default_application = nautilus_mime_get_default_application_for_uri (directory, file); + default_application = nautilus_mime_get_default_application_for_uri (file); result = (default_application != NULL && strcmp (default_application->id, application->id) == 0); - nautilus_directory_unref (directory); nautilus_file_unref (file); gnome_vfs_mime_application_free (default_application); @@ -511,18 +505,15 @@ is_component_default_for_uri (NautilusViewIdentifier *identifier, const char *ur { OAF_ServerInfo *default_component; gboolean result; - NautilusDirectory *directory; NautilusFile *file; g_assert (identifier != NULL); - directory = nautilus_directory_get (uri); file = nautilus_file_get (uri); - default_component = nautilus_mime_get_default_component_for_uri (directory, file); + default_component = nautilus_mime_get_default_component_for_uri (file); result = (default_component != NULL && strcmp (default_component->iid, identifier->iid) == 0); - nautilus_directory_unref (directory); nautilus_file_unref (file); CORBA_free (default_component); @@ -551,13 +542,11 @@ is_component_in_short_list_for_uri (NautilusViewIdentifier *identifier, const ch { GList *list; gboolean result; - NautilusDirectory *directory; NautilusFile *file; - directory = nautilus_directory_get (uri); file = nautilus_file_get (uri); - list = nautilus_mime_get_short_list_components_for_uri (directory, file); + list = nautilus_mime_get_short_list_components_for_uri (file); result = g_list_find_custom (list, identifier, (GCompareFunc)compare_component_with_view) @@ -565,7 +554,6 @@ is_component_in_short_list_for_uri (NautilusViewIdentifier *identifier, const ch gnome_vfs_mime_component_list_free (list); nautilus_file_unref (file); - nautilus_directory_unref (directory); return result; } @@ -591,14 +579,12 @@ is_application_in_short_list_for_uri (GnomeVFSMimeApplication *application, cons { GList *list; gboolean result; - NautilusDirectory *directory; NautilusFile *file; - directory = nautilus_directory_get (uri); file = nautilus_file_get (uri); - list = nautilus_mime_get_short_list_applications_for_uri (directory, file); + list = nautilus_mime_get_short_list_applications_for_uri (file); result = g_list_find_custom (list, application, (GCompareFunc)compare_mime_applications) @@ -606,7 +592,6 @@ is_application_in_short_list_for_uri (GnomeVFSMimeApplication *application, cons gnome_vfs_mime_application_list_free (list); - nautilus_directory_unref (directory); nautilus_file_unref (file); return result; @@ -643,20 +628,16 @@ program_file_pair_is_default_for_file (ProgramFilePair *pair) { char *uri; gboolean result; - NautilusDirectory *directory; g_assert (pair != NULL); g_assert (NAUTILUS_IS_FILE (pair->file)); uri = nautilus_file_get_uri (pair->file); - directory = nautilus_directory_get (uri); - if (pair->action_type != nautilus_mime_get_default_action_type_for_uri (directory, pair->file)) { + if (pair->action_type != nautilus_mime_get_default_action_type_for_uri (pair->file)) { return FALSE; } - nautilus_directory_unref (directory); - if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT) { result = is_component_default_for_uri (pair->view_identifier, uri); } else { @@ -819,18 +800,15 @@ static void add_to_short_list_for_file (ProgramFilePair *pair) { char *uri; - NautilusDirectory *directory; uri = nautilus_file_get_uri (pair->file); - directory = nautilus_directory_get (uri); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { - nautilus_mime_add_application_to_short_list_for_uri (directory, pair->file, pair->application->id); + nautilus_mime_add_application_to_short_list_for_uri (pair->file, pair->application->id); } else { - nautilus_mime_add_component_to_short_list_for_uri (directory, pair->file, pair->view_identifier->iid); + nautilus_mime_add_component_to_short_list_for_uri (pair->file, pair->view_identifier->iid); } - nautilus_directory_unref (directory); g_free (uri); } @@ -838,18 +816,15 @@ static void remove_from_short_list_for_file (ProgramFilePair *pair) { char *uri; - NautilusDirectory *directory; uri = nautilus_file_get_uri (pair->file); - directory = nautilus_directory_get (uri); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { - nautilus_mime_remove_application_from_short_list_for_uri (directory, pair->file, pair->application->id); + nautilus_mime_remove_application_from_short_list_for_uri (pair->file, pair->application->id); } else { - nautilus_mime_remove_component_from_short_list_for_uri (directory, pair->file, pair->view_identifier->iid); + nautilus_mime_remove_component_from_short_list_for_uri (pair->file, pair->view_identifier->iid); } - nautilus_directory_unref (directory); g_free (uri); } @@ -909,32 +884,29 @@ static void remove_default_for_item (ProgramFilePair *pair) { char *uri; - NautilusDirectory *directory; uri = nautilus_file_get_uri (pair->file); - directory = nautilus_directory_get (uri); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { /* If the default is just falling through to the default for this type, * don't do anything here. */ - if (nautilus_mime_is_default_application_for_uri_user_chosen (directory, pair->file)) { + if (nautilus_mime_is_default_application_for_uri_user_chosen (pair->file)) { if (is_application_default_for_uri (pair->application, uri)) { - nautilus_mime_set_default_application_for_uri (directory, pair->file, NULL); + nautilus_mime_set_default_application_for_uri (pair->file, NULL); } } } else { /* If the default is just falling through to the default for this type, * don't do anything here. */ - if (nautilus_mime_is_default_component_for_uri_user_chosen (directory, pair->file)) { + if (nautilus_mime_is_default_component_for_uri_user_chosen (pair->file)) { if (is_component_default_for_uri (pair->view_identifier, uri)) { - nautilus_mime_set_default_component_for_uri (directory, pair->file, NULL); + nautilus_mime_set_default_component_for_uri (pair->file, NULL); } } } - nautilus_directory_unref (directory); g_free (uri); } @@ -960,22 +932,19 @@ static void set_default_for_item (ProgramFilePair *pair) { char *uri; - NautilusDirectory *directory; uri = nautilus_file_get_uri (pair->file); - directory = nautilus_directory_get (uri); uri = nautilus_file_get_uri (pair->file); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { - nautilus_mime_set_default_application_for_uri (directory, pair->file, pair->application->id); + nautilus_mime_set_default_application_for_uri (pair->file, pair->application->id); } else { - nautilus_mime_set_default_component_for_uri (directory, pair->file, pair->view_identifier->iid); + nautilus_mime_set_default_component_for_uri (pair->file, pair->view_identifier->iid); } - nautilus_mime_set_default_action_type_for_uri (directory, pair->file, pair->action_type); + nautilus_mime_set_default_action_type_for_uri (pair->file, pair->action_type); - nautilus_directory_unref (directory); g_free (uri); } diff --git a/libnautilus-private/nautilus-program-choosing.c b/libnautilus-private/nautilus-program-choosing.c index d77694e74..d3c4f3ddc 100644 --- a/libnautilus-private/nautilus-program-choosing.c +++ b/libnautilus-private/nautilus-program-choosing.c @@ -41,19 +41,16 @@ any_programs_available_for_file (GnomeVFSMimeActionType action_type, NautilusFil { gboolean result; char *uri; - NautilusDirectory *directory; uri = nautilus_file_get_uri (file); - directory = nautilus_directory_get (uri); if (action_type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT) { - result = nautilus_mime_has_any_components_for_uri (directory, file); + result = nautilus_mime_has_any_components_for_uri (file); } else { g_assert (action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION); - result = nautilus_mime_has_any_applications_for_uri (directory, file); + result = nautilus_mime_has_any_applications_for_uri (file); } - nautilus_directory_unref (directory); g_free (uri); return result; diff --git a/libnautilus-private/nautilus-wait-until-ready.h b/libnautilus-private/nautilus-wait-until-ready.h index e6fe2610b..640e6c6b1 100644 --- a/libnautilus-private/nautilus-wait-until-ready.h +++ b/libnautilus-private/nautilus-wait-until-ready.h @@ -23,6 +23,11 @@ * Authors: Maciej Stachowiak */ +#include <glib.h> +#include <libnautilus-extensions/nautilus-file.h> +#include <libnautilus-extensions/nautilus-directory.h> + + /* nautilus-wait-until-ready.h: I'm adding this file as a temporary * measure in the process of eliminating the wait_until_ready calls. It * is deprecated! Do not use these calls in new code! diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 5e10954d8..bc5a83cab 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -565,14 +565,12 @@ switch_location_and_view (NautilusViewIdentifier *identifier, const char *new_uri, FMDirectoryView *directory_view) { - NautilusDirectory *directory; NautilusFile *file; g_assert (FM_IS_DIRECTORY_VIEW (directory_view)); g_assert (identifier != NULL); g_assert (new_uri != NULL); - directory = nautilus_directory_get (new_uri); file = nautilus_file_get (new_uri); /* User has explicitly chosen a viewer other than the default, so @@ -582,9 +580,8 @@ switch_location_and_view (NautilusViewIdentifier *identifier, * for switching location and viewer together, so we don't have to * rely on metadata for holding the default location. */ - nautilus_mime_set_default_component_for_uri (directory, file, identifier->iid); + nautilus_mime_set_default_component_for_uri (file, identifier->iid); - nautilus_directory_unref (directory); nautilus_file_unref (file); fm_directory_view_switch_location @@ -1716,8 +1713,8 @@ queue_pending_files (FMDirectoryView *view, static void files_added_callback (NautilusDirectory *directory, - GList *files, - gpointer callback_data) + GList *files, + gpointer callback_data) { FMDirectoryView *view; @@ -1727,8 +1724,8 @@ files_added_callback (NautilusDirectory *directory, static void files_changed_callback (NautilusDirectory *directory, - GList *files, - gpointer callback_data) + GList *files, + gpointer callback_data) { FMDirectoryView *view; @@ -2916,7 +2913,6 @@ create_open_with_gtk_menu (FMDirectoryView *view, GList *files) GList *applications, *components; GList *node; char *uri; - NautilusDirectory *directory; open_with_menu = GTK_MENU (gtk_menu_new ()); gtk_widget_show (GTK_WIDGET (open_with_menu)); @@ -2925,9 +2921,7 @@ create_open_with_gtk_menu (FMDirectoryView *view, GList *files) if (nautilus_g_list_exactly_one_item (files)) { uri = nautilus_file_get_uri (NAUTILUS_FILE (files->data)); - directory = nautilus_directory_get (uri); - - applications = nautilus_mime_get_short_list_applications_for_uri (directory, NAUTILUS_FILE (files->data)); + applications = nautilus_mime_get_short_list_applications_for_uri (NAUTILUS_FILE (files->data)); for (node = applications; node != NULL; node = node->next) { add_application_to_gtk_menu (view, open_with_menu, node->data, uri); } @@ -2942,14 +2936,13 @@ create_open_with_gtk_menu (FMDirectoryView *view, GList *files) nautilus_gtk_menu_append_separator (open_with_menu); - components = nautilus_mime_get_short_list_components_for_uri (directory, NAUTILUS_FILE (files->data)); + components = nautilus_mime_get_short_list_components_for_uri (NAUTILUS_FILE (files->data)); for (node = components; node != NULL; node = node->next) { add_component_to_gtk_menu (view, open_with_menu, node->data, uri); } gnome_vfs_mime_component_list_free (components); - nautilus_directory_unref (directory); g_free (uri); append_gtk_menu_item (view, @@ -3183,7 +3176,6 @@ reset_bonobo_open_with_menu (FMDirectoryView *view, GList *selection) GList *applications, *components; GList *node; char *uri; - NautilusDirectory *directory; int index; /* Clear any previous inserted items in the applications and viewers placeholders */ @@ -3194,9 +3186,8 @@ reset_bonobo_open_with_menu (FMDirectoryView *view, GList *selection) /* This menu is only displayed when there's one selected item. */ if (nautilus_g_list_exactly_one_item (selection)) { uri = nautilus_file_get_uri (NAUTILUS_FILE (selection->data)); - directory = nautilus_directory_get (uri); - applications = nautilus_mime_get_short_list_applications_for_uri (directory, NAUTILUS_FILE (selection->data)); + applications = nautilus_mime_get_short_list_applications_for_uri (NAUTILUS_FILE (selection->data)); for (node = applications, index = 0; node != NULL; node = node->next, index++) { add_application_to_bonobo_menu (view, node->data, uri, index); @@ -3204,7 +3195,7 @@ reset_bonobo_open_with_menu (FMDirectoryView *view, GList *selection) gnome_vfs_mime_application_list_free (applications); - components = nautilus_mime_get_short_list_components_for_uri (directory, NAUTILUS_FILE (selection->data)); + components = nautilus_mime_get_short_list_components_for_uri (NAUTILUS_FILE (selection->data)); for (node = components, index = 0; node != NULL; node = node->next, index++) { add_component_to_bonobo_menu (view, node->data, uri, index); @@ -3212,8 +3203,6 @@ reset_bonobo_open_with_menu (FMDirectoryView *view, GList *selection) gnome_vfs_mime_component_list_free (components); - nautilus_directory_unref (directory); - g_free (uri); } @@ -3527,7 +3516,6 @@ activate_callback (NautilusFile *file, gpointer callback_data) GnomeVFSMimeActionType action_type; GnomeVFSMimeApplication *application; gboolean performed_special_handling; - NautilusDirectory *directory; parameters = callback_data; @@ -3585,10 +3573,8 @@ activate_callback (NautilusFile *file, gpointer callback_data) } if (!performed_special_handling) { - directory = nautilus_directory_get (uri); - - action_type = nautilus_mime_get_default_action_type_for_uri (directory, file); - application = nautilus_mime_get_default_application_for_uri (directory, file); + action_type = nautilus_mime_get_default_action_type_for_uri (file); + application = nautilus_mime_get_default_application_for_uri (file); /* We need to check for the case of having * GNOME_VFS_MIME_ACTION_TYPE_APPLICATION as the @@ -3617,8 +3603,6 @@ activate_callback (NautilusFile *file, gpointer callback_data) if (application != NULL) { gnome_vfs_mime_application_free (application); } - - nautilus_directory_unref (directory); } g_free (uri); diff --git a/src/nautilus-applicable-views.c b/src/nautilus-applicable-views.c index 8ad7b0401..3592faa19 100644 --- a/src/nautilus-applicable-views.c +++ b/src/nautilus-applicable-views.c @@ -116,7 +116,7 @@ got_file_info_callback (NautilusFile *file, goto out; } - default_component = nautilus_mime_get_default_component_for_uri (navinfo->directory, navinfo->file); + default_component = nautilus_mime_get_default_component_for_uri (navinfo->file); if (default_component != NULL) { default_id = nautilus_view_identifier_new_from_content_view (default_component); CORBA_free (default_component); @@ -134,7 +134,7 @@ got_file_info_callback (NautilusFile *file, /* Map GnomeVFSResult to one of the types that Nautilus knows how to handle. */ if (vfs_result_code == GNOME_VFS_OK && default_id == NULL) { /* If the complete list is non-empty, the default shouldn't have been NULL */ - g_assert (!nautilus_mime_has_any_components_for_uri (navinfo->directory, navinfo->file)); + g_assert (!nautilus_mime_has_any_components_for_uri (navinfo->file)); result_code = NAUTILUS_NAVIGATION_RESULT_NO_HANDLER_FOR_TYPE; } diff --git a/src/nautilus-information-panel.c b/src/nautilus-information-panel.c index 13c1995bd..30e1cad37 100644 --- a/src/nautilus-information-panel.c +++ b/src/nautilus-information-panel.c @@ -1276,7 +1276,6 @@ nautilus_sidebar_update_buttons (NautilusSidebar *sidebar) { char *button_data; GList *short_application_list; - NautilusDirectory *directory; /* dispose of any existing buttons */ if (sidebar->details->has_buttons) { @@ -1299,11 +1298,9 @@ nautilus_sidebar_update_buttons (NautilusSidebar *sidebar) * unless there aren't any applications at all in complete list. */ - directory = nautilus_directory_get (sidebar->details->uri); - - if (nautilus_mime_has_any_applications_for_uri (directory, sidebar->details->file)) { + if (nautilus_mime_has_any_applications_for_uri (sidebar->details->file)) { short_application_list = - nautilus_mime_get_short_list_applications_for_uri (directory, sidebar->details->file); + nautilus_mime_get_short_list_applications_for_uri (sidebar->details->file); add_command_buttons (sidebar, short_application_list); gnome_vfs_mime_application_list_free (short_application_list); @@ -1315,8 +1312,6 @@ nautilus_sidebar_update_buttons (NautilusSidebar *sidebar) gtk_widget_show (GTK_WIDGET (sidebar->details->button_box_centerer)); } } - - nautilus_directory_unref (directory); } void diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index 32447dd59..2834c73db 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -925,7 +925,6 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) GtkWidget *new_menu; GtkWidget *menu_item; char *label; - NautilusDirectory *directory; NautilusFile *file; g_return_if_fail (NAUTILUS_IS_WINDOW (window)); @@ -934,9 +933,8 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) new_menu = gtk_menu_new (); file = nautilus_file_get (window->location); - directory = nautilus_directory_get (window->location); /* Add a menu item for each view in the preferred list for this location. */ - components = nautilus_mime_get_short_list_components_for_uri (directory, file); + components = nautilus_mime_get_short_list_components_for_uri (file); for (p = components; p != NULL; p = p->next) { menu_item = create_content_view_menu_item (window, nautilus_view_identifier_new_from_content_view (p->data)); @@ -949,7 +947,7 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) * one way trip if you choose one of these view menu items, but * it's better than nothing. */ - method = nautilus_mime_get_short_list_methods_for_uri (directory, file); + method = nautilus_mime_get_short_list_methods_for_uri (file); /* FIXME bugzilla.eazel.com 2466: Name of the function is plural, but it returns only * one item. That must be fixed. */ @@ -992,7 +990,6 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) new_menu); - nautilus_directory_unref (directory); nautilus_file_unref (file); nautilus_window_synch_content_view_menu (window); diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c index 32447dd59..2834c73db 100644 --- a/src/nautilus-object-window.c +++ b/src/nautilus-object-window.c @@ -925,7 +925,6 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) GtkWidget *new_menu; GtkWidget *menu_item; char *label; - NautilusDirectory *directory; NautilusFile *file; g_return_if_fail (NAUTILUS_IS_WINDOW (window)); @@ -934,9 +933,8 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) new_menu = gtk_menu_new (); file = nautilus_file_get (window->location); - directory = nautilus_directory_get (window->location); /* Add a menu item for each view in the preferred list for this location. */ - components = nautilus_mime_get_short_list_components_for_uri (directory, file); + components = nautilus_mime_get_short_list_components_for_uri (file); for (p = components; p != NULL; p = p->next) { menu_item = create_content_view_menu_item (window, nautilus_view_identifier_new_from_content_view (p->data)); @@ -949,7 +947,7 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) * one way trip if you choose one of these view menu items, but * it's better than nothing. */ - method = nautilus_mime_get_short_list_methods_for_uri (directory, file); + method = nautilus_mime_get_short_list_methods_for_uri (file); /* FIXME bugzilla.eazel.com 2466: Name of the function is plural, but it returns only * one item. That must be fixed. */ @@ -992,7 +990,6 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) new_menu); - nautilus_directory_unref (directory); nautilus_file_unref (file); nautilus_window_synch_content_view_menu (window); diff --git a/src/nautilus-sidebar.c b/src/nautilus-sidebar.c index 13c1995bd..30e1cad37 100644 --- a/src/nautilus-sidebar.c +++ b/src/nautilus-sidebar.c @@ -1276,7 +1276,6 @@ nautilus_sidebar_update_buttons (NautilusSidebar *sidebar) { char *button_data; GList *short_application_list; - NautilusDirectory *directory; /* dispose of any existing buttons */ if (sidebar->details->has_buttons) { @@ -1299,11 +1298,9 @@ nautilus_sidebar_update_buttons (NautilusSidebar *sidebar) * unless there aren't any applications at all in complete list. */ - directory = nautilus_directory_get (sidebar->details->uri); - - if (nautilus_mime_has_any_applications_for_uri (directory, sidebar->details->file)) { + if (nautilus_mime_has_any_applications_for_uri (sidebar->details->file)) { short_application_list = - nautilus_mime_get_short_list_applications_for_uri (directory, sidebar->details->file); + nautilus_mime_get_short_list_applications_for_uri (sidebar->details->file); add_command_buttons (sidebar, short_application_list); gnome_vfs_mime_application_list_free (short_application_list); @@ -1315,8 +1312,6 @@ nautilus_sidebar_update_buttons (NautilusSidebar *sidebar) gtk_widget_show (GTK_WIDGET (sidebar->details->button_box_centerer)); } } - - nautilus_directory_unref (directory); } void diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c index 32447dd59..2834c73db 100644 --- a/src/nautilus-spatial-window.c +++ b/src/nautilus-spatial-window.c @@ -925,7 +925,6 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) GtkWidget *new_menu; GtkWidget *menu_item; char *label; - NautilusDirectory *directory; NautilusFile *file; g_return_if_fail (NAUTILUS_IS_WINDOW (window)); @@ -934,9 +933,8 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) new_menu = gtk_menu_new (); file = nautilus_file_get (window->location); - directory = nautilus_directory_get (window->location); /* Add a menu item for each view in the preferred list for this location. */ - components = nautilus_mime_get_short_list_components_for_uri (directory, file); + components = nautilus_mime_get_short_list_components_for_uri (file); for (p = components; p != NULL; p = p->next) { menu_item = create_content_view_menu_item (window, nautilus_view_identifier_new_from_content_view (p->data)); @@ -949,7 +947,7 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) * one way trip if you choose one of these view menu items, but * it's better than nothing. */ - method = nautilus_mime_get_short_list_methods_for_uri (directory, file); + method = nautilus_mime_get_short_list_methods_for_uri (file); /* FIXME bugzilla.eazel.com 2466: Name of the function is plural, but it returns only * one item. That must be fixed. */ @@ -992,7 +990,6 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) new_menu); - nautilus_directory_unref (directory); nautilus_file_unref (file); nautilus_window_synch_content_view_menu (window); diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c index 94799c698..4918d95ae 100644 --- a/src/nautilus-window-manage-views.c +++ b/src/nautilus-window-manage-views.c @@ -1461,7 +1461,6 @@ nautilus_window_stop_loading (NautilusWindow *window) void nautilus_window_set_content_view (NautilusWindow *window, NautilusViewIdentifier *id) { - NautilusDirectory *directory; NautilusFile *file; NautilusViewFrame *view; @@ -1469,12 +1468,10 @@ nautilus_window_set_content_view (NautilusWindow *window, NautilusViewIdentifier g_return_if_fail (window->location != NULL); g_return_if_fail (id != NULL); - directory = nautilus_directory_get (window->location); file = nautilus_file_get (window->location); - g_assert (directory != NULL); + g_assert (file != NULL); nautilus_mime_set_default_component_for_uri - (directory, file, id->iid); - nautilus_directory_unref (directory); + (file, id->iid); nautilus_file_unref (file); nautilus_window_allow_stop (window, TRUE); diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 32447dd59..2834c73db 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -925,7 +925,6 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) GtkWidget *new_menu; GtkWidget *menu_item; char *label; - NautilusDirectory *directory; NautilusFile *file; g_return_if_fail (NAUTILUS_IS_WINDOW (window)); @@ -934,9 +933,8 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) new_menu = gtk_menu_new (); file = nautilus_file_get (window->location); - directory = nautilus_directory_get (window->location); /* Add a menu item for each view in the preferred list for this location. */ - components = nautilus_mime_get_short_list_components_for_uri (directory, file); + components = nautilus_mime_get_short_list_components_for_uri (file); for (p = components; p != NULL; p = p->next) { menu_item = create_content_view_menu_item (window, nautilus_view_identifier_new_from_content_view (p->data)); @@ -949,7 +947,7 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) * one way trip if you choose one of these view menu items, but * it's better than nothing. */ - method = nautilus_mime_get_short_list_methods_for_uri (directory, file); + method = nautilus_mime_get_short_list_methods_for_uri (file); /* FIXME bugzilla.eazel.com 2466: Name of the function is plural, but it returns only * one item. That must be fixed. */ @@ -992,7 +990,6 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) new_menu); - nautilus_directory_unref (directory); nautilus_file_unref (file); nautilus_window_synch_content_view_menu (window); diff --git a/test/test-nautilus-mime-actions-set.c b/test/test-nautilus-mime-actions-set.c index 25a267a55..226cb4521 100644 --- a/test/test-nautilus-mime-actions-set.c +++ b/test/test-nautilus-mime-actions-set.c @@ -101,7 +101,6 @@ main (int argc, char **argv) const char *uri; const char *field; const char *value; - NautilusDirectory *directory; NautilusFile *file; g_thread_init (NULL); @@ -118,34 +117,33 @@ main (int argc, char **argv) field = argv[2]; value = argv[3]; - directory = nautilus_directory_get (uri); file = nautilus_file_get (uri); if (strcmp (field, "default_action_type") == 0) { puts ("default_action_type"); - nautilus_mime_set_default_action_type_for_uri (directory, file, str_to_action_type (value)); + nautilus_mime_set_default_action_type_for_uri (file, str_to_action_type (value)); } else if (strcmp (field, "default_application") == 0) { puts ("default_application"); - nautilus_mime_set_default_application_for_uri (directory, file, value); + nautilus_mime_set_default_application_for_uri (file, value); } else if (strcmp (field, "default_component") == 0) { puts ("default_component"); - nautilus_mime_set_default_component_for_uri (directory, file, value); + nautilus_mime_set_default_component_for_uri (file, value); } else if (strcmp (field, "short_list_applicationss") == 0) { puts ("short_list_applications"); nautilus_mime_set_short_list_applications_for_uri - (directory, file, comma_separated_str_to_str_list (value)); + (file, comma_separated_str_to_str_list (value)); } else if (strcmp (field, "short_list_components") == 0) { puts ("short_list_components"); nautilus_mime_set_short_list_components_for_uri - (directory, file, comma_separated_str_to_str_list (value)); + (file, comma_separated_str_to_str_list (value)); } else if (strcmp (field, "add_to_all_applicationss") == 0) { puts ("add_to_all_applications"); nautilus_mime_extend_all_applications_for_uri - (directory, file, comma_separated_str_to_str_list (value)); + (file, comma_separated_str_to_str_list (value)); } else if (strcmp (field, "remove_from_all_applications") == 0) { puts ("remove_from_all_applications"); nautilus_mime_remove_from_all_applications_for_uri - (directory, file, comma_separated_str_to_str_list (value)); + (file, comma_separated_str_to_str_list (value)); } else { usage (argv[0]); diff --git a/test/test-nautilus-mime-actions.c b/test/test-nautilus-mime-actions.c index 12f1d758b..c8d9edb22 100644 --- a/test/test-nautilus-mime-actions.c +++ b/test/test-nautilus-mime-actions.c @@ -116,7 +116,6 @@ main (int argc, char **argv) GList *short_list_components; GList *short_list_applications; NautilusFile *file; - NautilusDirectory *directory; g_thread_init (NULL); oaf_init (argc, argv); @@ -131,39 +130,38 @@ main (int argc, char **argv) uri = argv[1]; file = nautilus_file_get (uri); - directory = nautilus_directory_get (uri); - default_action = nautilus_mime_get_default_action_for_uri (directory, file); + default_action = nautilus_mime_get_default_action_for_uri (file); puts ("Default Action"); print_action (default_action); puts (""); - default_application = nautilus_mime_get_default_application_for_uri (directory, file); + default_application = nautilus_mime_get_default_application_for_uri (file); puts("Default Application"); print_application (default_application); puts (""); - default_component = nautilus_mime_get_default_component_for_uri (directory, file); + default_component = nautilus_mime_get_default_component_for_uri (file); puts("Default Component"); print_component (default_component); puts (""); - short_list_applications = nautilus_mime_get_short_list_applications_for_uri (directory, file); + short_list_applications = nautilus_mime_get_short_list_applications_for_uri (file); puts("Short List Applications"); print_application_list (short_list_applications); puts (""); - short_list_components = nautilus_mime_get_short_list_components_for_uri (directory, file); + short_list_components = nautilus_mime_get_short_list_components_for_uri (file); puts("Short List Components"); print_component_list (short_list_components); puts (""); - all_applications = nautilus_mime_get_all_applications_for_uri (directory, file); + all_applications = nautilus_mime_get_all_applications_for_uri (file); puts("All Applications"); print_application_list (all_applications); puts (""); - all_components = nautilus_mime_get_all_components_for_uri (directory, file); + all_components = nautilus_mime_get_all_components_for_uri (file); puts("All Components"); print_component_list (all_components); puts (""); |