changeset 612:21864cc96369

Preserve last histogram modes. When a new histogram is displayed, it uses previously chosen modes. These modes are saved on exit to rc file as options: histogram.last_channel_mode histogram.last_log_mode
author zas_
date Fri, 09 May 2008 08:39:18 +0000
parents f31ae0d9e163
children d06f422a6673
files src/histogram.c src/options.c src/options.h src/rcfile.c
diffstat 4 files changed, 26 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/histogram.c	Fri May 09 08:03:25 2008 +0000
+++ b/src/histogram.c	Fri May 09 08:39:18 2008 +0000
@@ -37,8 +37,8 @@
 	Histogram *histogram;
 
 	histogram = g_new0(Histogram, 1);
-	histogram->histogram_chan = HCHAN_RGB;
-	histogram->histogram_logmode = 1;
+	histogram->histogram_chan = options->histogram.last_channel_mode;
+	histogram->histogram_logmode = options->histogram.last_log_mode;
 
 	return histogram;
 }
@@ -52,7 +52,7 @@
 gint histogram_set_channel(Histogram *histogram, gint chan)
 {
 	if (!histogram) return 0;
-	histogram->histogram_chan = chan;
+	options->histogram.last_channel_mode = histogram->histogram_chan = chan;
 	return chan;
 }
 
@@ -65,7 +65,7 @@
 gint histogram_set_mode(Histogram *histogram, gint mode)
 {
 	if (!histogram) return 0;
-	histogram->histogram_logmode = mode;
+	options->histogram.last_log_mode = histogram->histogram_logmode = mode;
 	return mode;
 }
 
--- a/src/options.c	Fri May 09 08:03:25 2008 +0000
+++ b/src/options.c	Fri May 09 08:39:18 2008 +0000
@@ -12,6 +12,8 @@
 #include "main.h"
 #include "options.h"
 
+#include "histogram.h" /* HCHAN_RGB */
+
 ConfOptions *init_options(ConfOptions *options)
 {
 	if (!options) options = g_new0(ConfOptions, 1);
@@ -48,6 +50,9 @@
 	options->fullscreen.disable_saver = TRUE;
 	options->fullscreen.screen = -1;
 
+	options->histogram.last_channel_mode = HCHAN_RGB;
+	options->histogram.last_log_mode = 1;
+	
 	memset(&options->image.border_color, 0, sizeof(options->image.border_color));
 	options->image.dither_quality = (gint)GDK_RGB_DITHER_NORMAL;
 	options->image.enable_read_ahead = TRUE;
--- a/src/options.h	Fri May 09 08:03:25 2008 +0000
+++ b/src/options.h	Fri May 09 08:39:18 2008 +0000
@@ -129,6 +129,12 @@
 		gint above;
 	} fullscreen;
 
+	/* histogram */
+	struct {
+		guint last_channel_mode;
+		guint last_log_mode;
+	} histogram;
+	
 	/* image overlay */
 	struct {
 		struct {
--- a/src/rcfile.c	Fri May 09 08:03:25 2008 +0000
+++ b/src/rcfile.c	Fri May 09 08:39:18 2008 +0000
@@ -441,11 +441,18 @@
 	WRITE_BOOL(fullscreen.disable_saver);
 	WRITE_BOOL(fullscreen.above);
 
+
+	WRITE_SUBTITLE("Histogram Options");
+	WRITE_UINT(histogram.last_channel_mode);
+	WRITE_UINT(histogram.last_log_mode);
+
+
 	WRITE_SUBTITLE("Image Overlay Options");
 	WRITE_BOOL(image_overlay.common.enabled);
 	WRITE_BOOL(image_overlay.common.show_at_startup);
 	WRITE_CHAR(image_overlay.common.template_string);
 
+
 	WRITE_SUBTITLE("Slideshow Options");
 
 	WRITE_INT_UNIT(slideshow.delay, SLIDESHOW_SUBSECOND_PRECISION);
@@ -738,6 +745,10 @@
 		READ_BOOL(fullscreen.disable_saver);
 		READ_BOOL(fullscreen.above);
 
+		/* histogram */
+		READ_UINT(histogram.last_channel_mode);
+		READ_UINT(histogram.last_log_mode);
+
 		/* image overlay */
 		COMPAT_READ_BOOL(fullscreen.show_info, image_overlay.common.show_at_startup);
 		COMPAT_READ_CHAR(fullscreen.info, image_overlay.common.template_string);