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