Fix and simplify thumbnails size combo box related code.
authorLaurent Monin <geeqie@norz.org>
Thu, 3 Apr 2008 14:35:03 +0000 (14:35 +0000)
committerLaurent Monin <geeqie@norz.org>
Thu, 3 Apr 2008 14:35:03 +0000 (14:35 +0000)
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.

src/globals.c
src/gqview.h
src/preferences.c
src/rcfile.c

index a52d793..19317ef 100644 (file)
@@ -54,8 +54,8 @@ gint zoom_to_fit_expands = TRUE;
 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;
index 12a652e..f8a96d6 100644 (file)
 
 #define COLOR_PROFILE_INPUTS 4
 
+#define DEFAULT_THUMB_WIDTH    96
+#define DEFAULT_THUMB_HEIGHT   72
+
+
 #include "typedefs.h"
 
 /*
index e3d012d..69dc60c 100644 (file)
@@ -545,9 +545,7 @@ static void add_thumb_size_menu(GtkWidget *table, gint column, gint row, gchar *
 {
        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 @@ static void add_thumb_size_menu(GtkWidget *table, gint column, gint row, gchar *
 
        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 @@ static void add_thumb_size_menu(GtkWidget *table, gint column, gint row, gchar *
                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);
index 19d75e4..18cc417 100644 (file)
@@ -561,8 +561,10 @@ void load_options(void)
                        "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,