[Xfce4-commits] r30024 - in thunar/branches/migration-to-gio: . thunar
Jannis Pohlmann
jannis at xfce.org
Mon Jun 15 22:06:18 CEST 2009
Author: jannis
Date: 2009-06-15 20:06:18 +0000 (Mon, 15 Jun 2009)
New Revision: 30024
Modified:
thunar/branches/migration-to-gio/ChangeLog
thunar/branches/migration-to-gio/thunar/thunar-file.c
thunar/branches/migration-to-gio/thunar/thunar-file.h
Log:
* thunar/thunar-file.{c,h}: Add new boolean method
thunar_file_is_thumbnail() which returns TRUE if, and only if
a file resides in $HOME/.thumbnails/.
Modified: thunar/branches/migration-to-gio/ChangeLog
===================================================================
--- thunar/branches/migration-to-gio/ChangeLog 2009-06-15 18:19:53 UTC (rev 30023)
+++ thunar/branches/migration-to-gio/ChangeLog 2009-06-15 20:06:18 UTC (rev 30024)
@@ -1,5 +1,11 @@
2009-06-15 Jannis Pohlmann <jannis at xfce.org>
+ * thunar/thunar-file.{c,h}: Add new boolean method
+ thunar_file_is_thumbnail() which returns TRUE if, and only if
+ a file resides in $HOME/.thumbnails/.
+
+2009-06-15 Jannis Pohlmann <jannis at xfce.org>
+
* thunar/thunar-icon-factory.c: Rewrite the file icon loading process
once again, this time based on the also rewritten ThunarThumbnailer.
We first assume no thumbnail exists and use the default icon for the
Modified: thunar/branches/migration-to-gio/thunar/thunar-file.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.c 2009-06-15 18:19:53 UTC (rev 30023)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.c 2009-06-15 20:06:18 UTC (rev 30024)
@@ -727,8 +727,10 @@
GError **error)
{
GKeyFile *key_file;
+ GFile *thumbnail_dir;
gchar *basename;
gchar *md5_hash;
+ gchar *thumbnail_dir_path;
gchar *uri;
_thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
@@ -786,9 +788,26 @@
file->basename = g_file_get_basename (file->gfile);
_thunar_assert (file->basename != NULL);
- /* determine the custom icon name for .desktop files */
- if (thunar_file_is_desktop_file (file))
+ /* assume all files are not thumbnails themselves */
+ file->is_thumbnail = FALSE;
+
+ /* create a GFile for the $HOME/.thumbnails/ directory */
+ thumbnail_dir_path = g_build_filename (xfce_get_homedir (), ".thumbnails", NULL);
+ thumbnail_dir = g_file_new_for_path (thumbnail_dir_path);
+
+ /* check if this file is a thumbnail */
+ if (g_file_has_prefix (file->gfile, thumbnail_dir))
{
+ /* remember that this file is a thumbnail */
+ file->is_thumbnail = TRUE;
+
+ /* use the filename as custom icon name for thumbnails */
+ file->custom_icon_name = g_file_get_path (file->gfile);
+ }
+ else if (thunar_file_is_desktop_file (file))
+ {
+ /* determine the custom icon name for .desktop files */
+
/* query a key file for the .desktop file */
key_file = g_file_query_key_file (file->gfile, cancellable, NULL);
if (key_file != NULL)
@@ -826,6 +845,10 @@
file->custom_icon_name = NULL;
}
+ /* free $HOME/.thumbnails/ GFile and path */
+ g_object_unref (thumbnail_dir);
+ g_free (thumbnail_dir_path);
+
/* determine the display name */
if (file->info != NULL)
{
@@ -2454,6 +2477,15 @@
+gboolean
+thunar_file_is_thumbnail (const ThunarFile *file)
+{
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+ return file->is_thumbnail;
+}
+
+
+
/**
* thunar_file_set_thumb_state:
* @file : a #ThunarFile.
Modified: thunar/branches/migration-to-gio/thunar/thunar-file.h
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.h 2009-06-15 18:19:53 UTC (rev 30023)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.h 2009-06-15 20:06:18 UTC (rev 30024)
@@ -124,6 +124,7 @@
gchar *basename;
gchar *thumbnail_path;
guint flags;
+ guint is_thumbnail : 1;
};
GType thunar_file_get_type (void) G_GNUC_CONST;
@@ -218,6 +219,7 @@
GError **error);
const gchar *thunar_file_get_thumbnail_path (const ThunarFile *file);
+gboolean thunar_file_is_thumbnail (const ThunarFile *file);
void thunar_file_set_thumb_state (ThunarFile *file,
ThunarFileThumbState state);
GIcon *thunar_file_get_preview_icon (const ThunarFile *file);
More information about the Xfce4-commits
mailing list