Don't check default action id if default action is NULL

2002-01-11  Bradford Hovinen  <hovinen@ximian.com>

	* 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
This commit is contained in:
Bradford Hovinen 2002-01-11 20:13:50 +00:00 committed by Bradford Hovinen (Gdict maintainer)
parent 2cebb9f9f0
commit e037e72d54
5 changed files with 56 additions and 2 deletions

View file

@ -1,5 +1,19 @@
2002-01-11 Bradford Hovinen <hovinen@ximian.com>
* 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

View file

@ -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
- Kill unused files in file-types
- Kill mime-type
- Kill wm-properties

View file

@ -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);

View file

@ -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);

View file

@ -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 *