mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-25 02:36:07 +00:00
Final portion of task 370 (mime write API)
* libnautilus-extensions/nautilus-mime-actions.h: * libnautilus-extensions/nautilus-mime-actions.c: (nautilus_mime_get_short_list_components_for_uri, nautilus_mime_set_default_action_type_for_uri, nautilus_mime_set_default_application_for_uri, nautilus_mime_set_default_component_for_uri, nautilus_mime_set_short_list_applications_for_uri, nautilus_mime_set_short_list_components_for_uri, nautilus_mime_extend_all_applications_for_uri, nautilus_mime_remove_from_all_applications_for_uri): Implemented (they write the metadata and everything - happy fun). (str_list_difference): Helper function compied from gnome-vfs. * test/test-nautilus-mime-actions-set.c: Tests for these functions. * test/Makefile.am: Build it.
This commit is contained in:
parent
f30271afae
commit
6a4de846aa
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
|||
2000-06-02 Maciej Stachowiak <mjs@eazel.com>
|
||||
|
||||
Final portion of task 370 (mime write API)
|
||||
|
||||
* libnautilus-extensions/nautilus-mime-actions.h: *
|
||||
libnautilus-extensions/nautilus-mime-actions.c:
|
||||
(nautilus_mime_get_short_list_components_for_uri,
|
||||
nautilus_mime_set_default_action_type_for_uri,
|
||||
nautilus_mime_set_default_application_for_uri,
|
||||
nautilus_mime_set_default_component_for_uri,
|
||||
nautilus_mime_set_short_list_applications_for_uri,
|
||||
nautilus_mime_set_short_list_components_for_uri,
|
||||
nautilus_mime_extend_all_applications_for_uri,
|
||||
nautilus_mime_remove_from_all_applications_for_uri): Implemented
|
||||
(they write the metadata and everything - happy fun).
|
||||
(str_list_difference): Helper function compied from gnome-vfs.
|
||||
|
||||
* test/test-nautilus-mime-actions-set.c: Tests for these
|
||||
functions.
|
||||
* test/Makefile.am: Build it.
|
||||
|
||||
2000-06-01 Andy Hertzfeld <andy@eazel.com>
|
||||
|
||||
* src/file-manager/fm-icon-view.c: (play_file):
|
||||
|
|
|
@ -501,6 +501,22 @@ nautilus_do_component_query (const char *mime_type,
|
|||
}
|
||||
|
||||
|
||||
static GList *str_list_difference (GList *a, GList *b)
|
||||
{
|
||||
GList *p;
|
||||
GList *retval;
|
||||
|
||||
retval = NULL;
|
||||
|
||||
for (p = a; p != NULL; p = p->next) {
|
||||
if (g_list_find_custom (b, p->data, (GCompareFunc) strcmp) == NULL) {
|
||||
retval = g_list_prepend (retval, p->data);
|
||||
}
|
||||
}
|
||||
|
||||
retval = g_list_reverse (retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
|
@ -831,8 +847,8 @@ nautilus_mime_get_short_list_components_for_uri (const char *uri)
|
|||
g_list_free (attributes);
|
||||
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
metadata_component_add_ids = nautilus_directory_get_metadata_list (directory, "SHORT_LIST_COMPONENT_ADD", "ID");
|
||||
metadata_component_remove_ids = nautilus_directory_get_metadata_list (directory, "SHORT_LIST_COMPONENT_REMOVE", "ID");
|
||||
metadata_component_add_ids = nautilus_directory_get_metadata_list (directory, "SHORT_LIST_COMPONENT_ADD", "IID");
|
||||
metadata_component_remove_ids = nautilus_directory_get_metadata_list (directory, "SHORT_LIST_COMPONENT_REMOVE", "IID");
|
||||
nautilus_directory_unref (directory);
|
||||
|
||||
mime_type = get_mime_type_from_uri (uri);
|
||||
|
@ -961,55 +977,187 @@ nautilus_mime_get_all_components_for_uri (const char *uri)
|
|||
|
||||
|
||||
void
|
||||
nautilus_mime_set_default_action_type_for_uri (const char *mime_type,
|
||||
nautilus_mime_set_default_action_type_for_uri (const char *uri,
|
||||
GnomeVFSMimeActionType action_type)
|
||||
{
|
||||
return;
|
||||
NautilusDirectory *directory;
|
||||
const char *action_string;
|
||||
|
||||
switch (action_type) {
|
||||
case GNOME_VFS_MIME_ACTION_TYPE_APPLICATION:
|
||||
action_string="application";
|
||||
break;
|
||||
case GNOME_VFS_MIME_ACTION_TYPE_COMPONENT:
|
||||
action_string="component";
|
||||
break;
|
||||
case GNOME_VFS_MIME_ACTION_TYPE_NONE:
|
||||
default:
|
||||
action_string="none";
|
||||
}
|
||||
|
||||
|
||||
directory = nautilus_directory_get (uri);
|
||||
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
nautilus_directory_set_metadata (directory, "DEFAULT_ACTION_TYPE", NULL, action_string);
|
||||
nautilus_directory_unref (directory);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nautilus_mime_set_default_application_for_uri (const char *mime_type,
|
||||
GnomeVFSMimeApplication *application)
|
||||
nautilus_mime_set_default_application_for_uri (const char *uri,
|
||||
const char *application_id)
|
||||
{
|
||||
return;
|
||||
NautilusDirectory *directory;
|
||||
|
||||
directory = nautilus_directory_get (uri);
|
||||
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
nautilus_directory_set_metadata (directory, "DEFAULT_APPLICATION", NULL, application_id);
|
||||
nautilus_directory_unref (directory);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nautilus_mime_set_default_component_for_uri (const char *mime_type,
|
||||
OAF_ServerInfo *component_iid)
|
||||
nautilus_mime_set_default_component_for_uri (const char *uri,
|
||||
const char *component_iid)
|
||||
{
|
||||
return;
|
||||
NautilusDirectory *directory;
|
||||
|
||||
directory = nautilus_directory_get (uri);
|
||||
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
nautilus_directory_set_metadata (directory, "DEFAULT_COMPONENT", NULL, component_iid);
|
||||
nautilus_directory_unref (directory);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nautilus_mime_set_short_list_applications_for_uri (const char *mime_type,
|
||||
nautilus_mime_set_short_list_applications_for_uri (const char *uri,
|
||||
GList *applications)
|
||||
{
|
||||
return;
|
||||
NautilusDirectory *directory;
|
||||
GList *add_list;
|
||||
GList *remove_list;
|
||||
GList *normal_short_list;
|
||||
GList *normal_short_list_ids;
|
||||
GList *p;
|
||||
char *mime_type;
|
||||
|
||||
/* get per-mime short list */
|
||||
|
||||
mime_type = get_mime_type_from_uri (uri);
|
||||
|
||||
if (mime_type != NULL) {
|
||||
normal_short_list = gnome_vfs_mime_get_short_list_applications (mime_type);
|
||||
} else {
|
||||
normal_short_list = NULL;
|
||||
}
|
||||
|
||||
normal_short_list_ids = NULL;
|
||||
for (p = normal_short_list; p != NULL; p = p->next) {
|
||||
normal_short_list_ids = g_list_prepend (normal_short_list_ids, ((GnomeVFSMimeApplication *) p->data)->id);
|
||||
}
|
||||
|
||||
/* compute delta */
|
||||
|
||||
add_list = str_list_difference (applications, normal_short_list_ids);
|
||||
remove_list = str_list_difference (normal_short_list_ids, applications);
|
||||
|
||||
directory = nautilus_directory_get (uri);
|
||||
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
nautilus_directory_set_metadata_list (directory, "SHORT_LIST_APPLICATION_ADD", "ID", add_list);
|
||||
nautilus_directory_set_metadata_list (directory, "SHORT_LIST_APPLICATION_REMOVE", "ID", remove_list);
|
||||
nautilus_directory_unref (directory);
|
||||
|
||||
/* FIXME: need to free normal_short_list, normal_short_list_ids, add_list, remove_list */
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_mime_set_short_list_components_for_uri (const char *mime_type,
|
||||
nautilus_mime_set_short_list_components_for_uri (const char *uri,
|
||||
GList *components)
|
||||
{
|
||||
return;
|
||||
NautilusDirectory *directory;
|
||||
GList *add_list;
|
||||
GList *remove_list;
|
||||
GList *normal_short_list;
|
||||
GList *normal_short_list_ids;
|
||||
GList *p;
|
||||
char *mime_type;
|
||||
|
||||
/* get per-mime short list */
|
||||
|
||||
mime_type = get_mime_type_from_uri (uri);
|
||||
|
||||
if (mime_type != NULL) {
|
||||
normal_short_list = gnome_vfs_mime_get_short_list_components (mime_type);
|
||||
} else {
|
||||
normal_short_list = NULL;
|
||||
}
|
||||
|
||||
normal_short_list_ids = NULL;
|
||||
for (p = normal_short_list; p != NULL; p = p->next) {
|
||||
normal_short_list_ids = g_list_prepend (normal_short_list_ids, ((OAF_ServerInfo *) p->data)->iid);
|
||||
}
|
||||
|
||||
/* compute delta */
|
||||
|
||||
add_list = str_list_difference (components, normal_short_list_ids);
|
||||
remove_list = str_list_difference (normal_short_list_ids, components);
|
||||
|
||||
directory = nautilus_directory_get (uri);
|
||||
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
nautilus_directory_set_metadata_list (directory, "SHORT_LIST_COMPONENT_ADD", "IID", add_list);
|
||||
nautilus_directory_set_metadata_list (directory, "SHORT_LIST_COMPONENT_REMOVE", "IID", remove_list);
|
||||
nautilus_directory_unref (directory);
|
||||
|
||||
/* FIXME: need to free normal_short_list, normal_short_list_ids, add_list, remove_list */
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_mime_extend_all_applications_for_uri (const char *mime_type,
|
||||
nautilus_mime_extend_all_applications_for_uri (const char *uri,
|
||||
GList *applications)
|
||||
{
|
||||
return;
|
||||
NautilusDirectory *directory;
|
||||
GList *metadata_application_ids;
|
||||
GList *extras;
|
||||
GList *final_applications;
|
||||
|
||||
directory = nautilus_directory_get (uri);
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
|
||||
metadata_application_ids = nautilus_directory_get_metadata_list (directory, "APPLICATION", "ID");
|
||||
|
||||
extras = str_list_difference (applications, metadata_application_ids);
|
||||
|
||||
final_applications = g_list_concat (g_list_copy (metadata_application_ids), extras);
|
||||
|
||||
nautilus_directory_set_metadata_list (directory, "APPLICATION", "ID", final_applications);
|
||||
nautilus_directory_unref (directory);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nautilus_mime_remove_from_all_applications_for_uri (const char *mime_type,
|
||||
nautilus_mime_remove_from_all_applications_for_uri (const char *uri,
|
||||
GList *applications)
|
||||
{
|
||||
return;
|
||||
NautilusDirectory *directory;
|
||||
GList *metadata_application_ids;
|
||||
GList *final_applications;
|
||||
|
||||
directory = nautilus_directory_get (uri);
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
|
||||
metadata_application_ids = nautilus_directory_get_metadata_list (directory, "APPLICATION", "ID");
|
||||
|
||||
final_applications = str_list_difference (metadata_application_ids, applications);
|
||||
|
||||
nautilus_directory_set_metadata_list (directory, "APPLICATION", "ID", final_applications);
|
||||
nautilus_directory_unref (directory);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,22 +38,22 @@ GList *nautilus_mime_get_all_applications_for_uri (co
|
|||
GList *nautilus_mime_get_all_components_for_uri (const char *uri);
|
||||
|
||||
|
||||
void nautilus_mime_set_default_action_type_for_uri (const char *mime_type,
|
||||
void nautilus_mime_set_default_action_type_for_uri (const char *uri,
|
||||
GnomeVFSMimeActionType action_type);
|
||||
void nautilus_mime_set_default_application_for_uri (const char *mime_type,
|
||||
GnomeVFSMimeApplication *application);
|
||||
void nautilus_mime_set_default_component_for_uri (const char *mime_type,
|
||||
OAF_ServerInfo *component_iid);
|
||||
void nautilus_mime_set_default_application_for_uri (const char *uri,
|
||||
const char *application_id);
|
||||
void nautilus_mime_set_default_component_for_uri (const char *uri,
|
||||
const char *component_iid);
|
||||
/* Stored as delta to current user level */
|
||||
void nautilus_mime_set_short_list_applications_for_uri (const char *mime_type,
|
||||
void nautilus_mime_set_short_list_applications_for_uri (const char *uri,
|
||||
GList *applications);
|
||||
void nautilus_mime_set_short_list_components_for_uri (const char *mime_type,
|
||||
void nautilus_mime_set_short_list_components_for_uri (const char *uri,
|
||||
GList *components);
|
||||
/* No way to override system list; can only add. */
|
||||
void nautilus_mime_extend_all_applications_for_uri (const char *mime_type,
|
||||
void nautilus_mime_extend_all_applications_for_uri (const char *uri,
|
||||
GList *applications);
|
||||
/* Only "user" entries may be removed. */
|
||||
void nautilus_mime_remove_from_all_applications_for_uri (const char *mime_type,
|
||||
void nautilus_mime_remove_from_all_applications_for_uri (const char *uri,
|
||||
GList *applications);
|
||||
/* No way to add to all components; oafinfo database assumed trusted in this regard. */
|
||||
|
||||
|
|
|
@ -501,6 +501,22 @@ nautilus_do_component_query (const char *mime_type,
|
|||
}
|
||||
|
||||
|
||||
static GList *str_list_difference (GList *a, GList *b)
|
||||
{
|
||||
GList *p;
|
||||
GList *retval;
|
||||
|
||||
retval = NULL;
|
||||
|
||||
for (p = a; p != NULL; p = p->next) {
|
||||
if (g_list_find_custom (b, p->data, (GCompareFunc) strcmp) == NULL) {
|
||||
retval = g_list_prepend (retval, p->data);
|
||||
}
|
||||
}
|
||||
|
||||
retval = g_list_reverse (retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
|
@ -831,8 +847,8 @@ nautilus_mime_get_short_list_components_for_uri (const char *uri)
|
|||
g_list_free (attributes);
|
||||
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
metadata_component_add_ids = nautilus_directory_get_metadata_list (directory, "SHORT_LIST_COMPONENT_ADD", "ID");
|
||||
metadata_component_remove_ids = nautilus_directory_get_metadata_list (directory, "SHORT_LIST_COMPONENT_REMOVE", "ID");
|
||||
metadata_component_add_ids = nautilus_directory_get_metadata_list (directory, "SHORT_LIST_COMPONENT_ADD", "IID");
|
||||
metadata_component_remove_ids = nautilus_directory_get_metadata_list (directory, "SHORT_LIST_COMPONENT_REMOVE", "IID");
|
||||
nautilus_directory_unref (directory);
|
||||
|
||||
mime_type = get_mime_type_from_uri (uri);
|
||||
|
@ -961,55 +977,187 @@ nautilus_mime_get_all_components_for_uri (const char *uri)
|
|||
|
||||
|
||||
void
|
||||
nautilus_mime_set_default_action_type_for_uri (const char *mime_type,
|
||||
nautilus_mime_set_default_action_type_for_uri (const char *uri,
|
||||
GnomeVFSMimeActionType action_type)
|
||||
{
|
||||
return;
|
||||
NautilusDirectory *directory;
|
||||
const char *action_string;
|
||||
|
||||
switch (action_type) {
|
||||
case GNOME_VFS_MIME_ACTION_TYPE_APPLICATION:
|
||||
action_string="application";
|
||||
break;
|
||||
case GNOME_VFS_MIME_ACTION_TYPE_COMPONENT:
|
||||
action_string="component";
|
||||
break;
|
||||
case GNOME_VFS_MIME_ACTION_TYPE_NONE:
|
||||
default:
|
||||
action_string="none";
|
||||
}
|
||||
|
||||
|
||||
directory = nautilus_directory_get (uri);
|
||||
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
nautilus_directory_set_metadata (directory, "DEFAULT_ACTION_TYPE", NULL, action_string);
|
||||
nautilus_directory_unref (directory);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nautilus_mime_set_default_application_for_uri (const char *mime_type,
|
||||
GnomeVFSMimeApplication *application)
|
||||
nautilus_mime_set_default_application_for_uri (const char *uri,
|
||||
const char *application_id)
|
||||
{
|
||||
return;
|
||||
NautilusDirectory *directory;
|
||||
|
||||
directory = nautilus_directory_get (uri);
|
||||
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
nautilus_directory_set_metadata (directory, "DEFAULT_APPLICATION", NULL, application_id);
|
||||
nautilus_directory_unref (directory);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nautilus_mime_set_default_component_for_uri (const char *mime_type,
|
||||
OAF_ServerInfo *component_iid)
|
||||
nautilus_mime_set_default_component_for_uri (const char *uri,
|
||||
const char *component_iid)
|
||||
{
|
||||
return;
|
||||
NautilusDirectory *directory;
|
||||
|
||||
directory = nautilus_directory_get (uri);
|
||||
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
nautilus_directory_set_metadata (directory, "DEFAULT_COMPONENT", NULL, component_iid);
|
||||
nautilus_directory_unref (directory);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nautilus_mime_set_short_list_applications_for_uri (const char *mime_type,
|
||||
nautilus_mime_set_short_list_applications_for_uri (const char *uri,
|
||||
GList *applications)
|
||||
{
|
||||
return;
|
||||
NautilusDirectory *directory;
|
||||
GList *add_list;
|
||||
GList *remove_list;
|
||||
GList *normal_short_list;
|
||||
GList *normal_short_list_ids;
|
||||
GList *p;
|
||||
char *mime_type;
|
||||
|
||||
/* get per-mime short list */
|
||||
|
||||
mime_type = get_mime_type_from_uri (uri);
|
||||
|
||||
if (mime_type != NULL) {
|
||||
normal_short_list = gnome_vfs_mime_get_short_list_applications (mime_type);
|
||||
} else {
|
||||
normal_short_list = NULL;
|
||||
}
|
||||
|
||||
normal_short_list_ids = NULL;
|
||||
for (p = normal_short_list; p != NULL; p = p->next) {
|
||||
normal_short_list_ids = g_list_prepend (normal_short_list_ids, ((GnomeVFSMimeApplication *) p->data)->id);
|
||||
}
|
||||
|
||||
/* compute delta */
|
||||
|
||||
add_list = str_list_difference (applications, normal_short_list_ids);
|
||||
remove_list = str_list_difference (normal_short_list_ids, applications);
|
||||
|
||||
directory = nautilus_directory_get (uri);
|
||||
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
nautilus_directory_set_metadata_list (directory, "SHORT_LIST_APPLICATION_ADD", "ID", add_list);
|
||||
nautilus_directory_set_metadata_list (directory, "SHORT_LIST_APPLICATION_REMOVE", "ID", remove_list);
|
||||
nautilus_directory_unref (directory);
|
||||
|
||||
/* FIXME: need to free normal_short_list, normal_short_list_ids, add_list, remove_list */
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_mime_set_short_list_components_for_uri (const char *mime_type,
|
||||
nautilus_mime_set_short_list_components_for_uri (const char *uri,
|
||||
GList *components)
|
||||
{
|
||||
return;
|
||||
NautilusDirectory *directory;
|
||||
GList *add_list;
|
||||
GList *remove_list;
|
||||
GList *normal_short_list;
|
||||
GList *normal_short_list_ids;
|
||||
GList *p;
|
||||
char *mime_type;
|
||||
|
||||
/* get per-mime short list */
|
||||
|
||||
mime_type = get_mime_type_from_uri (uri);
|
||||
|
||||
if (mime_type != NULL) {
|
||||
normal_short_list = gnome_vfs_mime_get_short_list_components (mime_type);
|
||||
} else {
|
||||
normal_short_list = NULL;
|
||||
}
|
||||
|
||||
normal_short_list_ids = NULL;
|
||||
for (p = normal_short_list; p != NULL; p = p->next) {
|
||||
normal_short_list_ids = g_list_prepend (normal_short_list_ids, ((OAF_ServerInfo *) p->data)->iid);
|
||||
}
|
||||
|
||||
/* compute delta */
|
||||
|
||||
add_list = str_list_difference (components, normal_short_list_ids);
|
||||
remove_list = str_list_difference (normal_short_list_ids, components);
|
||||
|
||||
directory = nautilus_directory_get (uri);
|
||||
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
nautilus_directory_set_metadata_list (directory, "SHORT_LIST_COMPONENT_ADD", "IID", add_list);
|
||||
nautilus_directory_set_metadata_list (directory, "SHORT_LIST_COMPONENT_REMOVE", "IID", remove_list);
|
||||
nautilus_directory_unref (directory);
|
||||
|
||||
/* FIXME: need to free normal_short_list, normal_short_list_ids, add_list, remove_list */
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_mime_extend_all_applications_for_uri (const char *mime_type,
|
||||
nautilus_mime_extend_all_applications_for_uri (const char *uri,
|
||||
GList *applications)
|
||||
{
|
||||
return;
|
||||
NautilusDirectory *directory;
|
||||
GList *metadata_application_ids;
|
||||
GList *extras;
|
||||
GList *final_applications;
|
||||
|
||||
directory = nautilus_directory_get (uri);
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
|
||||
metadata_application_ids = nautilus_directory_get_metadata_list (directory, "APPLICATION", "ID");
|
||||
|
||||
extras = str_list_difference (applications, metadata_application_ids);
|
||||
|
||||
final_applications = g_list_concat (g_list_copy (metadata_application_ids), extras);
|
||||
|
||||
nautilus_directory_set_metadata_list (directory, "APPLICATION", "ID", final_applications);
|
||||
nautilus_directory_unref (directory);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nautilus_mime_remove_from_all_applications_for_uri (const char *mime_type,
|
||||
nautilus_mime_remove_from_all_applications_for_uri (const char *uri,
|
||||
GList *applications)
|
||||
{
|
||||
return;
|
||||
NautilusDirectory *directory;
|
||||
GList *metadata_application_ids;
|
||||
GList *final_applications;
|
||||
|
||||
directory = nautilus_directory_get (uri);
|
||||
nautilus_directory_wait_until_ready (directory, NULL, TRUE);
|
||||
|
||||
metadata_application_ids = nautilus_directory_get_metadata_list (directory, "APPLICATION", "ID");
|
||||
|
||||
final_applications = str_list_difference (metadata_application_ids, applications);
|
||||
|
||||
nautilus_directory_set_metadata_list (directory, "APPLICATION", "ID", final_applications);
|
||||
nautilus_directory_unref (directory);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,22 +38,22 @@ GList *nautilus_mime_get_all_applications_for_uri (co
|
|||
GList *nautilus_mime_get_all_components_for_uri (const char *uri);
|
||||
|
||||
|
||||
void nautilus_mime_set_default_action_type_for_uri (const char *mime_type,
|
||||
void nautilus_mime_set_default_action_type_for_uri (const char *uri,
|
||||
GnomeVFSMimeActionType action_type);
|
||||
void nautilus_mime_set_default_application_for_uri (const char *mime_type,
|
||||
GnomeVFSMimeApplication *application);
|
||||
void nautilus_mime_set_default_component_for_uri (const char *mime_type,
|
||||
OAF_ServerInfo *component_iid);
|
||||
void nautilus_mime_set_default_application_for_uri (const char *uri,
|
||||
const char *application_id);
|
||||
void nautilus_mime_set_default_component_for_uri (const char *uri,
|
||||
const char *component_iid);
|
||||
/* Stored as delta to current user level */
|
||||
void nautilus_mime_set_short_list_applications_for_uri (const char *mime_type,
|
||||
void nautilus_mime_set_short_list_applications_for_uri (const char *uri,
|
||||
GList *applications);
|
||||
void nautilus_mime_set_short_list_components_for_uri (const char *mime_type,
|
||||
void nautilus_mime_set_short_list_components_for_uri (const char *uri,
|
||||
GList *components);
|
||||
/* No way to override system list; can only add. */
|
||||
void nautilus_mime_extend_all_applications_for_uri (const char *mime_type,
|
||||
void nautilus_mime_extend_all_applications_for_uri (const char *uri,
|
||||
GList *applications);
|
||||
/* Only "user" entries may be removed. */
|
||||
void nautilus_mime_remove_from_all_applications_for_uri (const char *mime_type,
|
||||
void nautilus_mime_remove_from_all_applications_for_uri (const char *uri,
|
||||
GList *applications);
|
||||
/* No way to add to all components; oafinfo database assumed trusted in this regard. */
|
||||
|
||||
|
|
|
@ -32,10 +32,13 @@ LDADD =\
|
|||
|
||||
noinst_PROGRAMS = \
|
||||
test-nautilus-mime-actions \
|
||||
test-nautilus-mime-actions-set \
|
||||
$(NULL)
|
||||
|
||||
test_nautilus_mime_actions_SOURCES = test-nautilus-mime-actions.c
|
||||
|
||||
test_nautilus_mime_actions_set_SOURCES = test-nautilus-mime-actions-set.c
|
||||
|
||||
EXTRA_DIST = \
|
||||
test-nautilus-mime-actions.c \
|
||||
$(NULL)
|
||||
|
|
156
test/test-nautilus-mime-actions-set.c
Normal file
156
test/test-nautilus-mime-actions-set.c
Normal file
|
@ -0,0 +1,156 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
/* test-mime.c - Test for the mime handler detection features of the GNOME
|
||||
Virtual File System Library
|
||||
|
||||
Copyright (C) 2000 Eazel
|
||||
|
||||
The Gnome Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Author: Maciej Stachowiak <mjs@eazel.com>
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
|
||||
#include <libnautilus-extensions/nautilus-mime-actions.h>
|
||||
#include <gnome.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
static void
|
||||
usage (const char *name)
|
||||
{
|
||||
fprintf (stderr, "Usage: %s uri field value\n", name);
|
||||
fprintf (stderr, "Valid field values are: \n");
|
||||
fprintf (stderr, "\tdefault_action_type\n");
|
||||
fprintf (stderr, "\tdefault_application\n");
|
||||
fprintf (stderr, "\tdefault_component\n");
|
||||
fprintf (stderr, "\tshort_list_applicationss\n");
|
||||
fprintf (stderr, "\tshort_list_components\n");
|
||||
fprintf (stderr, "\tadd_to_all_applicationss\n");
|
||||
fprintf (stderr, "\tremove_from_all_applications\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
static GnomeVFSMimeActionType
|
||||
str_to_action_type (const char *str)
|
||||
{
|
||||
if (strcasecmp (str, "component") == 0) {
|
||||
return GNOME_VFS_MIME_ACTION_TYPE_COMPONENT;
|
||||
} else if (strcasecmp (str, "application") == 0) {
|
||||
return GNOME_VFS_MIME_ACTION_TYPE_APPLICATION;
|
||||
} else {
|
||||
return GNOME_VFS_MIME_ACTION_TYPE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
static char **
|
||||
strsplit_handle_null (const char *str, const char *delim, int max)
|
||||
{
|
||||
return g_strsplit ((str == NULL ? "" : str), delim, max);
|
||||
}
|
||||
|
||||
|
||||
static GList *gnome_vfs_strsplit_to_list (const char *str, const char *delim, int max)
|
||||
{
|
||||
char **strv;
|
||||
GList *retval;
|
||||
int i;
|
||||
|
||||
strv = strsplit_handle_null (str, delim, max);
|
||||
|
||||
retval = NULL;
|
||||
|
||||
for (i = 0; strv[i] != NULL; i++) {
|
||||
retval = g_list_prepend (retval, strv[i]);
|
||||
}
|
||||
|
||||
retval = g_list_reverse (retval);
|
||||
/* Don't strfreev, since we didn't copy the individual strings. */
|
||||
g_free (strv);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GList *comma_separated_str_to_str_list (const char *str)
|
||||
{
|
||||
return gnome_vfs_strsplit_to_list (str, ",", 0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
const char *uri;
|
||||
const char *field;
|
||||
const char *value;
|
||||
|
||||
g_thread_init (NULL);
|
||||
oaf_init (argc, argv);
|
||||
gnome_vfs_init ();
|
||||
gnome_init("test-nautilus-mime-actions-set", "0.0",
|
||||
argc, argv);
|
||||
|
||||
if (argc < 3) {
|
||||
usage (argv[0]);
|
||||
}
|
||||
|
||||
uri = argv[1];
|
||||
field = argv[2];
|
||||
value = argv[3];
|
||||
|
||||
if (strcmp (field, "default_action_type") == 0) {
|
||||
puts ("default_action_type");
|
||||
nautilus_mime_set_default_action_type_for_uri (uri, str_to_action_type (value));
|
||||
} else if (strcmp (field, "default_application") == 0) {
|
||||
puts ("default_application");
|
||||
nautilus_mime_set_default_application_for_uri (uri, value);
|
||||
} else if (strcmp (field, "default_component") == 0) {
|
||||
puts ("default_component");
|
||||
nautilus_mime_set_default_component_for_uri (uri, value);
|
||||
} else if (strcmp (field, "short_list_applicationss") == 0) {
|
||||
puts ("short_list_applications");
|
||||
nautilus_mime_set_short_list_applications_for_uri
|
||||
(uri, comma_separated_str_to_str_list (value));
|
||||
} else if (strcmp (field, "short_list_components") == 0) {
|
||||
puts ("short_list_components");
|
||||
nautilus_mime_set_short_list_components_for_uri
|
||||
(uri, comma_separated_str_to_str_list (value));
|
||||
} else if (strcmp (field, "add_to_all_applicationss") == 0) {
|
||||
puts ("add_to_all_applications");
|
||||
nautilus_mime_extend_all_applications_for_uri
|
||||
(uri, comma_separated_str_to_str_list (value));
|
||||
} else if (strcmp (field, "remove_from_all_applications") == 0) {
|
||||
puts ("remove_from_all_applications");
|
||||
nautilus_mime_remove_from_all_applications_for_uri
|
||||
(uri, comma_separated_str_to_str_list (value));
|
||||
|
||||
} else {
|
||||
usage (argv[0]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue