Skip to content

Commit

Permalink
fixed overlay configuration
Browse files Browse the repository at this point in the history
split overlay options between global and layout window
  • Loading branch information
nadvornik committed Feb 28, 2009
1 parent d5b911c commit fa373d7
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 82 deletions.
53 changes: 27 additions & 26 deletions src/image-overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ void image_osd_histogram_chan_toggle(ImageWindow *imd)
if (!osd || !osd->histogram) return;

histogram_toggle_channel(osd->histogram);
options->image_overlay.common.histogram_channel = histogram_get_channel(osd->histogram);
image_osd_update(imd);
}

Expand All @@ -142,7 +141,6 @@ void image_osd_histogram_log_toggle(ImageWindow *imd)
if (!osd || !osd->histogram) return;

histogram_toggle_mode(osd->histogram);
options->image_overlay.common.histogram_mode = histogram_get_mode(osd->histogram);
image_osd_update(imd);
}

Expand All @@ -153,13 +151,12 @@ void image_osd_toggle(ImageWindow *imd)
if (!imd) return;

osd = image_get_osd_data(imd);
if (!osd)
if (osd->show == OSD_SHOW_NOTHING)
{
image_osd_set(imd, OSD_SHOW_INFO | OSD_SHOW_STATUS);
return;
}

if (osd->show != OSD_SHOW_NOTHING)
else
{
if (osd->show & OSD_SHOW_HISTOGRAM)
{
Expand Down Expand Up @@ -548,7 +545,7 @@ static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
osd_template_insert(vars, "res", NULL, OSDT_NONE);
}

text = image_osd_mkinfo(options->image_overlay.common.template_string, imd, vars);
text = image_osd_mkinfo(options->image_overlay.template_string, imd, vars);
g_hash_table_destroy(vars);

} else {
Expand Down Expand Up @@ -1011,28 +1008,18 @@ static void image_osd_enable(ImageWindow *imd, OsdShowFlags show)
osd->timer_id = -1;
osd->show = OSD_SHOW_NOTHING;
osd->histogram = NULL;
osd->x = options->image_overlay.common.x;
osd->y = options->image_overlay.common.y;
osd->x = options->image_overlay.x;
osd->y = options->image_overlay.y;

osd->histogram = histogram_new();

osd->destroy_id = g_signal_connect(G_OBJECT(imd->pr), "destroy",
G_CALLBACK(image_osd_destroy_cb), osd);
image_set_osd_data(imd, osd);

image_set_state_func(osd->imd, image_osd_state_cb, osd);
}

if (show & OSD_SHOW_HISTOGRAM)
{
osd->histogram = histogram_new();
histogram_set_channel(osd->histogram, options->image_overlay.common.histogram_channel);
histogram_set_mode(osd->histogram, options->image_overlay.common.histogram_mode);
}
else if (osd->histogram)
{
histogram_free(osd->histogram);
osd->histogram = NULL;
}

if (show & OSD_SHOW_STATUS)
image_osd_icon(imd, IMAGE_OSD_ICON, -1);

Expand All @@ -1046,12 +1033,6 @@ void image_osd_set(ImageWindow *imd, OsdShowFlags show)
{
if (!imd) return;

if (show == OSD_SHOW_NOTHING)
{
image_osd_remove(imd);
return;
}

image_osd_enable(imd, show);
}

Expand All @@ -1062,6 +1043,26 @@ OsdShowFlags image_osd_get(ImageWindow *imd)
return osd ? osd->show : OSD_SHOW_NOTHING;
}

Histogram *image_osd_get_histogram(ImageWindow *imd)
{
OverlayStateData *osd = image_get_osd_data(imd);

return osd ? osd->histogram : NULL;
}

void image_osd_copy_status(ImageWindow *src, ImageWindow *dest)
{
Histogram *h_src, *h_dest;
image_osd_set(dest, image_osd_get(src));

h_src = image_osd_get_histogram(src);
h_dest = image_osd_get_histogram(dest);

h_dest->histogram_mode = h_src->histogram_mode;
h_dest->histogram_channel = h_src->histogram_channel;

}

/* duration:
0 = hide
1 = show
Expand Down
4 changes: 4 additions & 0 deletions src/image-overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ void set_default_image_overlay_template_string(gchar **template_string);
void image_osd_set(ImageWindow *imd, OsdShowFlags show);
OsdShowFlags image_osd_get(ImageWindow *imd);

Histogram *image_osd_get_histogram(ImageWindow *imd);

void image_osd_copy_status(ImageWindow *src, ImageWindow *dest);

void image_osd_update(ImageWindow *imd);

void image_osd_icon(ImageWindow *imd, ImageOSDFlag flag, gint duration);
Expand Down
24 changes: 21 additions & 3 deletions src/layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,7 @@ gint layout_toolbar_hidden(LayoutWindow *lw)

void layout_sync_options_with_current_state(LayoutWindow *lw)
{
Histogram *histogram;
if (!layout_valid(&lw)) return;

lw->options.main_window.maximized = window_maximized(lw->window);
Expand All @@ -1929,6 +1930,12 @@ void layout_sync_options_with_current_state(LayoutWindow *lw)
layout_geometry_get_tools(lw, &lw->options.float_window.x, &lw->options.float_window.y,
&lw->options.float_window.w, &lw->options.float_window.h, &lw->options.float_window.vdivider_pos);

lw->options.image_overlay.state = image_osd_get(lw->image);
histogram = image_osd_get_histogram(lw->image);

lw->options.image_overlay.histogram_channel = histogram->histogram_channel;
lw->options.image_overlay.histogram_mode = histogram->histogram_mode;

// if (options->startup.restore_path && options->startup.use_last_path)
// {
// g_free(options->startup.path);
Expand Down Expand Up @@ -1995,6 +2002,7 @@ LayoutWindow *layout_new_with_geometry(FileData *dir_fd, LayoutOptions *lop,
LayoutWindow *lw;
GdkGeometry hint;
GdkWindowHints hint_mask;
Histogram *histogram;

lw = g_new0(LayoutWindow, 1);

Expand Down Expand Up @@ -2115,7 +2123,11 @@ LayoutWindow *layout_new_with_geometry(FileData *dir_fd, LayoutOptions *lop,
gtk_widget_show(lw->window);
layout_tools_hide(lw, lw->options.tools_hidden);

image_osd_set(lw->image, options->image_overlay.common.state | (options->image_overlay.common.show_at_startup ? OSD_SHOW_INFO : OSD_SHOW_NOTHING));
image_osd_set(lw->image, lw->options.image_overlay.state);
histogram = image_osd_get_histogram(lw->image);

histogram->histogram_channel = lw->options.image_overlay.histogram_channel;
histogram->histogram_mode = lw->options.image_overlay.histogram_mode;

layout_window_list = g_list_append(layout_window_list, lw);

Expand All @@ -2137,8 +2149,6 @@ void layout_write_attributes(LayoutOptions *layout, GString *outstr, gint indent
WRITE_SEPARATOR();

WRITE_BOOL(*layout, save_window_positions);
WRITE_SEPARATOR();

WRITE_INT(*layout, main_window.x);
WRITE_INT(*layout, main_window.y);
WRITE_INT(*layout, main_window.w);
Expand All @@ -2165,6 +2175,10 @@ void layout_write_attributes(LayoutOptions *layout, GString *outstr, gint indent
WRITE_SEPARATOR();

WRITE_BOOL(*layout, toolbar_hidden);

WRITE_UINT(*layout, image_overlay.state);
WRITE_INT(*layout, image_overlay.histogram_channel);
WRITE_INT(*layout, image_overlay.histogram_mode);
}


Expand Down Expand Up @@ -2229,6 +2243,10 @@ void layout_load_attributes(LayoutOptions *layout, const gchar **attribute_names
if (READ_BOOL(*layout, tools_restore_state)) continue;
if (READ_BOOL(*layout, toolbar_hidden)) continue;

if (READ_UINT(*layout, image_overlay.state)) continue;
if (READ_INT(*layout, image_overlay.histogram_channel)) continue;
if (READ_INT(*layout, image_overlay.histogram_mode)) continue;

DEBUG_1("unknown attribute %s = %s", option, value);
}

Expand Down
9 changes: 2 additions & 7 deletions src/layout_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,15 @@ void layout_image_full_screen_start(LayoutWindow *lw)
if (lw->tools) gtk_widget_set_sensitive(lw->tools, FALSE);
#endif

if (image_osd_get(lw->full_screen->normal_imd) & OSD_SHOW_INFO)
{
image_osd_set(lw->image, image_osd_get(lw->full_screen->normal_imd));
image_osd_set(lw->full_screen->normal_imd, OSD_SHOW_NOTHING);
}
image_osd_copy_status(lw->full_screen->normal_imd, lw->image);
}

void layout_image_full_screen_stop(LayoutWindow *lw)
{
if (!layout_valid(&lw)) return;
if (!lw->full_screen) return;

if (image_osd_get(lw->image) & OSD_SHOW_INFO)
image_osd_set(lw->full_screen->normal_imd, image_osd_get(lw->image));
image_osd_copy_status(lw->image, lw->full_screen->normal_imd);

fullscreen_stop(lw->full_screen);

Expand Down
19 changes: 8 additions & 11 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ ConfOptions *init_options(ConfOptions *options)
options->fullscreen.disable_saver = TRUE;
options->fullscreen.screen = -1;

options->image_overlay.common.histogram_channel = HCHAN_RGB;
options->image_overlay.common.histogram_mode = 1;

memset(&options->image.border_color, 0, sizeof(options->image.border_color));
options->image.dither_quality = GDK_RGB_DITHER_NORMAL;
options->image.enable_read_ahead = TRUE;
Expand All @@ -83,11 +80,9 @@ ConfOptions *init_options(ConfOptions *options)
options->image.zoom_quality = GDK_INTERP_BILINEAR;
options->image.zoom_to_fit_allow_expand = FALSE;

options->image_overlay.common.state = OSD_SHOW_NOTHING;
options->image_overlay.common.show_at_startup = FALSE;
options->image_overlay.common.template_string = NULL;
options->image_overlay.common.x = 10;
options->image_overlay.common.y = -10;
options->image_overlay.template_string = NULL;
options->image_overlay.x = 10;
options->image_overlay.y = -10;

options->layout.dir_view_type = DIRVIEW_LIST;
options->layout.file_view_type = FILEVIEW_LIST;
Expand All @@ -114,7 +109,10 @@ ConfOptions *init_options(ConfOptions *options)
options->layout.tools_float = FALSE;
options->layout.tools_hidden = FALSE;
options->layout.tools_restore_state = TRUE;

options->layout.image_overlay.histogram_channel = HCHAN_RGB;
options->layout.image_overlay.histogram_mode = 1;
options->layout.image_overlay.state = OSD_SHOW_NOTHING;

options->lazy_image_sync = FALSE;
options->mousewheel_scrolls = FALSE;
options->open_recent_list_maxsize = 10;
Expand Down Expand Up @@ -181,7 +179,7 @@ void setup_default_options(ConfOptions *options)
options->color_profile.input_name[i] = NULL;
}

set_default_image_overlay_template_string(&options->image_overlay.common.template_string);
set_default_image_overlay_template_string(&options->image_overlay.template_string);
options->sidecar.ext = g_strdup(".jpg;%raw;.xmp");
options->layout.order = g_strdup("123");

Expand Down Expand Up @@ -215,7 +213,6 @@ static void sync_options_with_current_state(ConfOptions *options)
{
layout_sync_options_with_current_state(lw);
copy_layout_options(&options->layout, &lw->options);
options->image_overlay.common.state = image_osd_get(lw->image);
layout_sort_get(lw, &options->file_sort.method, &options->file_sort.ascending);


Expand Down
12 changes: 3 additions & 9 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,9 @@ struct _ConfOptions

/* image overlay */
struct {
struct {
guint state;
gboolean show_at_startup;
gchar *template_string;
gint x;
gint y;
gint histogram_channel;
gint histogram_mode;
} common;
gchar *template_string;
gint x;
gint y;
} image_overlay;

/* layout */
Expand Down
17 changes: 7 additions & 10 deletions src/preferences.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,9 @@ static void config_window_apply(void)
options->fullscreen.clean_flip = c_options->fullscreen.clean_flip;
options->fullscreen.disable_saver = c_options->fullscreen.disable_saver;
options->fullscreen.above = c_options->fullscreen.above;
options->image_overlay.common.show_at_startup = c_options->image_overlay.common.show_at_startup;
if (c_options->image_overlay.common.template_string)
set_image_overlay_template_string(&options->image_overlay.common.template_string,
c_options->image_overlay.common.template_string);
if (c_options->image_overlay.template_string)
set_image_overlay_template_string(&options->image_overlay.template_string,
c_options->image_overlay.template_string);

options->update_on_time_change = c_options->update_on_time_change;
options->image.exif_rotate_enable = c_options->image.exif_rotate_enable;
Expand Down Expand Up @@ -952,7 +951,7 @@ static void image_overlay_template_view_changed_cb(GtkWidget *widget, gpointer d
gtk_text_buffer_get_start_iter(pTextBuffer, &iStart);
gtk_text_buffer_get_end_iter(pTextBuffer, &iEnd);

set_image_overlay_template_string(&c_options->image_overlay.common.template_string,
set_image_overlay_template_string(&c_options->image_overlay.template_string,
gtk_text_buffer_get_text(pTextBuffer, &iStart, &iEnd, TRUE));
}

Expand All @@ -961,11 +960,11 @@ static void image_overlay_default_template_ok_cb(GenericDialog *gd, gpointer dat
GtkTextView *text_view = data;
GtkTextBuffer *buffer;

set_default_image_overlay_template_string(&options->image_overlay.common.template_string);
set_default_image_overlay_template_string(&options->image_overlay.template_string);
if (!configwindow) return;

buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
gtk_text_buffer_set_text(buffer, options->image_overlay.common.template_string, -1);
gtk_text_buffer_set_text(buffer, options->image_overlay.template_string, -1);
}

static void image_overlay_default_template_cb(GtkWidget *widget, gpointer data)
Expand Down Expand Up @@ -1536,8 +1535,6 @@ static void config_tab_advanced(GtkWidget *notebook)

group = pref_group_new(vbox, FALSE, _("Overlay Screen Display"), GTK_ORIENTATION_VERTICAL);

pref_checkbox_new_int(group, _("Always show image overlay at startup"),
options->image_overlay.common.show_at_startup, &c_options->image_overlay.common.show_at_startup);
pref_label_new(group, _("Image overlay template"));

scrolled = gtk_scrolled_window_new(NULL, NULL);
Expand Down Expand Up @@ -1580,7 +1577,7 @@ static void config_tab_advanced(GtkWidget *notebook)
gtk_widget_show(button);

buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(image_overlay_template_view));
if (options->image_overlay.common.template_string) gtk_text_buffer_set_text(buffer, options->image_overlay.common.template_string, -1);
if (options->image_overlay.template_string) gtk_text_buffer_set_text(buffer, options->image_overlay.template_string, -1);
g_signal_connect(G_OBJECT(buffer), "changed",
G_CALLBACK(image_overlay_template_view_changed_cb), image_overlay_template_view);

Expand Down
23 changes: 7 additions & 16 deletions src/rcfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,22 +370,18 @@ static void write_global_attributes(GString *outstr, gint indent)
WRITE_BOOL(*options, fullscreen.disable_saver);
WRITE_BOOL(*options, fullscreen.above);

WRITE_SEPARATOR();

// WRITE_SUBTITLE("Image Overlay Options");
WRITE_UINT(*options, image_overlay.common.state);
WRITE_BOOL(*options, image_overlay.common.show_at_startup);
WRITE_CHAR(*options, image_overlay.common.template_string);
WRITE_INT(*options, image_overlay.common.histogram_channel);
WRITE_INT(*options, image_overlay.common.histogram_mode);
WRITE_SEPARATOR();
WRITE_CHAR(*options, image_overlay.template_string);

// g_string_append_printf(outstr, "# these are relative positions:\n");
// g_string_append_printf(outstr, "# x >= 0: |x| pixels from left border\n");
// g_string_append_printf(outstr, "# x < 0 : |x| pixels from right border\n");
// g_string_append_printf(outstr, "# y >= 0: |y| pixels from top border\n");
// g_string_append_printf(outstr, "# y < 0 : |y| pixels from bottom border\n");
WRITE_INT(*options, image_overlay.common.x);
WRITE_INT(*options, image_overlay.common.y);
WRITE_INT(*options, image_overlay.x);
WRITE_INT(*options, image_overlay.y);


// WRITE_SUBTITLE("Slideshow Options");
Expand Down Expand Up @@ -672,14 +668,9 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar **
if (READ_BOOL(*options, fullscreen.above)) continue;

/* image overlay */
if (READ_UINT(*options, image_overlay.common.state)) continue;
if (READ_BOOL(*options, image_overlay.common.show_at_startup)) continue;
if (READ_CHAR(*options, image_overlay.common.template_string)) continue;
if (READ_INT(*options, image_overlay.common.histogram_channel)) continue;
if (READ_INT(*options, image_overlay.common.histogram_mode)) continue;

if (READ_INT(*options, image_overlay.common.x)) continue;
if (READ_INT(*options, image_overlay.common.y)) continue;
if (READ_CHAR(*options, image_overlay.template_string)) continue;
if (READ_INT(*options, image_overlay.x)) continue;
if (READ_INT(*options, image_overlay.y)) continue;


/* slideshow options */
Expand Down
Loading

0 comments on commit fa373d7

Please sign in to comment.