[Xfce4-commits] [xfce/thunar] 01/01: More options for thumbnail size (Bug #14451) - added three additional zoom-levels and icon-sizes (160px, 192px and 256px) - added usage of "large" thumbnails (max 256px x 256px) - automatically use large thumbnails for icon-size > 128px - renamed zoom-levels, usage of percentage values - renamed icon-size values, count in pixels - support for old naming
noreply at xfce.org
noreply at xfce.org
Tue Jul 31 22:21:07 CEST 2018
This is an automated email from the git hooks/post-receive script.
a l e x p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository xfce/thunar.
commit 95a5c2559f45f662e0a4c1826cf77f863286c46f
Author: Alexander Schwinn <acs82 at gmx.de>
Date: Thu Jun 28 23:06:38 2018 +0200
More options for thumbnail size (Bug #14451)
- added three additional zoom-levels and icon-sizes (160px, 192px and 256px)
- added usage of "large" thumbnails (max 256px x 256px)
- automatically use large thumbnails for icon-size > 128px
- renamed zoom-levels, usage of percentage values
- renamed icon-size values, count in pixels
- support for old naming
---
thunar/thunar-enum-types.c | 148 ++++++++++++++++++++++++++++++-------
thunar/thunar-enum-types.h | 70 ++++++++++--------
thunar/thunar-file.c | 9 ++-
thunar/thunar-file.h | 3 +-
thunar/thunar-icon-factory.c | 37 ++++++++--
thunar/thunar-icon-factory.h | 7 --
thunar/thunar-icon-renderer.c | 2 +-
thunar/thunar-icon-view.c | 8 +-
thunar/thunar-preferences-dialog.c | 43 +++++++----
thunar/thunar-preferences.c | 10 +--
thunar/thunar-standard-view.c | 10 +++
thunar/thunar-thumbnailer.c | 80 +++++++++++++++++++-
thunar/thunar-view.c | 4 +-
thunar/thunar-window.c | 2 +-
14 files changed, 329 insertions(+), 104 deletions(-)
diff --git a/thunar/thunar-enum-types.c b/thunar/thunar-enum-types.c
index 5d93f91..63b4821 100644
--- a/thunar/thunar-enum-types.c
+++ b/thunar/thunar-enum-types.c
@@ -28,8 +28,12 @@
-static void thunar_icon_size_from_zoom_level (const GValue *src_value,
- GValue *dst_value);
+static void thunar_icon_size_from_zoom_level (const GValue *src_value,
+ GValue *dst_value);
+static void thunar_thumbnail_size_from_icon_size (const GValue *src_value,
+ GValue *dst_value);
+static ThunarIconSize thunar_zoom_level_to_icon_size (ThunarZoomLevel zoom_level);
+static ThunarThumbnailSize thunar_icon_size_to_thumbnail_size (ThunarIconSize icon_size);
@@ -126,17 +130,34 @@ thunar_icon_size_get_type (void)
{
static const GEnumValue values[] =
{
- { THUNAR_ICON_SIZE_SMALLEST, "THUNAR_ICON_SIZE_SMALLEST", "smallest", },
- { THUNAR_ICON_SIZE_SMALLER, "THUNAR_ICON_SIZE_SMALLER", "smaller", },
- { THUNAR_ICON_SIZE_SMALL, "THUNAR_ICON_SIZE_SMALL", "small", },
- { THUNAR_ICON_SIZE_NORMAL, "THUNAR_ICON_SIZE_NORMAL", "normal", },
- { THUNAR_ICON_SIZE_LARGE, "THUNAR_ICON_SIZE_LARGE", "large", },
- { THUNAR_ICON_SIZE_LARGER, "THUNAR_ICON_SIZE_LARGER", "larger", },
- { THUNAR_ICON_SIZE_LARGEST, "THUNAR_ICON_SIZE_LARGEST", "largest", },
- { 0, NULL, NULL, },
+ { THUNAR_ICON_SIZE_16, "THUNAR_ICON_SIZE_16", "16px", },
+ { THUNAR_ICON_SIZE_24, "THUNAR_ICON_SIZE_24", "24px", },
+ { THUNAR_ICON_SIZE_32, "THUNAR_ICON_SIZE_32", "32px", },
+ { THUNAR_ICON_SIZE_48, "THUNAR_ICON_SIZE_48", "48px", },
+ { THUNAR_ICON_SIZE_64, "THUNAR_ICON_SIZE_64", "64px", },
+ { THUNAR_ICON_SIZE_96, "THUNAR_ICON_SIZE_96", "96px", },
+ { THUNAR_ICON_SIZE_128, "THUNAR_ICON_SIZE_128", "128px", },
+ { THUNAR_ICON_SIZE_160, "THUNAR_ICON_SIZE_160", "160px", },
+ { THUNAR_ICON_SIZE_192, "THUNAR_ICON_SIZE_192", "192px", },
+ { THUNAR_ICON_SIZE_256, "THUNAR_ICON_SIZE_256", "256px", },
+ /* Support of old type-strings for two thunar stable releases. Old strings will be transformed to new ones on write*/
+ { THUNAR_ICON_SIZE_16, "THUNAR_ICON_SIZE_SMALLEST", "16px", },
+ { THUNAR_ICON_SIZE_24, "THUNAR_ICON_SIZE_SMALLER", "24px", },
+ { THUNAR_ICON_SIZE_32, "THUNAR_ICON_SIZE_SMALL", "32px", },
+ { THUNAR_ICON_SIZE_48, "THUNAR_ICON_SIZE_NORMAL", "48px", },
+ { THUNAR_ICON_SIZE_64, "THUNAR_ICON_SIZE_LARGE", "64px", },
+ { THUNAR_ICON_SIZE_96, "THUNAR_ICON_SIZE_LARGER", "96px", },
+ { THUNAR_ICON_SIZE_128, "THUNAR_ICON_SIZE_LARGEST", "128px", },
+ /* g_value_transform will pick the last value if nothing else matches. So we put the default there */
+ /* this is required here, because the names of the enum values have changed since the previous thunar-version*/
+ { THUNAR_ICON_SIZE_48, "*", "*", },
+ { 0, NULL, NULL, },
};
type = g_enum_register_static (I_("ThunarIconSize"), values);
+
+ /* register transformation function for ThunarIconSize->ThunarThumbnailSize */
+ g_value_register_transform_func (type, THUNAR_TYPE_THUMBNAIL_SIZE, thunar_thumbnail_size_from_icon_size);
}
return type;
@@ -176,14 +197,28 @@ thunar_zoom_level_get_type (void)
{
static const GEnumValue values[] =
{
- { THUNAR_ZOOM_LEVEL_SMALLEST, "THUNAR_ZOOM_LEVEL_SMALLEST", "smallest", },
- { THUNAR_ZOOM_LEVEL_SMALLER, "THUNAR_ZOOM_LEVEL_SMALLER", "smaller", },
- { THUNAR_ZOOM_LEVEL_SMALL, "THUNAR_ZOOM_LEVEL_SMALL", "small", },
- { THUNAR_ZOOM_LEVEL_NORMAL, "THUNAR_ZOOM_LEVEL_NORMAL", "normal", },
- { THUNAR_ZOOM_LEVEL_LARGE, "THUNAR_ZOOM_LEVEL_LARGE", "large", },
- { THUNAR_ZOOM_LEVEL_LARGER, "THUNAR_ZOOM_LEVEL_LARGER", "larger", },
- { THUNAR_ZOOM_LEVEL_LARGEST, "THUNAR_ZOOM_LEVEL_LARGEST", "largest", },
- { 0, NULL, NULL, },
+ { THUNAR_ZOOM_LEVEL_25_PERCENT, "THUNAR_ZOOM_LEVEL_25_PERCENT", "25%", },
+ { THUNAR_ZOOM_LEVEL_38_PERCENT, "THUNAR_ZOOM_LEVEL_38_PERCENT", "38%", },
+ { THUNAR_ZOOM_LEVEL_50_PERCENT, "THUNAR_ZOOM_LEVEL_50_PERCENT", "50%", },
+ { THUNAR_ZOOM_LEVEL_75_PERCENT, "THUNAR_ZOOM_LEVEL_75_PERCENT", "75%", },
+ { THUNAR_ZOOM_LEVEL_100_PERCENT, "THUNAR_ZOOM_LEVEL_100_PERCENT", "100%", },
+ { THUNAR_ZOOM_LEVEL_150_PERCENT, "THUNAR_ZOOM_LEVEL_150_PERCENT", "150%", },
+ { THUNAR_ZOOM_LEVEL_200_PERCENT, "THUNAR_ZOOM_LEVEL_200_PERCENT", "200%", },
+ { THUNAR_ZOOM_LEVEL_250_PERCENT, "THUNAR_ZOOM_LEVEL_250_PERCENT", "250%", },
+ { THUNAR_ZOOM_LEVEL_300_PERCENT, "THUNAR_ZOOM_LEVEL_300_PERCENT", "300%", },
+ { THUNAR_ZOOM_LEVEL_400_PERCENT, "THUNAR_ZOOM_LEVEL_400_PERCENT", "400%", },
+ /* Support of old type-strings for two thunar stable releases. Old strings will be transformed to new ones on write*/
+ { THUNAR_ZOOM_LEVEL_25_PERCENT, "THUNAR_ZOOM_LEVEL_SMALLEST", "25%", },
+ { THUNAR_ZOOM_LEVEL_38_PERCENT, "THUNAR_ZOOM_LEVEL_SMALLER", "38%", },
+ { THUNAR_ZOOM_LEVEL_50_PERCENT, "THUNAR_ZOOM_LEVEL_SMALL", "50%", },
+ { THUNAR_ZOOM_LEVEL_75_PERCENT, "THUNAR_ZOOM_LEVEL_NORMAL", "75%", },
+ { THUNAR_ZOOM_LEVEL_100_PERCENT, "THUNAR_ZOOM_LEVEL_LARGE", "100%", },
+ { THUNAR_ZOOM_LEVEL_150_PERCENT, "THUNAR_ZOOM_LEVEL_LARGER", "150%", },
+ { THUNAR_ZOOM_LEVEL_200_PERCENT, "THUNAR_ZOOM_LEVEL_LARGEST", "200%", },
+ /* g_value_transform will pick the last value if nothing else matches. So we put the default there */
+ /* this is required here, because the names of the enum values have changed since the previous thunar-version*/
+ { THUNAR_ZOOM_LEVEL_100_PERCENT, "*", "*", },
+ { 0, NULL, NULL, },
};
type = g_enum_register_static (I_("ThunarZoomLevel"), values);
@@ -197,6 +232,15 @@ thunar_zoom_level_get_type (void)
+ThunarThumbnailSize
+thunar_zoom_level_to_thumbnail_size (ThunarZoomLevel zoom_level)
+{
+ ThunarIconSize icon_size = thunar_zoom_level_to_icon_size (zoom_level);
+ return thunar_icon_size_to_thumbnail_size (icon_size);
+}
+
+
+
GType
thunar_thumbnail_mode_get_type (void)
{
@@ -220,6 +264,36 @@ thunar_thumbnail_mode_get_type (void)
+GType
+thunar_thumbnail_size_get_type (void)
+{
+ static GType type = G_TYPE_INVALID;
+
+ if (G_UNLIKELY (type == G_TYPE_INVALID))
+ {
+ static const GEnumValue values[] =
+ {
+ { THUNAR_THUMBNAIL_SIZE_NORMAL, "THUNAR_THUMBNAIL_SIZE_NORMAL", "normal", },
+ { THUNAR_THUMBNAIL_SIZE_LARGE, "THUNAR_THUMBNAIL_SIZE_LARGE", "large", },
+ { 0, NULL, NULL, },
+ };
+
+ type = g_enum_register_static (I_("ThunarThumbnailSize"), values);
+ }
+
+ return type;
+}
+
+const char*
+thunar_thumbnail_size_get_nick (ThunarThumbnailSize thumbnail_size)
+{
+ GEnumValue *thumbnail_size_enum_value;
+
+ thumbnail_size_enum_value = g_enum_get_value (g_type_class_ref (THUNAR_TYPE_THUMBNAIL_SIZE), thumbnail_size);
+ return thumbnail_size_enum_value->value_nick;
+}
+
+
/**
* thunar_zoom_level_to_icon_size:
* @zoom_level : a #ThunarZoomLevel.
@@ -233,18 +307,33 @@ thunar_zoom_level_to_icon_size (ThunarZoomLevel zoom_level)
{
switch (zoom_level)
{
- case THUNAR_ZOOM_LEVEL_SMALLEST: return THUNAR_ICON_SIZE_SMALLEST;
- case THUNAR_ZOOM_LEVEL_SMALLER: return THUNAR_ICON_SIZE_SMALLER;
- case THUNAR_ZOOM_LEVEL_SMALL: return THUNAR_ICON_SIZE_SMALL;
- case THUNAR_ZOOM_LEVEL_NORMAL: return THUNAR_ICON_SIZE_NORMAL;
- case THUNAR_ZOOM_LEVEL_LARGE: return THUNAR_ICON_SIZE_LARGE;
- case THUNAR_ZOOM_LEVEL_LARGER: return THUNAR_ICON_SIZE_LARGER;
- default: return THUNAR_ICON_SIZE_LARGEST;
+ case THUNAR_ZOOM_LEVEL_25_PERCENT: return THUNAR_ICON_SIZE_16;
+ case THUNAR_ZOOM_LEVEL_38_PERCENT: return THUNAR_ICON_SIZE_24;
+ case THUNAR_ZOOM_LEVEL_50_PERCENT: return THUNAR_ICON_SIZE_32;
+ case THUNAR_ZOOM_LEVEL_75_PERCENT: return THUNAR_ICON_SIZE_48;
+ case THUNAR_ZOOM_LEVEL_100_PERCENT: return THUNAR_ICON_SIZE_64;
+ case THUNAR_ZOOM_LEVEL_150_PERCENT: return THUNAR_ICON_SIZE_96;
+ case THUNAR_ZOOM_LEVEL_200_PERCENT: return THUNAR_ICON_SIZE_128;
+ case THUNAR_ZOOM_LEVEL_250_PERCENT: return THUNAR_ICON_SIZE_160;
+ case THUNAR_ZOOM_LEVEL_300_PERCENT: return THUNAR_ICON_SIZE_192;
+ case THUNAR_ZOOM_LEVEL_400_PERCENT: return THUNAR_ICON_SIZE_256;
+ default: return THUNAR_ICON_SIZE_64; // default = 100 %zoom
}
}
+static ThunarThumbnailSize
+thunar_icon_size_to_thumbnail_size (ThunarIconSize icon_size)
+{
+ if (icon_size > THUNAR_ICON_SIZE_128)
+ return THUNAR_THUMBNAIL_SIZE_LARGE;
+
+ return THUNAR_THUMBNAIL_SIZE_NORMAL;
+}
+
+
+
static void
thunar_icon_size_from_zoom_level (const GValue *src_value,
GValue *dst_value)
@@ -254,6 +343,15 @@ thunar_icon_size_from_zoom_level (const GValue *src_value,
+static void
+thunar_thumbnail_size_from_icon_size (const GValue *src_value,
+ GValue *dst_value)
+{
+ g_value_set_enum (dst_value, thunar_icon_size_to_thumbnail_size (g_value_get_enum (src_value)));
+}
+
+
+
GType
thunar_job_response_get_type (void)
{
diff --git a/thunar/thunar-enum-types.h b/thunar/thunar-enum-types.h
index 71d6695..17a792d 100644
--- a/thunar/thunar-enum-types.h
+++ b/thunar/thunar-enum-types.h
@@ -123,25 +123,20 @@ GType thunar_column_get_type (void) G_GNUC_CONST;
/**
* ThunarIconSize:
- * @THUNAR_ICON_SIZE_SMALLEST : icon size for #THUNAR_ZOOM_LEVEL_SMALLEST.
- * @THUNAR_ICON_SIZE_SMALLER : icon size for #THUNAR_ZOOM_LEVEL_SMALLER.
- * @THUNAR_ICON_SIZE_SMALL : icon size for #THUNAR_ZOOM_LEVEL_SMALL.
- * @THUNAR_ICON_SIZE_NORMAL : icon size for #THUNAR_ZOOM_LEVEL_NORMAL.
- * @THUNAR_ICON_SIZE_LARGE : icon size for #THUNAR_ZOOM_LEVEL_LARGE.
- * @THUNAR_ICON_SIZE_LARGER : icon size for #THUNAR_ZOOM_LEVEL_LARGER.
- * @THUNAR_ICON_SIZE_LARGEST : icon size for #THUNAR_ZOOM_LEVEL_LARGEST.
- *
* Icon sizes matching the various #ThunarZoomLevel<!---->s.
**/
typedef enum
{
- THUNAR_ICON_SIZE_SMALLEST = 16,
- THUNAR_ICON_SIZE_SMALLER = 24,
- THUNAR_ICON_SIZE_SMALL = 32,
- THUNAR_ICON_SIZE_NORMAL = 48,
- THUNAR_ICON_SIZE_LARGE = 64,
- THUNAR_ICON_SIZE_LARGER = 96,
- THUNAR_ICON_SIZE_LARGEST = 128,
+ THUNAR_ICON_SIZE_16 = 16,
+ THUNAR_ICON_SIZE_24 = 24,
+ THUNAR_ICON_SIZE_32 = 32,
+ THUNAR_ICON_SIZE_48 = 48,
+ THUNAR_ICON_SIZE_64 = 64,
+ THUNAR_ICON_SIZE_96 = 96,
+ THUNAR_ICON_SIZE_128 = 128,
+ THUNAR_ICON_SIZE_160 = 160,
+ THUNAR_ICON_SIZE_192 = 192,
+ THUNAR_ICON_SIZE_256 = 256,
} ThunarIconSize;
GType thunar_icon_size_get_type (void) G_GNUC_CONST;
@@ -165,6 +160,23 @@ typedef enum
GType thunar_thumbnail_mode_get_type (void) G_GNUC_CONST;
+#define THUNAR_TYPE_THUMBNAIL_SIZE (thunar_thumbnail_size_get_type ())
+
+/**
+ * ThunarThumbnailSize:
+ * @THUNAR_THUMBNAIL_NORMAL : max 128px x 128px
+ * @THUNAR_THUMBNAIL_LARGE : max 256px x 256px
+ **/
+typedef enum
+{
+ THUNAR_THUMBNAIL_SIZE_NORMAL,
+ THUNAR_THUMBNAIL_SIZE_LARGE
+} ThunarThumbnailSize;
+
+GType thunar_thumbnail_size_get_type (void) G_GNUC_CONST;
+const char* thunar_thumbnail_size_get_nick (ThunarThumbnailSize thumbnail_size) G_GNUC_CONST;
+
+
#define THUNAR_TYPE_RECURSIVE_PERMISSIONS (thunar_recursive_permissions_get_type ())
/**
@@ -189,32 +201,28 @@ GType thunar_recursive_permissions_get_type (void) G_GNUC_CONST;
/**
* ThunarZoomLevel:
- * @THUNAR_ZOOM_LEVEL_SMALLEST : smallest possible zoom level.
- * @THUNAR_ZOOM_LEVEL_SMALLER : smaller zoom level.
- * @THUNAR_ZOOM_LEVEL_SMALL : small zoom level.
- * @THUNAR_ZOOM_LEVEL_NORMAL : the default zoom level.
- * @THUNAR_ZOOM_LEVEL_LARGE : large zoom level.
- * @THUNAR_ZOOM_LEVEL_LARGER : larger zoom level.
- * @THUNAR_ZOOM_LEVEL_LARGEST : largest possible zoom level.
- *
* Lists the various zoom levels supported by Thunar's
* folder views.
**/
typedef enum
{
- THUNAR_ZOOM_LEVEL_SMALLEST,
- THUNAR_ZOOM_LEVEL_SMALLER,
- THUNAR_ZOOM_LEVEL_SMALL,
- THUNAR_ZOOM_LEVEL_NORMAL,
- THUNAR_ZOOM_LEVEL_LARGE,
- THUNAR_ZOOM_LEVEL_LARGER,
- THUNAR_ZOOM_LEVEL_LARGEST,
+ THUNAR_ZOOM_LEVEL_25_PERCENT,
+ THUNAR_ZOOM_LEVEL_38_PERCENT,
+ THUNAR_ZOOM_LEVEL_50_PERCENT,
+ THUNAR_ZOOM_LEVEL_75_PERCENT,
+ THUNAR_ZOOM_LEVEL_100_PERCENT,
+ THUNAR_ZOOM_LEVEL_150_PERCENT,
+ THUNAR_ZOOM_LEVEL_200_PERCENT,
+ THUNAR_ZOOM_LEVEL_250_PERCENT,
+ THUNAR_ZOOM_LEVEL_300_PERCENT,
+ THUNAR_ZOOM_LEVEL_400_PERCENT,
/*< private >*/
THUNAR_ZOOM_N_LEVELS,
} ThunarZoomLevel;
-GType thunar_zoom_level_get_type (void) G_GNUC_CONST;
+GType thunar_zoom_level_get_type (void) G_GNUC_CONST;
+ThunarThumbnailSize thunar_zoom_level_to_thumbnail_size (ThunarZoomLevel zoom_level) G_GNUC_CONST;
#define THUNAR_TYPE_JOB_RESPONSE (thunar_job_response_get_type ())
diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index 222b3c9..6758a76 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -3537,7 +3537,7 @@ thunar_file_is_desktop (const ThunarFile *file)
const gchar *
-thunar_file_get_thumbnail_path (ThunarFile *file)
+thunar_file_get_thumbnail_path (ThunarFile *file, ThunarThumbnailSize thumbnail_size)
{
GChecksum *checksum;
gchar *filename;
@@ -3571,7 +3571,7 @@ thunar_file_get_thumbnail_path (ThunarFile *file)
/* build and check if the thumbnail is in the new location */
file->thumbnail_path = g_build_path ("/", g_get_user_cache_dir(),
- "thumbnails", "normal",
+ "thumbnails", thunar_thumbnail_size_get_nick (thumbnail_size),
filename, NULL);
if (!g_file_test(file->thumbnail_path, G_FILE_TEST_EXISTS))
@@ -3579,8 +3579,9 @@ thunar_file_get_thumbnail_path (ThunarFile *file)
/* Fallback to old version */
g_free(file->thumbnail_path);
- file->thumbnail_path = g_build_filename (xfce_get_homedir (), ".thumbnails",
- "normal", filename, NULL);
+ file->thumbnail_path = g_build_filename (xfce_get_homedir (),
+ ".thumbnails", thunar_thumbnail_size_get_nick (thumbnail_size),
+ filename, NULL);
if(!g_file_test(file->thumbnail_path, G_FILE_TEST_EXISTS))
{
diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h
index e02168e..2c74439 100644
--- a/thunar/thunar-file.h
+++ b/thunar/thunar-file.h
@@ -231,7 +231,8 @@ gboolean thunar_file_set_custom_icon (ThunarFile
const gchar *custom_icon,
GError **error);
-const gchar *thunar_file_get_thumbnail_path (ThunarFile *file);
+const gchar *thunar_file_get_thumbnail_path (ThunarFile *file,
+ ThunarThumbnailSize thumbnail_size);
ThunarFileThumbState thunar_file_get_thumb_state (const ThunarFile *file);
void thunar_file_set_thumb_state (ThunarFile *file,
ThunarFileThumbState state);
diff --git a/thunar/thunar-icon-factory.c b/thunar/thunar-icon-factory.c
index eec5394..c00a286 100644
--- a/thunar/thunar-icon-factory.c
+++ b/thunar/thunar-icon-factory.c
@@ -50,6 +50,7 @@ enum
PROP_ICON_THEME,
PROP_THUMBNAIL_MODE,
PROP_THUMBNAIL_DRAW_FRAMES,
+ PROP_THUMBNAIL_SIZE,
};
@@ -109,6 +110,8 @@ struct _ThunarIconFactory
gboolean thumbnail_draw_frames;
+ ThunarThumbnailSize thumbnail_size;
+
guint sweep_timer_id;
gulong changed_hook_id;
@@ -200,6 +203,20 @@ thunar_icon_factory_class_init (ThunarIconFactoryClass *klass)
"thumbnail-draw-frames",
FALSE,
EXO_PARAM_READWRITE));
+
+ /**
+ * ThunarIconFactory:thumbnail-size:
+ *
+ * Size of the thumbnails to load
+ **/
+ g_object_class_install_property (gobject_class,
+ PROP_THUMBNAIL_SIZE,
+ g_param_spec_enum ("thumbnail-size",
+ "thumbnail-size",
+ "thumbnail-size",
+ THUNAR_TYPE_THUMBNAIL_SIZE,
+ THUNAR_THUMBNAIL_SIZE_NORMAL,
+ EXO_PARAM_READWRITE));
}
@@ -208,6 +225,7 @@ static void
thunar_icon_factory_init (ThunarIconFactory *factory)
{
factory->thumbnail_mode = THUNAR_THUMBNAIL_MODE_ONLY_LOCAL;
+ factory->thumbnail_size = THUNAR_THUMBNAIL_SIZE_NORMAL;
/* 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
@@ -288,6 +306,10 @@ thunar_icon_factory_get_property (GObject *object,
g_value_set_boolean (value, factory->thumbnail_draw_frames);
break;
+ case PROP_THUMBNAIL_SIZE:
+ g_value_set_enum (value, factory->thumbnail_size);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -314,6 +336,10 @@ thunar_icon_factory_set_property (GObject *object,
factory->thumbnail_draw_frames = g_value_get_boolean (value);
break;
+ case PROP_THUMBNAIL_SIZE:
+ factory->thumbnail_size = g_value_get_enum (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -381,14 +407,15 @@ thunar_icon_factory_sweep_timer_destroy (gpointer user_data)
static inline gboolean
thumbnail_needs_frame (const GdkPixbuf *thumbnail,
gint width,
- gint height)
+ gint height,
+ gint size)
{
const guchar *pixels;
gint rowstride;
gint n;
/* don't add frames to small thumbnails */
- if (width < THUNAR_THUMBNAIL_SIZE && height < THUNAR_THUMBNAIL_SIZE)
+ if (size < THUNAR_ICON_SIZE_64 )
return FALSE;
/* always add a frame to thumbnails w/o alpha channel */
@@ -475,7 +502,7 @@ thunar_icon_factory_load_from_file (ThunarIconFactory *factory,
* want to do this for icons displayed in the details view).
* */
needs_frame = (strstr (path, G_DIR_SEPARATOR_S ".cache/thumbnails" G_DIR_SEPARATOR_S) != NULL)
- && (size >= 32) && thumbnail_needs_frame (pixbuf, width, height);
+ && (size >= 32) && thumbnail_needs_frame (pixbuf, width, height, size);
}
/* be sure to make framed thumbnails fit into the size */
@@ -739,7 +766,7 @@ thunar_icon_factory_get_for_icon_theme (GtkIconTheme *icon_theme)
/**
- * thunar_icon_factory_get_thumbnail_mode:
+ * thunar_icon_factory_get_show_thumbnail:
* @factory : a #ThunarIconFactory instance.
* @file : a #ThunarFile.
*
@@ -929,7 +956,7 @@ thunar_icon_factory_load_file_icon (ThunarIconFactory *factory,
{
/* we have no preview icon but the thumbnail should be ready. determine
* the filename of the thumbnail */
- thumbnail_path = thunar_file_get_thumbnail_path (file);
+ thumbnail_path = thunar_file_get_thumbnail_path (file, factory->thumbnail_size);
/* check if we have a valid path */
if (thumbnail_path != NULL)
diff --git a/thunar/thunar-icon-factory.h b/thunar/thunar-icon-factory.h
index a7137ab..61d6b0a 100644
--- a/thunar/thunar-icon-factory.h
+++ b/thunar/thunar-icon-factory.h
@@ -34,13 +34,6 @@ typedef struct _ThunarIconFactory ThunarIconFactory;
#define THUNAR_IS_ICON_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_TYPE_ICON_FACTORY))
#define THUNAR_ICON_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TYPE_ICON_FACTORY, ThunarIconFactoryClass))
-/**
- * THUNAR_THUMBNAIL_SIZE:
- * The icon size which is used for loading and storing
- * thumbnails in Thunar.
- **/
-#define THUNAR_THUMBNAIL_SIZE (128)
-
GType thunar_icon_factory_get_type (void) G_GNUC_CONST;
diff --git a/thunar/thunar-icon-renderer.c b/thunar/thunar-icon-renderer.c
index 3d5f267..836e1d5 100644
--- a/thunar/thunar-icon-renderer.c
+++ b/thunar/thunar-icon-renderer.c
@@ -152,7 +152,7 @@ thunar_icon_renderer_class_init (ThunarIconRendererClass *klass)
PROP_SIZE,
g_param_spec_enum ("size", "size", "size",
THUNAR_TYPE_ICON_SIZE,
- THUNAR_ICON_SIZE_SMALL,
+ THUNAR_ICON_SIZE_32,
G_PARAM_CONSTRUCT | EXO_PARAM_READWRITE));
}
diff --git a/thunar/thunar-icon-view.c b/thunar/thunar-icon-view.c
index a5ac206..5dcc71e 100644
--- a/thunar/thunar-icon-view.c
+++ b/thunar/thunar-icon-view.c
@@ -181,19 +181,19 @@ thunar_icon_view_zoom_level_changed (ThunarStandardView *standard_view)
/* determine the "wrap-width" depending on the "zoom-level" */
switch (thunar_view_get_zoom_level (THUNAR_VIEW (standard_view)))
{
- case THUNAR_ZOOM_LEVEL_SMALLEST:
+ case THUNAR_ZOOM_LEVEL_25_PERCENT:
wrap_width = 48;
break;
- case THUNAR_ZOOM_LEVEL_SMALLER:
+ case THUNAR_ZOOM_LEVEL_38_PERCENT:
wrap_width = 64;
break;
- case THUNAR_ZOOM_LEVEL_SMALL:
+ case THUNAR_ZOOM_LEVEL_50_PERCENT:
wrap_width = 72;
break;
- case THUNAR_ZOOM_LEVEL_NORMAL:
+ case THUNAR_ZOOM_LEVEL_75_PERCENT:
wrap_width = 112;
break;
diff --git a/thunar/thunar-preferences-dialog.c b/thunar/thunar-preferences-dialog.c
index 0f57f1b..3d54bfb 100644
--- a/thunar/thunar-preferences-dialog.c
+++ b/thunar/thunar-preferences-dialog.c
@@ -72,8 +72,13 @@ transform_icon_size_to_index (const GValue *src_value,
klass = g_type_class_ref (THUNAR_TYPE_ICON_SIZE);
for (n = 0; n < klass->n_values; ++n)
- if (klass->values[n].value == g_value_get_enum (src_value))
- g_value_set_int (dst_value, n);
+ {
+ if (klass->values[n].value == g_value_get_enum (src_value))
+ {
+ g_value_set_int (dst_value, n);
+ break;
+ }
+ }
g_type_class_unref (klass);
return TRUE;
@@ -443,13 +448,16 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog)
gtk_widget_show (label);
combo = gtk_combo_box_text_new ();
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Very Small"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Smaller"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Small"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Normal"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Large"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Larger"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Very Large"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("16px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("24px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("32px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("48px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("64px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("96px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("128px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("160px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("192px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("256px"));
exo_mutual_binding_new_full (G_OBJECT (dialog->preferences), "shortcuts-icon-size", G_OBJECT (combo), "active",
transform_icon_size_to_index, transform_index_to_icon_size, NULL, NULL);
gtk_widget_set_hexpand (combo, TRUE);
@@ -487,13 +495,16 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog)
gtk_widget_show (label);
combo = gtk_combo_box_text_new ();
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Very Small"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Smaller"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Small"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Normal"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Large"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Larger"));
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Very Large"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("16px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("24px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("32px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("48px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("64px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("96px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("128px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("160px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("192px"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("256px"));
exo_mutual_binding_new_full (G_OBJECT (dialog->preferences), "tree-icon-size", G_OBJECT (combo), "active",
transform_icon_size_to_index, transform_index_to_icon_size, NULL, NULL);
gtk_widget_set_hexpand (combo, TRUE);
diff --git a/thunar/thunar-preferences.c b/thunar/thunar-preferences.c
index 4991e89..217ec7c 100644
--- a/thunar/thunar-preferences.c
+++ b/thunar/thunar-preferences.c
@@ -209,7 +209,7 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass)
"LastCompactViewZoomLevel",
NULL,
THUNAR_TYPE_ZOOM_LEVEL,
- THUNAR_ZOOM_LEVEL_SMALLEST,
+ THUNAR_ZOOM_LEVEL_25_PERCENT,
EXO_PARAM_READWRITE);
@@ -274,7 +274,7 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass)
"LastDetailsViewZoomLevel",
NULL,
THUNAR_TYPE_ZOOM_LEVEL,
- THUNAR_ZOOM_LEVEL_SMALLER,
+ THUNAR_ZOOM_LEVEL_38_PERCENT,
EXO_PARAM_READWRITE);
/**
@@ -287,7 +287,7 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass)
"LastIconViewZoomLevel",
NULL,
THUNAR_TYPE_ZOOM_LEVEL,
- THUNAR_ZOOM_LEVEL_NORMAL,
+ THUNAR_ZOOM_LEVEL_100_PERCENT,
EXO_PARAM_READWRITE);
/**
@@ -757,7 +757,7 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass)
"ShortcutsIconSize",
NULL,
THUNAR_TYPE_ICON_SIZE,
- THUNAR_ICON_SIZE_SMALLER,
+ THUNAR_ICON_SIZE_24,
EXO_PARAM_READWRITE);
/**
@@ -784,7 +784,7 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass)
"TreeIconSize",
NULL,
THUNAR_TYPE_ICON_SIZE,
- THUNAR_ICON_SIZE_SMALLEST,
+ THUNAR_ICON_SIZE_16,
EXO_PARAM_READWRITE);
/* install all properties */
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index 07b0e95..9b1f917 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -729,6 +729,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
standard_view->icon_renderer = thunar_icon_renderer_new ();
g_object_ref_sink (G_OBJECT (standard_view->icon_renderer));
exo_binding_new (G_OBJECT (standard_view), "zoom-level", G_OBJECT (standard_view->icon_renderer), "size");
+ exo_binding_new (G_OBJECT (standard_view->icon_renderer), "size", G_OBJECT (standard_view->priv->thumbnailer), "thumbnail-size");
/* setup the name renderer */
standard_view->name_renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT,
@@ -1090,6 +1091,7 @@ thunar_standard_view_realize (GtkWidget *widget)
/* determine the icon factory for the screen on which we are realized */
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
standard_view->icon_factory = thunar_icon_factory_get_for_icon_theme (icon_theme);
+ exo_binding_new (G_OBJECT (standard_view->icon_renderer), "size", G_OBJECT (standard_view->icon_factory), "thumbnail-size");
/* we need to redraw whenever the "thumbnail_mode" property is toggled */
g_signal_connect_swapped (standard_view->icon_factory,
@@ -1726,12 +1728,20 @@ thunar_standard_view_set_zoom_level (ThunarView *view,
ThunarZoomLevel zoom_level)
{
ThunarStandardView *standard_view = THUNAR_STANDARD_VIEW (view);
+ gboolean newThumbnailSize = FALSE;
/* check if we have a new zoom-level here */
if (G_LIKELY (standard_view->priv->zoom_level != zoom_level))
{
+ if (thunar_zoom_level_to_thumbnail_size (zoom_level) != thunar_zoom_level_to_thumbnail_size (standard_view->priv->zoom_level))
+ newThumbnailSize = TRUE;
+
standard_view->priv->zoom_level = zoom_level;
+
g_object_notify_by_pspec (G_OBJECT (standard_view), standard_view_props[PROP_ZOOM_LEVEL]);
+
+ if (newThumbnailSize)
+ thunar_standard_view_reload (view, TRUE);
}
}
diff --git a/thunar/thunar-thumbnailer.c b/thunar/thunar-thumbnailer.c
index 283dede..0fca0b9 100644
--- a/thunar/thunar-thumbnailer.c
+++ b/thunar/thunar-thumbnailer.c
@@ -101,6 +101,12 @@ enum
LAST_SIGNAL,
};
+/* Property identifiers */
+enum
+{
+ PROP_0,
+ PROP_THUMBNAIL_SIZE,
+};
static void thunar_thumbnailer_finalize (GObject *object);
@@ -126,6 +132,14 @@ static void thunar_thumbnailer_idle (ThunarT
const gchar **uris);
static gboolean thunar_thumbnailer_idle_func (gpointer user_data);
static void thunar_thumbnailer_idle_free (gpointer data);
+static void thunar_thumbnailer_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void thunar_thumbnailer_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
#if GLIB_CHECK_VERSION (2, 32, 0)
#define _thumbnailer_lock(thumbnailer) g_mutex_lock (&((thumbnailer)->lock))
@@ -167,6 +181,9 @@ struct _ThunarThumbnailer
/* last ThunarThumbnailer request ID */
guint last_request;
+ /* size to use to store thumbnails */
+ ThunarThumbnailSize thumbnail_size;
+
/* IDs of idle functions */
GSList *idles;
};
@@ -215,6 +232,8 @@ thunar_thumbnailer_class_init (ThunarThumbnailerClass *klass)
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = thunar_thumbnailer_finalize;
+ gobject_class->get_property = thunar_thumbnailer_get_property;
+ gobject_class->set_property = thunar_thumbnailer_set_property;
/**
* ThunarThumbnailer:request-finished:
@@ -231,11 +250,67 @@ thunar_thumbnailer_class_init (ThunarThumbnailerClass *klass)
0, NULL, NULL,
g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE, 1, G_TYPE_UINT);
+
+ /**
+ * ThunarIconFactory:thumbnail-size:
+ *
+ * Size of the thumbnails to load
+ **/
+ g_object_class_install_property (gobject_class,
+ PROP_THUMBNAIL_SIZE,
+ g_param_spec_enum ("thumbnail-size",
+ "thumbnail-size",
+ "thumbnail-size",
+ THUNAR_TYPE_THUMBNAIL_SIZE,
+ THUNAR_THUMBNAIL_SIZE_NORMAL,
+ EXO_PARAM_READWRITE));
+}
+
+
+
+static void
+thunar_thumbnailer_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ ThunarThumbnailer *thumbnailer = THUNAR_THUMBNAILER (object);
+
+ switch (prop_id)
+ {
+ case PROP_THUMBNAIL_SIZE:
+ g_value_set_enum (value, thumbnailer->thumbnail_size);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
+thunar_thumbnailer_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ThunarThumbnailer *thumbnailer = THUNAR_THUMBNAILER (object);
+
+ switch (prop_id)
+ {
+ case PROP_THUMBNAIL_SIZE:
+ thumbnailer->thumbnail_size = g_value_get_enum (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
thunar_thumbnailer_free_job (ThunarThumbnailerJob *job)
{
if (job->files)
@@ -360,7 +435,7 @@ thunar_thumbnailer_begin_job (ThunarThumbnailer *thumbnailer,
{
/* still a regular file, but the type is now known to tumbler but
* maybe the application created a thumbnail */
- thumbnail_path = thunar_file_get_thumbnail_path (lp->data);
+ thumbnail_path = thunar_file_get_thumbnail_path (lp->data, thumbnailer->thumbnail_size);
/* test if a thumbnail can be found */
if (thumbnail_path != NULL && g_file_test (thumbnail_path, G_FILE_TEST_EXISTS))
@@ -410,7 +485,8 @@ thunar_thumbnailer_begin_job (ThunarThumbnailer *thumbnailer,
thunar_thumbnailer_dbus_call_queue (thumbnailer->thumbnailer_proxy,
(const gchar *const *)uris,
(const gchar *const *)mime_hints,
- "normal", "foreground", 0,
+ thunar_thumbnail_size_get_nick (thumbnailer->thumbnail_size),
+ "foreground", 0,
NULL,
thunar_thumbnailer_queue_async_reply,
job);
diff --git a/thunar/thunar-view.c b/thunar/thunar-view.c
index 29d2b63..698d687 100644
--- a/thunar/thunar-view.c
+++ b/thunar/thunar-view.c
@@ -119,7 +119,7 @@ thunar_view_class_init (gpointer klass)
"zoom-level",
"zoom-level",
THUNAR_TYPE_ZOOM_LEVEL,
- THUNAR_ZOOM_LEVEL_NORMAL,
+ THUNAR_ZOOM_LEVEL_100_PERCENT,
EXO_PARAM_READWRITE));
}
@@ -210,7 +210,7 @@ thunar_view_set_show_hidden (ThunarView *view,
ThunarZoomLevel
thunar_view_get_zoom_level (ThunarView *view)
{
- _thunar_return_val_if_fail (THUNAR_IS_VIEW (view), THUNAR_ZOOM_LEVEL_NORMAL);
+ _thunar_return_val_if_fail (THUNAR_IS_VIEW (view), THUNAR_ZOOM_LEVEL_100_PERCENT);
return (*THUNAR_VIEW_GET_IFACE (view)->get_zoom_level) (view);
}
diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index 4b53d5d..33da6ef 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -483,7 +483,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
"zoom-level",
"zoom-level",
THUNAR_TYPE_ZOOM_LEVEL,
- THUNAR_ZOOM_LEVEL_NORMAL,
+ THUNAR_ZOOM_LEVEL_100_PERCENT,
EXO_PARAM_READWRITE));
/**
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list