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