diff options
author | Anders Carlsson <andersca@gnome.org> | 2004-10-11 08:10:42 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@src.gnome.org> | 2004-10-11 08:10:42 +0000 |
commit | d2d44c7f58239a851ea175e580429c056d3bca28 (patch) | |
tree | 176a3625d3285c7feac20667cb07d07cf2d1f1a0 /libnautilus-private | |
parent | 85a24fd18856d1c72d6a43af213ef2e9c7e23a59 (diff) | |
download | nautilus-d2d44c7f58239a851ea175e580429c056d3bca28.tar.gz |
Remove a couple of unused keys from nautilus-metadata.h
2004-10-11 Anders Carlsson <andersca@gnome.org>
* libnautilus-private/nautilus-metadata.h:
* libnautilus-private/nautilus-mime-actions.c:
(nautilus_mime_get_default_application_for_file),
(nautilus_mime_get_open_with_applications_for_file),
(nautilus_mime_get_applications_for_file),
(gnome_vfs_mime_application_has_id):
* libnautilus-private/nautilus-view-query.c:
(nautilus_view_query_get_default_component_for_file_internal),
(nautilus_view_query_get_components_for_file),
(make_bonobo_activation_query_with_known_mime_type),
(make_bonobo_activation_query_with_uri_scheme_only),
(server_matches_content_requirements),
(nautilus_do_component_query),
(nautilus_view_query_get_popup_components_for_file),
(nautilus_view_query_get_property_components_for_file):
Remove a couple of unused keys from nautilus-metadata.h
Diffstat (limited to 'libnautilus-private')
-rw-r--r-- | libnautilus-private/nautilus-metadata.h | 10 | ||||
-rw-r--r-- | libnautilus-private/nautilus-mime-actions.c | 186 | ||||
-rw-r--r-- | libnautilus-private/nautilus-view-query.c | 133 |
3 files changed, 42 insertions, 287 deletions
diff --git a/libnautilus-private/nautilus-metadata.h b/libnautilus-private/nautilus-metadata.h index 64dc7ec1c..254cb743b 100644 --- a/libnautilus-private/nautilus-metadata.h +++ b/libnautilus-private/nautilus-metadata.h @@ -33,17 +33,7 @@ #define NAUTILUS_METADATA_KEY_CONTENT_VIEWS "content_views" -#define NAUTILUS_METADATA_KEY_DEFAULT_ACTION_TYPE "default_action_type" -#define NAUTILUS_METADATA_KEY_DEFAULT_APPLICATION "default_application" #define NAUTILUS_METADATA_KEY_DEFAULT_COMPONENT "default_component" -#define NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_ADD "short_list_application_add" -#define NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE "short_list_application_remove" -#define NAUTILUS_METADATA_KEY_EXPLICIT_APPLICATION "application" -#define NAUTILUS_METADATA_SUBKEY_APPLICATION_ID "id" -#define NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_ADD "short_list_component_add" -#define NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_REMOVE "short_list_component_remove" -#define NAUTILUS_METADATA_KEY_EXPLICIT_COMPONENT "explicit_content_view" -#define NAUTILUS_METADATA_SUBKEY_COMPONENT_IID "iid" #define NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_COLOR "background_color" #define NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_IMAGE "background_tile_image" diff --git a/libnautilus-private/nautilus-mime-actions.c b/libnautilus-private/nautilus-mime-actions.c index fce813db5..830301535 100644 --- a/libnautilus-private/nautilus-mime-actions.c +++ b/libnautilus-private/nautilus-mime-actions.c @@ -37,10 +37,6 @@ static int gnome_vfs_mime_application_has_id (GnomeVFSMimeApplication *application, const char *id); -static int gnome_vfs_mime_id_matches_application (const char *id, - GnomeVFSMimeApplication *application); -static gboolean gnome_vfs_mime_application_has_id_not_in_list (GnomeVFSMimeApplication *application, - GList *ids); static gboolean application_supports_uri_scheme (gpointer data, gpointer uri_scheme); @@ -94,87 +90,51 @@ nautilus_mime_actions_get_full_file_attributes (void) NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES; } -static GnomeVFSMimeApplication * -nautilus_mime_get_default_application_for_file_internal (NautilusFile *file, - gboolean *user_chosen) +GnomeVFSMimeApplication * +nautilus_mime_get_default_application_for_file (NautilusFile *file) { char *mime_type; GnomeVFSMimeApplication *result; - char *default_application_string; - gboolean used_user_chosen_info; char *uri_scheme; if (!nautilus_mime_actions_check_if_open_with_attributes_ready (file)) { return NULL; } - - used_user_chosen_info = TRUE; - - default_application_string = nautilus_file_get_metadata - (file, NAUTILUS_METADATA_KEY_DEFAULT_APPLICATION, NULL); - - /* FIXME bugzilla.gnome.org 45085: should fall back to normal default - if user-specified default is bogus */ - uri_scheme = nautilus_file_get_uri_scheme (file); - result = NULL; - if (default_application_string != NULL) { - result = gnome_vfs_application_registry_get_mime_application (default_application_string); - if (result != NULL && !application_supports_uri_scheme (result, uri_scheme)) { - gnome_vfs_mime_application_free (result); - result = NULL; - } + /* TODO: this should maybe use gnome_vfs_mime_get_default_application_for_scheme, + but thats not public atm */ + + mime_type = nautilus_file_get_mime_type (file); + result = gnome_vfs_mime_get_default_application (mime_type); + if (result != NULL && !application_supports_uri_scheme (result, uri_scheme)) { + result = NULL; } - + if (result == NULL) { - /* TODO: this should maybe use gnome_vfs_mime_get_default_application_for_scheme, - but thats not public atm */ - - mime_type = nautilus_file_get_mime_type (file); - result = gnome_vfs_mime_get_default_application (mime_type); - if (result != NULL && !application_supports_uri_scheme (result, uri_scheme)) { - result = NULL; - } - - if (result == NULL) { - GList *all_applications, *l; - - all_applications = nautilus_mime_get_open_with_applications_for_file (file); - - for (l = all_applications; l != NULL; l = l->next) { - result = gnome_vfs_mime_application_copy (l->data); - if (result != NULL && !application_supports_uri_scheme (result, uri_scheme)) { - gnome_vfs_mime_application_free (result); - result = NULL; - } - if (result != NULL) - break; + GList *all_applications, *l; + + all_applications = nautilus_mime_get_open_with_applications_for_file (file); + + for (l = all_applications; l != NULL; l = l->next) { + result = gnome_vfs_mime_application_copy (l->data); + if (result != NULL && !application_supports_uri_scheme (result, uri_scheme)) { + gnome_vfs_mime_application_free (result); + result = NULL; } - gnome_vfs_mime_application_list_free (all_applications); + if (result != NULL) + break; } - - g_free (mime_type); - used_user_chosen_info = FALSE; - } - - g_free (uri_scheme); - - if (user_chosen != NULL) { - *user_chosen = used_user_chosen_info; + gnome_vfs_mime_application_list_free (all_applications); } + + g_free (mime_type); - g_free (default_application_string); + g_free (uri_scheme); return result; } -GnomeVFSMimeApplication * -nautilus_mime_get_default_application_for_file (NautilusFile *file) -{ - return nautilus_mime_get_default_application_for_file_internal (file, NULL); -} - static GList * get_open_with_mime_applications (NautilusFile *file) { @@ -218,10 +178,6 @@ nautilus_mime_get_open_with_applications_for_file (NautilusFile *file) char *uri_scheme; GList *result; GList *removed; - GList *metadata_application_add_ids; - GList *metadata_application_remove_ids; - GList *p; - GnomeVFSMimeApplication *application; if (!nautilus_mime_actions_check_if_open_with_attributes_ready (file)) { return NULL; @@ -236,81 +192,21 @@ nautilus_mime_get_open_with_applications_for_file (NautilusFile *file) uri_scheme, &removed); gnome_vfs_mime_application_list_free (removed); g_free (uri_scheme); - - metadata_application_add_ids = nautilus_file_get_metadata_list - (file, - NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_ADD, - NAUTILUS_METADATA_SUBKEY_APPLICATION_ID); - metadata_application_remove_ids = nautilus_file_get_metadata_list - (file, - NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE, - NAUTILUS_METADATA_SUBKEY_APPLICATION_ID); - - - result = eel_g_list_partition (result, (EelPredicateFunction) gnome_vfs_mime_application_has_id_not_in_list, - metadata_application_remove_ids, &removed); - - gnome_vfs_mime_application_list_free (removed); - result = g_list_reverse (result); - for (p = metadata_application_add_ids; p != NULL; p = p->next) { - if (g_list_find_custom (result, - p->data, - (GCompareFunc) gnome_vfs_mime_application_has_id) == NULL && - g_list_find_custom (metadata_application_remove_ids, - p->data, - (GCompareFunc) strcmp) == NULL) { - application = gnome_vfs_application_registry_get_mime_application (p->data); - if (application != NULL) { - result = g_list_prepend (result, application); - } - } - } - result = g_list_reverse (result); - - eel_g_list_free_deep (metadata_application_add_ids); - eel_g_list_free_deep (metadata_application_remove_ids); - - return result; + return g_list_reverse (result); } GList * nautilus_mime_get_applications_for_file (NautilusFile *file) { char *mime_type; - GList *result; - GList *metadata_application_ids; - GList *p; - GnomeVFSMimeApplication *application; if (!nautilus_mime_actions_check_if_minimum_attributes_ready (file)) { return NULL; } - - metadata_application_ids = nautilus_file_get_metadata_list - (file, - NAUTILUS_METADATA_KEY_EXPLICIT_APPLICATION, - NAUTILUS_METADATA_SUBKEY_APPLICATION_ID); - mime_type = nautilus_file_get_mime_type (file); - result = gnome_vfs_mime_get_all_applications (mime_type); - - for (p = metadata_application_ids; p != NULL; p = p->next) { - if (!g_list_find_custom (result, - p->data, - (GCompareFunc) gnome_vfs_mime_application_has_id)) { - application = gnome_vfs_application_registry_get_mime_application (p->data); - - if (application != NULL) { - result = g_list_prepend (result, application); - } - } - } - - eel_g_list_free_deep (metadata_application_ids); - g_free (mime_type); - return result; + return gnome_vfs_mime_get_all_applications (mime_type); } static int @@ -344,19 +240,6 @@ nautilus_mime_has_any_applications_for_file (NautilusFile *file) return result; } -GnomeVFSResult -nautilus_mime_set_default_application_for_file (NautilusFile *file, - const char *application_id) -{ - g_return_val_if_fail (nautilus_mime_actions_check_if_minimum_attributes_ready (file), - GNOME_VFS_ERROR_GENERIC); - - nautilus_file_set_metadata - (file, NAUTILUS_METADATA_KEY_DEFAULT_APPLICATION, NULL, application_id); - - return GNOME_VFS_OK; -} - static int gnome_vfs_mime_application_has_id (GnomeVFSMimeApplication *application, const char *id) @@ -364,21 +247,6 @@ gnome_vfs_mime_application_has_id (GnomeVFSMimeApplication *application, return strcmp (application->id, id); } -static int -gnome_vfs_mime_id_matches_application (const char *id, - GnomeVFSMimeApplication *application) -{ - return gnome_vfs_mime_application_has_id (application, id); -} - -static gboolean -gnome_vfs_mime_application_has_id_not_in_list (GnomeVFSMimeApplication *application, - GList *ids) -{ - return g_list_find_custom (ids, application, - (GCompareFunc) gnome_vfs_mime_id_matches_application) == NULL; -} - static gboolean application_supports_uri_scheme (gpointer data, gpointer uri_scheme) diff --git a/libnautilus-private/nautilus-view-query.c b/libnautilus-private/nautilus-view-query.c index ed71060df..bc0ce1614 100644 --- a/libnautilus-private/nautilus-view-query.c +++ b/libnautilus-private/nautilus-view-query.c @@ -38,13 +38,11 @@ #include <stdio.h> static char *mime_type_get_supertype (const char *mime_type); -static GList *get_explicit_content_view_iids_from_metafile (NautilusFile *file); static gboolean server_has_content_requirements (Bonobo_ServerInfo *server); static GList *nautilus_do_component_query (const char *mime_type, const char *uri_scheme, GList *content_mime_types, gboolean ignore_content_mime_types, - GList *explicit_iids, char **extra_sort_criteria, char *extra_requirements, gboolean must_be_view); @@ -153,7 +151,6 @@ nautilus_view_query_get_default_component_for_file_internal (NautilusFile *file, char *mime_type; char *uri_scheme; GList *item_mime_types; - GList *explicit_iids; Bonobo_ServerInfo *server; char **sort_conditions; char *extra_requirements; @@ -169,8 +166,6 @@ nautilus_view_query_get_default_component_for_file_internal (NautilusFile *file, uri_scheme = nautilus_file_get_uri_scheme (file); - explicit_iids = get_explicit_content_view_iids_from_metafile (file); - if (!nautilus_view_query_check_if_full_attributes_ready (file) || !nautilus_file_get_directory_item_mime_types (file, &item_mime_types)) { item_mime_types = NULL; @@ -202,13 +197,13 @@ nautilus_view_query_get_default_component_for_file_internal (NautilusFile *file, 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, TRUE); + sort_conditions, extra_requirements, TRUE); 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, TRUE); + sort_conditions, NULL, TRUE); } if (info_list != NULL) { @@ -219,7 +214,6 @@ nautilus_view_query_get_default_component_for_file_internal (NautilusFile *file, } eel_g_list_free_deep (item_mime_types); - eel_g_list_free_deep (explicit_iids); g_strfreev (sort_conditions); g_free (uri_scheme); @@ -250,7 +244,6 @@ nautilus_view_query_get_components_for_file (NautilusFile *file) char *uri_scheme; GList *item_mime_types; GList *info_list; - GList *explicit_iids; if (!nautilus_view_query_check_if_minimum_attributes_ready (file)) { return NULL; @@ -259,7 +252,6 @@ nautilus_view_query_get_components_for_file (NautilusFile *file) uri_scheme = nautilus_file_get_uri_scheme (file); mime_type = nautilus_file_get_mime_type (file); - explicit_iids = get_explicit_content_view_iids_from_metafile (file); if (!nautilus_view_query_check_if_full_attributes_ready (file) || !nautilus_file_get_directory_item_mime_types (file, &item_mime_types)) { @@ -268,10 +260,8 @@ nautilus_view_query_get_components_for_file (NautilusFile *file) info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, FALSE, - explicit_iids, NULL, - NULL, TRUE); + NULL, NULL, TRUE); - eel_g_list_free_deep (explicit_iids); eel_g_list_free_deep (item_mime_types); g_free (uri_scheme); @@ -326,80 +316,18 @@ mime_type_get_supertype (const char *mime_type) return extract_prefix_add_suffix (mime_type, "/", "/*"); } - -/* - * 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 <FILE> element. - */ - -static GList * -get_explicit_content_view_iids_from_metafile (NautilusFile *file) -{ - if (file != NULL) { - return nautilus_file_get_metadata_list - (file, - NAUTILUS_METADATA_KEY_EXPLICIT_COMPONENT, - NAUTILUS_METADATA_SUBKEY_COMPONENT_IID); - } else { - return NULL; - } -} - -static char * -make_bonobo_activation_query_for_explicit_content_view_iids (GList *view_iids) -{ - GList *p; - char *iid; - char *query; - char *old_query; - - query = NULL; - - for (p = view_iids; p != NULL; p = p->next) { - iid = (char *) p->data; - if (query != NULL) { - old_query = query; - query = g_strconcat (query, " OR ", NULL); - g_free (old_query); - } else { - query = g_strdup ("("); - } - - old_query = query; - query = g_strdup_printf ("%s iid=='%s'", old_query, iid); - g_free (old_query); - } - - - if (query != NULL) { - old_query = query; - query = g_strconcat (old_query, ")", NULL); - g_free (old_query); - } else { - query = g_strdup ("false"); - } - - return query; -} - static char * make_bonobo_activation_query_with_known_mime_type (const char *mime_type, const char *uri_scheme, - GList *explicit_iids, const char *extra_requirements, gboolean must_be_view) { char *mime_supertype; char *result; - char *explicit_iid_query; const char *view_as_name_logic; mime_supertype = mime_type_get_supertype (mime_type); - explicit_iid_query = make_bonobo_activation_query_for_explicit_content_view_iids (explicit_iids); - if (must_be_view) { view_as_name_logic = "nautilus:view_as_name.defined ()"; } else { @@ -432,7 +360,7 @@ make_bonobo_activation_query_with_known_mime_type (const char *mime_type, /* Check that the supported MIME types include the * URI's MIME type or its supertype. */ - "((NOT bonobo:supported_mime_types.defined ()" + "(NOT bonobo:supported_mime_types.defined ()" "OR bonobo:supported_mime_types.has ('%s')" "OR bonobo:supported_mime_types.has ('%s')" "OR bonobo:supported_mime_types.has ('*/*'))" @@ -458,12 +386,6 @@ make_bonobo_activation_query_with_known_mime_type (const char *mime_type, * Nautilus appear. */ "AND %s)" - - /* Also select iids that were specifically requested - for this location, even if they do not otherwise - meet the requirements. */ - "OR %s)" - /* Make it possible to add extra requirements */ " AND (%s)" @@ -472,8 +394,7 @@ make_bonobo_activation_query_with_known_mime_type (const char *mime_type, */ , mime_type, mime_supertype, uri_scheme, uri_scheme, - /* The explicit metafile iid query for the %s above. */ - view_as_name_logic, explicit_iid_query + view_as_name_logic /* extra requirements */ , extra_requirements != NULL ? extra_requirements : "true"); @@ -507,22 +428,17 @@ make_bonobo_activation_query_with_known_mime_type (const char *mime_type, } g_free (mime_supertype); - g_free (explicit_iid_query); return result; } static char * make_bonobo_activation_query_with_uri_scheme_only (const char *uri_scheme, - GList *explicit_iids, - const char *extra_requirements, - gboolean must_be_view) + const char *extra_requirements, + gboolean must_be_view) { char *result; - char *explicit_iid_query; const char *view_as_name_logic; - explicit_iid_query = make_bonobo_activation_query_for_explicit_content_view_iids (explicit_iids); - if (must_be_view) { view_as_name_logic = "nautilus:view_as_name.defined ()"; } else { @@ -535,7 +451,7 @@ make_bonobo_activation_query_with_uri_scheme_only (const char *uri_scheme, /* Check if the component supports this particular * URI scheme. */ - "(((bonobo:supported_uri_schemes.has ('%s')" + "((bonobo:supported_uri_schemes.has ('%s')" "OR bonobo:supported_uri_schemes.has ('*'))" /* Check that the component doesn't require @@ -557,12 +473,6 @@ make_bonobo_activation_query_with_uri_scheme_only (const char *uri_scheme, * Nautilus appear. */ "AND %s)" - /* Also select iids that were specifically requested - for this location, even if they do not otherwise - meet the requirements. */ - - "OR %s)" - /* Make it possible to add extra requirements */ " AND (%s)" @@ -570,8 +480,7 @@ make_bonobo_activation_query_with_uri_scheme_only (const char *uri_scheme, , uri_scheme, uri_scheme, view_as_name_logic /* The explicit metafile iid query for the %s above. */ - , explicit_iid_query, - extra_requirements != NULL ? extra_requirements : "true"); + , extra_requirements != NULL ? extra_requirements : "true"); if (must_be_view) { @@ -602,9 +511,6 @@ make_bonobo_activation_query_with_uri_scheme_only (const char *uri_scheme, result = str; } - - g_free (explicit_iid_query); - return result; } @@ -668,18 +574,12 @@ server_has_content_requirements (Bonobo_ServerInfo *server) static gboolean server_matches_content_requirements (Bonobo_ServerInfo *server, - GHashTable *type_table, - GList *explicit_iids) + GHashTable *type_table) { Bonobo_ActivationProperty *prop; Bonobo_StringList types; guint i; - /* Components explicitly requested in the metafile are not capability tested. */ - if (g_list_find_custom (explicit_iids, (gpointer) server->iid, (GCompareFunc) strcmp) != NULL) { - return TRUE; - } - if (!server_has_content_requirements (server)) { return TRUE; } else { @@ -716,7 +616,6 @@ 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, gboolean must_be_view) @@ -731,9 +630,9 @@ nautilus_do_component_query (const char *mime_type, query = NULL; if (is_known_mime_type (mime_type)) { - query = make_bonobo_activation_query_with_known_mime_type (mime_type, uri_scheme, explicit_iids, extra_requirements, must_be_view); + query = make_bonobo_activation_query_with_known_mime_type (mime_type, uri_scheme, extra_requirements, must_be_view); } else { - query = make_bonobo_activation_query_with_uri_scheme_only (uri_scheme, explicit_iids, extra_requirements, must_be_view); + query = make_bonobo_activation_query_with_uri_scheme_only (uri_scheme, extra_requirements, must_be_view); } all_sort_criteria = strv_concat (extra_sort_criteria, nautilus_sort_criteria); @@ -759,7 +658,7 @@ nautilus_do_component_query (const char *mime_type, server = &bonobo_activation_result->_buffer[i]; if (ignore_content_mime_types || - server_matches_content_requirements (server, content_types, explicit_iids)) { + server_matches_content_requirements (server, content_types)) { if (server->iid != NULL) { retval = g_list_prepend (retval, @@ -848,8 +747,7 @@ nautilus_view_query_get_popup_components_for_file (NautilusFile *file) info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, FALSE, - NULL, NULL, - extra_reqs, FALSE); + NULL, extra_reqs, FALSE); eel_g_list_free_deep (item_mime_types); @@ -886,8 +784,7 @@ nautilus_view_query_get_property_components_for_file (NautilusFile *file) info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, FALSE, - NULL, NULL, - extra_reqs, FALSE); + NULL, extra_reqs, FALSE); eel_g_list_free_deep (item_mime_types); |