From 6a71b6f339cbd6fd232357c799fdaeaa1099ce40 Mon Sep 17 00:00:00 2001 From: Bradford Hovinen Date: Fri, 11 Jan 2002 20:45:15 +0000 Subject: [PATCH] Remove from dirty list (mime_type_info_save): Use libuuid to generate a 2002-01-11 Bradford Hovinen * mime-type-info.c (mime_type_info_free): Remove from dirty list (mime_type_info_save): Use libuuid to generate a unique ID for the custom app (mime_type_info_load): Check for custom line based on name --- capplets/file-types/ChangeLog | 3 +++ capplets/file-types/TODO_NOTES | 1 + capplets/file-types/mime-type-info.c | 37 ++++++++++++++++++++-------- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/capplets/file-types/ChangeLog b/capplets/file-types/ChangeLog index f0ad9e6a0..defaabb21 100644 --- a/capplets/file-types/ChangeLog +++ b/capplets/file-types/ChangeLog @@ -1,6 +1,9 @@ 2002-01-11 Bradford Hovinen * mime-type-info.c (mime_type_info_free): Remove from dirty list + (mime_type_info_save): Use libuuid to generate a unique ID for the + custom app + (mime_type_info_load): Check for custom line based on name * mime-edit-dialog.c (populate_application_list): Don't check default action id if default action is NULL diff --git a/capplets/file-types/TODO_NOTES b/capplets/file-types/TODO_NOTES index 8e7779b7c..ad0e5a5ad 100644 --- a/capplets/file-types/TODO_NOTES +++ b/capplets/file-types/TODO_NOTES @@ -6,6 +6,7 @@ - Make add work - Need a way to get all apps in the app registry - Segfault when edit clicked and nothing selected + - Support needs terminal in custom line for mime types CVS Surgery - Move file-types to gnome-control-center, rename ??? diff --git a/capplets/file-types/mime-type-info.c b/capplets/file-types/mime-type-info.c index fbcbf48ac..23712760d 100644 --- a/capplets/file-types/mime-type-info.c +++ b/capplets/file-types/mime-type-info.c @@ -32,6 +32,8 @@ #include #include +#include "libuuid/uuid.h" + #include "mime-type-info.h" #include "mime-types-model.h" @@ -93,6 +95,7 @@ mime_type_info_load (GtkTreeModel *model, GtkTreeIter *iter) MimeTypeInfo *info; Bonobo_ServerInfo *component_info; GValue mime_type; + gchar *tmp; if (mime_type_table == NULL) mime_type_table = g_hash_table_new (g_str_hash, g_str_equal); @@ -118,12 +121,16 @@ mime_type_info_load (GtkTreeModel *model, GtkTreeIter *iter) info->print_line = g_strdup (gnome_vfs_mime_get_value (info->mime_type, "print-line")); info->default_action = gnome_vfs_mime_get_default_application (info->mime_type); - if (info->default_action != NULL && !strncmp (info->default_action->id, "custom-", strlen ("custom-"))) { + tmp = g_strdup_printf ("Custom %s", info->mime_type); + + if (info->default_action != NULL && !strcmp (info->default_action->name, tmp)) { info->custom_line = g_strdup (info->default_action->command); gnome_vfs_mime_application_free (info->default_action); info->default_action = NULL; } + g_free (tmp); + component_info = gnome_vfs_mime_get_default_component (info->mime_type); if (component_info != NULL) { @@ -140,8 +147,11 @@ mime_type_info_load (GtkTreeModel *model, GtkTreeIter *iter) void mime_type_info_save (const MimeTypeInfo *info) { - gchar *tmp, *tmp1; - gchar *appid; + gchar *tmp, *tmp1; + gchar *appid; + uuid_t app_uuid; + gchar app_uuid_str[100]; + GnomeVFSMimeApplication app; gnome_vfs_mime_set_description (info->mime_type, info->description); gnome_vfs_mime_set_icon (info->mime_type, info->icon_name); @@ -152,15 +162,22 @@ mime_type_info_save (const MimeTypeInfo *info) gnome_vfs_mime_set_default_application (info->mime_type, info->default_action->id); } else if (info->custom_line != NULL && *info->custom_line != '\0') { - tmp = g_strdup (info->mime_type); - for (tmp1 = tmp; *tmp1 != '\0'; tmp1++) - if (*tmp1 == '/') *tmp1 = '-'; - appid = g_strconcat ("custom-", tmp, NULL); - g_free (tmp); + uuid_generate (app_uuid); + uuid_unparse (app_uuid, app_uuid_str); - gnome_vfs_application_registry_set_value (appid, "command", info->custom_line); + app.id = app_uuid_str; + app.name = g_strdup_printf ("Custom %s", info->mime_type); + app.command = info->custom_line; + app.can_open_multiple_files = FALSE; + app.expects_uris = FALSE; + app.supported_uri_schemes = NULL; + app.requires_terminal = FALSE; - gnome_vfs_mime_set_default_application (info->mime_type, appid); + gnome_vfs_application_registry_save_mime_application (&app); + gnome_vfs_application_registry_sync (); + + gnome_vfs_mime_set_default_application (info->mime_type, app.id); + g_free (app.name); } tmp = form_extensions_string (info, " ", NULL);