diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 506713c..08729b3 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -2396,7 +2396,37 @@ thunar_file_is_desktop_file (const ThunarFile *file) && !g_str_has_suffix (thunar_file_get_basename (file), ".directory"); } - +/** + * thunar_image_get_size: + * @file : A #ThunarFile of the file to identify. + * @width : Return location for the width of the image, or NULL + * @height : Return location for the height of the image, or NULL + * + * adapter for gdk_pixbuf_get_file_info, which parses an file far + * enough to determine its size and format. + * + * return value : A GdkPixbufFormat holding information about the image format + * of the file or NULL if the format wasn't recognized. + **/ +GdkPixbufFormat * +thunar_file_get_image_size (const ThunarFile *file, + gint *width, + gint *height) +{ + gchar *absolute_path; + GdkPixbufFormat *result = NULL; + + _thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL); + + /* Don't use gdk_pixbuf_get_file_info for some vector formats */ + if(strcmp ("image/svg+xml", thunar_file_get_content_type (file)) == 0) + return NULL; + + absolute_path = g_file_get_path (thunar_file_get_file (file)); + result = gdk_pixbuf_get_file_info (absolute_path, width, height); + g_free (absolute_path); + return result; +} /** * thunar_file_get_display_name: diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h index d1a5704..bd09c73 100644 --- a/thunar/thunar-file.h +++ b/thunar/thunar-file.h @@ -264,6 +264,9 @@ GList *thunar_file_list_to_thunar_g_file_list (GList *file_list); gboolean thunar_file_is_desktop (const ThunarFile *file); +GdkPixbufFormat *thunar_file_get_image_size (const ThunarFile *file, + gint *width, + gint *height); /** * thunar_file_is_root: * @file : a #ThunarFile. diff --git a/thunar/thunar-list-model.c b/thunar/thunar-list-model.c index f5e42b3..0ee11c0 100644 --- a/thunar/thunar-list-model.c +++ b/thunar/thunar-list-model.c @@ -2271,7 +2271,6 @@ thunar_list_model_get_statusbar_text (ThunarListModel *store, guint64 size_summary; GSList *row; GList *lp; - gchar *absolute_path; gchar *fspace_string; gchar *display_name; gchar *size_string; @@ -2381,16 +2380,13 @@ thunar_list_model_get_statusbar_text (ThunarListModel *store, else if (thunar_file_is_local (file) && thunar_file_is_regular (file)) { /* check if we can determine the dimension of this file (only for image files) */ - absolute_path = g_file_get_path (thunar_file_get_file (file)); - if (absolute_path != NULL - && gdk_pixbuf_get_file_info (absolute_path, &width, &height) != NULL) + if (thunar_file_get_image_size(file, &width, &height) != NULL) { /* append the image dimensions to the statusbar text */ s = g_strdup_printf ("%s, %s %dx%d", text, _("Image Size:"), width, height); g_free (text); text = s; } - g_free (absolute_path); } } else