Mercurial > geeqie
annotate src/bar_histogram.c @ 1811:f405ec9b696b default tip
Some small logic mistakes
Use boolean operators for booleans and bitwise otherwise only.
author | mow |
---|---|
date | Mon, 10 May 2010 11:33:13 +0000 |
parents | c416d099a3dc |
children |
rev | line source |
---|---|
1298 | 1 /* |
2 * Geeqie | |
3 * (C) 2004 John Ellis | |
1802 | 4 * Copyright (C) 2008 - 2010 The Geeqie Team |
1298 | 5 * |
6 * Author: Vladimir Nadvornik | |
7 * | |
8 * This software is released under the GNU General Public License (GNU GPL). | |
9 * Please read the included file COPYING for more information. | |
10 * This software comes with no warranty of any kind, use at your own risk! | |
11 */ | |
12 | |
13 | |
14 #include "main.h" | |
1339 | 15 #include "bar_histogram.h" |
1298 | 16 |
17 #include "bar.h" | |
18 #include "metadata.h" | |
19 #include "filedata.h" | |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
20 #include "menu.h" |
1298 | 21 #include "ui_menu.h" |
22 #include "ui_misc.h" | |
23 #include "histogram.h" | |
1309 | 24 #include "rcfile.h" |
1298 | 25 |
26 /* | |
27 *------------------------------------------------------------------- | |
28 * keyword / comment utils | |
29 *------------------------------------------------------------------- | |
30 */ | |
31 | |
32 | |
33 | |
34 typedef struct _PaneHistogramData PaneHistogramData; | |
35 struct _PaneHistogramData | |
36 { | |
37 PaneData pane; | |
38 GtkWidget *widget; | |
39 GtkWidget *drawing_area; | |
40 Histogram *histogram; | |
41 gint histogram_width; | |
42 gint histogram_height; | |
43 GdkPixbuf *pixbuf; | |
44 FileData *fd; | |
1331
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
45 gboolean need_update; |
1523 | 46 guint idle_id; /* event source id */ |
1298 | 47 }; |
48 | |
1331
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
49 static gboolean bar_pane_histogram_update_cb(gpointer data); |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
50 |
1298 | 51 |
52 static void bar_pane_histogram_update(PaneHistogramData *phd) | |
53 { | |
54 if (phd->pixbuf) g_object_unref(phd->pixbuf); | |
55 phd->pixbuf = NULL; | |
56 | |
1344 | 57 gtk_label_set_text(GTK_LABEL(phd->pane.title), histogram_label(phd->histogram)); |
58 | |
1298 | 59 if (!phd->histogram_width || !phd->histogram_height || !phd->fd) return; |
60 | |
1331
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
61 /* histmap_get is relatively expensive, run it only when we really need it |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
62 and with lower priority than pixbuf_renderer |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
63 FIXME: this does not work for fullscreen*/ |
1810 | 64 #if GTK_CHECK_VERSION(2,20,0) |
65 if (gtk_widget_is_drawable(phd->drawing_area)) | |
66 #else | |
1331
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
67 if (GTK_WIDGET_DRAWABLE(phd->drawing_area)) |
1810 | 68 #endif |
1331
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
69 { |
1523 | 70 if (!phd->idle_id) |
71 { | |
72 phd->idle_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, bar_pane_histogram_update_cb, phd, NULL); | |
73 } | |
1331
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
74 } |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
75 else |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
76 { |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
77 phd->need_update = TRUE; |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
78 } |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
79 } |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
80 |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
81 static gboolean bar_pane_histogram_update_cb(gpointer data) |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
82 { |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
83 const HistMap *histmap; |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
84 PaneHistogramData *phd = data; |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
85 |
1523 | 86 phd->idle_id = 0; |
1331
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
87 phd->need_update = FALSE; |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
88 |
1298 | 89 gtk_widget_queue_draw_area(GTK_WIDGET(phd->drawing_area), 0, 0, phd->histogram_width, phd->histogram_height); |
90 | |
1474 | 91 if (phd->fd == NULL) return FALSE; |
1298 | 92 histmap = histmap_get(phd->fd); |
93 | |
1439 | 94 if (!histmap) |
95 { | |
96 histmap_start_idle(phd->fd); | |
97 return FALSE; | |
98 } | |
1298 | 99 |
100 phd->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, phd->histogram_width, phd->histogram_height); | |
101 gdk_pixbuf_fill(phd->pixbuf, 0xffffffff); | |
102 histogram_draw(phd->histogram, histmap, phd->pixbuf, 0, 0, phd->histogram_width, phd->histogram_height); | |
1330
8b6e2a47adc7
Add a tooltip showing current histogram state on bar histogram.
zas_
parents:
1329
diff
changeset
|
103 |
1331
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
104 return FALSE; |
1298 | 105 } |
106 | |
107 | |
108 static void bar_pane_histogram_set_fd(GtkWidget *pane, FileData *fd) | |
109 { | |
110 PaneHistogramData *phd; | |
111 | |
112 phd = g_object_get_data(G_OBJECT(pane), "pane_data"); | |
113 if (!phd) return; | |
114 | |
115 file_data_unref(phd->fd); | |
116 phd->fd = file_data_ref(fd); | |
117 | |
118 bar_pane_histogram_update(phd); | |
119 } | |
120 | |
1309 | 121 static void bar_pane_histogram_write_config(GtkWidget *pane, GString *outstr, gint indent) |
122 { | |
123 PaneHistogramData *phd; | |
124 | |
125 phd = g_object_get_data(G_OBJECT(pane), "pane_data"); | |
126 if (!phd) return; | |
127 | |
1461 | 128 WRITE_NL(); WRITE_STRING("<pane_histogram "); |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
129 write_char_option(outstr, indent, "id", phd->pane.id); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
130 write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(phd->pane.title))); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
131 WRITE_BOOL(phd->pane, expanded); |
1329
1fc356f629fe
Clean up histogram stuff: options saving/restoring, osd histogram separation, tidy up.
zas_
parents:
1324
diff
changeset
|
132 WRITE_INT(*phd->histogram, histogram_channel); |
1fc356f629fe
Clean up histogram stuff: options saving/restoring, osd histogram separation, tidy up.
zas_
parents:
1324
diff
changeset
|
133 WRITE_INT(*phd->histogram, histogram_mode); |
1461 | 134 WRITE_STRING("/>"); |
1309 | 135 } |
136 | |
1298 | 137 static void bar_pane_histogram_notify_cb(FileData *fd, NotifyType type, gpointer data) |
138 { | |
139 PaneHistogramData *phd = data; | |
1498 | 140 if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_HISTMAP | NOTIFY_PIXBUF)) && fd == phd->fd) |
141 { | |
142 DEBUG_1("Notify pane_histogram: %s %04x", fd->path, type); | |
143 bar_pane_histogram_update(phd); | |
144 } | |
1298 | 145 } |
146 | |
1346
c9949c19a6d0
No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents:
1344
diff
changeset
|
147 static gboolean bar_pane_histogram_expose_event_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) |
1298 | 148 { |
149 PaneHistogramData *phd = data; | |
1331
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
150 if (!phd) return TRUE; |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
151 |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
152 if (phd->need_update) |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
153 { |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
154 bar_pane_histogram_update(phd); |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
155 } |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
156 |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
157 if (!phd->pixbuf) return TRUE; |
1298 | 158 |
159 gdk_draw_pixbuf(widget->window, | |
1810 | 160 #if GTK_CHECK_VERSION(2,20,0) |
161 widget->style->fg_gc[gtk_widget_get_state(widget)], | |
162 #else | |
1298 | 163 widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
1810 | 164 #endif |
1298 | 165 phd->pixbuf, |
166 0, 0, | |
167 0, 0, | |
168 -1, -1, | |
169 GDK_RGB_DITHER_NORMAL, 0, 0); | |
170 return TRUE; | |
171 } | |
172 | |
173 static void bar_pane_histogram_size_cb(GtkWidget *widget, GtkAllocation *allocation, gpointer data) | |
174 { | |
175 PaneHistogramData *phd = data; | |
176 | |
177 phd->histogram_width = allocation->width; | |
178 phd->histogram_height = allocation->height; | |
179 bar_pane_histogram_update(phd); | |
180 } | |
181 | |
1740
6146ec0c9ab9
Comment out unused functions, silenting related compilation warnings.
zas_
parents:
1667
diff
changeset
|
182 #if 0 |
1298 | 183 static void bar_pane_histogram_close(GtkWidget *pane) |
184 { | |
185 PaneHistogramData *phd; | |
186 | |
187 phd = g_object_get_data(G_OBJECT(pane), "pane_data"); | |
188 if (!phd) return; | |
189 | |
190 gtk_widget_destroy(phd->widget); | |
191 } | |
1740
6146ec0c9ab9
Comment out unused functions, silenting related compilation warnings.
zas_
parents:
1667
diff
changeset
|
192 #endif |
1298 | 193 |
194 static void bar_pane_histogram_destroy(GtkWidget *widget, gpointer data) | |
195 { | |
196 PaneHistogramData *phd = data; | |
1331
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
197 |
1523 | 198 if (phd->idle_id) g_source_remove(phd->idle_id); |
1298 | 199 file_data_unregister_notify_func(bar_pane_histogram_notify_cb, phd); |
200 | |
201 file_data_unref(phd->fd); | |
202 histogram_free(phd->histogram); | |
203 if (phd->pixbuf) g_object_unref(phd->pixbuf); | |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
204 g_free(phd->pane.id); |
1298 | 205 |
206 g_free(phd); | |
207 } | |
208 | |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
209 static void bar_pane_histogram_popup_channels_cb(GtkWidget *widget, gpointer data) |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
210 { |
1667 | 211 PaneHistogramData *phd = data; |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
212 gint channel; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
213 |
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
214 if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return; |
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
215 |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
216 if (!phd) return; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
217 |
1667 | 218 channel = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "menu_item_radio_data")); |
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
219 if (channel == histogram_get_channel(phd->histogram)) return; |
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
220 |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
221 histogram_set_channel(phd->histogram, channel); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
222 bar_pane_histogram_update(phd); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
223 } |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
224 |
1667 | 225 static void bar_pane_histogram_popup_mode_cb(GtkWidget *widget, gpointer data) |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
226 { |
1667 | 227 PaneHistogramData *phd = data; |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
228 gint logmode; |
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
229 |
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
230 if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return; |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
231 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
232 if (!phd) return; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
233 |
1667 | 234 logmode = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "menu_item_radio_data")); |
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
235 if (logmode == histogram_get_mode(phd->histogram)) return; |
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
236 |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
237 histogram_set_mode(phd->histogram, logmode); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
238 bar_pane_histogram_update(phd); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
239 } |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
240 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
241 static GtkWidget *bar_pane_histogram_menu(PaneHistogramData *phd) |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
242 { |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
243 GtkWidget *menu; |
1667 | 244 gint channel = histogram_get_channel(phd->histogram); |
245 gint mode = histogram_get_mode(phd->histogram); | |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
246 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
247 menu = popup_menu_short_lived(); |
1667 | 248 |
249 /* use the same strings as in layout_util.c */ | |
250 menu_item_add_radio(menu, _("Histogram on _Red"), GINT_TO_POINTER(HCHAN_R), (channel == HCHAN_R), G_CALLBACK(bar_pane_histogram_popup_channels_cb), phd); | |
251 menu_item_add_radio(menu, _("Histogram on _Green"), GINT_TO_POINTER(HCHAN_G), (channel == HCHAN_G), G_CALLBACK(bar_pane_histogram_popup_channels_cb), phd); | |
252 menu_item_add_radio(menu, _("Histogram on _Blue"), GINT_TO_POINTER(HCHAN_B), (channel == HCHAN_B), G_CALLBACK(bar_pane_histogram_popup_channels_cb), phd); | |
253 menu_item_add_radio(menu, _("_Histogram on RGB"), GINT_TO_POINTER(HCHAN_RGB), (channel == HCHAN_RGB), G_CALLBACK(bar_pane_histogram_popup_channels_cb), phd); | |
254 menu_item_add_radio(menu, _("Histogram on _Value"), GINT_TO_POINTER(HCHAN_MAX), (channel == HCHAN_MAX), G_CALLBACK(bar_pane_histogram_popup_channels_cb), phd); | |
255 | |
256 menu_item_add_divider(menu); | |
257 | |
258 menu_item_add_radio(menu, _("Li_near Histogram"), GINT_TO_POINTER(0), (mode == 0), G_CALLBACK(bar_pane_histogram_popup_mode_cb), phd); | |
259 menu_item_add_radio(menu, _("L_og Histogram"), GINT_TO_POINTER(1), (mode == 1), G_CALLBACK(bar_pane_histogram_popup_mode_cb), phd); | |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
260 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
261 return menu; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
262 } |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
263 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
264 static gboolean bar_pane_histogram_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
265 { |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
266 PaneHistogramData *phd = data; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
267 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
268 if (bevent->button == MOUSE_BUTTON_RIGHT) |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
269 { |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
270 GtkWidget *menu; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
271 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
272 menu = bar_pane_histogram_menu(phd); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
273 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, bevent->button, bevent->time); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
274 return TRUE; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
275 } |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
276 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
277 return FALSE; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
278 } |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
279 |
1298 | 280 |
1485 | 281 static GtkWidget *bar_pane_histogram_new(const gchar *id, const gchar *title, gint height, gboolean expanded, gint histogram_channel, gint histogram_mode) |
1298 | 282 { |
283 PaneHistogramData *phd; | |
284 | |
285 phd = g_new0(PaneHistogramData, 1); | |
286 | |
287 phd->pane.pane_set_fd = bar_pane_histogram_set_fd; | |
1309 | 288 phd->pane.pane_write_config = bar_pane_histogram_write_config; |
1389
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
289 phd->pane.title = bar_pane_expander_title(title); |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
290 phd->pane.id = g_strdup(id); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
291 phd->pane.type = PANE_HISTOGRAM; |
1387 | 292 |
1309 | 293 phd->pane.expanded = expanded; |
1298 | 294 |
295 phd->histogram = histogram_new(); | |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
296 |
1324 | 297 histogram_set_channel(phd->histogram, histogram_channel); |
1329
1fc356f629fe
Clean up histogram stuff: options saving/restoring, osd histogram separation, tidy up.
zas_
parents:
1324
diff
changeset
|
298 histogram_set_mode(phd->histogram, histogram_mode); |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
299 |
1298 | 300 phd->widget = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
301 | |
302 g_object_set_data(G_OBJECT(phd->widget), "pane_data", phd); | |
303 g_signal_connect(G_OBJECT(phd->widget), "destroy", | |
304 G_CALLBACK(bar_pane_histogram_destroy), phd); | |
305 | |
306 | |
307 gtk_widget_set_size_request(GTK_WIDGET(phd->widget), -1, height); | |
308 | |
309 phd->drawing_area = gtk_drawing_area_new(); | |
310 g_signal_connect_after(G_OBJECT(phd->drawing_area), "size_allocate", | |
311 G_CALLBACK(bar_pane_histogram_size_cb), phd); | |
312 | |
313 g_signal_connect(G_OBJECT(phd->drawing_area), "expose_event", | |
314 G_CALLBACK(bar_pane_histogram_expose_event_cb), phd); | |
315 | |
316 gtk_box_pack_start(GTK_BOX(phd->widget), phd->drawing_area, TRUE, TRUE, 0); | |
317 gtk_widget_show(phd->drawing_area); | |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
318 gtk_widget_add_events(phd->drawing_area, GDK_BUTTON_PRESS_MASK); |
1298 | 319 |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
320 g_signal_connect(G_OBJECT(phd->drawing_area), "button_press_event", G_CALLBACK(bar_pane_histogram_press_cb), phd); |
1298 | 321 |
322 gtk_widget_show(phd->widget); | |
323 | |
324 file_data_register_notify_func(bar_pane_histogram_notify_cb, phd, NOTIFY_PRIORITY_LOW); | |
325 | |
326 return phd->widget; | |
327 } | |
328 | |
1309 | 329 GtkWidget *bar_pane_histogram_new_from_config(const gchar **attribute_names, const gchar **attribute_values) |
330 { | |
1471 | 331 gchar *title = NULL; |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
332 gchar *id = g_strdup("histogram"); |
1309 | 333 gboolean expanded = TRUE; |
334 gint height = 80; | |
1324 | 335 gint histogram_channel = HCHAN_RGB; |
1329
1fc356f629fe
Clean up histogram stuff: options saving/restoring, osd histogram separation, tidy up.
zas_
parents:
1324
diff
changeset
|
336 gint histogram_mode = 0; |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
337 GtkWidget *ret; |
1309 | 338 |
339 while (*attribute_names) | |
340 { | |
341 const gchar *option = *attribute_names++; | |
342 const gchar *value = *attribute_values++; | |
343 | |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
344 if (READ_CHAR_FULL("id", id)) continue; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
345 if (READ_CHAR_FULL("title", title)) continue; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
346 if (READ_BOOL_FULL("expanded", expanded)) continue; |
1324 | 347 if (READ_INT_FULL("histogram_channel", histogram_channel)) continue; |
1329
1fc356f629fe
Clean up histogram stuff: options saving/restoring, osd histogram separation, tidy up.
zas_
parents:
1324
diff
changeset
|
348 if (READ_INT_FULL("histogram_mode", histogram_mode)) continue; |
1324 | 349 |
1464 | 350 log_printf("unknown attribute %s = %s\n", option, value); |
1309 | 351 } |
352 | |
1471 | 353 bar_pane_translate_title(PANE_HISTOGRAM, id, &title); |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
354 ret = bar_pane_histogram_new(id, title, height, expanded, histogram_channel, histogram_mode); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
355 g_free(title); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
356 g_free(id); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
357 return ret; |
1309 | 358 } |
359 | |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
360 void bar_pane_histogram_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
361 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
362 PaneHistogramData *phd; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
363 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
364 phd = g_object_get_data(G_OBJECT(pane), "pane_data"); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
365 if (!phd) return; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
366 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
367 gint histogram_channel = phd->histogram->histogram_channel; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
368 gint histogram_mode = phd->histogram->histogram_mode; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
369 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
370 while (*attribute_names) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
371 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
372 const gchar *option = *attribute_names++; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
373 const gchar *value = *attribute_values++; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
374 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
375 if (READ_CHAR_FULL("id", phd->pane.id)) continue; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
376 // if (READ_CHAR_FULL("pane.title", title)) continue; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
377 if (READ_BOOL_FULL("expanded", phd->pane.expanded)) continue; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
378 if (READ_INT_FULL("histogram_channel", histogram_channel)) continue; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
379 if (READ_INT_FULL("histogram_mode", histogram_mode)) continue; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
380 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
381 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
382 log_printf("unknown attribute %s = %s\n", option, value); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
383 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
384 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
385 histogram_set_channel(phd->histogram, histogram_channel); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
386 histogram_set_mode(phd->histogram, histogram_mode); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
387 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
388 bar_update_expander(pane); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
389 bar_pane_histogram_update(phd); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
390 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
391 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
392 |
1298 | 393 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |