annotate src/bar_histogram.c @ 1439:2441a90c4bcf

compute histogram in idle time
author nadvornik
date Sun, 15 Mar 2009 11:34:09 +0000
parents c520cfd40aef
children e015b6573d36
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
1 /*
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
2 * Geeqie
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
3 * (C) 2004 John Ellis
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
5 *
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
6 * Author: Vladimir Nadvornik
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
7 *
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
9 * Please read the included file COPYING for more information.
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
11 */
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
12
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
13
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
14 #include "main.h"
1339
45bcfcb69f56 fixed bar_histogram headers
nadvornik
parents: 1331
diff changeset
15 #include "bar_histogram.h"
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
16
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
17 #include "bar.h"
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
18 #include "metadata.h"
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
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
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
21 #include "ui_menu.h"
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
22 #include "ui_misc.h"
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
23 #include "histogram.h"
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
24 #include "rcfile.h"
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
25
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
26 /*
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
27 *-------------------------------------------------------------------
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
28 * keyword / comment utils
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
29 *-------------------------------------------------------------------
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
30 */
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
31
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
32
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
33
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
34 typedef struct _PaneHistogramData PaneHistogramData;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
35 struct _PaneHistogramData
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
36 {
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
37 PaneData pane;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
38 GtkWidget *widget;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
39 GtkWidget *drawing_area;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
40 Histogram *histogram;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
41 gint histogram_width;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
42 gint histogram_height;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
43 GdkPixbuf *pixbuf;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
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
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
47 };
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
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
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
51
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
52 static void bar_pane_histogram_update(PaneHistogramData *phd)
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
53 {
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
54 if (phd->pixbuf) g_object_unref(phd->pixbuf);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
55 phd->pixbuf = NULL;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
56
1344
3f9be528787c show histogram label in the title
nadvornik
parents: 1343
diff changeset
57 gtk_label_set_text(GTK_LABEL(phd->pane.title), histogram_label(phd->histogram));
3f9be528787c show histogram label in the title
nadvornik
parents: 1343
diff changeset
58
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
59 if (!phd->histogram_width || !phd->histogram_height || !phd->fd) return;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
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
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
82 gtk_widget_queue_draw_area(GTK_WIDGET(phd->drawing_area), 0, 0, phd->histogram_width, phd->histogram_height);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
83
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
84 histmap = histmap_get(phd->fd);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
85
1439
2441a90c4bcf compute histogram in idle time
nadvornik
parents: 1419
diff changeset
86 if (!histmap)
2441a90c4bcf compute histogram in idle time
nadvornik
parents: 1419
diff changeset
87 {
2441a90c4bcf compute histogram in idle time
nadvornik
parents: 1419
diff changeset
88 histmap_start_idle(phd->fd);
2441a90c4bcf compute histogram in idle time
nadvornik
parents: 1419
diff changeset
89 return FALSE;
2441a90c4bcf compute histogram in idle time
nadvornik
parents: 1419
diff changeset
90 }
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
91
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
92 phd->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, phd->histogram_width, phd->histogram_height);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
93 gdk_pixbuf_fill(phd->pixbuf, 0xffffffff);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
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
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
97 }
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
98
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
99
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
100 static void bar_pane_histogram_set_fd(GtkWidget *pane, FileData *fd)
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
101 {
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
102 PaneHistogramData *phd;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
103
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
104 phd = g_object_get_data(G_OBJECT(pane), "pane_data");
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
105 if (!phd) return;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
106
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
107 file_data_unref(phd->fd);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
108 phd->fd = file_data_ref(fd);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
109
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
110 bar_pane_histogram_update(phd);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
111 }
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
112
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
113 static void bar_pane_histogram_write_config(GtkWidget *pane, GString *outstr, gint indent)
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
114 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
115 PaneHistogramData *phd;
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
116
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
117 phd = g_object_get_data(G_OBJECT(pane), "pane_data");
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
118 if (!phd) return;
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
119
1314
8cca18bce950 simplified config writing
nadvornik
parents: 1309
diff changeset
120 WRITE_STRING("<pane_histogram\n");
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
121 indent++;
1343
eebb8d0cb677 give the panes more control over expander title
nadvornik
parents: 1339
diff changeset
122 write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(phd->pane.title)));
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
123 WRITE_BOOL(*phd, pane.expanded);
1329
1fc356f629fe Clean up histogram stuff: options saving/restoring, osd histogram separation, tidy up.
zas_
parents: 1324
diff changeset
124 WRITE_INT(*phd->histogram, histogram_channel);
1fc356f629fe Clean up histogram stuff: options saving/restoring, osd histogram separation, tidy up.
zas_
parents: 1324
diff changeset
125 WRITE_INT(*phd->histogram, histogram_mode);
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
126 indent--;
1314
8cca18bce950 simplified config writing
nadvornik
parents: 1309
diff changeset
127 WRITE_STRING("/>\n");
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
128 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
129
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
130 static void bar_pane_histogram_notify_cb(FileData *fd, NotifyType type, gpointer data)
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
131 {
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
132 PaneHistogramData *phd = data;
1439
2441a90c4bcf compute histogram in idle time
nadvornik
parents: 1419
diff changeset
133 if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_HISTMAP | NOTIFY_PIXBUF)) && fd == phd->fd) bar_pane_histogram_update(phd);
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
134 }
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
135
1346
c9949c19a6d0 No space between function name and first parenthesis, it eases greping (see CODING).
zas_
parents: 1344
diff changeset
136 static gboolean bar_pane_histogram_expose_event_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
137 {
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
138 PaneHistogramData *phd = data;
1331
a5c15bf32cdb compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents: 1330
diff changeset
139 if (!phd) return TRUE;
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 if (phd->need_update)
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 bar_pane_histogram_update(phd);
a5c15bf32cdb compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents: 1330
diff changeset
144 }
a5c15bf32cdb compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents: 1330
diff changeset
145
a5c15bf32cdb compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents: 1330
diff changeset
146 if (!phd->pixbuf) return TRUE;
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
147
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
148 gdk_draw_pixbuf(widget->window,
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
149 widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
150 phd->pixbuf,
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
151 0, 0,
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
152 0, 0,
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
153 -1, -1,
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
154 GDK_RGB_DITHER_NORMAL, 0, 0);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
155 return TRUE;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
156 }
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
157
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
158 static void bar_pane_histogram_size_cb(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
159 {
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
160 PaneHistogramData *phd = data;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
161
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
162 phd->histogram_width = allocation->width;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
163 phd->histogram_height = allocation->height;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
164 bar_pane_histogram_update(phd);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
165 }
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
166
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
167 static void bar_pane_histogram_close(GtkWidget *pane)
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
168 {
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
169 PaneHistogramData *phd;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
170
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
171 phd = g_object_get_data(G_OBJECT(pane), "pane_data");
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
172 if (!phd) return;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
173
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
174 gtk_widget_destroy(phd->widget);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
175 }
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
176
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
177 static void bar_pane_histogram_destroy(GtkWidget *widget, gpointer data)
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
178 {
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
179 PaneHistogramData *phd = data;
1331
a5c15bf32cdb compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents: 1330
diff changeset
180
a5c15bf32cdb compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents: 1330
diff changeset
181 g_source_remove(phd->idle_id);
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
182 file_data_unregister_notify_func(bar_pane_histogram_notify_cb, phd);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
183
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
184 file_data_unref(phd->fd);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
185 histogram_free(phd->histogram);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
186 if (phd->pixbuf) g_object_unref(phd->pixbuf);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
187
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
188 g_free(phd);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
189 }
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
190
1319
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
191 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
192 {
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
193 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
194 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
195
1323
50ab4016ae0b Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents: 1319
diff changeset
196 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
197
1319
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
198 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
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 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
201
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
202 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
203 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
204
1319
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
205 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
206 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
207 }
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 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
210 {
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
211 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
212 gint logmode;
1323
50ab4016ae0b Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents: 1319
diff changeset
213
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;
1319
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 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
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 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
219
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
220 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
221 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
222
1319
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
223 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
224 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
225 }
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
226
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
227 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
228 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
229 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
230 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
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 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
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 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
235 {
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
236 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
237 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
238 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
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 else
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
241 {
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
242 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
243 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
244 }
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 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
247 }
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
248
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
249 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
250 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
251 {
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
252 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
253 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
254
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
255 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
256 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
257
1323
50ab4016ae0b Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents: 1319
diff changeset
258 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
259 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
260 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
261 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
262 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
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 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
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 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
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 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
269 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
270 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
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
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
273 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
274 }
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
275 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
276 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
277 {
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
278 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
279 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
280
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
281 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
282 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
283
1323
50ab4016ae0b Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents: 1319
diff changeset
284 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
285 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
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 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
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 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
290
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
291 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
292 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
293 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
294 }
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 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
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
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 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
301 {
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
302 GtkWidget *menu;
1323
50ab4016ae0b Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents: 1319
diff changeset
303 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
304
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
305 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
306 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
307 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
308 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
309 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
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 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
312 }
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 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
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 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
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 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
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 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
321
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
322 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
323 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
324 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
325 }
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 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
328 }
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
329
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
330
1339
45bcfcb69f56 fixed bar_histogram headers
nadvornik
parents: 1331
diff changeset
331 GtkWidget *bar_pane_histogram_new(const gchar *title, gint height, gboolean expanded, gint histogram_channel, gint histogram_mode)
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
332 {
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
333 PaneHistogramData *phd;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
334
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
335 phd = g_new0(PaneHistogramData, 1);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
336
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
337 phd->pane.pane_set_fd = bar_pane_histogram_set_fd;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
338 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
339 phd->pane.title = bar_pane_expander_title(title);
1387
6f31fa931d3f simplified bar interface
nadvornik
parents: 1346
diff changeset
340
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
341 phd->pane.expanded = expanded;
1331
a5c15bf32cdb compute histmap in idle callback and only if the histogram is expanded
nadvornik
parents: 1330
diff changeset
342 phd->idle_id = -1;
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
343
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
344 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
345
1324
e4f9e3567f0a Save bar pane histogram state to rc file.
zas_
parents: 1323
diff changeset
346 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
347 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
348
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
349 phd->widget = gtk_vbox_new(FALSE, PREF_PAD_GAP);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
350
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
351 g_object_set_data(G_OBJECT(phd->widget), "pane_data", phd);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
352 g_signal_connect(G_OBJECT(phd->widget), "destroy",
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
353 G_CALLBACK(bar_pane_histogram_destroy), phd);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
354
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
355
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
356 gtk_widget_set_size_request(GTK_WIDGET(phd->widget), -1, height);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
357
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
358 phd->drawing_area = gtk_drawing_area_new();
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
359 g_signal_connect_after(G_OBJECT(phd->drawing_area), "size_allocate",
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
360 G_CALLBACK(bar_pane_histogram_size_cb), phd);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
361
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
362 g_signal_connect(G_OBJECT(phd->drawing_area), "expose_event",
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
363 G_CALLBACK(bar_pane_histogram_expose_event_cb), phd);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
364
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
365 gtk_box_pack_start(GTK_BOX(phd->widget), phd->drawing_area, TRUE, TRUE, 0);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
366 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
367 gtk_widget_add_events(phd->drawing_area, GDK_BUTTON_PRESS_MASK);
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
368
1319
358685fb9dc9 Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents: 1315
diff changeset
369 g_signal_connect(G_OBJECT(phd->drawing_area), "button_press_event", G_CALLBACK(bar_pane_histogram_press_cb), phd);
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
370
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
371 gtk_widget_show(phd->widget);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
372
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
373 file_data_register_notify_func(bar_pane_histogram_notify_cb, phd, NOTIFY_PRIORITY_LOW);
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
374
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
375 return phd->widget;
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
376 }
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
377
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
378 GtkWidget *bar_pane_histogram_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
379 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
380 gchar *title = g_strdup(_("NoName"));
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
381 gboolean expanded = TRUE;
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
382 gint height = 80;
1324
e4f9e3567f0a Save bar pane histogram state to rc file.
zas_
parents: 1323
diff changeset
383 gint histogram_channel = HCHAN_RGB;
1329
1fc356f629fe Clean up histogram stuff: options saving/restoring, osd histogram separation, tidy up.
zas_
parents: 1324
diff changeset
384 gint histogram_mode = 0;
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
385
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
386 while (*attribute_names)
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
387 {
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
388 const gchar *option = *attribute_names++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
389 const gchar *value = *attribute_values++;
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
390
1315
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
391 if (READ_CHAR_FULL("pane.title", title)) continue;
c1d108ab3388 Since READ_*() macros are now exported, do not hide
zas_
parents: 1314
diff changeset
392 if (READ_BOOL_FULL("pane.expanded", expanded)) continue;
1324
e4f9e3567f0a Save bar pane histogram state to rc file.
zas_
parents: 1323
diff changeset
393 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
394 if (READ_INT_FULL("histogram_mode", histogram_mode)) continue;
1324
e4f9e3567f0a Save bar pane histogram state to rc file.
zas_
parents: 1323
diff changeset
395
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
396 DEBUG_1("unknown attribute %s = %s", option, value);
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
397 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
398
1329
1fc356f629fe Clean up histogram stuff: options saving/restoring, osd histogram separation, tidy up.
zas_
parents: 1324
diff changeset
399 return bar_pane_histogram_new(title, height, expanded, histogram_channel, histogram_mode);
1309
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
400 }
55ea4962887a config file format changed to XML
nadvornik
parents: 1298
diff changeset
401
1298
c37f36b97173 added histogram pane
nadvornik
parents:
diff changeset
402 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */