Skip to content

Commit

Permalink
Preserve last histogram modes.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Laurent Monin committed May 9, 2008
1 parent 7917c5a commit dd431ef
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/histogram.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ struct _ConfOptions
gint above;
} fullscreen;

/* histogram */
struct {
guint last_channel_mode;
guint last_log_mode;
} histogram;

/* image overlay */
struct {
struct {
Expand Down
11 changes: 11 additions & 0 deletions src/rcfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit dd431ef

Please sign in to comment.