nautilus/nautilus-2.24-fallback-file-icon.patch
Alexander Larsson ca101f0ba7 - Manually check for fallback file icon since we're not always returning
that from gio anymore (from upstream)
2008-10-24 09:33:34 +00:00

76 lines
2.8 KiB
Diff

Index: libnautilus-private/nautilus-icon-info.c
===================================================================
--- libnautilus-private/nautilus-icon-info.c (revision 14759)
+++ libnautilus-private/nautilus-icon-info.c (revision 14760)
@@ -59,6 +59,12 @@ nautilus_icon_info_init (NautilusIconInf
icon->sole_owner = TRUE;
}
+gboolean
+nautilus_icon_info_is_fallback (NautilusIconInfo *icon)
+{
+ return icon->pixbuf == NULL;
+}
+
static void
pixbuf_toggle_notify (gpointer info,
GObject *object,
Index: libnautilus-private/nautilus-icon-info.h
===================================================================
--- libnautilus-private/nautilus-icon-info.h (revision 14759)
+++ libnautilus-private/nautilus-icon-info.h (revision 14760)
@@ -58,6 +58,7 @@ NautilusIconInfo * nautilus_icon_info
int size);
NautilusIconInfo * nautilus_icon_info_lookup_from_name (const char *name,
int size);
+gboolean nautilus_icon_info_is_fallback (NautilusIconInfo *icon);
GdkPixbuf * nautilus_icon_info_get_pixbuf (NautilusIconInfo *icon);
GdkPixbuf * nautilus_icon_info_get_pixbuf_nodefault (NautilusIconInfo *icon);
GdkPixbuf * nautilus_icon_info_get_pixbuf_nodefault_at_size (NautilusIconInfo *icon,
Index: libnautilus-private/nautilus-file.c
===================================================================
--- libnautilus-private/nautilus-file.c (revision 14759)
+++ libnautilus-private/nautilus-file.c (revision 14760)
@@ -3482,6 +3482,23 @@ nautilus_file_get_gicon (NautilusFile *f
return g_themed_icon_new ("text-x-generic");
}
+static GIcon *
+get_default_file_icon (NautilusFileIconFlags flags)
+{
+ static GIcon *fallback_icon = NULL;
+ static GIcon *fallback_icon_preview = NULL;
+ if (fallback_icon == NULL) {
+ fallback_icon = g_themed_icon_new ("text-x-generic");
+ fallback_icon_preview = g_themed_icon_new ("text-x-preview");
+ g_themed_icon_append_name (G_THEMED_ICON (fallback_icon_preview), "text-x-generic");
+ }
+ if (flags & NAUTILUS_FILE_ICON_FLAGS_EMBEDDING_TEXT) {
+ return fallback_icon_preview;
+ } else {
+ return fallback_icon;
+ }
+}
+
NautilusIconInfo *
nautilus_file_get_icon (NautilusFile *file,
int size,
@@ -3573,11 +3590,15 @@ nautilus_file_get_icon (NautilusFile *fi
if (gicon) {
icon = nautilus_icon_info_lookup (gicon, size);
+ if (nautilus_icon_info_is_fallback (icon)) {
+ g_object_unref (icon);
+ icon = nautilus_icon_info_lookup (get_default_file_icon (flags), size);
+ }
g_object_unref (gicon);
return icon;
+ } else {
+ return nautilus_icon_info_lookup (get_default_file_icon (flags), size);
}
-
- return nautilus_icon_info_new_for_pixbuf (NULL);
}
GdkPixbuf *