diff src/preferences.c @ 226:3c89da4aef95

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.
author zas_
date Thu, 03 Apr 2008 14:35:03 +0000
parents 649f7cb544e0
children 41fc4bfc8b25
line wrap: on
line diff
--- 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);