# HG changeset patch # User zas_ # Date 1208853270 0 # Node ID 805c3258d2283d64fe52e8d3953247265c0c93da # Parent 5212d4fed37f2871880966d30a6c02396c9c53ed Make histogram depends on image window not layout window. It simplifies the code, and make more sense. diff -r 5212d4fed37f -r 805c3258d228 src/image-overlay.c --- a/src/image-overlay.c Tue Apr 22 08:16:02 2008 +0000 +++ b/src/image-overlay.c Tue Apr 22 08:34:30 2008 +0000 @@ -90,40 +90,28 @@ */ -#define HIST_PREPARE(imd, lw) \ - LayoutWindow *lw = NULL; \ - if (imd) \ - lw = layout_find_by_image(imd); - void image_osd_histogram_onoff_toggle(ImageWindow *imd, gint x) { - HIST_PREPARE(imd, lw) - if (lw) - { - lw->histogram_enabled = !!(x); - if (lw->histogram_enabled && !lw->histogram) - lw->histogram = histogram_new(); - } + imd->histogram_enabled = !!(x); + if (imd->histogram_enabled && !imd->histogram) + imd->histogram = histogram_new(); } gint image_osd_histogram_onoff_status(ImageWindow *imd) { - HIST_PREPARE(imd, lw) - return lw ? lw->histogram_enabled : FALSE; + return imd->histogram_enabled; } void image_osd_histogram_chan_toggle(ImageWindow *imd) { - HIST_PREPARE(imd, lw) - if (lw && lw->histogram) - histogram_set_channel(lw->histogram, (histogram_get_channel(lw->histogram) +1)%HCHAN_COUNT); + if (imd->histogram) + histogram_set_channel(imd->histogram, (histogram_get_channel(imd->histogram) +1)%HCHAN_COUNT); } void image_osd_histogram_log_toggle(ImageWindow *imd) { - HIST_PREPARE(imd,lw) - if (lw && lw->histogram) - histogram_set_mode(lw->histogram, !histogram_get_mode(lw->histogram)); + if (imd->histogram) + histogram_set_mode(imd->histogram, !histogram_get_mode(imd->histogram)); } @@ -317,10 +305,8 @@ pixbuf_renderer_get_image_size(PIXBUF_RENDERER(imd->pr), &w, &h); imgpixbuf = (PIXBUF_RENDERER(imd->pr))->pixbuf; } - if (!lw) - lw = layout_find_by_image(imd); - - if (imgpixbuf && lw && lw->histogram && lw->histogram_enabled + + if (imgpixbuf && imd->histogram_enabled && imd->histogram && (!imd->il || imd->il->done)) with_hist=1; @@ -387,9 +373,9 @@ if (with_hist) { if (*text) - text2 = g_strdup_printf("%s\n%s", text, histogram_label(lw->histogram)); + text2 = g_strdup_printf("%s\n%s", text, histogram_label(imd->histogram)); else - text2 = g_strdup(histogram_label(lw->histogram)); + text2 = g_strdup(histogram_label(imd->histogram)); g_free(text); text = text2; } @@ -411,7 +397,7 @@ if (with_hist) { - histogram_read(lw->histogram, imgpixbuf); + histogram_read(imd->histogram, imgpixbuf); if (width < 266) width = 266; height += HISTOGRAM_HEIGHT + 5; } @@ -430,7 +416,7 @@ pixbuf_pixel_set(pixbuf, width - 1, height - 1, 0, 0, 0, 0); if (with_hist) - histogram_draw(lw->histogram, pixbuf, 5, height - HISTOGRAM_HEIGHT - 5 , width - 10, HISTOGRAM_HEIGHT); + histogram_draw(imd->histogram, pixbuf, 5, height - HISTOGRAM_HEIGHT - 5 , width - 10, HISTOGRAM_HEIGHT); pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 0, 0, 0, 255); } diff -r 5212d4fed37f -r 805c3258d228 src/image.c --- a/src/image.c Tue Apr 22 08:16:02 2008 +0000 +++ b/src/image.c Tue Apr 22 08:34:30 2008 +0000 @@ -19,6 +19,7 @@ #include "collect.h" #include "color-man.h" #include "exif.h" +#include "histogram.h" #include "image-overlay.h" #include "layout.h" #include "layout_image.h" @@ -1934,6 +1935,8 @@ g_free(imd->title); g_free(imd->title_right); + if (imd->histogram) histogram_free(imd->histogram); + g_free(imd); } @@ -2055,6 +2058,8 @@ imd->orientation = 1; + imd->histogram_enabled = FALSE; /* TODO: option */ + imd->pr = GTK_WIDGET(pixbuf_renderer_new()); image_options_set(imd); diff -r 5212d4fed37f -r 805c3258d228 src/layout.c --- a/src/layout.c Tue Apr 22 08:16:02 2008 +0000 +++ b/src/layout.c Tue Apr 22 08:34:30 2008 +0000 @@ -1859,8 +1859,6 @@ gtk_widget_destroy(lw->window); - histogram_free(lw->histogram); - g_free(lw->path); g_free(lw); @@ -1906,8 +1904,6 @@ lw->bar_exif_size = -1; lw->bar_exif_advanced = FALSE; - lw->histogram_enabled = FALSE; - /* default layout */ layout_config_parse(options->layout.style, options->layout.order, diff -r 5212d4fed37f -r 805c3258d228 src/typedefs.h --- a/src/typedefs.h Tue Apr 22 08:16:02 2008 +0000 +++ b/src/typedefs.h Tue Apr 22 08:34:30 2008 +0000 @@ -377,6 +377,10 @@ gint color_profile_from_image; gpointer cm; + /* histogram */ + gint histogram_enabled; + Histogram *histogram; + AlterType delay_alter_type; ImageLoader *read_ahead_il; @@ -533,9 +537,6 @@ GtkWidget *bar_exif; GtkWidget *bar_info; - gint histogram_enabled; - Histogram *histogram; - gint bar_sort_enabled; gint bar_exif_enabled; gint bar_info_enabled;