Commit e2beb62b authored by Alexander Schwinn's avatar Alexander Schwinn

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

- fixed conflict after cherry-pick from
master (thunar/thunar-icon-factory.c)
parent 069141d6
......@@ -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)
{
......
......@@ -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 ())
......
......@@ -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))
{
......
......@@ -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);
......
......@@ -49,6 +49,7 @@ enum
PROP_0,
PROP_ICON_THEME,
PROP_THUMBNAIL_MODE,
PROP_THUMBNAIL_SIZE,
};
......@@ -106,6 +107,8 @@ struct _ThunarIconFactory
ThunarThumbnailMode thumbnail_mode;
ThunarThumbnailSize thumbnail_size;
guint sweep_timer_id;
gulong changed_hook_id;
......@@ -182,6 +185,20 @@ thunar_icon_factory_class_init (ThunarIconFactoryClass *klass)
THUNAR_TYPE_THUMBNAIL_MODE,
THUNAR_THUMBNAIL_MODE_ONLY_LOCAL,
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));
}
......@@ -190,6 +207,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
......@@ -266,6 +284,10 @@ thunar_icon_factory_get_property (GObject *object,
g_value_set_enum (value, factory->thumbnail_mode);
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;
......@@ -288,6 +310,10 @@ thunar_icon_factory_set_property (GObject *object,
factory->thumbnail_mode = g_value_get_enum (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;
......@@ -355,14 +381,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 */
......@@ -432,6 +459,8 @@ thunar_icon_factory_load_from_file (ThunarIconFactory *factory,
gint width;
gint height;
_thunar_return_val_if_fail (THUNAR_IS_ICON_FACTORY (factory), NULL);
/* try to load the image from the file */
pixbuf = gdk_pixbuf_new_from_file (path, NULL);
if (G_LIKELY (pixbuf != NULL))
......@@ -710,7 +739,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.
*
......@@ -900,7 +929,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)
......
......@@ -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;
......
......@@ -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));
}
......
......@@ -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;
......
......@@ -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;
......@@ -436,13 +441,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);
......@@ -480,13 +488,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);
......
......@@ -208,7 +208,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);
......@@ -273,7 +273,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);
/**
......@@ -286,7 +286,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);
/**
......@@ -742,7 +742,7 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass)
"ShortcutsIconSize",
NULL,
THUNAR_TYPE_ICON_SIZE,
THUNAR_ICON_SIZE_SMALLER,
THUNAR_ICON_SIZE_24,
EXO_PARAM_READWRITE);
/**
......@@ -769,7 +769,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 */
......
......@@ -714,6 +714,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,
......@@ -1064,6 +1065,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,
......@@ -1696,12 +1698,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);
}
}
......
......@@ -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);