changeset 858:171dd6e53656

Use stricter types for image options.
author zas_
date Thu, 26 Jun 2008 14:43:52 +0000
parents 7d387a25b1ec
children 63e1161ada52
files src/options.h src/pixbuf-renderer.h src/rcfile.c
diffstat 3 files changed, 25 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/options.h	Thu Jun 26 12:23:48 2008 +0000
+++ b/src/options.h	Thu Jun 26 14:43:52 2008 +0000
@@ -58,22 +58,22 @@
 
 	/* image */
 	struct {
-		gint exif_rotate_enable;
-		gint scroll_reset_method;
-		gint fit_window_to_image;
-		gint limit_window_size;
+		gboolean exif_rotate_enable;
+		guint scroll_reset_method;
+		gboolean fit_window_to_image;
+		gboolean limit_window_size;
 		gint max_window_size;
-		gint limit_autofit_size;
+		gboolean limit_autofit_size;
 		gint max_autofit_size;
 
 		gint tile_cache_max;	/* in megabytes */
 		gint image_cache_max;   /* in megabytes */
 		gint dither_quality;
-		gint enable_read_ahead;
+		gboolean enable_read_ahead;
 
 		gint zoom_mode;
-		gint zoom_2pass;
-		gint zoom_to_fit_allow_expand;
+		gboolean zoom_2pass;
+		gboolean zoom_to_fit_allow_expand;
 		gint zoom_quality;
 		gint zoom_increment;	/* 10 is 1.0, 5 is 0.05, 20 is 2.0, etc. */
 
--- a/src/pixbuf-renderer.h	Thu Jun 26 12:23:48 2008 +0000
+++ b/src/pixbuf-renderer.h	Thu Jun 26 14:43:52 2008 +0000
@@ -40,7 +40,8 @@
 typedef enum {
 	PR_SCROLL_RESET_TOPLEFT = 0,
 	PR_SCROLL_RESET_CENTER,
-	PR_SCROLL_RESET_NOCHANGE
+	PR_SCROLL_RESET_NOCHANGE,
+	PR_SCROLL_RESET_COUNT,
 } PixbufRendererScrollResetType;
 
 struct _PixbufRenderer
--- a/src/rcfile.c	Thu Jun 26 12:23:48 2008 +0000
+++ b/src/rcfile.c	Thu Jun 26 14:43:52 2008 +0000
@@ -19,6 +19,7 @@
 #include "bar_exif.h"
 #include "editors.h"
 #include "filefilter.h"
+#include "pixbuf-renderer.h"
 #include "secure_save.h"
 #include "slideshow.h"
 #include "ui_fileops.h"
@@ -210,6 +211,17 @@
 	return TRUE;
 }
 
+static gboolean read_uint_option_clamp(FILE *f, gchar *option, gchar *label, gchar *value, guint *n, guint min, guint max)
+{
+	gboolean ret;
+
+	ret = read_uint_option(f, option, label, value, n);
+	if (ret) *n = CLAMP(*n, min, max);
+
+	return ret;
+}
+
+
 static gboolean read_int_option_clamp(FILE *f, gchar *option, gchar *label, gchar *value, gint *n, gint min, gint max)
 {
 	gboolean ret;
@@ -446,7 +458,7 @@
 	WRITE_INT(image.max_window_size);
 	WRITE_BOOL(image.limit_autofit_size);
 	WRITE_INT(image.max_autofit_size);
-	WRITE_INT(image.scroll_reset_method);
+	WRITE_UINT(image.scroll_reset_method);
 	WRITE_INT(image.tile_cache_max);
 	WRITE_INT(image.image_cache_max);
 	WRITE_INT(image.dither_quality);
@@ -693,6 +705,7 @@
 #define READ_INT(_name_) if (read_int_option(f, option, #_name_, value, &options->_name_)) continue;
 #define READ_UINT(_name_) if (read_uint_option(f, option, #_name_, value, &options->_name_)) continue;
 #define READ_INT_CLAMP(_name_, _min_, _max_) if (read_int_option_clamp(f, option, #_name_, value, &options->_name_, _min_, _max_)) continue;
+#define READ_UINT_CLAMP(_name_, _min_, _max_) if (read_uint_option_clamp(f, option, #_name_, value, &options->_name_, _min_, _max_)) continue;
 #define READ_INT_UNIT(_name_, _unit_) if (read_int_unit_option(f, option, #_name_, value, &options->_name_, _unit_)) continue;
 #define READ_CHAR(_name_) if (read_char_option(f, option, #_name_, value_all, &options->_name_)) continue;
 #define READ_COLOR(_name_) if (read_color_option(f, option, #_name_, value, &options->_name_)) continue;
@@ -806,7 +819,7 @@
 		READ_INT(image.max_window_size);
 		READ_BOOL(image.limit_autofit_size);
 		READ_INT(image.max_autofit_size);
-		READ_INT(image.scroll_reset_method);
+		READ_UINT_CLAMP(image.scroll_reset_method, 0, PR_SCROLL_RESET_COUNT - 1);
 		READ_INT(image.tile_cache_max);
 		READ_INT(image.image_cache_max);
 		READ_INT_CLAMP(image.zoom_quality, GDK_INTERP_NEAREST, GDK_INTERP_HYPER);