Mercurial > geeqie.yaz
annotate src/bar_exif.c @ 882:912726c2f5e3
Fix a segfault occuring when opening some collection files.
Skip all lines not starting with a # when only geometry is required.
author | zas_ |
---|---|
date | Sun, 13 Jul 2008 12:36:18 +0000 |
parents | efed9a1520d6 |
children | b48c366d5707 |
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" | |
586 | 20 #include "filedata.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[]={ |
566
db08ccd54169
Change the prefix of formatted exif tags to a more explicit "formatted." prefix
zas_
parents:
550
diff
changeset
|
32 { 0, 0, EXIF_UI_IFSET, "formatted.Camera"}, |
db08ccd54169
Change the prefix of formatted exif tags to a more explicit "formatted." prefix
zas_
parents:
550
diff
changeset
|
33 { 0, 0, EXIF_UI_IFSET, "formatted.DateTime"}, |
db08ccd54169
Change the prefix of formatted exif tags to a more explicit "formatted." prefix
zas_
parents:
550
diff
changeset
|
34 { 0, 0, EXIF_UI_IFSET, "formatted.ShutterSpeed"}, |
db08ccd54169
Change the prefix of formatted exif tags to a more explicit "formatted." prefix
zas_
parents:
550
diff
changeset
|
35 { 0, 0, EXIF_UI_IFSET, "formatted.Aperture"}, |
db08ccd54169
Change the prefix of formatted exif tags to a more explicit "formatted." prefix
zas_
parents:
550
diff
changeset
|
36 { 0, 0, EXIF_UI_IFSET, "formatted.ExposureBias"}, |
db08ccd54169
Change the prefix of formatted exif tags to a more explicit "formatted." prefix
zas_
parents:
550
diff
changeset
|
37 { 0, 0, EXIF_UI_IFSET, "formatted.ISOSpeedRating"}, |
db08ccd54169
Change the prefix of formatted exif tags to a more explicit "formatted." prefix
zas_
parents:
550
diff
changeset
|
38 { 0, 0, EXIF_UI_IFSET, "formatted.FocalLength"}, |
db08ccd54169
Change the prefix of formatted exif tags to a more explicit "formatted." prefix
zas_
parents:
550
diff
changeset
|
39 { 0, 0, EXIF_UI_IFSET, "formatted.FocalLength35mmFilm"}, |
db08ccd54169
Change the prefix of formatted exif tags to a more explicit "formatted." prefix
zas_
parents:
550
diff
changeset
|
40 { 0, 0, EXIF_UI_IFSET, "formatted.Flash"}, |
325 | 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"}, | |
566
db08ccd54169
Change the prefix of formatted exif tags to a more explicit "formatted." prefix
zas_
parents:
550
diff
changeset
|
44 { 0, 0, EXIF_UI_IFSET, "formatted.ColorProfile"}, |
db08ccd54169
Change the prefix of formatted exif tags to a more explicit "formatted." prefix
zas_
parents:
550
diff
changeset
|
45 { 0, 0, EXIF_UI_IFSET, "formatted.SubjectDistance"}, |
db08ccd54169
Change the prefix of formatted exif tags to a more explicit "formatted." prefix
zas_
parents:
550
diff
changeset
|
46 { 0, 0, EXIF_UI_IFSET, "formatted.Resolution"}, |
325 | 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 | |
143 static void bar_exif_sensitive(ExifBar *eb, gint enable) | |
144 { | |
145 gtk_widget_set_sensitive(eb->table, enable); | |
146 if (eb->advanced_scrolled) gtk_widget_set_sensitive(eb->advanced_scrolled, enable); | |
147 } | |
148 | |
149 static gint bar_exif_row_enabled(const gchar *name) | |
150 { | |
151 GList *list; | |
152 | |
153 list = history_list_get_by_key("exif_extras"); | |
154 while (list) | |
155 { | |
156 if (name && strcmp(name, (gchar *)(list->data)) == 0) return TRUE; | |
157 list = list->next; | |
158 } | |
159 | |
160 return FALSE; | |
161 } | |
162 | |
163 static void bar_exif_update(ExifBar *eb) | |
164 { | |
165 ExifData *exif; | |
233 | 166 gint i; |
9 | 167 |
449 | 168 exif = exif_read_fd(eb->fd); |
9 | 169 |
170 if (!exif) | |
171 { | |
172 bar_exif_sensitive(eb, FALSE); | |
173 return; | |
174 } | |
175 | |
176 bar_exif_sensitive(eb, TRUE); | |
177 | |
178 if (GTK_WIDGET_VISIBLE(eb->scrolled)) | |
179 { | |
180 GList *list; | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
181 for (i = 0; ExifUIList[i].key; i++) |
9 | 182 { |
183 gchar *text; | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
184 gchar *utf8_text; |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
185 |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
186 if (ExifUIList[i].current == EXIF_UI_OFF) |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
187 { |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
188 gtk_widget_hide(eb->labels[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
189 gtk_widget_hide(eb->keys[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
190 continue; |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
191 } |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
192 text = exif_get_data_as_text(exif, ExifUIList[i].key); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
193 utf8_text = utf8_validate_or_convert(text); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
194 g_free(text); |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
195 if (ExifUIList[i].current == EXIF_UI_IFSET |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
196 && (!utf8_text || !*utf8_text)) |
442 | 197 { |
222
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]); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
200 g_free(utf8_text); |
222
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 gtk_widget_show(eb->labels[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
204 gtk_widget_show(eb->keys[i]); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
205 gtk_label_set_text(GTK_LABEL(eb->labels[i]), utf8_text); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
206 g_free(utf8_text); |
9 | 207 } |
208 | |
209 list = g_list_last(history_list_get_by_key("exif_extras")); | |
210 if (list) | |
211 { | |
212 gtk_widget_show(eb->custom_sep); | |
213 } | |
214 else | |
215 { | |
216 gtk_widget_hide(eb->custom_sep); | |
217 } | |
218 i = 0; | |
219 while (list && i < EXIF_BAR_CUSTOM_COUNT) | |
220 { | |
221 gchar *text; | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
222 gchar *utf8_text; |
9 | 223 gchar *name; |
224 gchar *buf; | |
225 | |
226 name = list->data; | |
227 list = list->prev; | |
228 | |
229 text = exif_get_data_as_text(exif, name); | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
230 utf8_text = utf8_validate_or_convert(text); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
231 g_free(text); |
9 | 232 |
233 buf = g_strconcat(name, ":", NULL); | |
234 gtk_label_set_text(GTK_LABEL(eb->custom_name[i]), buf); | |
235 g_free(buf); | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
236 gtk_label_set_text(GTK_LABEL(eb->custom_value[i]), utf8_text); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
237 g_free(utf8_text); |
9 | 238 |
239 gtk_widget_show(eb->custom_name[i]); | |
240 gtk_widget_show(eb->custom_value[i]); | |
241 | |
242 i++; | |
243 } | |
244 while (i < EXIF_BAR_CUSTOM_COUNT) | |
245 { | |
246 gtk_widget_hide(eb->custom_name[i]); | |
247 gtk_widget_hide(eb->custom_value[i]); | |
248 i++; | |
249 } | |
250 } | |
251 | |
252 if (eb->advanced_scrolled && GTK_WIDGET_VISIBLE(eb->advanced_scrolled)) | |
253 { | |
254 GtkListStore *store; | |
255 GtkTreeIter iter; | |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
256 ExifItem *item; |
442 | 257 |
9 | 258 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(eb->listview))); |
259 gtk_list_store_clear(store); | |
260 | |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
261 item = exif_get_first_item(exif); |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
262 while (item) |
9 | 263 { |
264 gchar *tag; | |
185 | 265 gchar *tag_name; |
9 | 266 gchar *text; |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
267 gchar *utf8_text; |
9 | 268 const gchar *format; |
269 gchar *elements; | |
185 | 270 gchar *description; |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
271 gchar *utf8_description; |
9 | 272 |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
273 tag = g_strdup_printf("0x%04x", exif_item_get_tag_id(item)); |
9 | 274 tag_name = exif_item_get_tag_name(item); |
275 format = exif_item_get_format_name(item, TRUE); | |
276 text = exif_item_get_data_as_text(item); | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
277 utf8_text = utf8_validate_or_convert(text); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
278 g_free(text); |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
279 elements = g_strdup_printf("%d", exif_item_get_elements(item)); |
9 | 280 description = exif_item_get_description(item); |
182 | 281 if (!description) description = g_strdup(""); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
282 utf8_description = utf8_validate_or_convert(description); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
283 g_free(description); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
284 |
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, | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
290 EXIF_ADVCOL_VALUE, utf8_text, |
9 | 291 EXIF_ADVCOL_FORMAT, format, |
292 EXIF_ADVCOL_ELEMENTS, elements, | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
293 EXIF_ADVCOL_DESCRIPTION, utf8_description, -1); |
9 | 294 g_free(tag); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
295 g_free(utf8_text); |
9 | 296 g_free(elements); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
297 g_free(utf8_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 | |
844 | 303 exif_free_fd(eb->fd, exif); |
9 | 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 | |
489
3809ffa3567b
Save state and width of exif, info and sort panels to rc file.
zas_
parents:
475
diff
changeset
|
511 static void bar_exif_width(ExifBar *eb, gint val) |
9 | 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); | |
489
3809ffa3567b
Save state and width of exif, info and sort panels to rc file.
zas_
parents:
475
diff
changeset
|
519 options->panels.exif.width = eb->vbox->allocation.width; |
9 | 520 } |
521 | |
522 static void bar_exif_larger(GtkWidget *widget, gpointer data) | |
523 { | |
524 ExifBar *eb = data; | |
525 | |
489
3809ffa3567b
Save state and width of exif, info and sort panels to rc file.
zas_
parents:
475
diff
changeset
|
526 bar_exif_width(eb, EXIF_BAR_SIZE_INCREMENT); |
9 | 527 } |
528 | |
529 static void bar_exif_smaller(GtkWidget *widget, gpointer data) | |
530 { | |
531 ExifBar *eb = data; | |
532 | |
489
3809ffa3567b
Save state and width of exif, info and sort panels to rc file.
zas_
parents:
475
diff
changeset
|
533 bar_exif_width(eb, -EXIF_BAR_SIZE_INCREMENT); |
9 | 534 } |
535 | |
536 static void bar_exif_destroy(GtkWidget *widget, gpointer data) | |
537 { | |
538 ExifBar *eb = data; | |
539 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
540 g_free(eb->keys); |
9 | 541 g_free(eb->labels); |
138 | 542 file_data_unref(eb->fd); |
9 | 543 g_free(eb); |
544 } | |
545 | |
138 | 546 GtkWidget *bar_exif_new(gint show_title, FileData *fd, gint advanced, GtkWidget *bounding_widget) |
9 | 547 { |
548 ExifBar *eb; | |
549 GtkWidget *table; | |
550 GtkWidget *viewport; | |
551 GtkWidget *hbox; | |
552 GtkWidget *button; | |
553 gint i; | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
554 gint exif_len; |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
555 |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
556 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
|
557 ; |
9 | 558 |
559 eb = g_new0(ExifBar, 1); | |
560 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
561 eb->keys = g_new0(GtkWidget *, exif_len); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
562 eb->labels = g_new0(GtkWidget *, exif_len); |
9 | 563 |
564 eb->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); | |
565 g_object_set_data(G_OBJECT(eb->vbox), "bar_exif_data", eb); | |
566 g_signal_connect_after(G_OBJECT(eb->vbox), "destroy", | |
567 G_CALLBACK(bar_exif_destroy), eb); | |
568 | |
569 eb->allow_search = !show_title; | |
570 | |
571 if (show_title) | |
572 { | |
573 GtkWidget *box; | |
574 GtkWidget *label; | |
575 GtkWidget *button; | |
576 GtkWidget *arrow; | |
577 | |
578 box = gtk_hbox_new(FALSE, 0); | |
579 | |
580 label = sizer_new(eb->vbox, bounding_widget, SIZER_POS_LEFT); | |
581 sizer_set_limits(label, EXIF_BAR_SIZE_INCREMENT * 2, -1, -1 , -1); | |
582 gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); | |
583 gtk_widget_show(label); | |
584 | |
585 label = gtk_label_new(_("Exif")); | |
586 pref_label_bold(label, TRUE, FALSE); | |
587 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0); | |
588 gtk_widget_show(label); | |
589 | |
590 button = gtk_button_new(); | |
591 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
592 g_signal_connect(G_OBJECT(button), "clicked", | |
593 G_CALLBACK(bar_exif_smaller), eb); | |
594 gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0); | |
595 arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE); | |
596 gtk_widget_set_size_request(arrow, EXIF_BAR_ARROW_SIZE, EXIF_BAR_ARROW_SIZE); | |
597 gtk_container_add(GTK_CONTAINER(button), arrow); | |
598 gtk_widget_show(arrow); | |
599 gtk_widget_show(button); | |
600 | |
601 button = gtk_button_new(); | |
602 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
603 g_signal_connect(G_OBJECT(button), "clicked", | |
604 G_CALLBACK(bar_exif_larger), eb); | |
605 gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0); | |
606 arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE); | |
607 gtk_widget_set_size_request(arrow, EXIF_BAR_ARROW_SIZE, EXIF_BAR_ARROW_SIZE); | |
608 gtk_container_add(GTK_CONTAINER(button), arrow); | |
609 gtk_widget_show(arrow); | |
610 gtk_widget_show(button); | |
611 | |
612 gtk_box_pack_start(GTK_BOX(eb->vbox), box, FALSE, FALSE, 0); | |
613 gtk_widget_show(box); | |
614 } | |
615 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
616 |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
617 table = gtk_table_new(2, exif_len + 1 + EXIF_BAR_CUSTOM_COUNT, FALSE); |
9 | 618 |
619 eb->table = table; | |
620 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
621 for (i = 0; ExifUIList[i].key; i++) |
9 | 622 { |
623 const gchar *text; | |
624 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
625 text = exif_get_description_by_key(ExifUIList[i].key); |
442 | 626 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
|
627 &eb->keys[i]); |
9 | 628 } |
629 | |
630 eb->custom_sep = gtk_hseparator_new(); | |
631 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
|
632 exif_len, exif_len + 1, |
9 | 633 GTK_FILL, GTK_FILL, 2, 2); |
634 | |
635 for (i = 0; i < EXIF_BAR_CUSTOM_COUNT; i++) | |
636 { | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
637 table_add_line_custom(table, 0, exif_len + 1 + i, |
9 | 638 "", "", &eb->custom_name[i], &eb->custom_value[i]); |
639 } | |
640 | |
641 eb->scrolled = gtk_scrolled_window_new(NULL, NULL); | |
642 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(eb->scrolled), | |
643 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
644 | |
645 viewport = gtk_viewport_new(NULL, NULL); | |
646 gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE); | |
647 gtk_container_add(GTK_CONTAINER(eb->scrolled), viewport); | |
648 gtk_widget_show(viewport); | |
649 | |
650 gtk_container_add(GTK_CONTAINER(viewport), table); | |
651 gtk_widget_show(table); | |
652 | |
653 gtk_box_pack_start(GTK_BOX(eb->vbox), eb->scrolled, TRUE, TRUE, 0); | |
654 | |
655 hbox = gtk_hbox_new(FALSE, PREF_PAD_SPACE); | |
656 gtk_box_pack_end(GTK_BOX(eb->vbox), hbox, FALSE, FALSE, 0); | |
657 gtk_widget_show(hbox); | |
658 | |
659 button = gtk_check_button_new_with_label(_("Advanced view")); | |
660 if (advanced) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); | |
661 g_signal_connect(G_OBJECT(button), "toggled", | |
662 G_CALLBACK(bar_exif_advanced_cb), eb); | |
663 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
664 gtk_widget_show(button); | |
665 | |
666 eb->advanced_scrolled = NULL; | |
667 eb->listview = NULL; | |
668 | |
669 if (advanced) | |
670 { | |
671 bar_exif_advanced_build_view(eb); | |
672 gtk_widget_show(eb->advanced_scrolled); | |
673 } | |
674 else | |
675 { | |
676 gtk_widget_show(eb->scrolled); | |
677 } | |
678 | |
138 | 679 eb->fd = file_data_ref(fd); |
9 | 680 bar_exif_update(eb); |
681 | |
682 return eb->vbox; | |
683 } |