Patch for fixing MIME icons in download dialog
Hongli Lai <[email protected]>
| Newsgroups | gmane.comp.web.galeon.devel |
|---|---|
| Message-ID | <[email protected]> |
When I click on a zipfile (or other file that has "Save" as default action), Galeon usually displays a "broken file"-icon as the file's MIME icon. I took a look at the source code and it seems Galeon uses the result of gnome_vfs_mime_get_icon() directly. That is not the correct way. This patch fixes that problem by using GNOME's icon theme functions.
galeon-mime.patch
(text/plain, 2.4 KB)
--- galeon-1.3.9/mozilla/ContentHandler.cpp.old Tue Sep 23 19:25:43 2003
+++ galeon-1.3.9/mozilla/ContentHandler.cpp Tue Sep 23 20:03:22 2003
@@ -149,6 +149,7 @@
extern "C" {
#include "libgnomevfs/gnome-vfs-mime-handlers.h"
+#include <libgnomeui/gnome-icon-theme.h>
}
#include "galeon-embed-shell.h"
@@ -174,6 +175,7 @@
#include <gtk/gtklabel.h>
#include <gtk/gtktreeselection.h>
#include <gtk/gtkcellrenderertext.h>
+#include <gtk/gtkstock.h>
#include <libgnome/gnome-exec.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-config.h>
@@ -726,8 +728,57 @@
GtkWidget *mimeIcon = glade_xml_get_widget(mGXml,
"mime_ask_action_icon");
- gtk_image_set_from_file(GTK_IMAGE(mimeIcon),
- gnome_vfs_mime_get_icon(aMimeType));
+ gchar *iconName = (gchar *) gnome_vfs_mime_get_icon(aMimeType);
+ if (!iconName)
+ {
+ /* Is gnome-vfs broken or is it just my system?
+ This works around the problem */
+ gchar *tmp;
+
+ iconName = g_strdup_printf("gnome-mime-%s", aMimeType);
+ while ((tmp = strchr(iconName, '/')))
+ *tmp = '-';
+ } else
+ iconName = g_strdup(iconName);
+
+ gchar *iconFile = NULL;
+ if (g_path_is_absolute(iconName))
+ iconFile = g_strdup(iconName);
+ else
+ {
+ GnomeIconTheme *theme = gnome_icon_theme_new();
+ GnomeProgram *app = gnome_program_get();
+
+ iconFile = gnome_icon_theme_lookup_icon(theme, iconName, 48, NULL, NULL);
+ if (app)
+ {
+ GSList *icon_theme_paths = NULL, *list;
+
+ /* Add legacy directory $prefix/share/pixmaps/document-icons to search path */
+ gnome_program_locate_file(app, GNOME_FILE_DOMAIN_PIXMAP, "document-icons", FALSE, &icon_theme_paths);
+ for (list = icon_theme_paths; list; list = list->next)
+ gnome_icon_theme_append_search_path(theme, (const char *) list->data);
+ g_slist_free (icon_theme_paths);
+ }
+
+ /* The icon for text/plain seems to be missing */
+ if (!iconFile && strcmp(iconName, "gnome-mime-text-plain") == 0)
+ iconFile = gnome_icon_theme_lookup_icon (theme, "gnome-textfile", 48, NULL, NULL);
+ g_object_unref(theme);
+ }
+
+ if (iconFile)
+ {
+ g_free(iconFile);
+ gtk_image_set_from_file(GTK_IMAGE(mimeIcon),
+ iconFile);
+ }
+ else
+ gtk_image_set_from_stock(GTK_IMAGE(mimeIcon),
+ GTK_STOCK_NEW,
+ GTK_ICON_SIZE_DIALOG);
+ g_free(iconName);
+
description = gnome_vfs_mime_get_description(aMimeType);
if (!description) description = aMimeType;