Mercurial > geeqie
annotate src/bar_histogram.c @ 1324:e4f9e3567f0a
Save bar pane histogram state to rc file.
| author | zas_ |
|---|---|
| date | Wed, 25 Feb 2009 20:54:38 +0000 |
| parents | 50ab4016ae0b |
| children | 1fc356f629fe |
| 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" | |
| 15 #include "bar_comment.h" | |
| 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; | |
| 1324 | 43 gint histogram_channel; |
| 44 gint histogram_logmode; | |
| 1298 | 45 GdkPixbuf *pixbuf; |
| 46 FileData *fd; | |
| 47 }; | |
| 48 | |
| 49 | |
| 50 static void bar_pane_histogram_update(PaneHistogramData *phd) | |
| 51 { | |
| 52 const HistMap *histmap; | |
| 53 if (phd->pixbuf) g_object_unref(phd->pixbuf); | |
| 54 phd->pixbuf = NULL; | |
| 55 | |
| 56 if (!phd->histogram_width || !phd->histogram_height || !phd->fd) return; | |
| 57 | |
| 58 gtk_widget_queue_draw_area(GTK_WIDGET(phd->drawing_area), 0, 0, phd->histogram_width, phd->histogram_height); | |
| 59 | |
| 60 histmap = histmap_get(phd->fd); | |
| 61 | |
| 62 if (!histmap) return; | |
| 63 | |
| 64 phd->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, phd->histogram_width, phd->histogram_height); | |
| 65 gdk_pixbuf_fill(phd->pixbuf, 0xffffffff); | |
| 66 histogram_draw(phd->histogram, histmap, phd->pixbuf, 0, 0, phd->histogram_width, phd->histogram_height); | |
| 67 } | |
| 68 | |
| 69 | |
| 70 static void bar_pane_histogram_set_fd(GtkWidget *pane, FileData *fd) | |
| 71 { | |
| 72 PaneHistogramData *phd; | |
| 73 | |
| 74 phd = g_object_get_data(G_OBJECT(pane), "pane_data"); | |
| 75 if (!phd) return; | |
| 76 | |
| 77 file_data_unref(phd->fd); | |
| 78 phd->fd = file_data_ref(fd); | |
| 79 | |
| 80 bar_pane_histogram_update(phd); | |
| 81 } | |
| 82 | |
| 1309 | 83 static void bar_pane_histogram_write_config(GtkWidget *pane, GString *outstr, gint indent) |
| 84 { | |
| 85 PaneHistogramData *phd; | |
| 86 | |
| 87 phd = g_object_get_data(G_OBJECT(pane), "pane_data"); | |
| 88 if (!phd) return; | |
| 89 | |
| 1314 | 90 WRITE_STRING("<pane_histogram\n"); |
| 1309 | 91 indent++; |
| 92 WRITE_CHAR(*phd, pane.title); | |
| 93 WRITE_BOOL(*phd, pane.expanded); | |
| 1324 | 94 WRITE_INT(*phd, histogram_channel); |
| 95 WRITE_INT(*phd, histogram_logmode); | |
| 1309 | 96 indent--; |
| 1314 | 97 WRITE_STRING("/>\n"); |
| 1309 | 98 } |
| 99 | |
| 100 | |
| 1298 | 101 static void bar_pane_histogram_notify_cb(FileData *fd, NotifyType type, gpointer data) |
| 102 { | |
| 103 PaneHistogramData *phd = data; | |
| 104 if (fd == phd->fd) bar_pane_histogram_update(phd); | |
| 105 } | |
| 106 | |
| 107 static gboolean bar_pane_histogram_expose_event_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) | |
| 108 { | |
| 109 PaneHistogramData *phd = data; | |
| 110 if (!phd || !phd->pixbuf) return TRUE; | |
| 111 | |
| 112 gdk_draw_pixbuf(widget->window, | |
| 113 widget->style->fg_gc[GTK_WIDGET_STATE (widget)], | |
| 114 phd->pixbuf, | |
| 115 0, 0, | |
| 116 0, 0, | |
| 117 -1, -1, | |
| 118 GDK_RGB_DITHER_NORMAL, 0, 0); | |
| 119 return TRUE; | |
| 120 } | |
| 121 | |
| 122 static void bar_pane_histogram_size_cb(GtkWidget *widget, GtkAllocation *allocation, gpointer data) | |
| 123 { | |
| 124 PaneHistogramData *phd = data; | |
| 125 | |
| 126 phd->histogram_width = allocation->width; | |
| 127 phd->histogram_height = allocation->height; | |
| 128 bar_pane_histogram_update(phd); | |
| 129 } | |
| 130 | |
| 131 static void bar_pane_histogram_close(GtkWidget *pane) | |
| 132 { | |
| 133 PaneHistogramData *phd; | |
| 134 | |
| 135 phd = g_object_get_data(G_OBJECT(pane), "pane_data"); | |
| 136 if (!phd) return; | |
| 137 | |
| 138 gtk_widget_destroy(phd->widget); | |
| 139 } | |
| 140 | |
| 141 static void bar_pane_histogram_destroy(GtkWidget *widget, gpointer data) | |
| 142 { | |
| 143 PaneHistogramData *phd = data; | |
| 144 | |
| 145 file_data_unregister_notify_func(bar_pane_histogram_notify_cb, phd); | |
| 146 | |
| 147 file_data_unref(phd->fd); | |
| 148 g_free(phd->pane.title); | |
| 149 histogram_free(phd->histogram); | |
| 150 if (phd->pixbuf) g_object_unref(phd->pixbuf); | |
| 151 | |
| 152 g_free(phd); | |
| 153 } | |
| 154 | |
|
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
155 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
|
156 { |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
157 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
|
158 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
|
159 |
|
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
160 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
|
161 |
|
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
162 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
|
163 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
164 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
|
165 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
166 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
|
167 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
|
168 |
|
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
169 histogram_set_channel(phd->histogram, channel); |
| 1324 | 170 phd->histogram_channel = channel; |
|
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
171 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
|
172 } |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
173 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
174 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
|
175 { |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
176 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
|
177 gint logmode; |
|
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
178 |
|
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
179 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
|
180 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
181 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
|
182 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
183 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
|
184 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
185 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
|
186 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
|
187 |
|
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
188 histogram_set_mode(phd->histogram, logmode); |
| 1324 | 189 phd->histogram_logmode = logmode; |
|
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
190 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
|
191 } |
|
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 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
|
194 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
|
195 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
|
196 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
|
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 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
|
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 (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
|
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 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
|
203 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
|
204 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
|
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 else |
|
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 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
|
209 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
|
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 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
212 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
|
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 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
215 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
|
216 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
|
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 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
|
219 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
|
220 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
221 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
|
222 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
|
223 |
|
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
224 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
|
225 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
|
226 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
|
227 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
|
228 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
|
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 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
|
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 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
|
235 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
|
236 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
|
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 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
239 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
|
240 } |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
241 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
|
242 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
|
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 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
|
245 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
|
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 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
|
248 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
|
249 |
|
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
250 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
|
251 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
|
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 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
|
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 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
|
256 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
257 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
|
258 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
|
259 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
|
260 } |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
261 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
262 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
|
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 |
|
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 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
|
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 GtkWidget *menu; |
|
1323
50ab4016ae0b
Fix up bar pane histogram contextual menu: show current state for channel and log mode.
zas_
parents:
1319
diff
changeset
|
269 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
|
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 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
|
272 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
|
273 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
|
274 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
|
275 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
|
276 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
277 return menu; |
|
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 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
280 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
|
281 { |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
282 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
|
283 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
284 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
|
285 { |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
286 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
|
287 |
|
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
288 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
|
289 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
|
290 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
|
291 } |
|
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 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
|
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 |
| 1298 | 296 |
| 1324 | 297 GtkWidget *bar_pane_histogram_new(const gchar *title, gint height, gint expanded, gint histogram_channel, gint histogram_logmode) |
| 1298 | 298 { |
| 299 PaneHistogramData *phd; | |
| 300 | |
| 301 phd = g_new0(PaneHistogramData, 1); | |
| 302 | |
| 303 phd->pane.pane_set_fd = bar_pane_histogram_set_fd; | |
| 1309 | 304 phd->pane.pane_write_config = bar_pane_histogram_write_config; |
| 1298 | 305 phd->pane.title = g_strdup(title); |
| 1309 | 306 phd->pane.expanded = expanded; |
| 1298 | 307 |
| 308 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
|
309 |
| 1324 | 310 histogram_set_channel(phd->histogram, histogram_channel); |
| 311 histogram_set_mode(phd->histogram, histogram_logmode); | |
|
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
312 |
| 1298 | 313 phd->widget = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
| 314 | |
| 315 g_object_set_data(G_OBJECT(phd->widget), "pane_data", phd); | |
| 316 g_signal_connect(G_OBJECT(phd->widget), "destroy", | |
| 317 G_CALLBACK(bar_pane_histogram_destroy), phd); | |
| 318 | |
| 319 | |
| 320 gtk_widget_set_size_request(GTK_WIDGET(phd->widget), -1, height); | |
| 321 | |
| 322 phd->drawing_area = gtk_drawing_area_new(); | |
| 323 g_signal_connect_after(G_OBJECT(phd->drawing_area), "size_allocate", | |
| 324 G_CALLBACK(bar_pane_histogram_size_cb), phd); | |
| 325 | |
| 326 g_signal_connect(G_OBJECT(phd->drawing_area), "expose_event", | |
| 327 G_CALLBACK(bar_pane_histogram_expose_event_cb), phd); | |
| 328 | |
| 329 gtk_box_pack_start(GTK_BOX(phd->widget), phd->drawing_area, TRUE, TRUE, 0); | |
| 330 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
|
331 gtk_widget_add_events(phd->drawing_area, GDK_BUTTON_PRESS_MASK); |
| 1298 | 332 |
|
1319
358685fb9dc9
Add a contextual menu on bar pane histogram allowing to change channels and mode. More work needed.
zas_
parents:
1315
diff
changeset
|
333 g_signal_connect(G_OBJECT(phd->drawing_area), "button_press_event", G_CALLBACK(bar_pane_histogram_press_cb), phd); |
| 1298 | 334 |
| 335 gtk_widget_show(phd->widget); | |
| 336 | |
| 337 file_data_register_notify_func(bar_pane_histogram_notify_cb, phd, NOTIFY_PRIORITY_LOW); | |
| 338 | |
| 339 return phd->widget; | |
| 340 } | |
| 341 | |
| 1309 | 342 GtkWidget *bar_pane_histogram_new_from_config(const gchar **attribute_names, const gchar **attribute_values) |
| 343 { | |
| 344 gchar *title = g_strdup(_("NoName")); | |
| 345 gboolean expanded = TRUE; | |
| 346 gint height = 80; | |
| 1324 | 347 gint histogram_channel = HCHAN_RGB; |
| 348 gint histogram_logmode = 0; | |
| 1309 | 349 |
| 350 while (*attribute_names) | |
| 351 { | |
| 352 const gchar *option = *attribute_names++; | |
| 353 const gchar *value = *attribute_values++; | |
| 354 | |
| 1315 | 355 if (READ_CHAR_FULL("pane.title", title)) continue; |
| 356 if (READ_BOOL_FULL("pane.expanded", expanded)) continue; | |
| 1324 | 357 if (READ_INT_FULL("histogram_channel", histogram_channel)) continue; |
| 358 if (READ_INT_FULL("histogram_logmode", histogram_logmode)) continue; | |
| 359 | |
| 1309 | 360 |
| 361 DEBUG_1("unknown attribute %s = %s", option, value); | |
| 362 } | |
| 363 | |
| 1324 | 364 return bar_pane_histogram_new(title, height, expanded, histogram_channel, histogram_logmode); |
| 1309 | 365 } |
| 366 | |
| 367 | |
| 1298 | 368 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |
