[gnome-photos] base-item: Get icon from RDF type as a fallback



commit dd0f400b00c887975f269bc8af5f9ebdde545012
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Apr 3 00:37:34 2013 +0200

    base-item: Get icon from RDF type as a fallback
    
    This is useful for collections which don't have a MIME type.

 src/photos-base-item.c |    3 ++-
 src/photos-utils.c     |   14 ++++++++++++++
 src/photos-utils.h     |    2 ++
 3 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 4144b1d..1c44496 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -481,7 +481,8 @@ photos_base_item_update_icon_from_type (PhotosBaseItem *self)
   if (priv->mime_type != NULL)
     icon = g_content_type_get_icon (priv->mime_type);
 
-  /* TODO: Get icon from RDF type */
+  if (icon == NULL)
+    icon = photos_utils_icon_from_rdf_type (priv->rdf_type);
 
   theme = gtk_icon_theme_get_default ();
   icon_size = photos_utils_get_icon_size ();
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 5ac0574..04c7b7d 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -598,6 +598,20 @@ photos_utils_get_urns_from_paths (GList *paths, GtkTreeModel *model)
 }
 
 
+GIcon *
+photos_utils_icon_from_rdf_type (const gchar *type)
+{
+  GIcon *ret_val = NULL;
+  gint size;
+
+  size = photos_utils_get_icon_size ();
+  if (strstr (type, "nfo#DataContainer") != NULL)
+    ret_val = photos_utils_create_collection_icon (size, NULL);
+
+  return ret_val;
+}
+
+
 void
 photos_utils_queue_thumbnail_job_for_file_async (GFile *file, GAsyncReadyCallback callback, gpointer 
user_data)
 {
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 89ef9cb..89b28d5 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -63,6 +63,8 @@ GtkBorder       *photos_utils_get_thumbnail_frame_border  (void);
 
 GList           *photos_utils_get_urns_from_paths         (GList *paths, GtkTreeModel *model);
 
+GIcon           *photos_utils_icon_from_rdf_type          (const gchar *type);
+
 void             photos_utils_queue_thumbnail_job_for_file_async (GFile *file,
                                                                   GAsyncReadyCallback callback,
                                                                   gpointer user_data);


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