Fixed bug 3107, Setting na icon for a mime type does not work.

2000-11-13  Gene Z. Ragan  <gzr@eazel.com>

	Fixed bug 3107, Setting na icon for a mime type does not work.

	* mime-type-capplet/nautilus-mime-type-capplet.c:
	* mime-type-capplet/nautilus-mime-type-capplet.h:
	(nautilus_mime_type_capplet_update_mime_list_icon):
	New function that sets/updates the icon in the mime list.

	* mime-type-capplet/nautilus-mime-type-icon-entry.c:
	(icon_selected_cb), (nautilus_mime_type_show_icon_selection):
	Add call to new nautilus_mime_type_capplet_update_mime_list_icon
	function.
This commit is contained in:
Gene Z. Ragan 2000-11-13 19:16:38 +00:00 committed by Gene Ragan
parent e58cefd2cd
commit 9dbfae956e
3 changed files with 68 additions and 15 deletions

View file

@ -1032,6 +1032,57 @@ edit_default_clicked (GtkWidget *widget, gpointer data)
}
}
void
nautilus_mime_type_capplet_update_mime_list_icon (const char *mime_string)
{
static gchar *text[0];
const char *description, *description_icon_name;
char *description_icon_path;
gint row;
GdkPixbuf *pixbuf;
GdkPixmap *pixmap;
GdkBitmap *bitmap;
GtkCList *clist;
clist = GTK_CLIST (mime_list);
pixbuf = NULL;
row = GPOINTER_TO_INT (clist->selection->data);
/* Get description text */
description = gnome_vfs_mime_get_description (mime_string);
if (description != NULL && strlen (description) > 0) {
text[0] = g_strdup (description);
} else {
text[0] = g_strdup ("");
}
/* Set description column icon */
description_icon_name = gnome_vfs_mime_get_icon (mime_string);
if (description_icon_name != NULL) {
/* Get custom icon */
description_icon_path = gnome_pixmap_file (description_icon_name);
if (description_icon_path != NULL) {
pixbuf = gdk_pixbuf_new_from_file (description_icon_path);
g_free (description_icon_path);
}
} else {
/* Use default icon */
pixbuf = gdk_pixbuf_new_from_file ("/gnome/share/pixmaps/nautilus/i-regular-24.png");
}
if (pixbuf != NULL) {
pixbuf = capplet_gdk_pixbuf_scale_to_fit (pixbuf, 18, 18);
gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &bitmap, 100);
gtk_clist_set_pixtext (clist, row, 0, text[0], 5, pixmap, bitmap);
gdk_pixbuf_unref (pixbuf);
}
g_free (text[0]);
}
/*
* nautilus_mime_type_capplet_update_application_info
*
@ -1438,3 +1489,4 @@ capplet_gdk_pixbuf_scale_to_fit (GdkPixbuf *pixbuf, int max_width, int max_heigh
return pixbuf;
}

View file

@ -30,6 +30,6 @@ void nautilus_mime_type_capplet_update_application_info (const char *mi
void nautilus_mime_type_capplet_update_viewer_info (const char *mime_type);
void nautilus_mime_type_capplet_add_extension (const char *extension);
const char *nautilus_mime_type_capplet_get_selected_item_mime_type (void);
void nautilus_mime_type_capplet_update_mime_list_icon (const char *mime_string);
#endif /* NAUTILUS_MIME_TYPE_CAPPLET_H */

View file

@ -314,6 +314,7 @@ icon_selected_cb (GtkButton *button, NautilusMimeIconEntry *icon_entry)
filename++;
mime_type = nautilus_mime_type_capplet_get_selected_item_mime_type ();
gnome_vfs_mime_set_icon (mime_type, filename);
nautilus_mime_type_capplet_update_mime_list_icon (mime_type);
}
g_free (path);
}
@ -376,11 +377,11 @@ nautilus_mime_type_show_icon_selection (NautilusMimeIconEntry *icon_entry)
/* Are we part of a modal window? If so, we need to be modal too. */
tl = gtk_widget_get_toplevel (GTK_WIDGET (icon_entry->frame));
if(!p) {
if(fe->default_path)
if (!p) {
if (fe->default_path) {
p = g_strdup (fe->default_path);
else {
/*get around the g_free/free issue*/
} else {
/* get around the g_free/free issue */
gchar *cwd = g_get_current_dir ();
p = g_strdup (cwd);
g_free (cwd);
@ -390,16 +391,16 @@ nautilus_mime_type_show_icon_selection (NautilusMimeIconEntry *icon_entry)
}
/*figure out the directory*/
if(!g_file_test (p, G_FILE_TEST_ISDIR)) {
if (!g_file_test (p, G_FILE_TEST_ISDIR)) {
gchar *d;
d = g_dirname (p);
g_free (p);
p = d;
if(!g_file_test (p, G_FILE_TEST_ISDIR)) {
if (!g_file_test (p, G_FILE_TEST_ISDIR)) {
g_free (p);
if (fe->default_path)
if (fe->default_path) {
p = g_strdup (fe->default_path);
else {
} else {
/*get around the g_free/free issue*/
gchar *cwd = g_get_current_dir ();
p = g_strdup (cwd);
@ -412,18 +413,18 @@ nautilus_mime_type_show_icon_selection (NautilusMimeIconEntry *icon_entry)
}
if(icon_entry->pick_dialog==NULL ||
icon_entry->pick_dialog_dir==NULL ||
strcmp(p,icon_entry->pick_dialog_dir)!=0) {
if (icon_entry->pick_dialog==NULL || icon_entry->pick_dialog_dir==NULL ||
strcmp(p,icon_entry->pick_dialog_dir)!=0) {
GtkWidget * iconsel;
if(icon_entry->pick_dialog) {
if (icon_entry->pick_dialog) {
gtk_container_remove (GTK_CONTAINER (icon_entry->fentry->parent), icon_entry->fentry);
gtk_widget_destroy(icon_entry->pick_dialog);
gtk_widget_destroy (icon_entry->pick_dialog);
}
if(icon_entry->pick_dialog_dir)
if (icon_entry->pick_dialog_dir) {
g_free(icon_entry->pick_dialog_dir);
}
icon_entry->pick_dialog_dir = p;
icon_entry->pick_dialog =
gnome_dialog_new(GNOME_FILE_ENTRY(icon_entry->fentry)->browse_dialog_title,