[gnome-shell] Fix shell_get_thumbnail* to not be specific for GtkRecentInfo items
- From: Marina Zhurakhinskaya <marinaz src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-shell] Fix shell_get_thumbnail* to not be specific for GtkRecentInfo items
- Date: Mon, 15 Jun 2009 20:11:00 -0400 (EDT)
commit e478cc4c4e472cf6260e7721e4f598a92442b0fa
Author: Siegfried-Angel Gevatter Pujals <rainct ubuntu com>
Date: Tue Jun 16 02:05:16 2009 +0200
Fix shell_get_thumbnail* to not be specific for GtkRecentInfo items
Currently function shell_get_thumbnail_for_recent_info located in
src/shell-global.c is used to get thumbnails for recently used files.
However, it only works if you have a GtkRecentInfo object for the file,
even though the thumbnail generation code doesn't depend on it. This commit
renames the function to shell_get_thumbnail and makes it generic so that it
just takes two strings: a filename and a mimetype.
js/ui/docDisplay.js | 2 +-
src/shell-global.c | 29 +++++++++++++++++++++--------
src/shell-global.h | 2 +-
3 files changed, 23 insertions(+), 10 deletions(-)
---
diff --git a/js/ui/docDisplay.js b/js/ui/docDisplay.js
index df02008..070fe62 100644
--- a/js/ui/docDisplay.js
+++ b/js/ui/docDisplay.js
@@ -34,7 +34,7 @@ DocDisplayItem.prototype = {
let description = "";
let icon = new Clutter.Texture();
- this._iconPixbuf = Shell.get_thumbnail_for_recent_info(docInfo);
+ this._iconPixbuf = Shell.get_thumbnail(docInfo.get_uri(), docInfo.get_mime_type());
if (this._iconPixbuf) {
// We calculate the width and height of the texture so as to preserve the aspect ratio of the thumbnail.
// Because the images generated based on thumbnails don't have an internal padding like system icons do,
diff --git a/src/shell-global.c b/src/shell-global.c
index b1913f9..f6e2af9 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -341,23 +341,36 @@ shell_clutter_texture_set_from_pixbuf (ClutterTexture *texture,
static GnomeThumbnailFactory *thumbnail_factory;
/**
- * shell_get_thumbnail_for_recent_info:
+ * shell_get_thumbnail:
*
- * @recent_info: #GtkRecentInfo for which to return a thumbnail
+ * @uri: URI of the file to thumbnail
*
- * Return value: #GdkPixbuf containing a thumbnail for the file described by #GtkRecentInfo
+ * @mime_type: Mime-Type of the file to thumbnail
+ *
+ * Return value: #GdkPixbuf containing a thumbnail for file @uri
* if the thumbnail exists or can be generated, %NULL otherwise
*/
GdkPixbuf *
-shell_get_thumbnail_for_recent_info(GtkRecentInfo *recent_info)
+shell_get_thumbnail(const gchar *uri,
+ const gchar *mime_type)
{
char *existing_thumbnail;
GdkPixbuf *pixbuf = NULL;
- const gchar *uri = gtk_recent_info_get_uri (recent_info);
- time_t mtime = gtk_recent_info_get_modified (recent_info);
- const gchar *mime_type = gtk_recent_info_get_mime_type (recent_info);
GError *error = NULL;
-
+ GFile *file = NULL;
+ GFileInfo *file_info = NULL;
+ GTimeVal mtime_g;
+ time_t mtime = 0;
+
+ file = g_file_new_for_uri (uri);
+ file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED, G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ g_object_unref (file);
+ if (file_info) {
+ g_file_info_get_modification_time (file_info, &mtime_g);
+ g_object_unref (file_info);
+ mtime = (time_t) mtime_g.tv_sec;
+ }
+
if (thumbnail_factory == NULL)
thumbnail_factory = gnome_thumbnail_factory_new (GNOME_THUMBNAIL_SIZE_NORMAL);
diff --git a/src/shell-global.h b/src/shell-global.h
index 0d43169..b7e92ed 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -36,7 +36,7 @@ GType shell_global_get_type (void) G_GNUC_CONST;
gboolean shell_clutter_texture_set_from_pixbuf (ClutterTexture *texture,
GdkPixbuf *pixbuf);
-GdkPixbuf *shell_get_thumbnail_for_recent_info(GtkRecentInfo *recent_info);
+GdkPixbuf *shell_get_thumbnail(const gchar *uri, const gchar *mime_type);
GSList *shell_get_categories_for_desktop_file(const char *desktop_file_name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]