From fa373d7547d5c23f65088dff3df36d43b90b0139 Mon Sep 17 00:00:00 2001 From: Vladimir Nadvornik Date: Sat, 28 Feb 2009 14:40:22 +0000 Subject: [PATCH] fixed overlay configuration split overlay options between global and layout window --- src/image-overlay.c | 53 +++++++++++++++++++++++---------------------- src/image-overlay.h | 4 ++++ src/layout.c | 24 +++++++++++++++++--- src/layout_image.c | 9 ++------ src/options.c | 19 +++++++--------- src/options.h | 12 +++------- src/preferences.c | 17 ++++++--------- src/rcfile.c | 23 ++++++-------------- src/typedefs.h | 6 +++++ 9 files changed, 85 insertions(+), 82 deletions(-) diff --git a/src/image-overlay.c b/src/image-overlay.c index f2cd3c5f..e46e89e2 100644 --- a/src/image-overlay.c +++ b/src/image-overlay.c @@ -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); } @@ -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); } @@ -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) { @@ -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 { @@ -1011,9 +1008,11 @@ 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); @@ -1021,18 +1020,6 @@ static void image_osd_enable(ImageWindow *imd, OsdShowFlags show) 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); @@ -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); } @@ -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 diff --git a/src/image-overlay.h b/src/image-overlay.h index 83757eed..9e70d92c 100644 --- a/src/image-overlay.h +++ b/src/image-overlay.h @@ -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); diff --git a/src/layout.c b/src/layout.c index 95229208..7c3e91d5 100644 --- a/src/layout.c +++ b/src/layout.c @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); } @@ -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); } diff --git a/src/layout_image.c b/src/layout_image.c index 280ef1c8..c237c3e0 100644 --- a/src/layout_image.c +++ b/src/layout_image.c @@ -99,11 +99,7 @@ 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) @@ -111,8 +107,7 @@ 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); diff --git a/src/options.c b/src/options.c index bf29c914..d4edfa28 100644 --- a/src/options.c +++ b/src/options.c @@ -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; @@ -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; @@ -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; @@ -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"); @@ -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); diff --git a/src/options.h b/src/options.h index 6db0921a..c3f75e9b 100644 --- a/src/options.h +++ b/src/options.h @@ -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 */ diff --git a/src/preferences.c b/src/preferences.c index 83eb389b..a720693e 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -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; @@ -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)); } @@ -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) @@ -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); @@ -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); diff --git a/src/rcfile.c b/src/rcfile.c index c79c066b..876eb4a1 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -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"); @@ -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 */ diff --git a/src/typedefs.h b/src/typedefs.h index 4fde26cb..06a26f59 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -519,6 +519,12 @@ struct _LayoutOptions gint h; } properties_window; + struct { + guint state; + gint histogram_channel; + gint histogram_mode; + } image_overlay; + gboolean save_window_positions; gboolean tools_float; -- 2.20.1