Preserve last histogram modes.
authorLaurent Monin <geeqie@norz.org>
Fri, 9 May 2008 08:39:18 +0000 (08:39 +0000)
committerLaurent Monin <geeqie@norz.org>
Fri, 9 May 2008 08:39:18 +0000 (08:39 +0000)
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

src/histogram.c
src/options.c
src/options.h
src/rcfile.c

index 5b5c029..a909981 100644 (file)
@@ -37,8 +37,8 @@ Histogram *histogram_new(void)
        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 @@ void histogram_free(Histogram *histogram)
 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_get_channel(Histogram *histogram)
 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;
 }
 
index 77d097d..ed88b7a 100644 (file)
@@ -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 @@ ConfOptions *init_options(ConfOptions *options)
        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;
index 3d5089b..72b632b 100644 (file)
@@ -129,6 +129,12 @@ struct _ConfOptions
                gint above;
        } fullscreen;
 
+       /* histogram */
+       struct {
+               guint last_channel_mode;
+               guint last_log_mode;
+       } histogram;
+       
        /* image overlay */
        struct {
                struct {
index edda5b3..e53b131 100644 (file)
@@ -441,11 +441,18 @@ void save_options(void)
        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 @@ void load_options(void)
                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);