Patch for #318140 - Fallback icon for .desktop files



Hi,

I just put an updated patch in bug #318140.  This makes Nautilus use a
fallback icon, instead of the generic "this is a .desktop file" icon,
for .desktop files which don't have the Icon property set.  This happens
very easily if you create a Launcher from the panel but don't specify an
icon.

Is the patch OK to commit?

  Federico
2005-11-30  Federico Mena Quintero  <federico ximian com>

	* libnautilus-private/nautilus-link-desktop-file.c
	(nautilus_link_desktop_file_get_link_icon_from_desktop): If the
	.desktop file doesn't have an Icon property, fall back to some
	reasonable icons depending on the type of the .desktop file.

	* libnautilus-private/nautilus-icon-factory.c
	(nautilus_icon_factory_get_icon_for_file): Clarify what we mean by
	custom icons vs. special icons.

Index: libnautilus-private/nautilus-icon-factory.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-factory.c,v
retrieving revision 1.318
diff -u -p -r1.318 nautilus-icon-factory.c
--- libnautilus-private/nautilus-icon-factory.c	29 Aug 2005 11:55:49 -0000	1.318
+++ libnautilus-private/nautilus-icon-factory.c	30 Nov 2005 18:04:25 -0000
@@ -856,13 +856,14 @@ nautilus_icon_factory_get_icon_for_file 
 	
 	custom_icon = NULL;
  
- 	/* if there is a custom image in the metadata or link info, use that. */
+	/* Custom icon set by user, taken from metadata */
  	custom_uri = nautilus_file_get_custom_icon (file);
 	if (custom_uri) {
 		custom_icon = image_uri_to_name_or_uri (custom_uri);
 	}
  	g_free (custom_uri);
 
+	/* Icon for "special files" (burn, computer, network, smb, trash) */
 	special_icon = get_special_icon_for_file (file);
 	if (special_icon != NULL) {
 		return g_strdup (special_icon);
Index: libnautilus-private/nautilus-link-desktop-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-link-desktop-file.c,v
retrieving revision 1.32
diff -u -p -r1.32 nautilus-link-desktop-file.c
--- libnautilus-private/nautilus-link-desktop-file.c	14 Jan 2005 10:40:12 -0000	1.32
+++ libnautilus-private/nautilus-link-desktop-file.c	30 Nov 2005 18:04:25 -0000
@@ -260,6 +260,7 @@ nautilus_link_desktop_file_get_link_icon
 {
 	char *icon_uri;
 	const char *icon;
+	GnomeDesktopItemType desktop_type;
 
 	icon_uri = g_strdup (gnome_desktop_item_get_string (desktop_file, "X-Nautilus-Icon"));
 	if (icon_uri != NULL) {
@@ -267,7 +268,34 @@ nautilus_link_desktop_file_get_link_icon
 	}
 
 	icon = gnome_desktop_item_get_string (desktop_file, GNOME_DESKTOP_ITEM_ICON);
-	return g_strdup (icon);
+	if (icon != NULL) {
+		return g_strdup (icon);
+	}
+
+	desktop_type = gnome_desktop_item_get_entry_type (desktop_file);
+	switch (desktop_type) {
+	case GNOME_DESKTOP_ITEM_TYPE_APPLICATION:
+		return g_strdup ("gnome-fs-executable");
+
+	case GNOME_DESKTOP_ITEM_TYPE_LINK:
+		return g_strdup ("gnome-dev-symlink");
+
+	case GNOME_DESKTOP_ITEM_TYPE_FSDEVICE:
+		return g_strdup ("gnome-dev-harddisk");
+
+	case GNOME_DESKTOP_ITEM_TYPE_DIRECTORY:
+		return g_strdup ("gnome-fs-directory");
+
+	case GNOME_DESKTOP_ITEM_TYPE_SERVICE:
+	case GNOME_DESKTOP_ITEM_TYPE_SERVICE_TYPE:
+		return g_strdup ("gnome-fs-web");
+
+	default:
+		return g_strdup ("gnome-fs-regular");
+	}
+
+	g_assert_not_reached ();
+	return NULL;
 }
 
 char *


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