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.
This commit is contained in:
Lauris Kaplinski 2002-03-30 02:05:22 +00:00
parent 84332cb647
commit 9f3911865f
5 changed files with 32 additions and 19 deletions

View file

@ -1,3 +1,12 @@
2002-03-30 Lauris Kaplinski <lauris@ximian.com>
* 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 <lauris@ximian.com> 2002-03-08 Lauris Kaplinski <lauris@ximian.com>
* mime-type-info.c (mime_type_info_using_custom_app): Return TRUE * mime-type-info.c (mime_type_info_using_custom_app): Return TRUE

View file

@ -644,6 +644,7 @@ store_data (MimeEditDialog *dialog)
tmp1 = gtk_entry_get_text (GTK_ENTRY (WID ("category_entry"))); tmp1 = gtk_entry_get_text (GTK_ENTRY (WID ("category_entry")));
if (strcmp (tmp, tmp1)) { if (strcmp (tmp, tmp1)) {
cat_changed = TRUE; cat_changed = TRUE;
if (tmp1[0] == '/') tmp1 += 1;
mime_type_info_set_category_name (dialog->p->info, tmp1, tmp1, dialog->p->model); mime_type_info_set_category_name (dialog->p->info, tmp1, tmp1, dialog->p->model);
} }
g_free (tmp); g_free (tmp);

View file

@ -281,7 +281,7 @@ mime_type_info_save (const MimeTypeInfo *info)
gnome_vfs_mime_set_default_component (info->mime_type, NULL); gnome_vfs_mime_set_default_component (info->mime_type, NULL);
tmp = mime_type_info_get_category_name (info); 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); g_free (tmp);
gnome_vfs_mime_set_value (info->mime_type, "use_category_default", info->use_category ? "yes" : "no"); 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) get_category (const gchar *category_name, const gchar *category_desc, GtkTreeModel *model)
{ {
ModelEntry *current, *child; ModelEntry *current, *child;
gchar **cf = NULL, **df = NULL;
gchar **categories = NULL, **desc_categories = NULL; gchar **categories = NULL, **desc_categories = NULL;
int i; int i;
if (category_name == NULL && category_desc == NULL) if (category_name == NULL && category_desc == NULL)
return NULL; return NULL;
if (category_name != NULL) if (category_name != NULL) {
categories = g_strsplit (category_name, "/", -1); cf = g_strsplit (category_name, "/", -1);
categories = (category_name[0] == '/') ? cf : cf;
}
if (category_desc != NULL) if (category_desc != NULL) {
desc_categories = g_strsplit (category_desc, "/", -1); df = g_strsplit (category_desc, "/", -1);
desc_categories = (category_desc[0] == '/') ? df : df;
}
if (category_name == NULL) if (category_name == NULL)
categories = desc_categories; categories = desc_categories;
@ -920,8 +925,8 @@ get_category (const gchar *category_name, const gchar *category_desc, GtkTreeMod
current = child; current = child;
} }
g_strfreev (categories); g_strfreev (cf);
g_strfreev (desc_categories); g_strfreev (df);
return MIME_CATEGORY_INFO (current); return MIME_CATEGORY_INFO (current);
} }

View file

@ -39,7 +39,7 @@ static GList *delete_list = NULL;
ModelEntry * ModelEntry *
get_model_entries (GtkTreeModel *model) get_model_entries (GtkTreeModel *model)
{ {
static ModelEntry *root; static ModelEntry *root = NULL;
if (root == NULL) { if (root == NULL) {
root = g_new0 (ModelEntry, 1); root = g_new0 (ModelEntry, 1);

View file

@ -47,6 +47,7 @@ const gchar *url_descriptions[][2] = {
{ "info", N_("Detailed documentation") }, { "info", N_("Detailed documentation") },
{ "man", N_("Manual pages") }, { "man", N_("Manual pages") },
{ "mailto", N_("Electronic mail transmission") }, { "mailto", N_("Electronic mail transmission") },
{ "ghelp", N_("Gnome documentation") },
{ NULL, NULL } { NULL, NULL }
}; };
@ -65,21 +66,17 @@ static gboolean get_bool (const ServiceInfo *info,
gchar *end); gchar *end);
static const gchar *get_protocol_name (const gchar *key); static const gchar *get_protocol_name (const gchar *key);
void void
load_all_services (GtkTreeModel *model) load_all_services (GtkTreeModel *model)
{ {
GSList *url_list; GSList *urls;
GSList *tmp;
const gchar *protocol_name; const gchar *protocol_name;
ServiceInfo *info; ServiceInfo *info;
tmp = url_list = gconf_client_all_dirs urls = gconf_client_all_dirs (gconf_client_get_default (), "/desktop/gnome/url-handlers", NULL);
(gconf_client_get_default (), "/desktop/gnome/url-handlers", NULL);
for (; tmp != NULL; tmp = tmp->next) { while (urls) {
protocol_name = get_protocol_name (tmp->data); protocol_name = get_protocol_name (urls->data);
if (protocol_name == NULL) if (protocol_name == NULL)
continue; continue;
@ -87,10 +84,9 @@ load_all_services (GtkTreeModel *model)
info = service_info_new (protocol_name, model); info = service_info_new (protocol_name, model);
model_entry_insert_child (get_services_category_entry (model), MODEL_ENTRY (info), 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 * ServiceInfo *
@ -160,6 +156,8 @@ service_info_using_custom_app (const ServiceInfo *info)
gchar *tmp; gchar *tmp;
gboolean ret; gboolean ret;
if (!info->app) return FALSE;
if (info->app->name == NULL) if (info->app->name == NULL)
return TRUE; return TRUE;