Mercurial > geeqie
annotate src/bar_histogram.c @ 1464:1b3751ac4743
be more verbose on parse errors
author | nadvornik |
---|---|
date | Fri, 20 Mar 2009 10:12:29 +0000 |
parents | e015b6573d36 |
children | 607c60506863 |
rev | line source |
---|---|
1298 | 1 /* |
2 * Geeqie | |
3 * (C) 2004 John Ellis | |
4 * Copyright (C) 2008 - 2009 The Geeqie Team | |
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; |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
46 gint idle_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*/ |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
64 if (GTK_WIDGET_DRAWABLE(phd->drawing_area)) |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
65 { |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
66 if (phd->idle_id == -1) phd->idle_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, bar_pane_histogram_update_cb, phd, NULL); |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
67 } |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
68 else |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
69 { |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
70 phd->need_update = TRUE; |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
71 } |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
72 } |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
73 |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
74 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
|
75 { |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
76 const HistMap *histmap; |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
77 PaneHistogramData *phd = data; |
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 phd->idle_id = -1; |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
80 phd->need_update = FALSE; |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
81 |
1298 | 82 gtk_widget_queue_draw_area(GTK_WIDGET(phd->drawing_area), 0, 0, phd->histogram_width, phd->histogram_height); |
83 | |
84 histmap = histmap_get(phd->fd); | |
85 | |
1439 | 86 if (!histmap) |
87 { | |
88 histmap_start_idle(phd->fd); | |
89 return FALSE; | |
90 } | |
1298 | 91 |
92 phd->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, phd->histogram_width, phd->histogram_height); | |
93 gdk_pixbuf_fill(phd->pixbuf, 0xffffffff); | |
94 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
|
95 |
1331
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
96 return FALSE; |
1298 | 97 } |
98 | |
99 | |
100 static void bar_pane_histogram_set_fd(GtkWidget *pane, FileData *fd) | |
101 { | |
102 PaneHistogramData *phd; | |
103 | |
104 phd = g_object_get_data(G_OBJECT(pane), "pane_data"); | |
105 if (!phd) return; | |
106 | |
107 file_data_unref(phd->fd); | |
108 phd->fd = file_data_ref(fd); | |
109 | |
110 bar_pane_histogram_update(phd); | |
111 } | |
112 | |
1309 | 113 static void bar_pane_histogram_write_config(GtkWidget *pane, GString *outstr, gint indent) |
114 { | |
115 PaneHistogramData *phd; | |
116 | |
117 phd = g_object_get_data(G_OBJECT(pane), "pane_data"); | |
118 if (!phd) return; | |
119 | |
1461 | 120 WRITE_NL(); WRITE_STRING("<pane_histogram "); |
1343 | 121 write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(phd->pane.title))); |
1309 | 122 WRITE_BOOL(*phd, pane.expanded); |
1329
1fc356f629fe
Clean up histogram stuff: options saving/restoring, osd histogram separation, tidy up.
zas_
parents:
1324
diff
changeset
|
123 WRITE_INT(*phd->histogram, histogram_channel); |
1fc356f629fe
Clean up histogram stuff: options saving/restoring, osd histogram separation, tidy up.
zas_
parents:
1324
diff
changeset
|
124 WRITE_INT(*phd->histogram, histogram_mode); |
1461 | 125 WRITE_STRING("/>"); |
1309 | 126 } |
127 | |
1298 | 128 static void bar_pane_histogram_notify_cb(FileData *fd, NotifyType type, gpointer data) |
129 { | |
130 PaneHistogramData *phd = data; | |
1439 | 131 if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_HISTMAP | NOTIFY_PIXBUF)) && fd == phd->fd) bar_pane_histogram_update(phd); |
1298 | 132 } |
133 | |
1346
c9949c19a6d0
No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents:
1344
diff
changeset
|
134 static gboolean bar_pane_histogram_expose_event_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) |
1298 | 135 { |
136 PaneHistogramData *phd = data; | |
1331
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
137 if (!phd) return TRUE; |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
138 |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
139 if (phd->need_update) |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
140 { |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
141 bar_pane_histogram_update(phd); |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
142 } |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
143 |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
144 if (!phd->pixbuf) return TRUE; |
1298 | 145 |
146 gdk_draw_pixbuf(widget->window, | |
147 widget->style->fg_gc[GTK_WIDGET_STATE (widget)], | |
148 phd->pixbuf, | |
149 0, 0, | |
150 0, 0, | |
151 -1, -1, | |
152 GDK_RGB_DITHER_NORMAL, 0, 0); | |
153 return TRUE; | |
154 } | |
155 | |
156 static void bar_pane_histogram_size_cb(GtkWidget *widget, GtkAllocation *allocation, gpointer data) | |
157 { | |
158 PaneHistogramData *phd = data; | |
159 | |
160 phd->histogram_width = allocation->width; | |
161 phd->histogram_height = allocation->height; | |
162 bar_pane_histogram_update(phd); | |
163 } | |
164 | |
165 static void bar_pane_histogram_close(GtkWidget *pane) | |
166 { | |
167 PaneHistogramData *phd; | |
168 | |
169 phd = g_object_get_data(G_OBJECT(pane), "pane_data"); | |
170 if (!phd) return; | |
171 | |
172 gtk_widget_destroy(phd->widget); | |
173 } | |
174 | |
175 static void bar_pane_histogram_destroy(GtkWidget *widget, gpointer data) | |
176 { | |
177 PaneHistogramData *phd = data; | |
1331
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
178 |
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
179 g_source_remove(phd->idle_id); |
1298 | 180 file_data_unregister_notify_func(bar_pane_histogram_notify_cb, phd); |
181 | |
182 file_data_unref(phd->fd); | |
183 histogram_free(phd->histogram); | |
184 if (phd->pixbuf) g_object_unref(phd->pixbuf); | |
185 | |
186 g_free(phd); | |
187 } | |
188 | |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
189 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
|
190 { |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
191 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
|
192 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
|
193 |
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
194 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
|
195 |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
196 phd = submenu_item_get_data(widget); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
197 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
198 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
|
199 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
200 channel = GPOINTER_TO_INT(data); |
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
201 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
|
202 |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
203 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
|
204 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
|
205 } |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
206 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
207 static void bar_pane_histogram_popup_logmode_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
|
208 { |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
209 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
|
210 gint logmode; |
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
211 |
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
212 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
|
213 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
214 phd = submenu_item_get_data(widget); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
215 |
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 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
218 logmode = GPOINTER_TO_INT(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 (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
|
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_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
|
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 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
225 static GtkWidget *bar_pane_histogram_add_radio(GtkWidget *menu, GtkWidget *parent, |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
226 const gchar *label, |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
227 GCallback func, gint value, |
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
228 gboolean show_current, gint current_value) |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
229 { |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
230 GtkWidget *item; |
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 (show_current) |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
233 { |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
234 item = menu_item_add_radio(menu, parent, |
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
235 label, (value == current_value), |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
236 func, GINT_TO_POINTER((gint)value)); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
237 } |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
238 else |
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 item = menu_item_add(menu, label, |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
241 func, GINT_TO_POINTER((gint)value)); |
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 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
244 return item; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
245 } |
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 GtkWidget *bar_pane_histogram_add_channels(GtkWidget *menu, GCallback func, gpointer data, |
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
248 gboolean show_current, gint current_value) |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
249 { |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
250 GtkWidget *submenu; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
251 GtkWidget *parent; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
252 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
253 submenu = gtk_menu_new(); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
254 g_object_set_data(G_OBJECT(submenu), "submenu_data", data); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
255 |
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
256 parent = bar_pane_histogram_add_radio(submenu, NULL, _("_Red"), func, HCHAN_R, show_current, current_value); |
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
257 bar_pane_histogram_add_radio(submenu, parent, _("_Green"), func, HCHAN_G, show_current, current_value); |
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
258 bar_pane_histogram_add_radio(submenu, parent, _("_Blue"),func, HCHAN_B, show_current, current_value); |
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
259 bar_pane_histogram_add_radio(submenu, parent, _("_RGB"),func, HCHAN_RGB, show_current, current_value); |
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
260 bar_pane_histogram_add_radio(submenu, parent, _("_Value"),func, HCHAN_MAX, show_current, current_value); |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
261 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
262 if (menu) |
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 GtkWidget *item; |
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 item = menu_item_add(menu, _("Channels"), NULL, NULL); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
267 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
268 return item; |
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 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
271 return submenu; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
272 } |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
273 GtkWidget *bar_pane_histogram_add_logmode(GtkWidget *menu, GCallback func, gpointer data, |
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
274 gboolean show_current, gint current_value) |
1319
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 GtkWidget *submenu; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
277 GtkWidget *parent; |
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 submenu = gtk_menu_new(); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
280 g_object_set_data(G_OBJECT(submenu), "submenu_data", data); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
281 |
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
282 parent = bar_pane_histogram_add_radio(submenu, NULL, _("_Linear"), func, 0, show_current, current_value); |
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
283 bar_pane_histogram_add_radio(submenu, parent, _("Lo_garithmical"), func, 1, show_current, current_value); |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
284 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
285 if (menu) |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
286 { |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
287 GtkWidget *item; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
288 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
289 item = menu_item_add(menu, _("Mode"), NULL, NULL); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
290 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
291 return item; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
292 } |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
293 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
294 return submenu; |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
295 } |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
296 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
297 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
298 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
|
299 { |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
300 GtkWidget *menu; |
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
301 static gboolean show_current = TRUE; |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
302 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
303 menu = popup_menu_short_lived(); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
304 bar_pane_histogram_add_channels(menu, G_CALLBACK(bar_pane_histogram_popup_channels_cb), phd, |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
305 show_current, histogram_get_channel(phd->histogram)); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
306 bar_pane_histogram_add_logmode(menu, G_CALLBACK(bar_pane_histogram_popup_logmode_cb), phd, |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
307 show_current, histogram_get_mode(phd->histogram)); |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
308 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
309 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
|
310 } |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
311 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
312 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
|
313 { |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
314 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
|
315 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
316 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
|
317 { |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
318 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
|
319 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
320 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
|
321 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
|
322 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
|
323 } |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
324 |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
325 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
|
326 } |
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
327 |
1298 | 328 |
1339 | 329 GtkWidget *bar_pane_histogram_new(const gchar *title, gint height, gboolean expanded, gint histogram_channel, gint histogram_mode) |
1298 | 330 { |
331 PaneHistogramData *phd; | |
332 | |
333 phd = g_new0(PaneHistogramData, 1); | |
334 | |
335 phd->pane.pane_set_fd = bar_pane_histogram_set_fd; | |
1309 | 336 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
|
337 phd->pane.title = bar_pane_expander_title(title); |
1387 | 338 |
1309 | 339 phd->pane.expanded = expanded; |
1331
a5c15bf32cdb
compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents:
1330
diff
changeset
|
340 phd->idle_id = -1; |
1298 | 341 |
342 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
|
343 |
1324 | 344 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
|
345 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
|
346 |
1298 | 347 phd->widget = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
348 | |
349 g_object_set_data(G_OBJECT(phd->widget), "pane_data", phd); | |
350 g_signal_connect(G_OBJECT(phd->widget), "destroy", | |
351 G_CALLBACK(bar_pane_histogram_destroy), phd); | |
352 | |
353 | |
354 gtk_widget_set_size_request(GTK_WIDGET(phd->widget), -1, height); | |
355 | |
356 phd->drawing_area = gtk_drawing_area_new(); | |
357 g_signal_connect_after(G_OBJECT(phd->drawing_area), "size_allocate", | |
358 G_CALLBACK(bar_pane_histogram_size_cb), phd); | |
359 | |
360 g_signal_connect(G_OBJECT(phd->drawing_area), "expose_event", | |
361 G_CALLBACK(bar_pane_histogram_expose_event_cb), phd); | |
362 | |
363 gtk_box_pack_start(GTK_BOX(phd->widget), phd->drawing_area, TRUE, TRUE, 0); | |
364 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
|
365 gtk_widget_add_events(phd->drawing_area, GDK_BUTTON_PRESS_MASK); |
1298 | 366 |
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
367 g_signal_connect(G_OBJECT(phd->drawing_area), "button_press_event", G_CALLBACK(bar_pane_histogram_press_cb), phd); |
1298 | 368 |
369 gtk_widget_show(phd->widget); | |
370 | |
371 file_data_register_notify_func(bar_pane_histogram_notify_cb, phd, NOTIFY_PRIORITY_LOW); | |
372 | |
373 return phd->widget; | |
374 } | |
375 | |
1309 | 376 GtkWidget *bar_pane_histogram_new_from_config(const gchar **attribute_names, const gchar **attribute_values) |
377 { | |
378 gchar *title = g_strdup(_("NoName")); | |
379 gboolean expanded = TRUE; | |
380 gint height = 80; | |
1324 | 381 gint histogram_channel = HCHAN_RGB; |
1329
1fc356f629fe
Clean up histogram stuff: options saving/restoring, osd histogram separation, tidy up.
zas_
parents:
1324
diff
changeset
|
382 gint histogram_mode = 0; |
1309 | 383 |
384 while (*attribute_names) | |
385 { | |
386 const gchar *option = *attribute_names++; | |
387 const gchar *value = *attribute_values++; | |
388 | |
1315 | 389 if (READ_CHAR_FULL("pane.title", title)) continue; |
390 if (READ_BOOL_FULL("pane.expanded", expanded)) continue; | |
1324 | 391 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
|
392 if (READ_INT_FULL("histogram_mode", histogram_mode)) continue; |
1324 | 393 |
1464 | 394 log_printf("unknown attribute %s = %s\n", option, value); |
1309 | 395 } |
396 | |
1329
1fc356f629fe
Clean up histogram stuff: options saving/restoring, osd histogram separation, tidy up.
zas_
parents:
1324
diff
changeset
|
397 return bar_pane_histogram_new(title, height, expanded, histogram_channel, histogram_mode); |
1309 | 398 } |
399 | |
1298 | 400 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |