diff options
author | Maciej Stachowiak <mstachow@src.gnome.org> | 2000-11-01 01:24:17 +0000 |
---|---|---|
committer | Maciej Stachowiak <mstachow@src.gnome.org> | 2000-11-01 01:24:17 +0000 |
commit | 0bda5d31c06c39a7ad3d058b56556543f3849d4d (patch) | |
tree | 8483375c0e2310035aa4ab1eb0dd20872f2ef593 | |
parent | ffbf52578e2b406c5e34d4f659aa70cc7ad3930c (diff) | |
download | nautilus-0bda5d31c06c39a7ad3d058b56556543f3849d4d.tar.gz |
Un-revert my changes from before, fixing the bugs in the process.
* libnautilus-extensions/nautilus-mime-actions.c:
(nautilus_mime_actions_check_if_minimum_attributes_ready),
(nautilus_mime_actions_check_if_full_attributes_ready),
(nautilus_mime_actions_get_minimum_file_attributes),
(nautilus_mime_actions_get_full_file_attributes),
(nautilus_mime_actions_wait_for_full_file_attributes),
(nautilus_mime_get_default_action_type_for_file),
(nautilus_mime_get_default_action_for_file),
(nautilus_mime_get_default_application_for_file_internal),
(nautilus_mime_get_default_application_for_file),
(nautilus_mime_is_default_application_for_file_user_chosen),
(nautilus_mime_get_default_component_sort_conditions),
(nautilus_mime_get_default_component_for_file_internal),
(nautilus_mime_get_short_list_applications_for_file),
(nautilus_mime_get_short_list_components_for_file),
(nautilus_mime_get_short_list_methods_for_file),
(nautilus_mime_get_all_applications_for_file),
(nautilus_mime_get_all_components_for_file),
(nautilus_mime_set_default_application_for_file),
(nautilus_mime_set_default_component_for_file),
(nautilus_mime_set_short_list_applications_for_file),
(nautilus_mime_set_short_list_components_for_file),
(nautilus_mime_add_application_to_short_list_for_file),
(nautilus_mime_remove_application_from_short_list_for_file),
(nautilus_mime_add_component_to_short_list_for_file),
(nautilus_mime_remove_component_from_short_list_for_file),
(nautilus_mime_extend_all_applications_for_file),
(nautilus_mime_remove_from_all_applications_for_file),
(nautilus_do_component_query):
* libnautilus-extensions/nautilus-mime-actions.h:
* libnautilus-extensions/nautilus-program-chooser.c:
(repopulate_program_list), (is_component_default_for_file),
(program_file_pair_is_default_for_file),
(program_file_pair_is_in_short_list_for_file),
(add_to_short_list_for_file), (remove_from_short_list_for_file),
(remove_default_for_item), (set_default_for_item):
* libnautilus-extensions/nautilus-program-choosing.c:
(any_programs_available_for_file):
* libnautilus/nautilus-clipboard-ui.xml.h:
* src/file-manager/fm-directory-view.c: (switch_location_and_view),
(create_open_with_gtk_menu), (reset_bonobo_open_with_menu),
(activate_callback):
* src/file-manager/nautilus-directory-view-ui.xml.h:
* src/file-manager/nautilus-icon-view-ui.xml.h:
* src/file-manager/nautilus-search-list-view-ui.xml.h:
* src/nautilus-applicable-views.c: (nautilus_navigation_info_new):
* src/nautilus-shell-ui.xml.h:
* src/nautilus-sidebar.c: (nautilus_sidebar_update_all),
(nautilus_sidebar_set_uri):
* src/nautilus-window.c: (nautilus_window_load_content_view_menu):
* test/test-nautilus-mime-actions-set.c: (main):
* test/test-nautilus-mime-actions.c: (main): Un-revert my changes
from before, fixing the bugs in the process.
-rw-r--r-- | ChangeLog | 56 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-mime-actions.c | 268 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-mime-actions.h | 5 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-program-chooser.c | 16 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-program-choosing.c | 2 | ||||
-rw-r--r-- | libnautilus-private/nautilus-mime-actions.c | 268 | ||||
-rw-r--r-- | libnautilus-private/nautilus-mime-actions.h | 5 | ||||
-rw-r--r-- | libnautilus-private/nautilus-program-chooser.c | 16 | ||||
-rw-r--r-- | libnautilus-private/nautilus-program-choosing.c | 2 | ||||
-rw-r--r-- | src/file-manager/fm-directory-view.c | 8 | ||||
-rw-r--r-- | src/nautilus-applicable-views.c | 2 | ||||
-rw-r--r-- | src/nautilus-information-panel.c | 4 | ||||
-rw-r--r-- | src/nautilus-navigation-window.c | 2 | ||||
-rw-r--r-- | src/nautilus-object-window.c | 2 | ||||
-rw-r--r-- | src/nautilus-sidebar.c | 4 | ||||
-rw-r--r-- | src/nautilus-spatial-window.c | 2 | ||||
-rw-r--r-- | src/nautilus-window.c | 2 | ||||
-rw-r--r-- | test/test-nautilus-mime-actions-set.c | 2 | ||||
-rw-r--r-- | test/test-nautilus-mime-actions.c | 2 |
19 files changed, 435 insertions, 233 deletions
@@ -1,3 +1,59 @@ +2000-10-31 Maciej Stachowiak <mjs@eazel.com> + + * libnautilus-extensions/nautilus-mime-actions.c: + (nautilus_mime_actions_check_if_minimum_attributes_ready), + (nautilus_mime_actions_check_if_full_attributes_ready), + (nautilus_mime_actions_get_minimum_file_attributes), + (nautilus_mime_actions_get_full_file_attributes), + (nautilus_mime_actions_wait_for_full_file_attributes), + (nautilus_mime_get_default_action_type_for_file), + (nautilus_mime_get_default_action_for_file), + (nautilus_mime_get_default_application_for_file_internal), + (nautilus_mime_get_default_application_for_file), + (nautilus_mime_is_default_application_for_file_user_chosen), + (nautilus_mime_get_default_component_sort_conditions), + (nautilus_mime_get_default_component_for_file_internal), + (nautilus_mime_get_short_list_applications_for_file), + (nautilus_mime_get_short_list_components_for_file), + (nautilus_mime_get_short_list_methods_for_file), + (nautilus_mime_get_all_applications_for_file), + (nautilus_mime_get_all_components_for_file), + (nautilus_mime_set_default_application_for_file), + (nautilus_mime_set_default_component_for_file), + (nautilus_mime_set_short_list_applications_for_file), + (nautilus_mime_set_short_list_components_for_file), + (nautilus_mime_add_application_to_short_list_for_file), + (nautilus_mime_remove_application_from_short_list_for_file), + (nautilus_mime_add_component_to_short_list_for_file), + (nautilus_mime_remove_component_from_short_list_for_file), + (nautilus_mime_extend_all_applications_for_file), + (nautilus_mime_remove_from_all_applications_for_file), + (nautilus_do_component_query): + * libnautilus-extensions/nautilus-mime-actions.h: + * libnautilus-extensions/nautilus-program-chooser.c: + (repopulate_program_list), (is_component_default_for_file), + (program_file_pair_is_default_for_file), + (program_file_pair_is_in_short_list_for_file), + (add_to_short_list_for_file), (remove_from_short_list_for_file), + (remove_default_for_item), (set_default_for_item): + * libnautilus-extensions/nautilus-program-choosing.c: + (any_programs_available_for_file): + * libnautilus/nautilus-clipboard-ui.xml.h: + * src/file-manager/fm-directory-view.c: (switch_location_and_view), + (create_open_with_gtk_menu), (reset_bonobo_open_with_menu), + (activate_callback): + * src/file-manager/nautilus-directory-view-ui.xml.h: + * src/file-manager/nautilus-icon-view-ui.xml.h: + * src/file-manager/nautilus-search-list-view-ui.xml.h: + * src/nautilus-applicable-views.c: (nautilus_navigation_info_new): + * src/nautilus-shell-ui.xml.h: + * src/nautilus-sidebar.c: (nautilus_sidebar_update_all), + (nautilus_sidebar_set_uri): + * src/nautilus-window.c: (nautilus_window_load_content_view_menu): + * test/test-nautilus-mime-actions-set.c: (main): + * test/test-nautilus-mime-actions.c: (main): Un-revert my changes + from before, fixing the bugs in the process. + 2000-10-31 Ramiro Estrugo <ramiro@eazel.com> * applets/launcher/Makefile.am: diff --git a/libnautilus-extensions/nautilus-mime-actions.c b/libnautilus-extensions/nautilus-mime-actions.c index 375c5e0e1..94f24fb47 100644 --- a/libnautilus-extensions/nautilus-mime-actions.c +++ b/libnautilus-extensions/nautilus-mime-actions.c @@ -70,7 +70,8 @@ static gboolean server_matches_content_requirements (OAF_ServerInfo GList *explicit_iids); static GList *nautilus_do_component_query (const char *mime_type, const char *uri_scheme, - GList *files, + GList *content_mime_types, + gboolean ignore_content_mime_types, GList *explicit_iids, char **extra_sort_criteria, char *extra_requirements, @@ -98,40 +99,64 @@ is_known_mime_type (const char *mime_type) static gboolean -nautilus_mime_actions_check_if_required_attributes_ready (NautilusFile *file) +nautilus_mime_actions_check_if_minimum_attributes_ready (NautilusFile *file) { GList *attributes; gboolean ready; - attributes = nautilus_mime_actions_get_required_file_attributes (); + attributes = nautilus_mime_actions_get_minimum_file_attributes (); ready = nautilus_file_check_if_ready (file, attributes); g_list_free (attributes); return ready; } +static gboolean +nautilus_mime_actions_check_if_full_attributes_ready (NautilusFile *file) +{ + GList *attributes; + gboolean ready; + + attributes = nautilus_mime_actions_get_full_file_attributes (); + ready = nautilus_file_check_if_ready (file, attributes); + g_list_free (attributes); + + return ready; +} GList * -nautilus_mime_actions_get_required_file_attributes () +nautilus_mime_actions_get_minimum_file_attributes () { GList *attributes; attributes = NULL; attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_METADATA); attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE); + + return attributes; +} + + +GList * +nautilus_mime_actions_get_full_file_attributes () +{ + GList *attributes; + + attributes = nautilus_mime_actions_get_minimum_file_attributes (); attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES); return attributes; } + void -nautilus_mime_actions_wait_for_required_file_attributes (NautilusFile *file) +nautilus_mime_actions_wait_for_full_file_attributes (NautilusFile *file) { GList *attributes; - attributes = nautilus_mime_actions_get_required_file_attributes (); + attributes = nautilus_mime_actions_get_full_file_attributes (); nautilus_file_wait_until_ready (file, attributes); @@ -146,7 +171,7 @@ nautilus_mime_get_default_action_type_for_file (NautilusFile *file) char *action_type_string; GnomeVFSMimeActionType action_type; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_MIME_ACTION_TYPE_NONE); action_type_string = nautilus_file_get_metadata @@ -173,7 +198,7 @@ nautilus_mime_get_default_action_for_file (NautilusFile *file) { GnomeVFSMimeAction *action; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), NULL); action = g_new0 (GnomeVFSMimeAction, 1); @@ -209,15 +234,15 @@ nautilus_mime_get_default_action_for_file (NautilusFile *file) static GnomeVFSMimeApplication * -nautilus_mime_get_default_application_for_file_internal (NautilusFile *file, - gboolean *user_chosen) +nautilus_mime_get_default_application_for_file_internal (NautilusFile *file, + gboolean *user_chosen) { char *mime_type; GnomeVFSMimeApplication *result; char *default_application_string; gboolean used_user_chosen_info; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), NULL); used_user_chosen_info = TRUE; @@ -225,6 +250,8 @@ nautilus_mime_get_default_application_for_file_internal (NautilusFile *file default_application_string = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_DEFAULT_APPLICATION, NULL); + /* FIXME: should fall back to normal default if user-specified default is bogus */ + if (default_application_string == NULL) { mime_type = nautilus_file_get_mime_type (file); result = gnome_vfs_mime_get_default_application (mime_type); @@ -242,13 +269,13 @@ nautilus_mime_get_default_application_for_file_internal (NautilusFile *file } GnomeVFSMimeApplication * -nautilus_mime_get_default_application_for_file (NautilusFile *file) +nautilus_mime_get_default_application_for_file (NautilusFile *file) { return nautilus_mime_get_default_application_for_file_internal (file, NULL); } gboolean -nautilus_mime_is_default_application_for_file_user_chosen (NautilusFile *file) +nautilus_mime_is_default_application_for_file_user_chosen (NautilusFile *file) { GnomeVFSMimeApplication *application; gboolean user_chosen; @@ -268,60 +295,19 @@ nautilus_mime_is_default_application_for_file_user_chosen (NautilusFile *fi } -static OAF_ServerInfo * -nautilus_mime_get_default_component_for_file_internal (NautilusFile *file, - gboolean *user_chosen) +static char ** +nautilus_mime_get_default_component_sort_conditions (NautilusFile *file, char *default_component_string) { - GList *info_list; - OAF_ServerInfo *mime_default; - char *default_component_string; - char *mime_type; - char *uri_scheme; - GList *item_mime_types; - GList *explicit_iids; - CORBA_Environment ev; - OAF_ServerInfo *server; - char *sort_conditions[5]; + char **sort_conditions; char *supertype; - gboolean used_user_chosen_info; + char *mime_type; GList *short_list; GList *p; char *prev; - - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), - NULL); - - used_user_chosen_info = TRUE; - - CORBA_exception_init (&ev); - - mime_type = nautilus_file_get_mime_type (file); - - uri_scheme = nautilus_file_get_uri_scheme (file); - - explicit_iids = get_explicit_content_view_iids_from_metafile (file); - 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); - - if (default_component_string == NULL && is_known_mime_type (mime_type)) { - mime_default = gnome_vfs_mime_get_default_component (mime_type); - if (mime_default != NULL) { - default_component_string = g_strdup (mime_default->iid); - if (default_component_string != NULL) { - /* Default component chosen based only on type. */ - used_user_chosen_info = FALSE; - } - CORBA_free (mime_default); - } - } - /* FIXME bugzilla.eazel.com 1264: - * should return NULL for the following cases: - * - Known URI scheme pointing to nonexistent location - * - Syntactically invalid URI - */ + sort_conditions = g_new0 (char *, 5); + + mime_type = nautilus_file_get_mime_type (file); supertype = mime_type_get_supertype (mime_type); @@ -373,9 +359,96 @@ nautilus_mime_get_default_component_for_file_internal (NautilusFile *file, } sort_conditions[4] = NULL; + + g_free (mime_type); + g_free (supertype); + + return sort_conditions; +} + + + +static OAF_ServerInfo * +nautilus_mime_get_default_component_for_file_internal (NautilusFile *file, + gboolean *user_chosen) +{ + GList *info_list; + OAF_ServerInfo *mime_default; + char *default_component_string; + char *mime_type; + char *uri_scheme; + GList *item_mime_types; + GList *explicit_iids; + CORBA_Environment ev; + OAF_ServerInfo *server; + char **sort_conditions; + char *extra_requirements; + gboolean used_user_chosen_info; + gboolean metadata_default; + + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), + NULL); + + used_user_chosen_info = TRUE; + + info_list = NULL; + + CORBA_exception_init (&ev); + + mime_type = nautilus_file_get_mime_type (file); + + uri_scheme = nautilus_file_get_uri_scheme (file); + + explicit_iids = get_explicit_content_view_iids_from_metafile (file); + + if (!nautilus_mime_actions_check_if_full_attributes_ready (file) || + !nautilus_file_get_directory_item_mime_types (file, &item_mime_types)) { + item_mime_types = NULL; + } + + default_component_string = nautilus_file_get_metadata + (file, NAUTILUS_METADATA_KEY_DEFAULT_COMPONENT, NULL); + + if (default_component_string == NULL) { + metadata_default = FALSE; + + if (is_known_mime_type (mime_type)) { + mime_default = gnome_vfs_mime_get_default_component (mime_type); + if (mime_default != NULL) { + default_component_string = g_strdup (mime_default->iid); + if (default_component_string != NULL) { + /* Default component chosen based only on type. */ + used_user_chosen_info = FALSE; + } + CORBA_free (mime_default); + } + } + } else { + metadata_default = TRUE; + } - info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, explicit_iids, - sort_conditions, NULL, &ev); + /* FIXME bugzilla.eazel.com 1264: + * should return NULL for the following cases: + * - Known URI scheme pointing to nonexistent location + * - Syntactically invalid URI + */ + + sort_conditions = nautilus_mime_get_default_component_sort_conditions (file, default_component_string); + + /* If the default is specified in the per-uri metadata, + respect the setting regardless of content type requirements */ + if (metadata_default) { + extra_requirements = g_strconcat ("iid == '", default_component_string, "'", NULL); + + info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, TRUE, + explicit_iids, sort_conditions, extra_requirements, &ev); + g_free (extra_requirements); + } + + if (info_list == NULL) { + info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, FALSE, + explicit_iids, sort_conditions, NULL, &ev); + } if (ev._major == CORBA_NO_EXCEPTION && info_list != NULL) { server = OAF_ServerInfo_duplicate (info_list->data); @@ -390,11 +463,8 @@ nautilus_mime_get_default_component_for_file_internal (NautilusFile *file, return NULL; } - g_free (sort_conditions[0]); - g_free (sort_conditions[1]); - g_free (sort_conditions[2]); - g_free (sort_conditions[3]); - g_free (supertype); + g_strfreev (sort_conditions); + g_free (uri_scheme); g_free (mime_type); g_free (default_component_string); @@ -448,7 +518,7 @@ nautilus_mime_get_short_list_applications_for_file (NautilusFile *file) GnomeVFSMimeApplication *application; CORBA_Environment ev; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), NULL); CORBA_exception_init (&ev); @@ -510,7 +580,7 @@ nautilus_mime_get_short_list_components_for_file (NautilusFile *file) char *extra_requirements; char *prev; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), NULL); CORBA_exception_init (&ev); @@ -518,7 +588,11 @@ nautilus_mime_get_short_list_components_for_file (NautilusFile *file) uri_scheme = nautilus_file_get_uri_scheme (file); explicit_iids = get_explicit_content_view_iids_from_metafile (file); - nautilus_file_get_directory_item_mime_types (file, &item_mime_types); + + if (!nautilus_mime_actions_check_if_full_attributes_ready (file) || + !nautilus_file_get_directory_item_mime_types (file, &item_mime_types)) { + item_mime_types = NULL; + } metadata_component_add_ids = nautilus_file_get_metadata_list (file, @@ -574,7 +648,8 @@ nautilus_mime_get_short_list_components_for_file (NautilusFile *file) } - result = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, explicit_iids, NULL, extra_requirements, &ev); + result = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, FALSE, + explicit_iids, NULL, extra_requirements, &ev); g_free (extra_requirements); } @@ -594,7 +669,7 @@ nautilus_mime_get_short_list_methods_for_file (NautilusFile *file) char *mime_type; const char *method; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), NULL); mime_type = nautilus_file_get_mime_type (file); @@ -612,7 +687,7 @@ nautilus_mime_get_all_applications_for_file (NautilusFile *file) GList *p; GnomeVFSMimeApplication *application; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), NULL); metadata_application_ids = nautilus_file_get_metadata_list @@ -663,7 +738,7 @@ nautilus_mime_get_all_components_for_file (NautilusFile *file) GList *explicit_iids; CORBA_Environment ev; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), NULL); CORBA_exception_init (&ev); @@ -672,9 +747,14 @@ nautilus_mime_get_all_components_for_file (NautilusFile *file) mime_type = nautilus_file_get_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, item_mime_types, explicit_iids, NULL, NULL, &ev); + if (!nautilus_mime_actions_check_if_full_attributes_ready (file) || + !nautilus_file_get_directory_item_mime_types (file, &item_mime_types)) { + item_mime_types = NULL; + } + + info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, FALSE, + explicit_iids, NULL, NULL, &ev); g_free (uri_scheme); g_free (mime_type); @@ -724,7 +804,7 @@ GnomeVFSResult nautilus_mime_set_default_application_for_file (NautilusFile *file, const char *application_id) { - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); nautilus_file_set_metadata @@ -743,7 +823,7 @@ GnomeVFSResult nautilus_mime_set_default_component_for_file (NautilusFile *file, const char *component_iid) { - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); nautilus_file_set_metadata @@ -769,7 +849,7 @@ nautilus_mime_set_short_list_applications_for_file (NautilusFile *file, GList *p; char *mime_type; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); /* get per-mime short list */ @@ -817,7 +897,7 @@ nautilus_mime_set_short_list_components_for_file (NautilusFile *file, GList *p; char *mime_type; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); /* get per-mime short list */ @@ -860,7 +940,7 @@ nautilus_mime_add_application_to_short_list_for_file (NautilusFile *file, GList *old_list, *new_list; GnomeVFSResult result; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); result = GNOME_VFS_OK; @@ -887,7 +967,7 @@ nautilus_mime_remove_application_from_short_list_for_file (NautilusFile *fi gboolean was_in_list; GnomeVFSResult result; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); old_list = nautilus_mime_get_short_list_applications_for_file (file); @@ -914,7 +994,7 @@ nautilus_mime_add_component_to_short_list_for_file (NautilusFile *file, GList *old_list, *new_list; GnomeVFSResult result; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); old_list = nautilus_mime_get_short_list_components_for_file (file); @@ -941,7 +1021,7 @@ nautilus_mime_remove_component_from_short_list_for_file (NautilusFile *file, gboolean was_in_list; GnomeVFSResult result; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); old_list = nautilus_mime_get_short_list_components_for_file (file); @@ -969,7 +1049,7 @@ nautilus_mime_extend_all_applications_for_file (NautilusFile *file, GList *extras; GList *final_applications; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); metadata_application_ids = nautilus_file_get_metadata_list @@ -997,7 +1077,7 @@ nautilus_mime_remove_from_all_applications_for_file (NautilusFile *file, GList *metadata_application_ids; GList *final_applications; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); metadata_application_ids = nautilus_file_get_metadata_list @@ -1390,22 +1470,13 @@ static char *nautilus_sort_criteria[] = { "name", NULL}; -#if 0 - /* Prefer the industrial strengthe html viewer most */ - "iid == 'OAFIID:nautilus_mozilla_content_view:1ee70717-57bf-4079-aae5-922abdd576b1'", - /* Prefer the gtkhtml viewer next */ - "iid == 'OAFIID:ntl_web_browser:0ce1a736-c939-4ac7-b12c-19d72bf1510b'", - /* Prefer the icon view next */ - "iid == 'OAFIID:ntl_file_manager_icon_view:42681b21-d5ca-4837-87d2-394d88ecc058'", -#endif; - - static GList * nautilus_do_component_query (const char *mime_type, const char *uri_scheme, GList *item_mime_types, + gboolean ignore_content_mime_types, GList *explicit_iids, char **extra_sort_criteria, char *extra_requirements, @@ -1449,7 +1520,8 @@ nautilus_do_component_query (const char *mime_type, server = &oaf_result->_buffer[i]; - if (server_matches_content_requirements (server, content_types, explicit_iids)) { + if (ignore_content_mime_types || + server_matches_content_requirements (server, content_types, explicit_iids)) { retval = g_list_append (retval, OAF_ServerInfo_duplicate (server)); diff --git a/libnautilus-extensions/nautilus-mime-actions.h b/libnautilus-extensions/nautilus-mime-actions.h index fd76cd161..f97f7f84b 100644 --- a/libnautilus-extensions/nautilus-mime-actions.h +++ b/libnautilus-extensions/nautilus-mime-actions.h @@ -30,9 +30,10 @@ #include <libnautilus-extensions/nautilus-file.h> -GList *nautilus_mime_actions_get_required_file_attributes (void); +GList *nautilus_mime_actions_get_minimum_file_attributes (void); +GList *nautilus_mime_actions_get_full_file_attributes (void); -void nautilus_mime_actions_wait_for_required_file_attributes (NautilusFile *file); +void nautilus_mime_actions_wait_for_full_file_attributes (NautilusFile *file); GnomeVFSMimeActionType nautilus_mime_get_default_action_type_for_file (NautilusFile *file); diff --git a/libnautilus-extensions/nautilus-program-chooser.c b/libnautilus-extensions/nautilus-program-chooser.c index 3458c78e0..014f30cf0 100644 --- a/libnautilus-extensions/nautilus-program-chooser.c +++ b/libnautilus-extensions/nautilus-program-chooser.c @@ -315,7 +315,7 @@ repopulate_program_list (GnomeDialog *program_chooser, int new_row; GnomeVFSMimeActionType type; - nautilus_mime_actions_wait_for_required_file_attributes (file); + nautilus_mime_actions_wait_for_full_file_attributes (file); type = nautilus_program_chooser_get_type (program_chooser); @@ -504,7 +504,7 @@ is_component_default_for_file (NautilusViewIdentifier *identifier, NautilusFile g_assert (identifier != NULL); - nautilus_mime_actions_wait_for_required_file_attributes (file); + nautilus_mime_actions_wait_for_full_file_attributes (file); default_component = nautilus_mime_get_default_component_for_file (file); result = (default_component != NULL && strcmp (default_component->iid, identifier->iid) == 0); @@ -613,7 +613,7 @@ program_file_pair_is_default_for_file (ProgramFilePair *pair) g_assert (pair != NULL); g_assert (NAUTILUS_IS_FILE (pair->file)); - nautilus_mime_actions_wait_for_required_file_attributes (pair->file); + nautilus_mime_actions_wait_for_full_file_attributes (pair->file); if (pair->action_type != nautilus_mime_get_default_action_type_for_file (pair->file)) { return FALSE; @@ -658,7 +658,7 @@ program_file_pair_is_in_short_list_for_file (ProgramFilePair *pair) g_assert (pair != NULL); g_assert (NAUTILUS_IS_FILE (pair->file)); - nautilus_mime_actions_wait_for_required_file_attributes (pair->file); + nautilus_mime_actions_wait_for_full_file_attributes (pair->file); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT) { result = is_component_in_short_list_for_file (pair->view_identifier, pair->file); @@ -775,7 +775,7 @@ pack_radio_button (GtkBox *box, const char *label_text, GtkRadioButton *group) static void add_to_short_list_for_file (ProgramFilePair *pair) { - nautilus_mime_actions_wait_for_required_file_attributes (pair->file); + nautilus_mime_actions_wait_for_full_file_attributes (pair->file); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { nautilus_mime_add_application_to_short_list_for_file (pair->file, pair->application->id); @@ -787,7 +787,7 @@ add_to_short_list_for_file (ProgramFilePair *pair) static void remove_from_short_list_for_file (ProgramFilePair *pair) { - nautilus_mime_actions_wait_for_required_file_attributes (pair->file); + nautilus_mime_actions_wait_for_full_file_attributes (pair->file); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { nautilus_mime_remove_application_from_short_list_for_file (pair->file, pair->application->id); @@ -851,7 +851,7 @@ remove_default_for_type (ProgramFilePair *pair) static void remove_default_for_item (ProgramFilePair *pair) { - nautilus_mime_actions_wait_for_required_file_attributes (pair->file); + nautilus_mime_actions_wait_for_full_file_attributes (pair->file); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { /* If the default is just falling through to the default for this type, @@ -895,7 +895,7 @@ set_default_for_type (ProgramFilePair *pair) static void set_default_for_item (ProgramFilePair *pair) { - nautilus_mime_actions_wait_for_required_file_attributes (pair->file); + nautilus_mime_actions_wait_for_full_file_attributes (pair->file); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { nautilus_mime_set_default_application_for_file (pair->file, pair->application->id); diff --git a/libnautilus-extensions/nautilus-program-choosing.c b/libnautilus-extensions/nautilus-program-choosing.c index b3acd1ab4..f8fdf4526 100644 --- a/libnautilus-extensions/nautilus-program-choosing.c +++ b/libnautilus-extensions/nautilus-program-choosing.c @@ -41,7 +41,7 @@ any_programs_available_for_file (GnomeVFSMimeActionType action_type, NautilusFil { gboolean result; - nautilus_mime_actions_wait_for_required_file_attributes (file); + nautilus_mime_actions_wait_for_full_file_attributes (file); if (action_type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT) { result = nautilus_mime_has_any_components_for_file (file); diff --git a/libnautilus-private/nautilus-mime-actions.c b/libnautilus-private/nautilus-mime-actions.c index 375c5e0e1..94f24fb47 100644 --- a/libnautilus-private/nautilus-mime-actions.c +++ b/libnautilus-private/nautilus-mime-actions.c @@ -70,7 +70,8 @@ static gboolean server_matches_content_requirements (OAF_ServerInfo GList *explicit_iids); static GList *nautilus_do_component_query (const char *mime_type, const char *uri_scheme, - GList *files, + GList *content_mime_types, + gboolean ignore_content_mime_types, GList *explicit_iids, char **extra_sort_criteria, char *extra_requirements, @@ -98,40 +99,64 @@ is_known_mime_type (const char *mime_type) static gboolean -nautilus_mime_actions_check_if_required_attributes_ready (NautilusFile *file) +nautilus_mime_actions_check_if_minimum_attributes_ready (NautilusFile *file) { GList *attributes; gboolean ready; - attributes = nautilus_mime_actions_get_required_file_attributes (); + attributes = nautilus_mime_actions_get_minimum_file_attributes (); ready = nautilus_file_check_if_ready (file, attributes); g_list_free (attributes); return ready; } +static gboolean +nautilus_mime_actions_check_if_full_attributes_ready (NautilusFile *file) +{ + GList *attributes; + gboolean ready; + + attributes = nautilus_mime_actions_get_full_file_attributes (); + ready = nautilus_file_check_if_ready (file, attributes); + g_list_free (attributes); + + return ready; +} GList * -nautilus_mime_actions_get_required_file_attributes () +nautilus_mime_actions_get_minimum_file_attributes () { GList *attributes; attributes = NULL; attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_METADATA); attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE); + + return attributes; +} + + +GList * +nautilus_mime_actions_get_full_file_attributes () +{ + GList *attributes; + + attributes = nautilus_mime_actions_get_minimum_file_attributes (); attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES); return attributes; } + void -nautilus_mime_actions_wait_for_required_file_attributes (NautilusFile *file) +nautilus_mime_actions_wait_for_full_file_attributes (NautilusFile *file) { GList *attributes; - attributes = nautilus_mime_actions_get_required_file_attributes (); + attributes = nautilus_mime_actions_get_full_file_attributes (); nautilus_file_wait_until_ready (file, attributes); @@ -146,7 +171,7 @@ nautilus_mime_get_default_action_type_for_file (NautilusFile *file) char *action_type_string; GnomeVFSMimeActionType action_type; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_MIME_ACTION_TYPE_NONE); action_type_string = nautilus_file_get_metadata @@ -173,7 +198,7 @@ nautilus_mime_get_default_action_for_file (NautilusFile *file) { GnomeVFSMimeAction *action; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), NULL); action = g_new0 (GnomeVFSMimeAction, 1); @@ -209,15 +234,15 @@ nautilus_mime_get_default_action_for_file (NautilusFile *file) static GnomeVFSMimeApplication * -nautilus_mime_get_default_application_for_file_internal (NautilusFile *file, - gboolean *user_chosen) +nautilus_mime_get_default_application_for_file_internal (NautilusFile *file, + gboolean *user_chosen) { char *mime_type; GnomeVFSMimeApplication *result; char *default_application_string; gboolean used_user_chosen_info; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), NULL); used_user_chosen_info = TRUE; @@ -225,6 +250,8 @@ nautilus_mime_get_default_application_for_file_internal (NautilusFile *file default_application_string = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_DEFAULT_APPLICATION, NULL); + /* FIXME: should fall back to normal default if user-specified default is bogus */ + if (default_application_string == NULL) { mime_type = nautilus_file_get_mime_type (file); result = gnome_vfs_mime_get_default_application (mime_type); @@ -242,13 +269,13 @@ nautilus_mime_get_default_application_for_file_internal (NautilusFile *file } GnomeVFSMimeApplication * -nautilus_mime_get_default_application_for_file (NautilusFile *file) +nautilus_mime_get_default_application_for_file (NautilusFile *file) { return nautilus_mime_get_default_application_for_file_internal (file, NULL); } gboolean -nautilus_mime_is_default_application_for_file_user_chosen (NautilusFile *file) +nautilus_mime_is_default_application_for_file_user_chosen (NautilusFile *file) { GnomeVFSMimeApplication *application; gboolean user_chosen; @@ -268,60 +295,19 @@ nautilus_mime_is_default_application_for_file_user_chosen (NautilusFile *fi } -static OAF_ServerInfo * -nautilus_mime_get_default_component_for_file_internal (NautilusFile *file, - gboolean *user_chosen) +static char ** +nautilus_mime_get_default_component_sort_conditions (NautilusFile *file, char *default_component_string) { - GList *info_list; - OAF_ServerInfo *mime_default; - char *default_component_string; - char *mime_type; - char *uri_scheme; - GList *item_mime_types; - GList *explicit_iids; - CORBA_Environment ev; - OAF_ServerInfo *server; - char *sort_conditions[5]; + char **sort_conditions; char *supertype; - gboolean used_user_chosen_info; + char *mime_type; GList *short_list; GList *p; char *prev; - - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), - NULL); - - used_user_chosen_info = TRUE; - - CORBA_exception_init (&ev); - - mime_type = nautilus_file_get_mime_type (file); - - uri_scheme = nautilus_file_get_uri_scheme (file); - - explicit_iids = get_explicit_content_view_iids_from_metafile (file); - 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); - - if (default_component_string == NULL && is_known_mime_type (mime_type)) { - mime_default = gnome_vfs_mime_get_default_component (mime_type); - if (mime_default != NULL) { - default_component_string = g_strdup (mime_default->iid); - if (default_component_string != NULL) { - /* Default component chosen based only on type. */ - used_user_chosen_info = FALSE; - } - CORBA_free (mime_default); - } - } - /* FIXME bugzilla.eazel.com 1264: - * should return NULL for the following cases: - * - Known URI scheme pointing to nonexistent location - * - Syntactically invalid URI - */ + sort_conditions = g_new0 (char *, 5); + + mime_type = nautilus_file_get_mime_type (file); supertype = mime_type_get_supertype (mime_type); @@ -373,9 +359,96 @@ nautilus_mime_get_default_component_for_file_internal (NautilusFile *file, } sort_conditions[4] = NULL; + + g_free (mime_type); + g_free (supertype); + + return sort_conditions; +} + + + +static OAF_ServerInfo * +nautilus_mime_get_default_component_for_file_internal (NautilusFile *file, + gboolean *user_chosen) +{ + GList *info_list; + OAF_ServerInfo *mime_default; + char *default_component_string; + char *mime_type; + char *uri_scheme; + GList *item_mime_types; + GList *explicit_iids; + CORBA_Environment ev; + OAF_ServerInfo *server; + char **sort_conditions; + char *extra_requirements; + gboolean used_user_chosen_info; + gboolean metadata_default; + + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), + NULL); + + used_user_chosen_info = TRUE; + + info_list = NULL; + + CORBA_exception_init (&ev); + + mime_type = nautilus_file_get_mime_type (file); + + uri_scheme = nautilus_file_get_uri_scheme (file); + + explicit_iids = get_explicit_content_view_iids_from_metafile (file); + + if (!nautilus_mime_actions_check_if_full_attributes_ready (file) || + !nautilus_file_get_directory_item_mime_types (file, &item_mime_types)) { + item_mime_types = NULL; + } + + default_component_string = nautilus_file_get_metadata + (file, NAUTILUS_METADATA_KEY_DEFAULT_COMPONENT, NULL); + + if (default_component_string == NULL) { + metadata_default = FALSE; + + if (is_known_mime_type (mime_type)) { + mime_default = gnome_vfs_mime_get_default_component (mime_type); + if (mime_default != NULL) { + default_component_string = g_strdup (mime_default->iid); + if (default_component_string != NULL) { + /* Default component chosen based only on type. */ + used_user_chosen_info = FALSE; + } + CORBA_free (mime_default); + } + } + } else { + metadata_default = TRUE; + } - info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, explicit_iids, - sort_conditions, NULL, &ev); + /* FIXME bugzilla.eazel.com 1264: + * should return NULL for the following cases: + * - Known URI scheme pointing to nonexistent location + * - Syntactically invalid URI + */ + + sort_conditions = nautilus_mime_get_default_component_sort_conditions (file, default_component_string); + + /* If the default is specified in the per-uri metadata, + respect the setting regardless of content type requirements */ + if (metadata_default) { + extra_requirements = g_strconcat ("iid == '", default_component_string, "'", NULL); + + info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, TRUE, + explicit_iids, sort_conditions, extra_requirements, &ev); + g_free (extra_requirements); + } + + if (info_list == NULL) { + info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, FALSE, + explicit_iids, sort_conditions, NULL, &ev); + } if (ev._major == CORBA_NO_EXCEPTION && info_list != NULL) { server = OAF_ServerInfo_duplicate (info_list->data); @@ -390,11 +463,8 @@ nautilus_mime_get_default_component_for_file_internal (NautilusFile *file, return NULL; } - g_free (sort_conditions[0]); - g_free (sort_conditions[1]); - g_free (sort_conditions[2]); - g_free (sort_conditions[3]); - g_free (supertype); + g_strfreev (sort_conditions); + g_free (uri_scheme); g_free (mime_type); g_free (default_component_string); @@ -448,7 +518,7 @@ nautilus_mime_get_short_list_applications_for_file (NautilusFile *file) GnomeVFSMimeApplication *application; CORBA_Environment ev; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), NULL); CORBA_exception_init (&ev); @@ -510,7 +580,7 @@ nautilus_mime_get_short_list_components_for_file (NautilusFile *file) char *extra_requirements; char *prev; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), NULL); CORBA_exception_init (&ev); @@ -518,7 +588,11 @@ nautilus_mime_get_short_list_components_for_file (NautilusFile *file) uri_scheme = nautilus_file_get_uri_scheme (file); explicit_iids = get_explicit_content_view_iids_from_metafile (file); - nautilus_file_get_directory_item_mime_types (file, &item_mime_types); + + if (!nautilus_mime_actions_check_if_full_attributes_ready (file) || + !nautilus_file_get_directory_item_mime_types (file, &item_mime_types)) { + item_mime_types = NULL; + } metadata_component_add_ids = nautilus_file_get_metadata_list (file, @@ -574,7 +648,8 @@ nautilus_mime_get_short_list_components_for_file (NautilusFile *file) } - result = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, explicit_iids, NULL, extra_requirements, &ev); + result = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, FALSE, + explicit_iids, NULL, extra_requirements, &ev); g_free (extra_requirements); } @@ -594,7 +669,7 @@ nautilus_mime_get_short_list_methods_for_file (NautilusFile *file) char *mime_type; const char *method; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), NULL); mime_type = nautilus_file_get_mime_type (file); @@ -612,7 +687,7 @@ nautilus_mime_get_all_applications_for_file (NautilusFile *file) GList *p; GnomeVFSMimeApplication *application; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), NULL); metadata_application_ids = nautilus_file_get_metadata_list @@ -663,7 +738,7 @@ nautilus_mime_get_all_components_for_file (NautilusFile *file) GList *explicit_iids; CORBA_Environment ev; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), NULL); CORBA_exception_init (&ev); @@ -672,9 +747,14 @@ nautilus_mime_get_all_components_for_file (NautilusFile *file) mime_type = nautilus_file_get_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, item_mime_types, explicit_iids, NULL, NULL, &ev); + if (!nautilus_mime_actions_check_if_full_attributes_ready (file) || + !nautilus_file_get_directory_item_mime_types (file, &item_mime_types)) { + item_mime_types = NULL; + } + + info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, FALSE, + explicit_iids, NULL, NULL, &ev); g_free (uri_scheme); g_free (mime_type); @@ -724,7 +804,7 @@ GnomeVFSResult nautilus_mime_set_default_application_for_file (NautilusFile *file, const char *application_id) { - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); nautilus_file_set_metadata @@ -743,7 +823,7 @@ GnomeVFSResult nautilus_mime_set_default_component_for_file (NautilusFile *file, const char *component_iid) { - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); nautilus_file_set_metadata @@ -769,7 +849,7 @@ nautilus_mime_set_short_list_applications_for_file (NautilusFile *file, GList *p; char *mime_type; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); /* get per-mime short list */ @@ -817,7 +897,7 @@ nautilus_mime_set_short_list_components_for_file (NautilusFile *file, GList *p; char *mime_type; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); /* get per-mime short list */ @@ -860,7 +940,7 @@ nautilus_mime_add_application_to_short_list_for_file (NautilusFile *file, GList *old_list, *new_list; GnomeVFSResult result; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); result = GNOME_VFS_OK; @@ -887,7 +967,7 @@ nautilus_mime_remove_application_from_short_list_for_file (NautilusFile *fi gboolean was_in_list; GnomeVFSResult result; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); old_list = nautilus_mime_get_short_list_applications_for_file (file); @@ -914,7 +994,7 @@ nautilus_mime_add_component_to_short_list_for_file (NautilusFile *file, GList *old_list, *new_list; GnomeVFSResult result; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); old_list = nautilus_mime_get_short_list_components_for_file (file); @@ -941,7 +1021,7 @@ nautilus_mime_remove_component_from_short_list_for_file (NautilusFile *file, gboolean was_in_list; GnomeVFSResult result; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); old_list = nautilus_mime_get_short_list_components_for_file (file); @@ -969,7 +1049,7 @@ nautilus_mime_extend_all_applications_for_file (NautilusFile *file, GList *extras; GList *final_applications; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); metadata_application_ids = nautilus_file_get_metadata_list @@ -997,7 +1077,7 @@ nautilus_mime_remove_from_all_applications_for_file (NautilusFile *file, GList *metadata_application_ids; GList *final_applications; - g_return_val_if_fail (nautilus_mime_actions_check_if_required_attributes_ready (file), + g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), GNOME_VFS_ERROR_GENERIC); metadata_application_ids = nautilus_file_get_metadata_list @@ -1390,22 +1470,13 @@ static char *nautilus_sort_criteria[] = { "name", NULL}; -#if 0 - /* Prefer the industrial strengthe html viewer most */ - "iid == 'OAFIID:nautilus_mozilla_content_view:1ee70717-57bf-4079-aae5-922abdd576b1'", - /* Prefer the gtkhtml viewer next */ - "iid == 'OAFIID:ntl_web_browser:0ce1a736-c939-4ac7-b12c-19d72bf1510b'", - /* Prefer the icon view next */ - "iid == 'OAFIID:ntl_file_manager_icon_view:42681b21-d5ca-4837-87d2-394d88ecc058'", -#endif; - - static GList * nautilus_do_component_query (const char *mime_type, const char *uri_scheme, GList *item_mime_types, + gboolean ignore_content_mime_types, GList *explicit_iids, char **extra_sort_criteria, char *extra_requirements, @@ -1449,7 +1520,8 @@ nautilus_do_component_query (const char *mime_type, server = &oaf_result->_buffer[i]; - if (server_matches_content_requirements (server, content_types, explicit_iids)) { + if (ignore_content_mime_types || + server_matches_content_requirements (server, content_types, explicit_iids)) { retval = g_list_append (retval, OAF_ServerInfo_duplicate (server)); diff --git a/libnautilus-private/nautilus-mime-actions.h b/libnautilus-private/nautilus-mime-actions.h index fd76cd161..f97f7f84b 100644 --- a/libnautilus-private/nautilus-mime-actions.h +++ b/libnautilus-private/nautilus-mime-actions.h @@ -30,9 +30,10 @@ #include <libnautilus-extensions/nautilus-file.h> -GList *nautilus_mime_actions_get_required_file_attributes (void); +GList *nautilus_mime_actions_get_minimum_file_attributes (void); +GList *nautilus_mime_actions_get_full_file_attributes (void); -void nautilus_mime_actions_wait_for_required_file_attributes (NautilusFile *file); +void nautilus_mime_actions_wait_for_full_file_attributes (NautilusFile *file); GnomeVFSMimeActionType nautilus_mime_get_default_action_type_for_file (NautilusFile *file); diff --git a/libnautilus-private/nautilus-program-chooser.c b/libnautilus-private/nautilus-program-chooser.c index 3458c78e0..014f30cf0 100644 --- a/libnautilus-private/nautilus-program-chooser.c +++ b/libnautilus-private/nautilus-program-chooser.c @@ -315,7 +315,7 @@ repopulate_program_list (GnomeDialog *program_chooser, int new_row; GnomeVFSMimeActionType type; - nautilus_mime_actions_wait_for_required_file_attributes (file); + nautilus_mime_actions_wait_for_full_file_attributes (file); type = nautilus_program_chooser_get_type (program_chooser); @@ -504,7 +504,7 @@ is_component_default_for_file (NautilusViewIdentifier *identifier, NautilusFile g_assert (identifier != NULL); - nautilus_mime_actions_wait_for_required_file_attributes (file); + nautilus_mime_actions_wait_for_full_file_attributes (file); default_component = nautilus_mime_get_default_component_for_file (file); result = (default_component != NULL && strcmp (default_component->iid, identifier->iid) == 0); @@ -613,7 +613,7 @@ program_file_pair_is_default_for_file (ProgramFilePair *pair) g_assert (pair != NULL); g_assert (NAUTILUS_IS_FILE (pair->file)); - nautilus_mime_actions_wait_for_required_file_attributes (pair->file); + nautilus_mime_actions_wait_for_full_file_attributes (pair->file); if (pair->action_type != nautilus_mime_get_default_action_type_for_file (pair->file)) { return FALSE; @@ -658,7 +658,7 @@ program_file_pair_is_in_short_list_for_file (ProgramFilePair *pair) g_assert (pair != NULL); g_assert (NAUTILUS_IS_FILE (pair->file)); - nautilus_mime_actions_wait_for_required_file_attributes (pair->file); + nautilus_mime_actions_wait_for_full_file_attributes (pair->file); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT) { result = is_component_in_short_list_for_file (pair->view_identifier, pair->file); @@ -775,7 +775,7 @@ pack_radio_button (GtkBox *box, const char *label_text, GtkRadioButton *group) static void add_to_short_list_for_file (ProgramFilePair *pair) { - nautilus_mime_actions_wait_for_required_file_attributes (pair->file); + nautilus_mime_actions_wait_for_full_file_attributes (pair->file); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { nautilus_mime_add_application_to_short_list_for_file (pair->file, pair->application->id); @@ -787,7 +787,7 @@ add_to_short_list_for_file (ProgramFilePair *pair) static void remove_from_short_list_for_file (ProgramFilePair *pair) { - nautilus_mime_actions_wait_for_required_file_attributes (pair->file); + nautilus_mime_actions_wait_for_full_file_attributes (pair->file); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { nautilus_mime_remove_application_from_short_list_for_file (pair->file, pair->application->id); @@ -851,7 +851,7 @@ remove_default_for_type (ProgramFilePair *pair) static void remove_default_for_item (ProgramFilePair *pair) { - nautilus_mime_actions_wait_for_required_file_attributes (pair->file); + nautilus_mime_actions_wait_for_full_file_attributes (pair->file); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { /* If the default is just falling through to the default for this type, @@ -895,7 +895,7 @@ set_default_for_type (ProgramFilePair *pair) static void set_default_for_item (ProgramFilePair *pair) { - nautilus_mime_actions_wait_for_required_file_attributes (pair->file); + nautilus_mime_actions_wait_for_full_file_attributes (pair->file); if (pair->action_type == GNOME_VFS_MIME_ACTION_TYPE_APPLICATION) { nautilus_mime_set_default_application_for_file (pair->file, pair->application->id); diff --git a/libnautilus-private/nautilus-program-choosing.c b/libnautilus-private/nautilus-program-choosing.c index b3acd1ab4..f8fdf4526 100644 --- a/libnautilus-private/nautilus-program-choosing.c +++ b/libnautilus-private/nautilus-program-choosing.c @@ -41,7 +41,7 @@ any_programs_available_for_file (GnomeVFSMimeActionType action_type, NautilusFil { gboolean result; - nautilus_mime_actions_wait_for_required_file_attributes (file); + nautilus_mime_actions_wait_for_full_file_attributes (file); if (action_type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT) { result = nautilus_mime_has_any_components_for_file (file); diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index f052a42a2..f2b27cd71 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -577,7 +577,7 @@ switch_location_and_view (NautilusViewIdentifier *identifier, file = nautilus_file_get (new_uri); - nautilus_mime_actions_wait_for_required_file_attributes (file); + nautilus_mime_actions_wait_for_full_file_attributes (file); /* User has explicitly chosen a viewer other than the default, so * make it the default and then switch locations. @@ -3108,7 +3108,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)); - nautilus_mime_actions_wait_for_required_file_attributes (NAUTILUS_FILE (files->data)); + nautilus_mime_actions_wait_for_full_file_attributes (NAUTILUS_FILE (files->data)); applications = nautilus_mime_get_short_list_applications_for_file (NAUTILUS_FILE (files->data)); for (node = applications; node != NULL; node = node->next) { @@ -3378,7 +3378,7 @@ reset_bonobo_open_with_menu (FMDirectoryView *view, GList *selection) if (nautilus_g_list_exactly_one_item (selection)) { uri = nautilus_file_get_uri (NAUTILUS_FILE (selection->data)); - nautilus_mime_actions_wait_for_required_file_attributes (NAUTILUS_FILE (selection->data)); + nautilus_mime_actions_wait_for_full_file_attributes (NAUTILUS_FILE (selection->data)); applications = nautilus_mime_get_short_list_applications_for_file (NAUTILUS_FILE (selection->data)); for (node = applications, index = 0; node != NULL; node = node->next, index++) { @@ -3761,7 +3761,7 @@ activate_callback (NautilusFile *file, gpointer callback_data) } if (!performed_special_handling) { - nautilus_mime_actions_wait_for_required_file_attributes (file); + nautilus_mime_actions_wait_for_full_file_attributes (file); action_type = nautilus_mime_get_default_action_type_for_file (file); application = nautilus_mime_get_default_application_for_file (file); diff --git a/src/nautilus-applicable-views.c b/src/nautilus-applicable-views.c index 441d6bec9..13b5164ed 100644 --- a/src/nautilus-applicable-views.c +++ b/src/nautilus-applicable-views.c @@ -203,7 +203,7 @@ nautilus_navigation_info_new (const char *location, NULL, FALSE); /* Arrange for all the file attributes we will need. */ - attributes = nautilus_mime_actions_get_required_file_attributes (); + attributes = nautilus_mime_actions_get_full_file_attributes (); nautilus_file_call_when_ready (info->file, attributes, got_file_info_callback, info); g_list_free (attributes); diff --git a/src/nautilus-information-panel.c b/src/nautilus-information-panel.c index 16c613264..844151c26 100644 --- a/src/nautilus-information-panel.c +++ b/src/nautilus-information-panel.c @@ -1394,7 +1394,7 @@ nautilus_sidebar_update_all (NautilusSidebar *sidebar) GList *attributes; gboolean ready; - attributes = nautilus_mime_actions_get_required_file_attributes (); + attributes = nautilus_mime_actions_get_minimum_file_attributes (); ready = nautilus_file_check_if_ready (sidebar->details->file, attributes); g_list_free (attributes); @@ -1448,7 +1448,7 @@ nautilus_sidebar_set_uri (NautilusSidebar *sidebar, nautilus_sidebar_update_all, GTK_OBJECT (sidebar)); - attributes = nautilus_mime_actions_get_required_file_attributes (); + attributes = nautilus_mime_actions_get_minimum_file_attributes (); nautilus_file_monitor_add (sidebar->details->file, sidebar, attributes); g_list_free (attributes); diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index 8fade7482..932483841 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -1050,7 +1050,7 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - attributes = nautilus_mime_actions_get_required_file_attributes (); + attributes = nautilus_mime_actions_get_full_file_attributes (); /* FIXME: need to cancel this when appropriate... */ nautilus_file_call_when_ready (window->details->viewed_file, attributes, diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c index 8fade7482..932483841 100644 --- a/src/nautilus-object-window.c +++ b/src/nautilus-object-window.c @@ -1050,7 +1050,7 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - attributes = nautilus_mime_actions_get_required_file_attributes (); + attributes = nautilus_mime_actions_get_full_file_attributes (); /* FIXME: need to cancel this when appropriate... */ nautilus_file_call_when_ready (window->details->viewed_file, attributes, diff --git a/src/nautilus-sidebar.c b/src/nautilus-sidebar.c index 16c613264..844151c26 100644 --- a/src/nautilus-sidebar.c +++ b/src/nautilus-sidebar.c @@ -1394,7 +1394,7 @@ nautilus_sidebar_update_all (NautilusSidebar *sidebar) GList *attributes; gboolean ready; - attributes = nautilus_mime_actions_get_required_file_attributes (); + attributes = nautilus_mime_actions_get_minimum_file_attributes (); ready = nautilus_file_check_if_ready (sidebar->details->file, attributes); g_list_free (attributes); @@ -1448,7 +1448,7 @@ nautilus_sidebar_set_uri (NautilusSidebar *sidebar, nautilus_sidebar_update_all, GTK_OBJECT (sidebar)); - attributes = nautilus_mime_actions_get_required_file_attributes (); + attributes = nautilus_mime_actions_get_minimum_file_attributes (); nautilus_file_monitor_add (sidebar->details->file, sidebar, attributes); g_list_free (attributes); diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c index 8fade7482..932483841 100644 --- a/src/nautilus-spatial-window.c +++ b/src/nautilus-spatial-window.c @@ -1050,7 +1050,7 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - attributes = nautilus_mime_actions_get_required_file_attributes (); + attributes = nautilus_mime_actions_get_full_file_attributes (); /* FIXME: need to cancel this when appropriate... */ nautilus_file_call_when_ready (window->details->viewed_file, attributes, diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 8fade7482..932483841 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -1050,7 +1050,7 @@ nautilus_window_load_content_view_menu (NautilusWindow *window) g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - attributes = nautilus_mime_actions_get_required_file_attributes (); + attributes = nautilus_mime_actions_get_full_file_attributes (); /* FIXME: need to cancel this when appropriate... */ nautilus_file_call_when_ready (window->details->viewed_file, attributes, diff --git a/test/test-nautilus-mime-actions-set.c b/test/test-nautilus-mime-actions-set.c index 00d6b7671..b79e0a976 100644 --- a/test/test-nautilus-mime-actions-set.c +++ b/test/test-nautilus-mime-actions-set.c @@ -119,7 +119,7 @@ main (int argc, char **argv) file = nautilus_file_get (uri); - nautilus_mime_actions_wait_for_required_file_attributes (file); + nautilus_mime_actions_wait_for_full_file_attributes (file); if (strcmp (field, "default_action_type") == 0) { puts ("default_action_type"); diff --git a/test/test-nautilus-mime-actions.c b/test/test-nautilus-mime-actions.c index 2882be790..a95b0f01b 100644 --- a/test/test-nautilus-mime-actions.c +++ b/test/test-nautilus-mime-actions.c @@ -131,7 +131,7 @@ main (int argc, char **argv) uri = argv[1]; file = nautilus_file_get (uri); - nautilus_mime_actions_wait_for_required_file_attributes (file); + nautilus_mime_actions_wait_for_full_file_attributes (file); default_action = nautilus_mime_get_default_action_for_file (file); puts ("Default Action"); |