diff --git a/capplets/file-types/ChangeLog b/capplets/file-types/ChangeLog index 71e766df4..45ebee385 100644 --- a/capplets/file-types/ChangeLog +++ b/capplets/file-types/ChangeLog @@ -1,5 +1,12 @@ 2002-01-14 Bradford Hovinen + * mime-type-info.c (mime_type_info_update): Reparent the iterator + if necessary + (mime_type_info_update): Don't call reinsert_model_entry + + * mime-types-model.c (insert_mime_type): Implement. Factor from + mime_types_model_new + * mime-category-edit-dialog.c (populate_application_list): Implement. Mostly a copy from the corresponding function in mime-edit-dialog.c diff --git a/capplets/file-types/TODO_NOTES b/capplets/file-types/TODO_NOTES index 33b8e4ffa..d3c10270e 100644 --- a/capplets/file-types/TODO_NOTES +++ b/capplets/file-types/TODO_NOTES @@ -10,6 +10,8 @@ - When no apps/components are available, desensitize app/component list - Better sorting on the MIME types tree - Category selection + - Don't consider a mime type when generating category handler list if the mime type overrides the category default + - Implement override_category_default flag CVS Surgery - Move file-types to gnome-control-center, rename ??? diff --git a/capplets/file-types/mime-type-info.c b/capplets/file-types/mime-type-info.c index a22885b3e..64d99f46b 100644 --- a/capplets/file-types/mime-type-info.c +++ b/capplets/file-types/mime-type-info.c @@ -185,9 +185,6 @@ mime_type_info_save (const MimeTypeInfo *info) tmp = form_extensions_string (info, " ", NULL); gnome_vfs_mime_set_extensions_list (info->mime_type, tmp); g_free (tmp); - - if (strcmp (info->category, get_category_name (info->model, info->iter, FALSE))) - reinsert_model_entry (info->model, info->iter); } void @@ -195,6 +192,17 @@ mime_type_info_update (MimeTypeInfo *info) { GdkPixbuf *pixbuf; gchar *tmp; + GtkTreeIter parent; + + tmp = get_category_name (info->model, info->iter, FALSE); + + if (strcmp (info->category, tmp)) { + gtk_tree_store_remove (GTK_TREE_STORE (info->model), info->iter); + get_insertion_point (GTK_TREE_STORE (info->model), info->category, &parent); + gtk_tree_store_append (GTK_TREE_STORE (info->model), info->iter, &parent); + } + + g_free (tmp); pixbuf = get_icon_pixbuf (info->icon_name); diff --git a/capplets/file-types/mime-types-model.c b/capplets/file-types/mime-types-model.c index 9e96b1061..256fe7dcb 100644 --- a/capplets/file-types/mime-types-model.c +++ b/capplets/file-types/mime-types-model.c @@ -131,6 +131,40 @@ get_protocol_name (const gchar *key) return NULL; } +static void +insert_mime_type (GtkTreeStore *model, const gchar *mime_type) +{ + gchar *path_str; + const gchar *description; + const gchar *extensions; + GdkPixbuf *pixbuf; + + GtkTreeIter iter; + GtkTreeIter child_iter; + + path_str = get_category_path_for_mime_type (mime_type); + + if (path_str != NULL) { + description = gnome_vfs_mime_get_description (mime_type); + extensions = gnome_vfs_mime_get_extensions_pretty_string (mime_type); + + if (extensions == NULL || *extensions == '\0') + return; + + pixbuf = get_icon_pixbuf (gnome_vfs_mime_get_icon (mime_type)); + + get_insertion_point (model, path_str, &iter); + + gtk_tree_store_append (model, &child_iter, &iter); + gtk_tree_store_set (model, &child_iter, + ICON_COLUMN, pixbuf, + DESCRIPTION_COLUMN, description, + MIME_TYPE_COLUMN, mime_type, + EXTENSIONS_COLUMN, extensions, + -1); + } +} + GtkTreeModel * mime_types_model_new (gboolean is_category_select) { @@ -139,11 +173,6 @@ mime_types_model_new (gboolean is_category_select) GList *tmp; GtkTreeIter iter; GtkTreeIter child_iter; - gchar *mime_type; - gchar *path_str; - const gchar *description; - const gchar *extensions; - GdkPixbuf *pixbuf; GSList *url_list; GSList *tmps; @@ -161,30 +190,11 @@ mime_types_model_new (gboolean is_category_select) gtk_tree_store_set (model, &iter, DESCRIPTION_COLUMN, categories[i], -1); } - for (; tmp != NULL; tmp = tmp->next) { - mime_type = tmp->data; - path_str = get_category_path_for_mime_type (mime_type); - - if (path_str != NULL && !is_category_select) { - description = gnome_vfs_mime_get_description (mime_type); - extensions = gnome_vfs_mime_get_extensions_pretty_string (mime_type); - - if (extensions == NULL || *extensions == '\0') - continue; - - pixbuf = get_icon_pixbuf (gnome_vfs_mime_get_icon (mime_type)); - - get_insertion_point (model, path_str, &iter); - - gtk_tree_store_append (model, &child_iter, &iter); - gtk_tree_store_set (model, &child_iter, - ICON_COLUMN, pixbuf, - DESCRIPTION_COLUMN, description, - MIME_TYPE_COLUMN, mime_type, - EXTENSIONS_COLUMN, extensions, - -1); - } - } + for (; tmp != NULL; tmp = tmp->next) + if (!is_category_select) + insert_mime_type (model, tmp->data); + else + get_category_path_for_mime_type (tmp->data); g_list_free (type_list); @@ -222,11 +232,6 @@ mime_types_model_new (gboolean is_category_select) return GTK_TREE_MODEL (model); } -void -reinsert_model_entry (GtkTreeModel *model, GtkTreeIter *iter) -{ -} - GdkPixbuf * get_icon_pixbuf (const gchar *short_icon_name) {