[Xfce4-commits] <thunar:nick/1.8> Add option to only generate thumbs in $HOME.
Nick Schermer
noreply at xfce.org
Sun Aug 4 21:52:07 CEST 2013
Updating branch refs/heads/nick/1.8
to 7e2ce51655cd9803c5b6dc6828e0ebdd0c69fb74 (commit)
from 80143edb6b5ab64080fa74421fc2ccf060a5b92c (commit)
commit 7e2ce51655cd9803c5b6dc6828e0ebdd0c69fb74
Author: Nick Schermer <nick at xfce.org>
Date: Sun Aug 4 00:51:02 2013 +0200
Add option to only generate thumbs in $HOME.
Also improve the check a bit. The G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW
value is for most users noncens, so drop this.
thunar/thunar-enum-types.c | 1 +
thunar/thunar-enum-types.h | 2 ++
thunar/thunar-file.c | 26 --------------------------
thunar/thunar-file.h | 1 -
thunar/thunar-icon-factory.c | 35 +++++++++++++++++++++++------------
5 files changed, 26 insertions(+), 39 deletions(-)
diff --git a/thunar/thunar-enum-types.c b/thunar/thunar-enum-types.c
index 52f1096..1881598 100644
--- a/thunar/thunar-enum-types.c
+++ b/thunar/thunar-enum-types.c
@@ -201,6 +201,7 @@ thunar_thumbnail_mode_get_type (void)
static const GEnumValue values[] =
{
{ THUNAR_THUMBNAIL_MODE_NEVER, "THUNAR_THUMBNAIL_MODE_NEVER", N_("Never"), },
+ { THUNAR_THUMBNAIL_MODE_ONLY_HOME, "THUNAR_THUMBNAIL_MODE_ONLY_HOME", N_("Only in Home"), },
{ THUNAR_THUMBNAIL_MODE_ONLY_LOCAL, "THUNAR_THUMBNAIL_MODE_ONLY_LOCAL", N_("Local Files Only"), },
{ THUNAR_THUMBNAIL_MODE_ALWAYS, "THUNAR_THUMBNAIL_MODE_ALWAYS", N_("Always"), },
{ 0, NULL, NULL, },
diff --git a/thunar/thunar-enum-types.h b/thunar/thunar-enum-types.h
index c372436..f1f2193 100644
--- a/thunar/thunar-enum-types.h
+++ b/thunar/thunar-enum-types.h
@@ -147,12 +147,14 @@ GType thunar_icon_size_get_type (void) G_GNUC_CONST;
/**
* ThunarThumbnailsShow:
* @THUNAR_THUMBNAIL_MODE_NEVER : never show thumbnails.
+ * @THUNAR_THUMBNAIL_MODE_ONLY_HOME : only files in the HOME directory.
* @THUNAR_THUMBNAIL_MODE_ONLY_LOCAL : only show thumbnails on local filesystems.
* @THUNAR_THUMBNAIL_MODE_ALWAYS : always show thumbnails (everywhere).
**/
typedef enum
{
THUNAR_THUMBNAIL_MODE_NEVER,
+ THUNAR_THUMBNAIL_MODE_ONLY_HOME,
THUNAR_THUMBNAIL_MODE_ONLY_LOCAL,
THUNAR_THUMBNAIL_MODE_ALWAYS
} ThunarThumbnailMode;
diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index dc31654..6f43def 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -3463,32 +3463,6 @@ thunar_file_get_preview_icon (const ThunarFile *file)
-GFilesystemPreviewType
-thunar_file_get_preview_type (const ThunarFile *file)
-{
- GFilesystemPreviewType preview;
- GFileInfo *info;
-
- _thunar_return_val_if_fail (THUNAR_IS_FILE (file), G_FILESYSTEM_PREVIEW_TYPE_NEVER);
- _thunar_return_val_if_fail (G_IS_FILE (file->gfile), G_FILESYSTEM_PREVIEW_TYPE_NEVER);
-
- info = g_file_query_filesystem_info (file->gfile, G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW, NULL, NULL);
- if (G_LIKELY (info != NULL))
- {
- preview = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW);
- g_object_unref (G_OBJECT (info));
- }
- else
- {
- /* assume we don't know */
- preview = G_FILESYSTEM_PREVIEW_TYPE_NEVER;
- }
-
- return preview;
-}
-
-
-
static const gchar *
thunar_file_get_icon_name_for_state (const gchar *icon_name,
ThunarFileIconState icon_state)
diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h
index 74ed6f8..019291b 100644
--- a/thunar/thunar-file.h
+++ b/thunar/thunar-file.h
@@ -228,7 +228,6 @@ ThunarFileThumbState thunar_file_get_thumb_state (const ThunarFile *fil
void thunar_file_set_thumb_state (ThunarFile *file,
ThunarFileThumbState state);
GIcon *thunar_file_get_preview_icon (const ThunarFile *file);
-GFilesystemPreviewType thunar_file_get_preview_type (const ThunarFile *file);
const gchar *thunar_file_get_icon_name (ThunarFile *file,
ThunarFileIconState icon_state,
GtkIconTheme *icon_theme);
diff --git a/thunar/thunar-icon-factory.c b/thunar/thunar-icon-factory.c
index 96d783d..62aefdd 100644
--- a/thunar/thunar-icon-factory.c
+++ b/thunar/thunar-icon-factory.c
@@ -112,6 +112,8 @@ struct _ThunarIconFactory
/* stamp that gets bumped when the theme changes */
guint theme_stamp;
+
+ ThunarFile *home_file;
};
struct _ThunarIconKey
@@ -189,8 +191,14 @@ thunar_icon_factory_class_init (ThunarIconFactoryClass *klass)
static void
thunar_icon_factory_init (ThunarIconFactory *factory)
{
+ GFile *home_file;
+
factory->thumbnail_mode = THUNAR_THUMBNAIL_MODE_ONLY_LOCAL;
+ home_file = thunar_g_file_new_for_home ();
+ factory->home_file = thunar_file_get (home_file, NULL);
+ g_object_unref (home_file);
+
/* connect emission hook for the "changed" signal on the GtkIconTheme class. We use the emission
* hook way here, because that way we can make sure that the icon cache is definetly cleared
* before any other part of the application gets notified about the icon theme change.
@@ -243,6 +251,8 @@ thunar_icon_factory_finalize (GObject *object)
/* disconnect from the preferences */
g_object_unref (G_OBJECT (factory->preferences));
+ g_object_unref (G_OBJECT (factory->home_file));
+
(*G_OBJECT_CLASS (thunar_icon_factory_parent_class)->finalize) (object);
}
@@ -694,7 +704,8 @@ gboolean
thunar_icon_factory_get_show_thumbnail (const ThunarIconFactory *factory,
const ThunarFile *file)
{
- GFilesystemPreviewType preview;
+ static const gchar *local_ish[] = { "file", "gphoto2", "recent", "trash" };
+ guint n;
_thunar_return_val_if_fail (THUNAR_IS_ICON_FACTORY (factory), THUNAR_THUMBNAIL_MODE_NEVER);
_thunar_return_val_if_fail (file == NULL || THUNAR_IS_FILE (file), THUNAR_THUMBNAIL_MODE_NEVER);
@@ -703,22 +714,22 @@ thunar_icon_factory_get_show_thumbnail (const ThunarIconFactory *factory,
|| factory->thumbnail_mode == THUNAR_THUMBNAIL_MODE_NEVER)
return FALSE;
- /* always create thumbs for local files */
- if (thunar_file_is_local (file))
+ /* don't check anything */
+ if (factory->thumbnail_mode == THUNAR_THUMBNAIL_MODE_ALWAYS)
return TRUE;
- preview = thunar_file_get_preview_type (file);
-
- /* file system says to never thumbnail anything */
- if (preview == G_FILESYSTEM_PREVIEW_TYPE_NEVER)
+ /* check for not home files */
+ if (factory->thumbnail_mode == THUNAR_THUMBNAIL_MODE_ONLY_HOME
+ && !thunar_file_is_ancestor (file, factory->home_file))
return FALSE;
- /* only if the setting is local and the fs reports to be local */
- if (factory->thumbnail_mode == THUNAR_THUMBNAIL_MODE_ONLY_LOCAL)
- return preview == G_FILESYSTEM_PREVIEW_TYPE_IF_LOCAL;
+ /* schemes that are most likely local */
+ for (n = 0; n < G_N_ELEMENTS (local_ish); n++)
+ if (thunar_file_has_uri_scheme (file, local_ish[n]))
+ return TRUE;
- /* THUNAR_THUMBNAIL_MODE_ALWAYS */
- return TRUE;
+ /* not a local scheme */
+ return FALSE;
}
More information about the Xfce4-commits
mailing list