From 558c9c00f4eee843259010108c8794c82ac30c36 Mon Sep 17 00:00:00 2001 From: Bradford Hovinen Date: Fri, 11 Jan 2002 19:28:08 +0000 Subject: [PATCH] Read custom_line from default_action (mime_type_info_save): Set custom 2002-01-11 Bradford Hovinen * mime-type-info.c (mime_type_info_load): Read custom_line from default_action (mime_type_info_save): Set custom line through GnomeVFS app registry --- capplets/file-types/ChangeLog | 5 +++++ capplets/file-types/TODO_NOTES | 3 +-- capplets/file-types/mime-edit-dialog.c | 8 +++++++- capplets/file-types/mime-type-info.c | 28 ++++++++++++++++++++++---- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/capplets/file-types/ChangeLog b/capplets/file-types/ChangeLog index ff7fa578f..35186d946 100644 --- a/capplets/file-types/ChangeLog +++ b/capplets/file-types/ChangeLog @@ -1,5 +1,10 @@ 2002-01-11 Bradford Hovinen + * mime-type-info.c (mime_type_info_load): Read custom_line from + default_action + (mime_type_info_save): Set custom line through GnomeVFS app + registry + * file-types-capplet.c (row_activated_cb): Implement. Callback for row_activated signal diff --git a/capplets/file-types/TODO_NOTES b/capplets/file-types/TODO_NOTES index 4f9ae2628..9c5518688 100644 --- a/capplets/file-types/TODO_NOTES +++ b/capplets/file-types/TODO_NOTES @@ -1,11 +1,10 @@ - Get icon name (esp. use of stock icons) working correctly - Add categories to many types in MIME database - Validation - - Talk to gnome-vfs people about edit and print lines - - Do something better about custom-line (i.e. create a dummy app in the app register) - Implement tree cascading - Fix gnome_url_show - Make add work + - Need a way to get all apps in the app registry CVS Surgery - Move file-types to gnome-control-center, rename ??? diff --git a/capplets/file-types/mime-edit-dialog.c b/capplets/file-types/mime-edit-dialog.c index f036df76d..979847e8c 100644 --- a/capplets/file-types/mime-edit-dialog.c +++ b/capplets/file-types/mime-edit-dialog.c @@ -450,6 +450,8 @@ store_data (MimeEditDialog *dialog) GList *ext_list; + GnomeVFSMimeApplication *app; + g_free (dialog->p->info->description); dialog->p->info->description = g_strdup (gtk_entry_get_text (GTK_ENTRY (WID ("description_entry")))); @@ -473,7 +475,11 @@ store_data (MimeEditDialog *dialog) menu_item = (g_list_nth (menu_shell->children, idx))->data; gnome_vfs_mime_application_free (dialog->p->info->default_action); - dialog->p->info->default_action = gnome_vfs_mime_application_copy (g_object_get_data (menu_item, "app")); + app = g_object_get_data (menu_item, "app"); + if (app != NULL) + dialog->p->info->default_action = gnome_vfs_mime_application_copy (app); + else + dialog->p->info->default_action = NULL; g_free (dialog->p->info->custom_line); dialog->p->info->custom_line = g_strdup (gnome_file_entry_get_full_path (GNOME_FILE_ENTRY (WID ("program_entry")), FALSE)); diff --git a/capplets/file-types/mime-type-info.c b/capplets/file-types/mime-type-info.c index 6d0b7a9de..eaaab8939 100644 --- a/capplets/file-types/mime-type-info.c +++ b/capplets/file-types/mime-type-info.c @@ -30,6 +30,7 @@ #endif #include +#include #include "mime-type-info.h" #include "mime-types-model.h" @@ -102,7 +103,12 @@ mime_type_info_load (GtkTreeModel *model, GtkTreeIter *iter) info->edit_line = g_strdup (gnome_vfs_mime_get_value (info->mime_type, "edit-line")); 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); - info->custom_line = g_strdup (gnome_vfs_mime_get_value (info->mime_type, "custom-line")); + + if (!strncmp (info->default_action->id, "custom-", strlen ("custom-"))) { + info->custom_line = g_strdup (info->default_action->command); + gnome_vfs_mime_application_free (info->default_action); + info->default_action = NULL; + } component_info = gnome_vfs_mime_get_default_component (info->mime_type); @@ -119,15 +125,29 @@ mime_type_info_load (GtkTreeModel *model, GtkTreeIter *iter) void mime_type_info_save (const MimeTypeInfo *info) { - gchar *tmp; + gchar *tmp, *tmp1; + gchar *appid; gnome_vfs_mime_set_description (info->mime_type, info->description); gnome_vfs_mime_set_icon (info->mime_type, info->icon_name); - gnome_vfs_mime_set_default_application (info->mime_type, info->default_action->id); - gnome_vfs_mime_set_value (info->mime_type, "custom-line", info->custom_line); gnome_vfs_mime_set_value (info->mime_type, "print-line", info->print_line); gnome_vfs_mime_set_value (info->mime_type, "edit-line", info->edit_line); + if (info->default_action != NULL) { + 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); + + gnome_vfs_application_registry_set_value (appid, "command", info->custom_line); + + gnome_vfs_mime_set_default_application (info->mime_type, appid); + } + tmp = form_extensions_string (info, " ", NULL); gnome_vfs_mime_set_extensions_list (info->mime_type, tmp); g_free (tmp);