From 9f3911865f2608ecc99dd6959eb3823a8793337f Mon Sep 17 00:00:00 2001 From: Lauris Kaplinski Date: Sat, 30 Mar 2002 02:05:22 +0000 Subject: [PATCH] Fixed some crashes and made capplet to save/load new mime types the right way (I hope). We still mess up TreeModel if adding new entries - no idea where in model impl that resides. --- capplets/file-types/ChangeLog | 9 +++++++++ capplets/file-types/mime-edit-dialog.c | 1 + capplets/file-types/mime-type-info.c | 19 ++++++++++++------- capplets/file-types/model-entry.c | 2 +- capplets/file-types/service-info.c | 20 +++++++++----------- 5 files changed, 32 insertions(+), 19 deletions(-) diff --git a/capplets/file-types/ChangeLog b/capplets/file-types/ChangeLog index c936e8922..11a99cbde 100644 --- a/capplets/file-types/ChangeLog +++ b/capplets/file-types/ChangeLog @@ -1,3 +1,12 @@ +2002-03-30 Lauris Kaplinski + + * service-info.c: Added ghelp + (service_info_using_custom_app): Fix crash + + * mime-type-info.c (mime_type_info_save): Strip starting slash + + * mime-edit-dialog.c (store_data): Strip starting slash + 2002-03-08 Lauris Kaplinski * mime-type-info.c (mime_type_info_using_custom_app): Return TRUE diff --git a/capplets/file-types/mime-edit-dialog.c b/capplets/file-types/mime-edit-dialog.c index 4dc0fecfd..d0f4f0fd0 100644 --- a/capplets/file-types/mime-edit-dialog.c +++ b/capplets/file-types/mime-edit-dialog.c @@ -644,6 +644,7 @@ store_data (MimeEditDialog *dialog) tmp1 = gtk_entry_get_text (GTK_ENTRY (WID ("category_entry"))); if (strcmp (tmp, tmp1)) { cat_changed = TRUE; + if (tmp1[0] == '/') tmp1 += 1; mime_type_info_set_category_name (dialog->p->info, tmp1, tmp1, dialog->p->model); } g_free (tmp); diff --git a/capplets/file-types/mime-type-info.c b/capplets/file-types/mime-type-info.c index 673dac669..dc22c1e0a 100644 --- a/capplets/file-types/mime-type-info.c +++ b/capplets/file-types/mime-type-info.c @@ -281,7 +281,7 @@ mime_type_info_save (const MimeTypeInfo *info) gnome_vfs_mime_set_default_component (info->mime_type, NULL); tmp = mime_type_info_get_category_name (info); - gnome_vfs_mime_set_value (info->mime_type, "category", tmp); + gnome_vfs_mime_set_value (info->mime_type, "category", tmp + 1); g_free (tmp); gnome_vfs_mime_set_value (info->mime_type, "use_category_default", info->use_category ? "yes" : "no"); @@ -880,17 +880,22 @@ static MimeCategoryInfo * get_category (const gchar *category_name, const gchar *category_desc, GtkTreeModel *model) { ModelEntry *current, *child; + gchar **cf = NULL, **df = NULL; gchar **categories = NULL, **desc_categories = NULL; int i; if (category_name == NULL && category_desc == NULL) return NULL; - if (category_name != NULL) - categories = g_strsplit (category_name, "/", -1); + if (category_name != NULL) { + cf = g_strsplit (category_name, "/", -1); + categories = (category_name[0] == '/') ? cf : cf; + } - if (category_desc != NULL) - desc_categories = g_strsplit (category_desc, "/", -1); + if (category_desc != NULL) { + df = g_strsplit (category_desc, "/", -1); + desc_categories = (category_desc[0] == '/') ? df : df; + } if (category_name == NULL) categories = desc_categories; @@ -920,8 +925,8 @@ get_category (const gchar *category_name, const gchar *category_desc, GtkTreeMod current = child; } - g_strfreev (categories); - g_strfreev (desc_categories); + g_strfreev (cf); + g_strfreev (df); return MIME_CATEGORY_INFO (current); } diff --git a/capplets/file-types/model-entry.c b/capplets/file-types/model-entry.c index 5580092d6..f537f5c84 100644 --- a/capplets/file-types/model-entry.c +++ b/capplets/file-types/model-entry.c @@ -39,7 +39,7 @@ static GList *delete_list = NULL; ModelEntry * get_model_entries (GtkTreeModel *model) { - static ModelEntry *root; + static ModelEntry *root = NULL; if (root == NULL) { root = g_new0 (ModelEntry, 1); diff --git a/capplets/file-types/service-info.c b/capplets/file-types/service-info.c index a8a680bd3..1aededee7 100644 --- a/capplets/file-types/service-info.c +++ b/capplets/file-types/service-info.c @@ -47,6 +47,7 @@ const gchar *url_descriptions[][2] = { { "info", N_("Detailed documentation") }, { "man", N_("Manual pages") }, { "mailto", N_("Electronic mail transmission") }, + { "ghelp", N_("Gnome documentation") }, { NULL, NULL } }; @@ -65,21 +66,17 @@ static gboolean get_bool (const ServiceInfo *info, gchar *end); static const gchar *get_protocol_name (const gchar *key); - - void load_all_services (GtkTreeModel *model) { - GSList *url_list; - GSList *tmp; + GSList *urls; const gchar *protocol_name; ServiceInfo *info; - tmp = url_list = gconf_client_all_dirs - (gconf_client_get_default (), "/desktop/gnome/url-handlers", NULL); + urls = gconf_client_all_dirs (gconf_client_get_default (), "/desktop/gnome/url-handlers", NULL); - for (; tmp != NULL; tmp = tmp->next) { - protocol_name = get_protocol_name (tmp->data); + while (urls) { + protocol_name = get_protocol_name (urls->data); if (protocol_name == NULL) continue; @@ -87,10 +84,9 @@ load_all_services (GtkTreeModel *model) info = service_info_new (protocol_name, model); model_entry_insert_child (get_services_category_entry (model), MODEL_ENTRY (info), model); - g_free (tmp->data); + g_free (urls->data); + urls = g_slist_remove (urls, urls->data); } - - g_slist_free (url_list); } ServiceInfo * @@ -160,6 +156,8 @@ service_info_using_custom_app (const ServiceInfo *info) gchar *tmp; gboolean ret; + if (!info->app) return FALSE; + if (info->app->name == NULL) return TRUE;