nautilus r14759 - in trunk: . libnautilus-private



Author: alexl
Date: Thu Oct 23 10:06:59 2008
New Revision: 14759
URL: http://svn.gnome.org/viewvc/nautilus?rev=14759&view=rev

Log:
2008-10-23  Alexander Larsson  <alexl redhat com>

        * libnautilus-private/nautilus-file.c:
        * libnautilus-private/nautilus-icon-info.[ch]:
	Manually fall back to default fallback icon for
	files if not found. Goes with the corresponding
	glib/gvfs change to not add the fallback icon to
	the end of files icons. (#528320)




Modified:
   trunk/ChangeLog
   trunk/libnautilus-private/nautilus-file.c
   trunk/libnautilus-private/nautilus-icon-info.c
   trunk/libnautilus-private/nautilus-icon-info.h

Modified: trunk/libnautilus-private/nautilus-file.c
==============================================================================
--- trunk/libnautilus-private/nautilus-file.c	(original)
+++ trunk/libnautilus-private/nautilus-file.c	Thu Oct 23 10:06:59 2008
@@ -3481,6 +3481,23 @@
 	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,
@@ -3572,11 +3589,15 @@
 	
 	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 *

Modified: trunk/libnautilus-private/nautilus-icon-info.c
==============================================================================
--- trunk/libnautilus-private/nautilus-icon-info.c	(original)
+++ trunk/libnautilus-private/nautilus-icon-info.c	Thu Oct 23 10:06:59 2008
@@ -59,6 +59,12 @@
 	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,

Modified: trunk/libnautilus-private/nautilus-icon-info.h
==============================================================================
--- trunk/libnautilus-private/nautilus-icon-info.h	(original)
+++ trunk/libnautilus-private/nautilus-icon-info.h	Thu Oct 23 10:06:59 2008
@@ -58,6 +58,7 @@
 								       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,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]