Commit 64265335 authored by John Sullivan's avatar John Sullivan

Used newly-publicized functions from gnome-vfs-mime-handlers.c

	to avoid replicating a bunch of code.

	* libnautilus-extensions/nautilus-mime-actions.c:
	(gnome_vfs_mime_application_matches_id),
	(gnome_vfs_mime_component_matches_id),
	(gnome_vfs_mime_id_in_application_list),
	(gnome_vfs_mime_id_in_component_list),
	(id_list_from_application_list),
	(id_list_from_component_list):
	Removed these functions.

	(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):
	Rewrote to call newly-publicized gnome-vfs-mime functions.
parent 715b2e71
2000-06-05 John Sullivan <sullivan@eazel.com>
Used newly-publicized functions from gnome-vfs-mime-handlers.c
to avoid replicating a bunch of code.
* libnautilus-extensions/nautilus-mime-actions.c:
(gnome_vfs_mime_application_matches_id),
(gnome_vfs_mime_component_matches_id),
(gnome_vfs_mime_id_in_application_list),
(gnome_vfs_mime_id_in_component_list),
(id_list_from_application_list),
(id_list_from_component_list):
Removed these functions.
(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):
Rewrote to call newly-publicized gnome-vfs-mime functions.
2000-06-05 John Sullivan <sullivan@eazel.com>
Cleaned up the directory view code that launches applications
......
......@@ -39,15 +39,9 @@
static gint gnome_vfs_mime_application_has_id (GnomeVFSMimeApplication *application, const char *id);
static gint gnome_vfs_mime_id_matches_application (const char *id, GnomeVFSMimeApplication *application);
static gint gnome_vfs_mime_id_matches_component (const char *iid, OAF_ServerInfo *component);
static gint gnome_vfs_mime_application_matches_id (GnomeVFSMimeApplication *application, const char *id);
static gint gnome_vfs_mime_component_matches_id (OAF_ServerInfo *component, const char *iid);
static gboolean gnome_vfs_mime_application_has_id_not_in_list (GnomeVFSMimeApplication *application, GList *ids);
static gboolean component_has_id_in_list (OAF_ServerInfo *server, GList *iids);
static gboolean gnome_vfs_mime_id_in_application_list (const char *id, GList *applications);
static gboolean gnome_vfs_mime_id_in_component_list (const char *iid, GList *components);
static gboolean string_not_in_list (const char *str, GList *list);
static GList *id_list_from_application_list (GList *applications);
static GList *id_list_from_component_list (GList *applications);
static OAF_ServerInfo *OAF_ServerInfo__copy (OAF_ServerInfo *orig);
static char *extract_prefix_add_suffix (const char *string, const char *separator, const char *suffix);
static char *mime_type_get_supertype (const char *mime_type);
......@@ -638,38 +632,6 @@ nautilus_mime_set_short_list_components_for_uri (const char *uri,
/* FIXME: need to free normal_short_list, normal_short_list_ids, add_list, remove_list */
}
static GList *
id_list_from_application_list (GList *applications)
{
GList *result;
GList *node;
result = NULL;
for (node = applications; node != NULL; node = node->next) {
result = g_list_append
(result, g_strdup (((GnomeVFSMimeApplication *)node->data)->id));
}
return result;
}
static GList *
id_list_from_component_list (GList *components)
{
GList *result;
GList *node;
result = NULL;
for (node = components; node != NULL; node = node->next) {
result = g_list_append
(result, g_strdup (((OAF_ServerInfo *)node->data)->iid));
}
return result;
}
void nautilus_mime_add_application_to_short_list_for_uri (const char *uri,
const char *application_id)
{
......@@ -678,7 +640,7 @@ void nautilus_mime_add_application_to_short_list_for_uri (const char *uri,
old_list = nautilus_mime_get_short_list_applications_for_uri (uri);
if (!gnome_vfs_mime_id_in_application_list (application_id, old_list)) {
new_list = g_list_append (id_list_from_application_list (old_list),
new_list = g_list_append (gnome_vfs_mime_id_list_from_application_list (old_list),
g_strdup (application_id));
nautilus_mime_set_short_list_applications_for_uri (uri, new_list);
nautilus_g_list_free_deep (new_list);
......@@ -691,16 +653,15 @@ void
nautilus_mime_remove_application_from_short_list_for_uri (const char *uri,
const char *application_id)
{
GList *old_list, *matching_node, *new_list;
GList *old_list, *new_list;
gboolean was_in_list;
old_list = nautilus_mime_get_short_list_applications_for_uri (uri);
old_list = gnome_vfs_mime_remove_application_from_list
(old_list, application_id, &was_in_list);
matching_node = g_list_find_custom
(old_list, (gpointer)application_id, (GCompareFunc) gnome_vfs_mime_application_matches_id);
if (matching_node != NULL) {
old_list = g_list_remove_link (old_list, matching_node);
gnome_vfs_mime_application_list_free (matching_node);
new_list = id_list_from_application_list (old_list);
if (was_in_list) {
new_list = gnome_vfs_mime_id_list_from_application_list (old_list);
nautilus_mime_set_short_list_applications_for_uri (uri, new_list);
nautilus_g_list_free_deep (new_list);
}
......@@ -717,7 +678,7 @@ nautilus_mime_add_component_to_short_list_for_uri (const char *uri,
old_list = nautilus_mime_get_short_list_components_for_uri (uri);
if (!gnome_vfs_mime_id_in_component_list (iid, old_list)) {
new_list = g_list_append (id_list_from_component_list (old_list),
new_list = g_list_append (gnome_vfs_mime_id_list_from_component_list (old_list),
g_strdup (iid));
nautilus_mime_set_short_list_components_for_uri (uri, new_list);
nautilus_g_list_free_deep (new_list);
......@@ -730,16 +691,15 @@ void
nautilus_mime_remove_component_from_short_list_for_uri (const char *uri,
const char *iid)
{
GList *old_list, *matching_node, *new_list;
GList *old_list, *new_list;
gboolean was_in_list;
old_list = nautilus_mime_get_short_list_components_for_uri (uri);
old_list = gnome_vfs_mime_remove_component_from_list
(old_list, iid, &was_in_list);
matching_node = g_list_find_custom
(old_list, (gpointer) iid, (GCompareFunc) gnome_vfs_mime_component_matches_id);
if (matching_node != NULL) {
old_list = g_list_remove_link (old_list, matching_node);
gnome_vfs_mime_component_list_free (matching_node);
new_list = id_list_from_component_list (old_list);
if (was_in_list) {
new_list = gnome_vfs_mime_id_list_from_component_list (old_list);
nautilus_mime_set_short_list_components_for_uri (uri, new_list);
nautilus_g_list_free_deep (new_list);
}
......@@ -809,19 +769,6 @@ gnome_vfs_mime_id_matches_component (const char *iid, OAF_ServerInfo *component)
return strcmp (component->iid, iid);
}
static gint
gnome_vfs_mime_application_matches_id (GnomeVFSMimeApplication *application, const char *id)
{
return gnome_vfs_mime_id_matches_application (id, application);
}
static gint
gnome_vfs_mime_component_matches_id (OAF_ServerInfo *component, const char *iid)
{
return gnome_vfs_mime_id_matches_component (iid, component);
}
static gboolean
gnome_vfs_mime_application_has_id_not_in_list (GnomeVFSMimeApplication *application, GList *ids)
{
......@@ -834,18 +781,6 @@ component_has_id_in_list (OAF_ServerInfo *server, GList *iids)
return g_list_find_custom (iids, server, (GCompareFunc) gnome_vfs_mime_id_matches_component) != NULL;
}
static gboolean
gnome_vfs_mime_id_in_application_list (const char *id, GList *applications)
{
return g_list_find_custom (applications, (gpointer) id, (GCompareFunc) gnome_vfs_mime_application_matches_id) != NULL;
}
static gboolean
gnome_vfs_mime_id_in_component_list (const char *iid, GList *components)
{
return g_list_find_custom (components, (gpointer) iid, (GCompareFunc) gnome_vfs_mime_component_matches_id) != NULL;
}
static gboolean
string_not_in_list (const char *str, GList *list)
{
......
......@@ -39,15 +39,9 @@
static gint gnome_vfs_mime_application_has_id (GnomeVFSMimeApplication *application, const char *id);
static gint gnome_vfs_mime_id_matches_application (const char *id, GnomeVFSMimeApplication *application);
static gint gnome_vfs_mime_id_matches_component (const char *iid, OAF_ServerInfo *component);
static gint gnome_vfs_mime_application_matches_id (GnomeVFSMimeApplication *application, const char *id);
static gint gnome_vfs_mime_component_matches_id (OAF_ServerInfo *component, const char *iid);
static gboolean gnome_vfs_mime_application_has_id_not_in_list (GnomeVFSMimeApplication *application, GList *ids);
static gboolean component_has_id_in_list (OAF_ServerInfo *server, GList *iids);
static gboolean gnome_vfs_mime_id_in_application_list (const char *id, GList *applications);
static gboolean gnome_vfs_mime_id_in_component_list (const char *iid, GList *components);
static gboolean string_not_in_list (const char *str, GList *list);
static GList *id_list_from_application_list (GList *applications);
static GList *id_list_from_component_list (GList *applications);
static OAF_ServerInfo *OAF_ServerInfo__copy (OAF_ServerInfo *orig);
static char *extract_prefix_add_suffix (const char *string, const char *separator, const char *suffix);
static char *mime_type_get_supertype (const char *mime_type);
......@@ -638,38 +632,6 @@ nautilus_mime_set_short_list_components_for_uri (const char *uri,
/* FIXME: need to free normal_short_list, normal_short_list_ids, add_list, remove_list */
}
static GList *
id_list_from_application_list (GList *applications)
{
GList *result;
GList *node;
result = NULL;
for (node = applications; node != NULL; node = node->next) {
result = g_list_append
(result, g_strdup (((GnomeVFSMimeApplication *)node->data)->id));
}
return result;
}
static GList *
id_list_from_component_list (GList *components)
{
GList *result;
GList *node;
result = NULL;
for (node = components; node != NULL; node = node->next) {
result = g_list_append
(result, g_strdup (((OAF_ServerInfo *)node->data)->iid));
}
return result;
}
void nautilus_mime_add_application_to_short_list_for_uri (const char *uri,
const char *application_id)
{
......@@ -678,7 +640,7 @@ void nautilus_mime_add_application_to_short_list_for_uri (const char *uri,
old_list = nautilus_mime_get_short_list_applications_for_uri (uri);
if (!gnome_vfs_mime_id_in_application_list (application_id, old_list)) {
new_list = g_list_append (id_list_from_application_list (old_list),
new_list = g_list_append (gnome_vfs_mime_id_list_from_application_list (old_list),
g_strdup (application_id));
nautilus_mime_set_short_list_applications_for_uri (uri, new_list);
nautilus_g_list_free_deep (new_list);
......@@ -691,16 +653,15 @@ void
nautilus_mime_remove_application_from_short_list_for_uri (const char *uri,
const char *application_id)
{
GList *old_list, *matching_node, *new_list;
GList *old_list, *new_list;
gboolean was_in_list;
old_list = nautilus_mime_get_short_list_applications_for_uri (uri);
old_list = gnome_vfs_mime_remove_application_from_list
(old_list, application_id, &was_in_list);
matching_node = g_list_find_custom
(old_list, (gpointer)application_id, (GCompareFunc) gnome_vfs_mime_application_matches_id);
if (matching_node != NULL) {
old_list = g_list_remove_link (old_list, matching_node);
gnome_vfs_mime_application_list_free (matching_node);
new_list = id_list_from_application_list (old_list);
if (was_in_list) {
new_list = gnome_vfs_mime_id_list_from_application_list (old_list);
nautilus_mime_set_short_list_applications_for_uri (uri, new_list);
nautilus_g_list_free_deep (new_list);
}
......@@ -717,7 +678,7 @@ nautilus_mime_add_component_to_short_list_for_uri (const char *uri,
old_list = nautilus_mime_get_short_list_components_for_uri (uri);
if (!gnome_vfs_mime_id_in_component_list (iid, old_list)) {
new_list = g_list_append (id_list_from_component_list (old_list),
new_list = g_list_append (gnome_vfs_mime_id_list_from_component_list (old_list),
g_strdup (iid));
nautilus_mime_set_short_list_components_for_uri (uri, new_list);
nautilus_g_list_free_deep (new_list);
......@@ -730,16 +691,15 @@ void
nautilus_mime_remove_component_from_short_list_for_uri (const char *uri,
const char *iid)
{
GList *old_list, *matching_node, *new_list;
GList *old_list, *new_list;
gboolean was_in_list;
old_list = nautilus_mime_get_short_list_components_for_uri (uri);
old_list = gnome_vfs_mime_remove_component_from_list
(old_list, iid, &was_in_list);
matching_node = g_list_find_custom
(old_list, (gpointer) iid, (GCompareFunc) gnome_vfs_mime_component_matches_id);
if (matching_node != NULL) {
old_list = g_list_remove_link (old_list, matching_node);
gnome_vfs_mime_component_list_free (matching_node);
new_list = id_list_from_component_list (old_list);
if (was_in_list) {
new_list = gnome_vfs_mime_id_list_from_component_list (old_list);
nautilus_mime_set_short_list_components_for_uri (uri, new_list);
nautilus_g_list_free_deep (new_list);
}
......@@ -809,19 +769,6 @@ gnome_vfs_mime_id_matches_component (const char *iid, OAF_ServerInfo *component)
return strcmp (component->iid, iid);
}
static gint
gnome_vfs_mime_application_matches_id (GnomeVFSMimeApplication *application, const char *id)
{
return gnome_vfs_mime_id_matches_application (id, application);
}
static gint
gnome_vfs_mime_component_matches_id (OAF_ServerInfo *component, const char *iid)
{
return gnome_vfs_mime_id_matches_component (iid, component);
}
static gboolean
gnome_vfs_mime_application_has_id_not_in_list (GnomeVFSMimeApplication *application, GList *ids)
{
......@@ -834,18 +781,6 @@ component_has_id_in_list (OAF_ServerInfo *server, GList *iids)
return g_list_find_custom (iids, server, (GCompareFunc) gnome_vfs_mime_id_matches_component) != NULL;
}
static gboolean
gnome_vfs_mime_id_in_application_list (const char *id, GList *applications)
{
return g_list_find_custom (applications, (gpointer) id, (GCompareFunc) gnome_vfs_mime_application_matches_id) != NULL;
}
static gboolean
gnome_vfs_mime_id_in_component_list (const char *iid, GList *components)
{
return g_list_find_custom (components, (gpointer) iid, (GCompareFunc) gnome_vfs_mime_component_matches_id) != NULL;
}
static gboolean
string_not_in_list (const char *str, GList *list)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment