Mercurial > geeqie
annotate src/bar_exif.c @ 323:4e721492341b
Add Exif.Photo.ColorSpace tag in Preferences > Properties > Exif.
Requested by Frdric Mantegazza.
author | zas_ |
---|---|
date | Sat, 12 Apr 2008 06:42:47 +0000 |
parents | 9995c5fb202a |
children | 6c2cf2f12b0d |
rev | line source |
---|---|
9 | 1 /* |
196 | 2 * Geeqie |
9 | 3 * (C) 2004 John Ellis |
4 * | |
5 * Author: John Ellis | |
6 * | |
7 * This software is released under the GNU General Public License (GNU GPL). | |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
10 */ | |
11 | |
12 | |
281 | 13 #include "main.h" |
9 | 14 #include "bar_exif.h" |
15 | |
16 #include "exif.h" | |
17 #include "ui_bookmark.h" | |
18 #include "ui_misc.h" | |
138 | 19 #include "filelist.h" |
9 | 20 |
21 #include <math.h> | |
22 | |
23 #define EXIF_BAR_SIZE_INCREMENT 48 | |
24 #define EXIF_BAR_ARROW_SIZE 7 | |
25 | |
26 #define EXIF_BAR_CUSTOM_COUNT 20 | |
27 | |
48
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
28 #define BAR_EXIF_DATA_COLUMN_WIDTH 250 |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
29 |
95
eb9bb29cbd65
Fri Nov 3 11:40:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
48
diff
changeset
|
30 static const gchar *bar_exif_key_list_real[] = { |
182 | 31 "fCamera", |
9 | 32 "fDateTime", |
33 "fShutterSpeed", | |
34 "fAperture", | |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
179
diff
changeset
|
35 "Exif.Photo.ExposureProgram", |
9 | 36 "fExposureBias", |
37 "fISOSpeedRating", | |
38 "fFocalLength", | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
39 "fFocalLength35mmFilm", |
9 | 40 "fSubjectDistance", |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
179
diff
changeset
|
41 "Exif.Photo.MeteringMode", |
9 | 42 "fFlash", |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
179
diff
changeset
|
43 "Exif.Photo.LightSource", |
9 | 44 "fResolution", |
181
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
179
diff
changeset
|
45 "Exif.Image.Orientation", |
c01dd7c9c7dc
unified tag names between exiv2 and internal rxif parser
nadvornik
parents:
179
diff
changeset
|
46 "Exif.Image.ImageDescription", |
182 | 47 "Exif.Image.Copyright" |
9 | 48 }; |
49 | |
95
eb9bb29cbd65
Fri Nov 3 11:40:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
48
diff
changeset
|
50 const gchar **bar_exif_key_list = bar_exif_key_list_real; |
eb9bb29cbd65
Fri Nov 3 11:40:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
48
diff
changeset
|
51 const gint bar_exif_key_count = (sizeof(bar_exif_key_list_real) / sizeof(gchar *)); |
9 | 52 |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
53 ExifUI ExifUIList[]={ |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
54 { 0, 0, EXIF_UI_ON, "fCamera"}, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
55 { 0, 0, EXIF_UI_ON, "fDateTime"}, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
56 { 0, 0, EXIF_UI_ON, "fShutterSpeed"}, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
57 { 0, 0, EXIF_UI_ON, "fAperture"}, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
58 { 0, 0, EXIF_UI_IFSET, "fExposureBias"}, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
59 { 0, 0, EXIF_UI_IFSET, "fISOSpeedRating"}, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
60 { 0, 0, EXIF_UI_ON, "fFocalLength"}, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
61 { 0, 0, EXIF_UI_IFSET, "fFocalLength35mmFilm"}, |
258
395d7115df14
Change default exif order a bit to move up common and useful
zas_
parents:
233
diff
changeset
|
62 { 0, 0, EXIF_UI_ON, "fFlash"}, |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
63 { 0, 0, EXIF_UI_IFSET, "fSubjectDistance"}, |
258
395d7115df14
Change default exif order a bit to move up common and useful
zas_
parents:
233
diff
changeset
|
64 { 0, 0, EXIF_UI_IFSET, "Exif.Photo.ExposureProgram"}, |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
65 { 0, 0, EXIF_UI_IFSET, "Exif.Photo.MeteringMode"}, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
66 { 0, 0, EXIF_UI_IFSET, "Exif.Photo.LightSource"}, |
323
4e721492341b
Add Exif.Photo.ColorSpace tag in Preferences > Properties > Exif.
zas_
parents:
281
diff
changeset
|
67 { 0, 0, EXIF_UI_IFSET, "Exif.Photo.ColorSpace"}, |
258
395d7115df14
Change default exif order a bit to move up common and useful
zas_
parents:
233
diff
changeset
|
68 { 0, 0, EXIF_UI_IFSET, "fSubjectDistance"}, |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
69 { 0, 0, EXIF_UI_OFF, "fResolution"}, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
70 { 0, 0, EXIF_UI_IFSET, "Exif.Image.Orientation"}, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
71 { 0, 0, EXIF_UI_IFSET, "Exif.Image.ImageDescription"}, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
72 { 0, 0, EXIF_UI_IFSET, "Exif.Image.Copyright"}, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
73 { 0, 0, EXIF_UI_OFF, NULL} |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
74 }; |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
75 |
9 | 76 |
77 /* | |
78 *------------------------------------------------------------------- | |
79 * table util | |
80 *------------------------------------------------------------------- | |
81 */ | |
82 | |
83 static void table_add_line_custom(GtkWidget *table, gint x, gint y, | |
84 const gchar *text1, const gchar *text2, | |
85 GtkWidget **label1, GtkWidget **label2) | |
86 { | |
87 GtkWidget *label; | |
88 gchar *buf; | |
89 | |
90 buf = g_strconcat((text1) ? text1 : "fixme", ":", NULL); | |
91 if (!text2) text2 = ""; | |
92 | |
93 label = gtk_label_new(buf); | |
94 gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.0); | |
95 pref_label_bold(label, TRUE, FALSE); | |
96 gtk_table_attach(GTK_TABLE(table), label, | |
97 x, x + 1, y, y + 1, | |
98 GTK_FILL, GTK_FILL, | |
99 2, 2); | |
100 *label1 = label; | |
101 | |
102 label = gtk_label_new(text2); | |
103 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); | |
104 gtk_table_attach(GTK_TABLE(table), label, | |
105 x + 1, x + 2, y, y + 1, | |
106 GTK_FILL, GTK_FILL, | |
107 2, 2); | |
108 *label2 = label; | |
109 | |
110 g_free(buf); | |
111 } | |
112 | |
113 static GtkWidget *table_add_line(GtkWidget *table, gint x, gint y, | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
114 const gchar *description, const gchar *text, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
115 GtkWidget **keyret) |
9 | 116 { |
117 GtkWidget *key; | |
118 GtkWidget *label; | |
119 | |
120 table_add_line_custom(table, x, y, description, text, &key, &label); | |
121 gtk_widget_show(key); | |
122 gtk_widget_show(label); | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
123 if (keyret) *keyret = key; |
9 | 124 |
125 return label; | |
126 } | |
127 | |
128 | |
129 /* | |
130 *------------------------------------------------------------------- | |
131 * EXIF bar | |
132 *------------------------------------------------------------------- | |
133 */ | |
134 | |
135 typedef struct _ExifBar ExifBar; | |
136 struct _ExifBar | |
137 { | |
138 GtkWidget *vbox; | |
139 GtkWidget *scrolled; | |
140 GtkWidget *table; | |
141 GtkWidget *advanced_scrolled; | |
142 GtkWidget *listview; | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
143 GtkWidget **keys; |
9 | 144 GtkWidget **labels; |
145 | |
146 GtkWidget *custom_sep; | |
147 GtkWidget *custom_name[EXIF_BAR_CUSTOM_COUNT]; | |
148 GtkWidget *custom_value[EXIF_BAR_CUSTOM_COUNT]; | |
149 | |
138 | 150 FileData *fd; |
9 | 151 |
152 gint allow_search; | |
153 }; | |
154 | |
155 enum { | |
156 EXIF_ADVCOL_ENABLED = 0, | |
157 EXIF_ADVCOL_TAG, | |
158 EXIF_ADVCOL_NAME, | |
159 EXIF_ADVCOL_VALUE, | |
160 EXIF_ADVCOL_FORMAT, | |
161 EXIF_ADVCOL_ELEMENTS, | |
162 EXIF_ADVCOL_DESCRIPTION, | |
163 EXIF_ADVCOL_COUNT | |
164 }; | |
165 | |
95
eb9bb29cbd65
Fri Nov 3 11:40:48 2006 John Ellis <johne@verizon.net>
gqview
parents:
48
diff
changeset
|
166 gchar *bar_exif_validate_text(gchar *text) |
9 | 167 { |
168 if (text && !g_utf8_validate(text, strlen(text), NULL)) | |
169 { | |
170 gchar *tmp = text; | |
171 text = g_convert(tmp, strlen(tmp), "UTF-8", "ISO-8859-1", NULL, NULL, NULL); | |
172 g_free(tmp); | |
173 } | |
174 return text; | |
175 } | |
176 | |
177 static void bar_exif_sensitive(ExifBar *eb, gint enable) | |
178 { | |
179 gtk_widget_set_sensitive(eb->table, enable); | |
180 if (eb->advanced_scrolled) gtk_widget_set_sensitive(eb->advanced_scrolled, enable); | |
181 } | |
182 | |
183 static gint bar_exif_row_enabled(const gchar *name) | |
184 { | |
185 GList *list; | |
186 | |
187 list = history_list_get_by_key("exif_extras"); | |
188 while (list) | |
189 { | |
190 if (name && strcmp(name, (gchar *)(list->data)) == 0) return TRUE; | |
191 list = list->next; | |
192 } | |
193 | |
194 return FALSE; | |
195 } | |
196 | |
197 static void bar_exif_update(ExifBar *eb) | |
198 { | |
199 ExifData *exif; | |
233 | 200 gint i; |
9 | 201 |
188
0584cb78aa14
write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents:
185
diff
changeset
|
202 exif = exif_read_fd(eb->fd, FALSE); |
9 | 203 |
204 if (!exif) | |
205 { | |
206 bar_exif_sensitive(eb, FALSE); | |
207 return; | |
208 } | |
209 | |
210 bar_exif_sensitive(eb, TRUE); | |
211 | |
212 if (GTK_WIDGET_VISIBLE(eb->scrolled)) | |
213 { | |
214 GList *list; | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
215 for (i = 0; ExifUIList[i].key; i++) |
9 | 216 { |
217 gchar *text; | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
218 |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
219 if (ExifUIList[i].current == EXIF_UI_OFF) |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
220 { |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
221 gtk_widget_hide(eb->labels[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
222 gtk_widget_hide(eb->keys[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
223 continue; |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
224 } |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
225 text = exif_get_data_as_text(exif, ExifUIList[i].key); |
9 | 226 text = bar_exif_validate_text(text); |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
227 if (ExifUIList[i].current == EXIF_UI_IFSET |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
228 && (!text || !*text)) |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
229 { |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
230 gtk_widget_hide(eb->labels[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
231 gtk_widget_hide(eb->keys[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
232 continue; |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
233 } |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
234 gtk_widget_show(eb->labels[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
235 gtk_widget_show(eb->keys[i]); |
9 | 236 gtk_label_set_text(GTK_LABEL(eb->labels[i]), text); |
237 g_free(text); | |
238 } | |
239 | |
240 list = g_list_last(history_list_get_by_key("exif_extras")); | |
241 if (list) | |
242 { | |
243 gtk_widget_show(eb->custom_sep); | |
244 } | |
245 else | |
246 { | |
247 gtk_widget_hide(eb->custom_sep); | |
248 } | |
249 i = 0; | |
250 while (list && i < EXIF_BAR_CUSTOM_COUNT) | |
251 { | |
252 gchar *text; | |
253 gchar *name; | |
254 gchar *buf; | |
255 | |
256 name = list->data; | |
257 list = list->prev; | |
258 | |
259 text = exif_get_data_as_text(exif, name); | |
260 text = bar_exif_validate_text(text); | |
261 | |
262 buf = g_strconcat(name, ":", NULL); | |
263 gtk_label_set_text(GTK_LABEL(eb->custom_name[i]), buf); | |
264 g_free(buf); | |
265 gtk_label_set_text(GTK_LABEL(eb->custom_value[i]), text); | |
266 g_free(text); | |
267 | |
268 gtk_widget_show(eb->custom_name[i]); | |
269 gtk_widget_show(eb->custom_value[i]); | |
270 | |
271 i++; | |
272 } | |
273 while (i < EXIF_BAR_CUSTOM_COUNT) | |
274 { | |
275 gtk_widget_hide(eb->custom_name[i]); | |
276 gtk_widget_hide(eb->custom_value[i]); | |
277 i++; | |
278 } | |
279 } | |
280 | |
281 if (eb->advanced_scrolled && GTK_WIDGET_VISIBLE(eb->advanced_scrolled)) | |
282 { | |
283 GtkListStore *store; | |
284 GtkTreeIter iter; | |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
285 ExifItem *item; |
9 | 286 |
287 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(eb->listview))); | |
288 gtk_list_store_clear(store); | |
289 | |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
290 item = exif_get_first_item(exif); |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
291 while (item) |
9 | 292 { |
293 gchar *tag; | |
185 | 294 gchar *tag_name; |
9 | 295 gchar *text; |
296 const gchar *format; | |
297 gchar *elements; | |
185 | 298 gchar *description; |
9 | 299 |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
300 tag = g_strdup_printf("0x%04x", exif_item_get_tag_id(item)); |
9 | 301 tag_name = exif_item_get_tag_name(item); |
302 format = exif_item_get_format_name(item, TRUE); | |
303 text = exif_item_get_data_as_text(item); | |
304 text = bar_exif_validate_text(text); | |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
305 elements = g_strdup_printf("%d", exif_item_get_elements(item)); |
9 | 306 description = exif_item_get_description(item); |
182 | 307 if (!description) description = g_strdup(""); |
9 | 308 gtk_list_store_append(store, &iter); |
309 gtk_list_store_set(store, &iter, | |
310 EXIF_ADVCOL_ENABLED, bar_exif_row_enabled(tag_name), | |
311 EXIF_ADVCOL_TAG, tag, | |
312 EXIF_ADVCOL_NAME, tag_name, | |
313 EXIF_ADVCOL_VALUE, text, | |
314 EXIF_ADVCOL_FORMAT, format, | |
315 EXIF_ADVCOL_ELEMENTS, elements, | |
316 EXIF_ADVCOL_DESCRIPTION, description, -1); | |
317 g_free(tag); | |
318 g_free(text); | |
319 g_free(elements); | |
182 | 320 g_free(description); |
185 | 321 g_free(tag_name); |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
322 item = exif_get_next_item(exif); |
9 | 323 } |
324 } | |
325 | |
326 exif_free(exif); | |
327 } | |
328 | |
329 static void bar_exif_clear(ExifBar *eb) | |
330 { | |
331 gint i; | |
332 | |
333 if (!GTK_WIDGET_SENSITIVE(eb->labels[0])) return; | |
334 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
335 for (i = 0; ExifUIList[i].key; i++) |
9 | 336 { |
337 gtk_label_set_text(GTK_LABEL(eb->labels[i]), ""); | |
338 } | |
339 for (i = 0; i < EXIF_BAR_CUSTOM_COUNT; i++) | |
340 { | |
341 gtk_label_set_text(GTK_LABEL(eb->custom_value[i]), ""); | |
342 } | |
343 | |
344 if (eb->listview) | |
345 { | |
346 GtkListStore *store; | |
347 | |
348 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(eb->listview))); | |
349 gtk_list_store_clear(store); | |
350 } | |
351 } | |
352 | |
138 | 353 void bar_exif_set(GtkWidget *bar, FileData *fd) |
9 | 354 { |
355 ExifBar *eb; | |
356 | |
357 eb = g_object_get_data(G_OBJECT(bar), "bar_exif_data"); | |
358 if (!eb) return; | |
359 | |
360 /* store this, advanced view toggle needs to reload data */ | |
138 | 361 file_data_unref(eb->fd); |
362 eb->fd = file_data_ref(fd); | |
9 | 363 |
364 bar_exif_clear(eb); | |
365 bar_exif_update(eb); | |
366 } | |
367 | |
368 static void bar_exif_row_toggled_cb(GtkCellRendererToggle *toggle, const gchar *path, gpointer data) | |
369 { | |
370 GtkWidget *listview = data; | |
371 GtkTreeModel *store; | |
372 GtkTreeIter iter; | |
373 GtkTreePath *tpath; | |
374 gchar *name = NULL; | |
375 gboolean active; | |
376 | |
377 store = gtk_tree_view_get_model(GTK_TREE_VIEW(listview)); | |
378 | |
379 tpath = gtk_tree_path_new_from_string(path); | |
380 gtk_tree_model_get_iter(store, &iter, tpath); | |
381 gtk_tree_path_free(tpath); | |
382 | |
383 gtk_tree_model_get(store, &iter, EXIF_ADVCOL_ENABLED, &active, | |
384 EXIF_ADVCOL_NAME, &name, -1); | |
385 active = (!active); | |
386 | |
387 if (active && | |
388 g_list_length(history_list_get_by_key("exif_extras")) >= EXIF_BAR_CUSTOM_COUNT) | |
389 { | |
390 active = FALSE; | |
391 } | |
392 | |
393 gtk_list_store_set(GTK_LIST_STORE(store), &iter, EXIF_ADVCOL_ENABLED, active, -1); | |
394 | |
395 if (active) | |
396 { | |
397 history_list_add_to_key("exif_extras", name, EXIF_BAR_CUSTOM_COUNT); | |
398 } | |
399 else | |
400 { | |
401 history_list_item_change("exif_extras", name, NULL); | |
402 } | |
403 | |
404 g_free(name); | |
405 } | |
406 | |
407 static void bar_exif_add_column_check(GtkWidget *listview, const gchar *title, gint n) | |
408 { | |
409 GtkTreeViewColumn *column; | |
410 GtkCellRenderer *renderer; | |
411 | |
412 column = gtk_tree_view_column_new(); | |
413 gtk_tree_view_column_set_title(column, title); | |
414 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
415 | |
416 renderer = gtk_cell_renderer_toggle_new(); | |
417 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
418 gtk_tree_view_column_add_attribute(column, renderer, "active", n); | |
419 gtk_tree_view_append_column(GTK_TREE_VIEW(listview), column); | |
420 | |
421 g_signal_connect(G_OBJECT(renderer), "toggled", | |
422 G_CALLBACK(bar_exif_row_toggled_cb), listview); | |
423 } | |
424 | |
48
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
425 static void bar_exif_add_column(GtkWidget *listview, const gchar *title, gint n, gint sizable) |
9 | 426 { |
427 GtkTreeViewColumn *column; | |
428 GtkCellRenderer *renderer; | |
429 | |
430 column = gtk_tree_view_column_new(); | |
431 gtk_tree_view_column_set_title(column, title); | |
48
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
432 |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
433 if (sizable) |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
434 { |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
435 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
436 gtk_tree_view_column_set_fixed_width(column, BAR_EXIF_DATA_COLUMN_WIDTH); |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
437 gtk_tree_view_column_set_resizable(column, TRUE); |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
438 } |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
439 else |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
440 { |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
441 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
442 } |
9 | 443 |
444 renderer = gtk_cell_renderer_text_new(); | |
445 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
446 gtk_tree_view_column_add_attribute(column, renderer, "text", n); | |
447 gtk_tree_view_append_column(GTK_TREE_VIEW(listview), column); | |
448 } | |
449 | |
450 static void bar_exif_advanced_build_view(ExifBar *eb) | |
451 { | |
452 GtkListStore *store; | |
453 | |
454 if (eb->listview) return; | |
455 | |
456 store = gtk_list_store_new(7, G_TYPE_BOOLEAN, | |
457 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, | |
458 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); | |
459 eb->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | |
460 g_object_unref(store); | |
461 | |
462 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(eb->listview), TRUE); | |
463 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(eb->listview), TRUE); | |
464 | |
465 if (eb->allow_search) | |
466 { | |
467 gtk_tree_view_set_search_column(GTK_TREE_VIEW(eb->listview), EXIF_ADVCOL_NAME); | |
468 } | |
469 else | |
470 { | |
471 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(eb->listview), FALSE); | |
472 } | |
473 | |
474 bar_exif_add_column_check(eb->listview, "", EXIF_ADVCOL_ENABLED); | |
475 | |
48
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
476 bar_exif_add_column(eb->listview, _("Tag"), EXIF_ADVCOL_TAG, FALSE); |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
477 bar_exif_add_column(eb->listview, _("Name"), EXIF_ADVCOL_NAME, FALSE); |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
478 bar_exif_add_column(eb->listview, _("Value"), EXIF_ADVCOL_VALUE, TRUE); |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
479 bar_exif_add_column(eb->listview, _("Format"), EXIF_ADVCOL_FORMAT, FALSE); |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
480 bar_exif_add_column(eb->listview, _("Elements"), EXIF_ADVCOL_ELEMENTS, FALSE); |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
481 bar_exif_add_column(eb->listview, _("Description"), EXIF_ADVCOL_DESCRIPTION, FALSE); |
9 | 482 |
483 eb->advanced_scrolled = gtk_scrolled_window_new(NULL, NULL); | |
484 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(eb->advanced_scrolled), GTK_SHADOW_IN); | |
485 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(eb->advanced_scrolled), | |
486 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
487 gtk_box_pack_start(GTK_BOX(eb->vbox), eb->advanced_scrolled, TRUE, TRUE, 0); | |
488 gtk_container_add(GTK_CONTAINER(eb->advanced_scrolled), eb->listview); | |
489 gtk_widget_show(eb->listview); | |
490 } | |
491 | |
492 static void bar_exif_advanced_cb(GtkWidget *widget, gpointer data) | |
493 { | |
494 ExifBar *eb = data; | |
495 gint advanced; | |
496 | |
497 advanced = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
498 | |
499 if (advanced) | |
500 { | |
501 gtk_widget_hide(eb->scrolled); | |
502 bar_exif_advanced_build_view(eb); | |
503 gtk_widget_show(eb->advanced_scrolled); | |
504 } | |
505 else | |
506 { | |
507 gtk_widget_hide(eb->advanced_scrolled); | |
508 gtk_widget_show(eb->scrolled); | |
509 } | |
510 | |
511 bar_exif_update(eb); | |
512 } | |
513 | |
514 gint bar_exif_is_advanced(GtkWidget *bar) | |
515 { | |
516 ExifBar *eb; | |
517 | |
518 eb = g_object_get_data(G_OBJECT(bar), "bar_exif_data"); | |
519 if (!eb) return FALSE; | |
520 | |
521 return (eb->advanced_scrolled && GTK_WIDGET_VISIBLE(eb->advanced_scrolled)); | |
522 } | |
523 | |
524 void bar_exif_close(GtkWidget *bar) | |
525 { | |
526 ExifBar *eb; | |
527 | |
528 eb = g_object_get_data(G_OBJECT(bar), "bar_exif_data"); | |
529 if (!eb) return; | |
530 | |
531 gtk_widget_destroy(eb->vbox); | |
532 } | |
533 | |
534 static void bar_exif_size(ExifBar *eb, gint val) | |
535 { | |
536 gint size; | |
537 | |
538 size = eb->vbox->allocation.width; | |
539 size = CLAMP(size + val, EXIF_BAR_SIZE_INCREMENT * 2, EXIF_BAR_SIZE_INCREMENT * 16); | |
540 | |
541 gtk_widget_set_size_request(eb->vbox, size, -1); | |
542 } | |
543 | |
544 static void bar_exif_larger(GtkWidget *widget, gpointer data) | |
545 { | |
546 ExifBar *eb = data; | |
547 | |
548 bar_exif_size(eb, EXIF_BAR_SIZE_INCREMENT); | |
549 } | |
550 | |
551 static void bar_exif_smaller(GtkWidget *widget, gpointer data) | |
552 { | |
553 ExifBar *eb = data; | |
554 | |
555 bar_exif_size(eb, -EXIF_BAR_SIZE_INCREMENT); | |
556 } | |
557 | |
558 static void bar_exif_destroy(GtkWidget *widget, gpointer data) | |
559 { | |
560 ExifBar *eb = data; | |
561 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
562 g_free(eb->keys); |
9 | 563 g_free(eb->labels); |
138 | 564 file_data_unref(eb->fd); |
9 | 565 g_free(eb); |
566 } | |
567 | |
138 | 568 GtkWidget *bar_exif_new(gint show_title, FileData *fd, gint advanced, GtkWidget *bounding_widget) |
9 | 569 { |
570 ExifBar *eb; | |
571 GtkWidget *table; | |
572 GtkWidget *viewport; | |
573 GtkWidget *hbox; | |
574 GtkWidget *button; | |
575 gint i; | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
576 gint exif_len; |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
577 |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
578 for (exif_len = 0; ExifUIList[exif_len].key; exif_len++) |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
579 ; |
9 | 580 |
581 eb = g_new0(ExifBar, 1); | |
582 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
583 eb->keys = g_new0(GtkWidget *, exif_len); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
584 eb->labels = g_new0(GtkWidget *, exif_len); |
9 | 585 |
586 eb->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); | |
587 g_object_set_data(G_OBJECT(eb->vbox), "bar_exif_data", eb); | |
588 g_signal_connect_after(G_OBJECT(eb->vbox), "destroy", | |
589 G_CALLBACK(bar_exif_destroy), eb); | |
590 | |
591 eb->allow_search = !show_title; | |
592 | |
593 if (show_title) | |
594 { | |
595 GtkWidget *box; | |
596 GtkWidget *label; | |
597 GtkWidget *button; | |
598 GtkWidget *arrow; | |
599 | |
600 box = gtk_hbox_new(FALSE, 0); | |
601 | |
602 label = sizer_new(eb->vbox, bounding_widget, SIZER_POS_LEFT); | |
603 sizer_set_limits(label, EXIF_BAR_SIZE_INCREMENT * 2, -1, -1 , -1); | |
604 gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); | |
605 gtk_widget_show(label); | |
606 | |
607 label = gtk_label_new(_("Exif")); | |
608 pref_label_bold(label, TRUE, FALSE); | |
609 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0); | |
610 gtk_widget_show(label); | |
611 | |
612 button = gtk_button_new(); | |
613 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
614 g_signal_connect(G_OBJECT(button), "clicked", | |
615 G_CALLBACK(bar_exif_smaller), eb); | |
616 gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0); | |
617 arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE); | |
618 gtk_widget_set_size_request(arrow, EXIF_BAR_ARROW_SIZE, EXIF_BAR_ARROW_SIZE); | |
619 gtk_container_add(GTK_CONTAINER(button), arrow); | |
620 gtk_widget_show(arrow); | |
621 gtk_widget_show(button); | |
622 | |
623 button = gtk_button_new(); | |
624 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
625 g_signal_connect(G_OBJECT(button), "clicked", | |
626 G_CALLBACK(bar_exif_larger), eb); | |
627 gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0); | |
628 arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE); | |
629 gtk_widget_set_size_request(arrow, EXIF_BAR_ARROW_SIZE, EXIF_BAR_ARROW_SIZE); | |
630 gtk_container_add(GTK_CONTAINER(button), arrow); | |
631 gtk_widget_show(arrow); | |
632 gtk_widget_show(button); | |
633 | |
634 gtk_box_pack_start(GTK_BOX(eb->vbox), box, FALSE, FALSE, 0); | |
635 gtk_widget_show(box); | |
636 } | |
637 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
638 |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
639 table = gtk_table_new(2, exif_len + 1 + EXIF_BAR_CUSTOM_COUNT, FALSE); |
9 | 640 |
641 eb->table = table; | |
642 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
643 for (i = 0; ExifUIList[i].key; i++) |
9 | 644 { |
645 const gchar *text; | |
646 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
647 text = exif_get_description_by_key(ExifUIList[i].key); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
648 eb->labels[i] = table_add_line(table, 0, i, text, NULL, |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
649 &eb->keys[i]); |
9 | 650 } |
651 | |
652 eb->custom_sep = gtk_hseparator_new(); | |
653 gtk_table_attach(GTK_TABLE(table), eb->custom_sep, 0, 1, | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
654 exif_len, exif_len + 1, |
9 | 655 GTK_FILL, GTK_FILL, 2, 2); |
656 | |
657 for (i = 0; i < EXIF_BAR_CUSTOM_COUNT; i++) | |
658 { | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
659 table_add_line_custom(table, 0, exif_len + 1 + i, |
9 | 660 "", "", &eb->custom_name[i], &eb->custom_value[i]); |
661 } | |
662 | |
663 eb->scrolled = gtk_scrolled_window_new(NULL, NULL); | |
664 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(eb->scrolled), | |
665 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
666 | |
667 viewport = gtk_viewport_new(NULL, NULL); | |
668 gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE); | |
669 gtk_container_add(GTK_CONTAINER(eb->scrolled), viewport); | |
670 gtk_widget_show(viewport); | |
671 | |
672 gtk_container_add(GTK_CONTAINER(viewport), table); | |
673 gtk_widget_show(table); | |
674 | |
675 gtk_box_pack_start(GTK_BOX(eb->vbox), eb->scrolled, TRUE, TRUE, 0); | |
676 | |
677 hbox = gtk_hbox_new(FALSE, PREF_PAD_SPACE); | |
678 gtk_box_pack_end(GTK_BOX(eb->vbox), hbox, FALSE, FALSE, 0); | |
679 gtk_widget_show(hbox); | |
680 | |
681 button = gtk_check_button_new_with_label(_("Advanced view")); | |
682 if (advanced) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); | |
683 g_signal_connect(G_OBJECT(button), "toggled", | |
684 G_CALLBACK(bar_exif_advanced_cb), eb); | |
685 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
686 gtk_widget_show(button); | |
687 | |
688 eb->advanced_scrolled = NULL; | |
689 eb->listview = NULL; | |
690 | |
691 if (advanced) | |
692 { | |
693 bar_exif_advanced_build_view(eb); | |
694 gtk_widget_show(eb->advanced_scrolled); | |
695 } | |
696 else | |
697 { | |
698 gtk_widget_show(eb->scrolled); | |
699 } | |
700 | |
138 | 701 eb->fd = file_data_ref(fd); |
9 | 702 bar_exif_update(eb); |
703 | |
704 return eb->vbox; | |
705 } | |
706 |