diff options
author | Alexander Larsson <alexl@redhat.com> | 2007-04-12 13:05:04 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2007-04-12 13:05:04 +0000 |
commit | e1218221c2e5fa8ceca017ea15b8aaf7b7ee83e1 (patch) | |
tree | 9e42ac4f90c02e060d4b3895e21c39810ccdebfc /libnautilus-private | |
parent | 4476462b1868b10dc48b3db77ef4cc9ef2f1a380 (diff) | |
download | nautilus-e1218221c2e5fa8ceca017ea15b8aaf7b7ee83e1.tar.gz |
Added support for a thumbnail icon size prefs (#424127)
2007-04-12 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/apps_nautilus_preferences.schemas.in:
* libnautilus-private/nautilus-global-preferences.c:
* libnautilus-private/nautilus-global-preferences.h:
* libnautilus-private/nautilus-icon-factory.c:
* libnautilus-private/nautilus-thumbnails.c:
Added support for a thumbnail icon size prefs (#424127)
svn path=/trunk/; revision=12858
Diffstat (limited to 'libnautilus-private')
-rw-r--r-- | libnautilus-private/apps_nautilus_preferences.schemas.in | 14 | ||||
-rw-r--r-- | libnautilus-private/nautilus-global-preferences.c | 6 | ||||
-rw-r--r-- | libnautilus-private/nautilus-global-preferences.h | 3 | ||||
-rw-r--r-- | libnautilus-private/nautilus-icon-factory.c | 26 | ||||
-rw-r--r-- | libnautilus-private/nautilus-thumbnails.c | 14 |
5 files changed, 58 insertions, 5 deletions
diff --git a/libnautilus-private/apps_nautilus_preferences.schemas.in b/libnautilus-private/apps_nautilus_preferences.schemas.in index aae44bd4b..b61ce13b4 100644 --- a/libnautilus-private/apps_nautilus_preferences.schemas.in +++ b/libnautilus-private/apps_nautilus_preferences.schemas.in @@ -555,6 +555,20 @@ most cases, this should be left alone. -->Sans 10</default> </locale> </schema> + <schema> + <key>/schemas/apps/nautilus/icon_view/thumbnail_size</key> + <applyto>/apps/nautilus/icon_view/thumbnail_size</applyto> + <owner>nautilus</owner> + <type>int</type> + <default>96</default> + <locale name="C"> + <short>Default Thumbnail Icon Size</short> + <long> + The default size of an icon for a thumbnail thumbnail in the icon view. + </long> + </locale> + </schema> + <!-- List View --> <schema> diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c index dbc58bc31..51332e424 100644 --- a/libnautilus-private/nautilus-global-preferences.c +++ b/libnautilus-private/nautilus-global-preferences.c @@ -440,7 +440,11 @@ static const PreferenceDefault preference_defaults[] = { NULL, NULL, "default_zoom_level" }, - + { NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE, + PREFERENCE_INTEGER, + GINT_TO_POINTER (96) + }, + /* List View Default Preferences */ { NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_ORDER, PREFERENCE_STRING, diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h index f8a75f584..0c3342ac7 100644 --- a/libnautilus-private/nautilus-global-preferences.h +++ b/libnautilus-private/nautilus-global-preferences.h @@ -130,6 +130,9 @@ enum /* Which text attributes appear beneath icon names */ #define NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS "icon_view/captions" +/* The default size for thumbnail icons */ +#define NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE "icon_view/thumbnail_size" + /* List View */ #define NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER "list_view/default_sort_in_reverse_order" #define NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_ORDER "list_view/default_sort_order" diff --git a/libnautilus-private/nautilus-icon-factory.c b/libnautilus-private/nautilus-icon-factory.c index 7716338a0..ae04d59f3 100644 --- a/libnautilus-private/nautilus-icon-factory.c +++ b/libnautilus-private/nautilus-icon-factory.c @@ -171,6 +171,7 @@ static guint signals[LAST_SIGNAL]; static int cached_thumbnail_limit; +static int cached_thumbnail_size; static int show_image_thumbs; /* forward declarations */ @@ -180,6 +181,7 @@ static void nautilus_icon_factory_class_init (NautilusIconFactoryCla static void nautilus_icon_factory_instance_init (NautilusIconFactory *factory); static void nautilus_icon_factory_finalize (GObject *object); static void thumbnail_limit_changed_callback (gpointer user_data); +static void thumbnail_size_changed_callback (gpointer user_data); static void show_thumbnails_changed_callback (gpointer user_data); static void mime_type_data_changed_callback (GnomeVFSMIMEMonitor *monitor, gpointer user_data); @@ -210,6 +212,9 @@ destroy_icon_factory (void) eel_preferences_remove_callback (NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT, thumbnail_limit_changed_callback, NULL); + eel_preferences_remove_callback (NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE, + thumbnail_size_changed_callback, + NULL); eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS, show_thumbnails_changed_callback, NULL); @@ -231,6 +236,11 @@ get_icon_factory (void) thumbnail_limit_changed_callback, NULL); + thumbnail_size_changed_callback (NULL); + eel_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE, + thumbnail_size_changed_callback, + NULL); + show_thumbnails_changed_callback (NULL); eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS, show_thumbnails_changed_callback, @@ -719,6 +729,20 @@ thumbnail_limit_changed_callback (gpointer user_data) } static void +thumbnail_size_changed_callback (gpointer user_data) +{ + cached_thumbnail_size = eel_preferences_get_integer (NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE); + + /* Tell the world that icons might have changed. We could invent a narrower-scope + * signal to mean only "thumbnails might have changed" if this ends up being slow + * for some reason. + */ + nautilus_icon_factory_clear (); + g_signal_emit (global_icon_factory, + signals[ICONS_CHANGED], 0); +} + +static void show_thumbnails_changed_callback (gpointer user_data) { show_image_thumbs = eel_preferences_get_enum (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS); @@ -1163,7 +1187,7 @@ load_icon_file (const char *filename, original_size = ceil (MAX (gdk_pixbuf_get_width (pixbuf) / *scale_x, gdk_pixbuf_get_height (pixbuf) / *scale_y)); - if ((is_thumbnail || (!force_nominal && base_size == 0 && original_size > NAUTILUS_ICON_SIZE_THUMBNAIL)) + if ((is_thumbnail || (!force_nominal && base_size == 0 && original_size > cached_thumbnail_size)) && !gdk_pixbuf_get_has_alpha (pixbuf)) { add_frame = TRUE; } diff --git a/libnautilus-private/nautilus-thumbnails.c b/libnautilus-private/nautilus-thumbnails.c index 8b9c8df93..f8b0a5cf5 100644 --- a/libnautilus-private/nautilus-thumbnails.c +++ b/libnautilus-private/nautilus-thumbnails.c @@ -96,6 +96,8 @@ static NautilusThumbnailInfo *currently_thumbnailing = NULL; static GnomeThumbnailFactory *thumbnail_factory = NULL; +static int thumbnail_icon_size = 0; + static gboolean get_file_mtime (const char *file_uri, time_t* mtime) { @@ -290,10 +292,10 @@ thumbnail_loader_size_prepared (GdkPixbufLoader *loader, args->base_size = size; } else if (args->base_size == 0) { if (args->is_thumbnail) { - args->base_size = 128 * NAUTILUS_ICON_SIZE_STANDARD / NAUTILUS_ICON_SIZE_THUMBNAIL; + args->base_size = 128 * NAUTILUS_ICON_SIZE_STANDARD / thumbnail_icon_size; } else { - if (size > args->nominal_size * NAUTILUS_ICON_SIZE_THUMBNAIL / NAUTILUS_ICON_SIZE_STANDARD) { - args->base_size = size * NAUTILUS_ICON_SIZE_STANDARD / NAUTILUS_ICON_SIZE_THUMBNAIL; + if (size > args->nominal_size * thumbnail_icon_size / NAUTILUS_ICON_SIZE_STANDARD) { + args->base_size = size * NAUTILUS_ICON_SIZE_STANDARD / thumbnail_icon_size; } else if (size > NAUTILUS_ICON_SIZE_STANDARD) { args->base_size = args->nominal_size; } else { @@ -353,6 +355,12 @@ nautilus_thumbnail_load_image (const char *path, error = NULL; + if (thumbnail_icon_size == 0) { + eel_preferences_add_auto_integer (NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE, + &thumbnail_icon_size); + } + + if (!g_file_get_contents (path, (gchar **) &buffer, &buflen, &error)) { g_message ("Failed to load %s into memory: %s", path, error->message); |