# HG changeset patch # User zas_ # Date 1207233303 0 # Node ID 3c89da4aef9583724448d776308c2e4758562e2d # Parent 649f7cb544e0d821c1902ad2111ff5ce20f4ecc5 Fix and simplify thumbnails size combo box related code. Some variables were unused, code was buggy (spurious entry at the end of the list). A sanity check for values coming from rc file was added. Two constants now define the default thumbnail size. diff -r 649f7cb544e0 -r 3c89da4aef95 src/globals.c --- a/src/globals.c Thu Apr 03 13:58:20 2008 +0000 +++ b/src/globals.c Thu Apr 03 14:35:03 2008 +0000 @@ -54,8 +54,8 @@ gint max_window_size = 100; gint limit_autofit_size = FALSE; gint max_autofit_size = 100; -gint thumb_max_width = 96; -gint thumb_max_height = 72; +gint thumb_max_width = DEFAULT_THUMB_WIDTH; +gint thumb_max_height = DEFAULT_THUMB_HEIGHT; gint enable_thumb_caching = TRUE; gint enable_thumb_dirs = FALSE; gint use_xvpics_thumbnails = TRUE; diff -r 649f7cb544e0 -r 3c89da4aef95 src/gqview.h --- a/src/gqview.h Thu Apr 03 13:58:20 2008 +0000 +++ b/src/gqview.h Thu Apr 03 14:35:03 2008 +0000 @@ -82,6 +82,10 @@ #define COLOR_PROFILE_INPUTS 4 +#define DEFAULT_THUMB_WIDTH 96 +#define DEFAULT_THUMB_HEIGHT 72 + + #include "typedefs.h" /* diff -r 649f7cb544e0 -r 3c89da4aef95 src/preferences.c --- a/src/preferences.c Thu Apr 03 13:58:20 2008 +0000 +++ b/src/preferences.c Thu Apr 03 14:35:03 2008 +0000 @@ -545,9 +545,7 @@ { GtkWidget *combo; gint current; - gint last_w, last_h; gint i; - gint c; thumb_max_width_c = thumb_max_width; thumb_max_height_c = thumb_max_height; @@ -556,35 +554,20 @@ combo = gtk_combo_box_new_text(); - last_w = last_h = 0; current = -1; - i = 0; - c = TRUE; - while (c) + for (i = 0; i < sizeof(thumb_size_list) / sizeof(ThumbSize); i++) { gint w, h; + gchar *buf; w = thumb_size_list[i].w; h = thumb_size_list[i].h; - if ( w > 0 && h > 0) - { - gchar *buf; - - buf = g_strdup_printf("%d x %d", w, h); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), buf); - g_free(buf); - - if (w == thumb_max_width && h == thumb_max_height) current = i; - - last_w = w; - last_h = h; - } - else - { - c = FALSE; - } - i++; + buf = g_strdup_printf("%d x %d", w, h); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), buf); + g_free(buf); + + if (w == thumb_max_width && h == thumb_max_height) current = i; } if (current == -1) @@ -595,7 +578,7 @@ gtk_combo_box_append_text(GTK_COMBO_BOX(combo), buf); g_free(buf); - current = i - 1; + current = i; } gtk_combo_box_set_active(GTK_COMBO_BOX(combo), current); diff -r 649f7cb544e0 -r 3c89da4aef95 src/rcfile.c --- a/src/rcfile.c Thu Apr 03 13:58:20 2008 +0000 +++ b/src/rcfile.c Thu Apr 03 14:35:03 2008 +0000 @@ -561,8 +561,10 @@ "enable_thumbnails", value, thumbnails_enabled); thumb_max_width = read_int_option(f, option, "thumbnail_width", value, thumb_max_width); + if (thumb_max_width < 16) thumb_max_width = 16; thumb_max_height = read_int_option(f, option, "thumbnail_height", value, thumb_max_height); + if (thumb_max_height < 16) thumb_max_height = 16; enable_thumb_caching = read_bool_option(f, option, "cache_thumbnails", value, enable_thumb_caching); enable_thumb_dirs = read_bool_option(f, option,