[nautilus] metadata: add a metadata::custom-icon-name metadata key



commit 362696f86bce90dcfa599bf6f4e17ffd0a679860
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed May 25 10:47:27 2011 -0400

    metadata: add a metadata::custom-icon-name metadata key
    
    It's similar to metadata::custom-icon, only that it works on icon names
    instead of URIs.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=626338

 libnautilus-private/nautilus-file.c     |   26 ++++++++++++++++++++++++--
 libnautilus-private/nautilus-metadata.c |    1 +
 libnautilus-private/nautilus-metadata.h |    1 +
 3 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 0f31e5d..55b7407 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -3899,10 +3899,21 @@ get_custom_icon_metadata_uri (NautilusFile *file)
 	return custom_icon_uri;
 }
 
+static char *
+get_custom_icon_metadata_name (NautilusFile *file)
+{
+	char *icon_name;
+
+	icon_name = nautilus_file_get_metadata (file,
+						NAUTILUS_METADATA_KEY_CUSTOM_ICON_NAME, NULL);
+
+	return icon_name;
+}
+
 static GIcon *
 get_custom_icon (NautilusFile *file)
 {
-	char *custom_icon_uri;
+	char *custom_icon_uri, *custom_icon_name;
 	GFile *icon_file;
 	GIcon *icon;
 
@@ -3912,7 +3923,9 @@ get_custom_icon (NautilusFile *file)
 
 	icon = NULL;
 	
-	/* Metadata takes precedence */
+	/* Metadata takes precedence; first we look at the custom
+	 * icon URI, then at the custom icon name.
+	 */
 	custom_icon_uri = get_custom_icon_metadata_uri (file);
 
 	if (custom_icon_uri) {
@@ -3921,6 +3934,15 @@ get_custom_icon (NautilusFile *file)
 		g_object_unref (icon_file);
 		g_free (custom_icon_uri);
 	}
+
+	if (icon == NULL) {
+		custom_icon_name = get_custom_icon_metadata_name (file);
+
+		if (custom_icon_name != NULL) {
+			icon = g_themed_icon_new_with_default_fallbacks (custom_icon_name);
+			g_free (custom_icon_name);
+		}
+	}
  
 	if (icon == NULL && file->details->got_link_info && file->details->custom_icon != NULL) {
 		icon = g_object_ref (file->details->custom_icon);
diff --git a/libnautilus-private/nautilus-metadata.c b/libnautilus-private/nautilus-metadata.c
index acbc890..7e3f8dd 100644
--- a/libnautilus-private/nautilus-metadata.c
+++ b/libnautilus-private/nautilus-metadata.c
@@ -54,6 +54,7 @@ static char *used_metadata_names[] = {
   NAUTILUS_METADATA_KEY_ICON_POSITION_TIMESTAMP,
   NAUTILUS_METADATA_KEY_ICON_SCALE,
   NAUTILUS_METADATA_KEY_CUSTOM_ICON,
+  NAUTILUS_METADATA_KEY_CUSTOM_ICON_NAME,
   NAUTILUS_METADATA_KEY_SCREEN,
   NAUTILUS_METADATA_KEY_EMBLEMS,
   NULL
diff --git a/libnautilus-private/nautilus-metadata.h b/libnautilus-private/nautilus-metadata.h
index 47a735e..7ea4389 100644
--- a/libnautilus-private/nautilus-metadata.h
+++ b/libnautilus-private/nautilus-metadata.h
@@ -70,6 +70,7 @@
 #define NAUTILUS_METADATA_KEY_ANNOTATION                 	"annotation"
 #define NAUTILUS_METADATA_KEY_ICON_SCALE                 	"icon-scale"
 #define NAUTILUS_METADATA_KEY_CUSTOM_ICON                	"custom-icon"
+#define NAUTILUS_METADATA_KEY_CUSTOM_ICON_NAME                	"custom-icon-name"
 #define NAUTILUS_METADATA_KEY_SCREEN				"screen"
 #define NAUTILUS_METADATA_KEY_EMBLEMS				"emblems"
 



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