diff options
author | John Sullivan <sullivan@src.gnome.org> | 2001-03-29 18:55:53 +0000 |
---|---|---|
committer | John Sullivan <sullivan@src.gnome.org> | 2001-03-29 18:55:53 +0000 |
commit | 586793d2bb4687f8a13081e9e35e01147dbf313e (patch) | |
tree | c1dc62f05d5c861887feb17ee6f6b4fb72fd195a | |
parent | 5df94af1979914c9d676764ad1d37cc7f2665520 (diff) | |
download | nautilus-586793d2bb4687f8a13081e9e35e01147dbf313e.tar.gz |
reviewed by: Ramiro Estrugo <ramiro@eazel.com>
Fixed bug 3328 (Need a preference to specify upper bounds for
thumbnailing)
In Speed Tradeoffs at Advanced level, you can now choose an
upper bound for image file size that will get thumbnailed.
* libnautilus-extensions/nautilus-global-preferences.c:
* libnautilus-extensions/nautilus-global-preferences.h:
Add thumbnail limit preference.
* libnautilus-extensions/nautilus-icon-factory.c:
(destroy_icon_factory), (get_icon_factory): Add and
remove callback for thumbnail-limit preference.
(thumbnail_limit_changed_callback): Store new value in global
variable; send icons-changed signal.
(nautilus_icon_factory_get_icon_for_file): Use global
variable instead of constant when determining thumbail limit.
* libnautilus-extensions/nautilus-preferences-item.c:
(preferences_item_update_constrained_integer): Check the
label strings correctly; this was working for the font size
menus only because the label strings were just the number
printf'ed into a string.
-rw-r--r-- | ChangeLog | 28 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-global-preferences.c | 16 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-global-preferences.h | 1 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-icon-factory.c | 34 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-preferences-item.c | 32 | ||||
-rw-r--r-- | libnautilus-private/nautilus-global-preferences.c | 16 | ||||
-rw-r--r-- | libnautilus-private/nautilus-global-preferences.h | 1 | ||||
-rw-r--r-- | libnautilus-private/nautilus-icon-factory.c | 34 | ||||
-rw-r--r-- | libnautilus-private/nautilus-preferences-item.c | 32 |
9 files changed, 164 insertions, 30 deletions
@@ -1,3 +1,31 @@ +2001-03-29 John Sullivan <sullivan@eazel.com> + + reviewed by: Ramiro Estrugo <ramiro@eazel.com> + + Fixed bug 3328 (Need a preference to specify upper bounds for + thumbnailing) + + In Speed Tradeoffs at Advanced level, you can now choose an + upper bound for image file size that will get thumbnailed. + + * libnautilus-extensions/nautilus-global-preferences.c: + * libnautilus-extensions/nautilus-global-preferences.h: + Add thumbnail limit preference. + + * libnautilus-extensions/nautilus-icon-factory.c: + (destroy_icon_factory), (get_icon_factory): Add and + remove callback for thumbnail-limit preference. + (thumbnail_limit_changed_callback): Store new value in global + variable; send icons-changed signal. + (nautilus_icon_factory_get_icon_for_file): Use global + variable instead of constant when determining thumbail limit. + + * libnautilus-extensions/nautilus-preferences-item.c: + (preferences_item_update_constrained_integer): Check the + label strings correctly; this was working for the font size + menus only because the label strings were just the number + printf'ed into a string. + 2001-03-28 Darin Adler <darin@eazel.com> reviewed by: John Sullivan <sullivan@eazel.com> diff --git a/libnautilus-extensions/nautilus-global-preferences.c b/libnautilus-extensions/nautilus-global-preferences.c index 762c37ff7..d8f726537 100644 --- a/libnautilus-extensions/nautilus-global-preferences.c +++ b/libnautilus-extensions/nautilus-global-preferences.c @@ -231,6 +231,12 @@ static const PreferenceDefault preference_defaults[] = { { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY) }, { USER_LEVEL_NONE } }, + { NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT, + PREFERENCE_INTEGER, + NAUTILUS_USER_LEVEL_ADVANCED, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (1048576) }, + { USER_LEVEL_NONE } + }, { NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA, PREFERENCE_INTEGER, NAUTILUS_USER_LEVEL_ADVANCED, @@ -858,6 +864,16 @@ static PreferenceDialogItem tradeoffs_items[] = { 0, speed_tradeoff_enumeration }, + { N_("Show Thumbnails for Image Files"), + NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT, + N_("Don't make thumbnails for files larger than:"), + NAUTILUS_PREFERENCE_ITEM_CONSTRAINED_INTEGER, + NULL, + 0, + NULL, + "102400,512000,1048576,2097152,5242880,10485760,104857600", + "100 K,500 K,1 MB,2 MB,5 MB,10 MB,100 MB", + }, { N_("Preview Sound Files"), NAUTILUS_PREFERENCES_PREVIEW_SOUND, N_(""), diff --git a/libnautilus-extensions/nautilus-global-preferences.h b/libnautilus-extensions/nautilus-global-preferences.h index 1dd731f14..eeb37815e 100644 --- a/libnautilus-extensions/nautilus-global-preferences.h +++ b/libnautilus-extensions/nautilus-global-preferences.h @@ -144,6 +144,7 @@ typedef enum #define NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS "preferences/show_icon_text" #define NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS "preferences/show_directory_item_counts" #define NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS "preferences/show_image_thumbnails" +#define NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT "preferences/thumbnail_limit" #define NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA "preferences/use_public_metadata" #define NAUTILUS_PREFERENCES_PREVIEW_SOUND "preferences/preview_sound" diff --git a/libnautilus-extensions/nautilus-icon-factory.c b/libnautilus-extensions/nautilus-icon-factory.c index beabac0be..85f2ca0a5 100644 --- a/libnautilus-extensions/nautilus-icon-factory.c +++ b/libnautilus-extensions/nautilus-icon-factory.c @@ -116,14 +116,6 @@ static const char *icon_file_name_suffixes[] = * complex rule about when to use an image for itself. */ #define SELF_THUMBNAIL_SIZE_THRESHOLD 16384 - -/* Extremely large images can eat up hundreds of megabytes of memory, - * so we shouldn't automatically thumbnail when larges are too large. - */ -/* FIXME bugzilla.eazel.com 5082: Eventually, we want this threshold - * to be user-settable, but for now it's hard-wired. - */ -#define INHIBIT_THUMBNAIL_SIZE_THRESHOLD (1024 * 1024) /* Maximum size for either dimension at the standard zoom level. */ #define MAXIMUM_ICON_SIZE 96 @@ -253,6 +245,7 @@ typedef struct { } CacheIcon; static CacheIcon *fallback_icon; +static int cached_thumbnail_limit; /* forward declarations */ @@ -261,6 +254,7 @@ static void nautilus_icon_factory_initialize_class (NautilusIconFactoryCla static void nautilus_icon_factory_initialize (NautilusIconFactory *factory); static void nautilus_icon_factory_destroy (GtkObject *object); static void icon_theme_changed_callback (gpointer user_data); +static void thumbnail_limit_changed_callback (gpointer user_data); static void mime_type_data_changed_callback (GnomeVFSMIMEMonitor *monitor, gpointer user_data); static guint nautilus_scalable_icon_hash (gconstpointer p); @@ -288,6 +282,9 @@ destroy_icon_factory (void) nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME, icon_theme_changed_callback, NULL); + nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT, + thumbnail_limit_changed_callback, + NULL); gtk_object_unref (GTK_OBJECT (global_icon_factory)); } @@ -301,11 +298,15 @@ get_icon_factory (void) gtk_object_ref (GTK_OBJECT (global_icon_factory)); gtk_object_sink (GTK_OBJECT (global_icon_factory)); - /* Update to match the theme. */ icon_theme_changed_callback (NULL); nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_THEME, icon_theme_changed_callback, NULL); + + thumbnail_limit_changed_callback (NULL); + nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT, + thumbnail_limit_changed_callback, + NULL); gtk_signal_connect (GTK_OBJECT (gnome_vfs_mime_monitor_get ()), "data_changed", @@ -1147,6 +1148,19 @@ icon_theme_changed_callback (gpointer user_data) g_free (icon_theme); } +static void +thumbnail_limit_changed_callback (gpointer user_data) +{ + cached_thumbnail_limit = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT); + + /* 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. + */ + gtk_signal_emit (GTK_OBJECT (global_icon_factory), + signals[ICONS_CHANGED]); +} + static void mime_type_data_changed_callback (GnomeVFSMIMEMonitor *monitor, gpointer user_data) { @@ -1399,7 +1413,7 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie if (file_size < SELF_THUMBNAIL_SIZE_THRESHOLD && is_local) { uri = nautilus_file_get_uri (file); } else if (strstr (file_uri, "/.thumbnails/") == NULL - && file_size < INHIBIT_THUMBNAIL_SIZE_THRESHOLD) { + && file_size < cached_thumbnail_limit) { uri = nautilus_get_thumbnail_uri (file, anti_aliased); if (uri == NULL) { uri = get_icon_file_path diff --git a/libnautilus-extensions/nautilus-preferences-item.c b/libnautilus-extensions/nautilus-preferences-item.c index 7648aa939..25f256ef9 100644 --- a/libnautilus-extensions/nautilus-preferences-item.c +++ b/libnautilus-extensions/nautilus-preferences-item.c @@ -459,21 +459,43 @@ preferences_item_create_editable_integer (NautilusPreferencesItem *item, static void preferences_item_update_constrained_integer (NautilusPreferencesItem *item) { - char *current_value_string; + char *current_label; int current_value; + char *current_value_as_string; + int position; g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item)); g_return_if_fail (item->details->item_type == NAUTILUS_PREFERENCE_ITEM_CONSTRAINED_INTEGER); + /* Too early if the value and label lists haven't been set up yet. */ + if (item->details->constrained_integer_value_list == NULL) { + return; + } + g_return_if_fail (item->details->constrained_integer_label_list != NULL); + current_value = nautilus_preferences_get_integer (item->details->preference_name); - current_value_string = g_strdup_printf ("%d", current_value); + current_value_as_string = g_strdup_printf ("%d", current_value); + position = nautilus_string_list_get_index_for_string + (item->details->constrained_integer_value_list, + current_value_as_string); + g_free (current_value_as_string); + + g_return_if_fail (position != NAUTILUS_STRING_LIST_NOT_FOUND); + + current_label = nautilus_string_list_nth + (item->details->constrained_integer_label_list, + position); - if (nautilus_string_picker_contains (NAUTILUS_STRING_PICKER (item->details->child), current_value_string)) { + if (nautilus_string_picker_contains (NAUTILUS_STRING_PICKER (item->details->child), current_label)) { nautilus_string_picker_set_selected_string (NAUTILUS_STRING_PICKER (item->details->child), - current_value_string); + current_label); + } else { + g_warning ("Value string for %s is %s, which isn't in the expected set of values", + item->details->preference_name, + current_label); } - g_free (current_value_string); + g_free (current_label); } static void diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c index 762c37ff7..d8f726537 100644 --- a/libnautilus-private/nautilus-global-preferences.c +++ b/libnautilus-private/nautilus-global-preferences.c @@ -231,6 +231,12 @@ static const PreferenceDefault preference_defaults[] = { { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY) }, { USER_LEVEL_NONE } }, + { NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT, + PREFERENCE_INTEGER, + NAUTILUS_USER_LEVEL_ADVANCED, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (1048576) }, + { USER_LEVEL_NONE } + }, { NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA, PREFERENCE_INTEGER, NAUTILUS_USER_LEVEL_ADVANCED, @@ -858,6 +864,16 @@ static PreferenceDialogItem tradeoffs_items[] = { 0, speed_tradeoff_enumeration }, + { N_("Show Thumbnails for Image Files"), + NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT, + N_("Don't make thumbnails for files larger than:"), + NAUTILUS_PREFERENCE_ITEM_CONSTRAINED_INTEGER, + NULL, + 0, + NULL, + "102400,512000,1048576,2097152,5242880,10485760,104857600", + "100 K,500 K,1 MB,2 MB,5 MB,10 MB,100 MB", + }, { N_("Preview Sound Files"), NAUTILUS_PREFERENCES_PREVIEW_SOUND, N_(""), diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h index 1dd731f14..eeb37815e 100644 --- a/libnautilus-private/nautilus-global-preferences.h +++ b/libnautilus-private/nautilus-global-preferences.h @@ -144,6 +144,7 @@ typedef enum #define NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS "preferences/show_icon_text" #define NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS "preferences/show_directory_item_counts" #define NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS "preferences/show_image_thumbnails" +#define NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT "preferences/thumbnail_limit" #define NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA "preferences/use_public_metadata" #define NAUTILUS_PREFERENCES_PREVIEW_SOUND "preferences/preview_sound" diff --git a/libnautilus-private/nautilus-icon-factory.c b/libnautilus-private/nautilus-icon-factory.c index beabac0be..85f2ca0a5 100644 --- a/libnautilus-private/nautilus-icon-factory.c +++ b/libnautilus-private/nautilus-icon-factory.c @@ -116,14 +116,6 @@ static const char *icon_file_name_suffixes[] = * complex rule about when to use an image for itself. */ #define SELF_THUMBNAIL_SIZE_THRESHOLD 16384 - -/* Extremely large images can eat up hundreds of megabytes of memory, - * so we shouldn't automatically thumbnail when larges are too large. - */ -/* FIXME bugzilla.eazel.com 5082: Eventually, we want this threshold - * to be user-settable, but for now it's hard-wired. - */ -#define INHIBIT_THUMBNAIL_SIZE_THRESHOLD (1024 * 1024) /* Maximum size for either dimension at the standard zoom level. */ #define MAXIMUM_ICON_SIZE 96 @@ -253,6 +245,7 @@ typedef struct { } CacheIcon; static CacheIcon *fallback_icon; +static int cached_thumbnail_limit; /* forward declarations */ @@ -261,6 +254,7 @@ static void nautilus_icon_factory_initialize_class (NautilusIconFactoryCla static void nautilus_icon_factory_initialize (NautilusIconFactory *factory); static void nautilus_icon_factory_destroy (GtkObject *object); static void icon_theme_changed_callback (gpointer user_data); +static void thumbnail_limit_changed_callback (gpointer user_data); static void mime_type_data_changed_callback (GnomeVFSMIMEMonitor *monitor, gpointer user_data); static guint nautilus_scalable_icon_hash (gconstpointer p); @@ -288,6 +282,9 @@ destroy_icon_factory (void) nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME, icon_theme_changed_callback, NULL); + nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT, + thumbnail_limit_changed_callback, + NULL); gtk_object_unref (GTK_OBJECT (global_icon_factory)); } @@ -301,11 +298,15 @@ get_icon_factory (void) gtk_object_ref (GTK_OBJECT (global_icon_factory)); gtk_object_sink (GTK_OBJECT (global_icon_factory)); - /* Update to match the theme. */ icon_theme_changed_callback (NULL); nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_THEME, icon_theme_changed_callback, NULL); + + thumbnail_limit_changed_callback (NULL); + nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT, + thumbnail_limit_changed_callback, + NULL); gtk_signal_connect (GTK_OBJECT (gnome_vfs_mime_monitor_get ()), "data_changed", @@ -1147,6 +1148,19 @@ icon_theme_changed_callback (gpointer user_data) g_free (icon_theme); } +static void +thumbnail_limit_changed_callback (gpointer user_data) +{ + cached_thumbnail_limit = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT); + + /* 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. + */ + gtk_signal_emit (GTK_OBJECT (global_icon_factory), + signals[ICONS_CHANGED]); +} + static void mime_type_data_changed_callback (GnomeVFSMIMEMonitor *monitor, gpointer user_data) { @@ -1399,7 +1413,7 @@ nautilus_icon_factory_get_icon_for_file (NautilusFile *file, const char *modifie if (file_size < SELF_THUMBNAIL_SIZE_THRESHOLD && is_local) { uri = nautilus_file_get_uri (file); } else if (strstr (file_uri, "/.thumbnails/") == NULL - && file_size < INHIBIT_THUMBNAIL_SIZE_THRESHOLD) { + && file_size < cached_thumbnail_limit) { uri = nautilus_get_thumbnail_uri (file, anti_aliased); if (uri == NULL) { uri = get_icon_file_path diff --git a/libnautilus-private/nautilus-preferences-item.c b/libnautilus-private/nautilus-preferences-item.c index 7648aa939..25f256ef9 100644 --- a/libnautilus-private/nautilus-preferences-item.c +++ b/libnautilus-private/nautilus-preferences-item.c @@ -459,21 +459,43 @@ preferences_item_create_editable_integer (NautilusPreferencesItem *item, static void preferences_item_update_constrained_integer (NautilusPreferencesItem *item) { - char *current_value_string; + char *current_label; int current_value; + char *current_value_as_string; + int position; g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item)); g_return_if_fail (item->details->item_type == NAUTILUS_PREFERENCE_ITEM_CONSTRAINED_INTEGER); + /* Too early if the value and label lists haven't been set up yet. */ + if (item->details->constrained_integer_value_list == NULL) { + return; + } + g_return_if_fail (item->details->constrained_integer_label_list != NULL); + current_value = nautilus_preferences_get_integer (item->details->preference_name); - current_value_string = g_strdup_printf ("%d", current_value); + current_value_as_string = g_strdup_printf ("%d", current_value); + position = nautilus_string_list_get_index_for_string + (item->details->constrained_integer_value_list, + current_value_as_string); + g_free (current_value_as_string); + + g_return_if_fail (position != NAUTILUS_STRING_LIST_NOT_FOUND); + + current_label = nautilus_string_list_nth + (item->details->constrained_integer_label_list, + position); - if (nautilus_string_picker_contains (NAUTILUS_STRING_PICKER (item->details->child), current_value_string)) { + if (nautilus_string_picker_contains (NAUTILUS_STRING_PICKER (item->details->child), current_label)) { nautilus_string_picker_set_selected_string (NAUTILUS_STRING_PICKER (item->details->child), - current_value_string); + current_label); + } else { + g_warning ("Value string for %s is %s, which isn't in the expected set of values", + item->details->preference_name, + current_label); } - g_free (current_value_string); + g_free (current_label); } static void |