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>
* 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")));
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);

View file

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

View file

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

View file

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