diff --git a/capplets/file-types/ChangeLog b/capplets/file-types/ChangeLog index 87508ba16..074631731 100644 --- a/capplets/file-types/ChangeLog +++ b/capplets/file-types/ChangeLog @@ -1,5 +1,19 @@ 2002-01-11 Bradford Hovinen + * mime-edit-dialog.c (populate_application_list): Don't check + default action id if default action is NULL + + * mime-type-info.c (mime_type_info_free): Remove data from + mime_type_table + + * service-info.c (service_info_free): Free the info structure + + * mime-type-info.c (mime_type_info_load): Ditto below + + * service-info.c (service_info_load): Use service_info_table as a + cache + (service_info_free): Remove data from service_info_table + * mime-edit-dialog.c (populate_application_list): Use custom_line for program_entry diff --git a/capplets/file-types/TODO_NOTES b/capplets/file-types/TODO_NOTES index a6f8abaaf..8e7779b7c 100644 --- a/capplets/file-types/TODO_NOTES +++ b/capplets/file-types/TODO_NOTES @@ -13,4 +13,6 @@ CVS Surgery - Rename .glade files in standard convention (gnome-xxx-properties.glade) - Rename primary .c files in standard convention (gnome-xxx-properties.c) - Kill url-properties, preferably with extreme prejudice - - Kill unused files in file-types \ No newline at end of file + - Kill unused files in file-types + - Kill mime-type + - Kill wm-properties diff --git a/capplets/file-types/mime-edit-dialog.c b/capplets/file-types/mime-edit-dialog.c index 5299d9696..d630e823e 100644 --- a/capplets/file-types/mime-edit-dialog.c +++ b/capplets/file-types/mime-edit-dialog.c @@ -362,7 +362,8 @@ populate_application_list (MimeEditDialog *dialog) for (tmp = app_list, i = 0; tmp != NULL; tmp = tmp->next, i++) { app = tmp->data; - if (!strcmp (app->id, dialog->p->info->default_action->id)) + if (dialog->p->info->default_action != NULL && + !strcmp (app->id, dialog->p->info->default_action->id)) found_idx = i; menu_item = gtk_menu_item_new_with_label (app->name); diff --git a/capplets/file-types/mime-type-info.c b/capplets/file-types/mime-type-info.c index f7e6fd647..1dd229750 100644 --- a/capplets/file-types/mime-type-info.c +++ b/capplets/file-types/mime-type-info.c @@ -35,6 +35,10 @@ #include "mime-type-info.h" #include "mime-types-model.h" +/* Hash table of mime type info structures */ + +static GHashTable *mime_type_table = NULL; + static GList *dirty_list = NULL; static GSList * @@ -90,9 +94,19 @@ mime_type_info_load (GtkTreeModel *model, GtkTreeIter *iter) Bonobo_ServerInfo *component_info; GValue mime_type; + if (mime_type_table == NULL) + mime_type_table = g_hash_table_new (g_str_hash, g_str_equal); + mime_type.g_type = G_TYPE_INVALID; gtk_tree_model_get_value (model, iter, MIME_TYPE_COLUMN, &mime_type); + info = g_hash_table_lookup (mime_type_table, g_value_get_string (&mime_type)); + + if (info != NULL) { + g_value_unset (&mime_type); + return info; + } + info = g_new0 (MimeTypeInfo, 1); info->model = model; info->iter = gtk_tree_iter_copy (iter); @@ -117,6 +131,7 @@ mime_type_info_load (GtkTreeModel *model, GtkTreeIter *iter) CORBA_free (component_info); } + g_hash_table_insert (mime_type_table, g_strdup (info->mime_type), info); g_value_unset (&mime_type); return info; @@ -173,6 +188,8 @@ mime_type_info_update (MimeTypeInfo *info) void mime_type_info_free (MimeTypeInfo *info) { + g_hash_table_remove (mime_type_table, info->mime_type); + g_free (info->mime_type); g_free (info->description); g_free (info->icon_name); diff --git a/capplets/file-types/service-info.c b/capplets/file-types/service-info.c index e0f9c02ed..0404e295c 100644 --- a/capplets/file-types/service-info.c +++ b/capplets/file-types/service-info.c @@ -32,6 +32,10 @@ #include "service-info.h" #include "mime-types-model.h" +/* Hash table of service info structures */ + +static GHashTable *service_info_table = NULL; + /* This is a hash table of GLists indexed by protocol name; each entry in each * list is a GnomeVFSMimeApplication that can handle that protocol */ @@ -168,9 +172,19 @@ service_info_load (GtkTreeModel *model, GtkTreeIter *iter, GConfChangeSet *chang gchar *id; GValue protocol; + if (service_info_table == NULL) + service_info_table = g_hash_table_new (g_str_hash, g_str_equal); + protocol.g_type = G_TYPE_INVALID; gtk_tree_model_get_value (model, iter, MIME_TYPE_COLUMN, &protocol); + info = g_hash_table_lookup (service_info_table, g_value_get_string (&protocol)); + + if (info != NULL) { + g_value_unset (&protocol); + return info; + } + info = g_new0 (ServiceInfo, 1); info->model = model; info->iter = gtk_tree_iter_copy (iter); @@ -186,6 +200,9 @@ service_info_load (GtkTreeModel *model, GtkTreeIter *iter, GConfChangeSet *chang info->app = gnome_vfs_mime_application_new_from_id (id); g_free (id); + g_hash_table_insert (service_info_table, info->protocol, info); + g_value_unset (&protocol); + return info; } @@ -217,10 +234,13 @@ service_info_update (ServiceInfo *info) void service_info_free (ServiceInfo *info) { + g_hash_table_remove (service_info_table, info->protocol); + g_free (info->protocol); g_free (info->description); gnome_vfs_mime_application_free (info->app); g_free (info->custom_line); + g_free (info); } const GList *