Mercurial > geeqie.yaz
annotate src/bar_exif.c @ 1051:2a02fa29478b
The comment section in the meta file is the last section. However it do
not accept comment lines starting with a '['. This patch will fix that.
- patch by Klaus Ethgen
author | nadvornik |
---|---|
date | Mon, 29 Sep 2008 21:17:19 +0000 |
parents | 9962b24b6b43 |
children | 338c21c87ff5 |
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" | |
1022
9962b24b6b43
Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents:
902
diff
changeset
|
18 #include "filedata.h" |
902 | 19 #include "history_list.h" |
1022
9962b24b6b43
Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents:
902
diff
changeset
|
20 #include "misc.h" |
9 | 21 #include "ui_misc.h" |
22 | |
23 #include <math.h> | |
24 | |
25 #define EXIF_BAR_SIZE_INCREMENT 48 | |
26 #define EXIF_BAR_ARROW_SIZE 7 | |
27 | |
28 #define EXIF_BAR_CUSTOM_COUNT 20 | |
29 | |
48
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
30 #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
|
31 |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
32 ExifUI ExifUIList[]={ |
566
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.Camera"}, |
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.DateTime"}, |
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.ShutterSpeed"}, |
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.Aperture"}, |
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.ExposureBias"}, |
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.ISOSpeedRating"}, |
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.FocalLength"}, |
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.FocalLength35mmFilm"}, |
db08ccd54169
Change the prefix of formatted exif tags to a more explicit "formatted." prefix
zas_
parents:
550
diff
changeset
|
41 { 0, 0, EXIF_UI_IFSET, "formatted.Flash"}, |
325 | 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"}, | |
566
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.ColorProfile"}, |
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.SubjectDistance"}, |
db08ccd54169
Change the prefix of formatted exif tags to a more explicit "formatted." prefix
zas_
parents:
550
diff
changeset
|
47 { 0, 0, EXIF_UI_IFSET, "formatted.Resolution"}, |
325 | 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 | |
144 static void bar_exif_sensitive(ExifBar *eb, gint enable) | |
145 { | |
146 gtk_widget_set_sensitive(eb->table, enable); | |
147 if (eb->advanced_scrolled) gtk_widget_set_sensitive(eb->advanced_scrolled, enable); | |
148 } | |
149 | |
150 static gint bar_exif_row_enabled(const gchar *name) | |
151 { | |
152 GList *list; | |
153 | |
895 | 154 if (!name) return FALSE; |
155 | |
9 | 156 list = history_list_get_by_key("exif_extras"); |
157 while (list) | |
158 { | |
895 | 159 if (strcmp(name, (gchar *)(list->data)) == 0) return TRUE; |
9 | 160 list = list->next; |
161 } | |
162 | |
163 return FALSE; | |
164 } | |
165 | |
166 static void bar_exif_update(ExifBar *eb) | |
167 { | |
168 ExifData *exif; | |
233 | 169 gint i; |
9 | 170 |
449 | 171 exif = exif_read_fd(eb->fd); |
9 | 172 |
173 if (!exif) | |
174 { | |
175 bar_exif_sensitive(eb, FALSE); | |
176 return; | |
177 } | |
178 | |
179 bar_exif_sensitive(eb, TRUE); | |
180 | |
181 if (GTK_WIDGET_VISIBLE(eb->scrolled)) | |
182 { | |
183 GList *list; | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
184 for (i = 0; ExifUIList[i].key; i++) |
9 | 185 { |
186 gchar *text; | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
187 gchar *utf8_text; |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
188 |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
189 if (ExifUIList[i].current == EXIF_UI_OFF) |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
190 { |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
191 gtk_widget_hide(eb->labels[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
192 gtk_widget_hide(eb->keys[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
193 continue; |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
194 } |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
195 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
|
196 utf8_text = utf8_validate_or_convert(text); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
197 g_free(text); |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
198 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
|
199 && (!utf8_text || !*utf8_text)) |
442 | 200 { |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
201 gtk_widget_hide(eb->labels[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
202 gtk_widget_hide(eb->keys[i]); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
203 g_free(utf8_text); |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
204 continue; |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
205 } |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
206 gtk_widget_show(eb->labels[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
207 gtk_widget_show(eb->keys[i]); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
208 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
|
209 g_free(utf8_text); |
9 | 210 } |
211 | |
212 list = g_list_last(history_list_get_by_key("exif_extras")); | |
213 if (list) | |
214 { | |
215 gtk_widget_show(eb->custom_sep); | |
216 } | |
217 else | |
218 { | |
219 gtk_widget_hide(eb->custom_sep); | |
220 } | |
221 i = 0; | |
222 while (list && i < EXIF_BAR_CUSTOM_COUNT) | |
223 { | |
224 gchar *text; | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
225 gchar *utf8_text; |
9 | 226 gchar *name; |
227 gchar *buf; | |
228 | |
229 name = list->data; | |
230 list = list->prev; | |
231 | |
232 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
|
233 utf8_text = utf8_validate_or_convert(text); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
234 g_free(text); |
9 | 235 |
236 buf = g_strconcat(name, ":", NULL); | |
237 gtk_label_set_text(GTK_LABEL(eb->custom_name[i]), buf); | |
238 g_free(buf); | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
239 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
|
240 g_free(utf8_text); |
9 | 241 |
242 gtk_widget_show(eb->custom_name[i]); | |
243 gtk_widget_show(eb->custom_value[i]); | |
244 | |
245 i++; | |
246 } | |
247 while (i < EXIF_BAR_CUSTOM_COUNT) | |
248 { | |
249 gtk_widget_hide(eb->custom_name[i]); | |
250 gtk_widget_hide(eb->custom_value[i]); | |
251 i++; | |
252 } | |
253 } | |
254 | |
255 if (eb->advanced_scrolled && GTK_WIDGET_VISIBLE(eb->advanced_scrolled)) | |
256 { | |
257 GtkListStore *store; | |
258 GtkTreeIter iter; | |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
259 ExifItem *item; |
442 | 260 |
9 | 261 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(eb->listview))); |
262 gtk_list_store_clear(store); | |
263 | |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
264 item = exif_get_first_item(exif); |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
265 while (item) |
9 | 266 { |
267 gchar *tag; | |
185 | 268 gchar *tag_name; |
9 | 269 gchar *text; |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
270 gchar *utf8_text; |
9 | 271 const gchar *format; |
272 gchar *elements; | |
185 | 273 gchar *description; |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
274 gchar *utf8_description; |
9 | 275 |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
276 tag = g_strdup_printf("0x%04x", exif_item_get_tag_id(item)); |
9 | 277 tag_name = exif_item_get_tag_name(item); |
278 format = exif_item_get_format_name(item, TRUE); | |
279 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
|
280 utf8_text = utf8_validate_or_convert(text); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
281 g_free(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(""); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
285 utf8_description = utf8_validate_or_convert(description); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
286 g_free(description); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
287 |
9 | 288 gtk_list_store_append(store, &iter); |
289 gtk_list_store_set(store, &iter, | |
290 EXIF_ADVCOL_ENABLED, bar_exif_row_enabled(tag_name), | |
291 EXIF_ADVCOL_TAG, tag, | |
292 EXIF_ADVCOL_NAME, tag_name, | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
293 EXIF_ADVCOL_VALUE, utf8_text, |
9 | 294 EXIF_ADVCOL_FORMAT, format, |
295 EXIF_ADVCOL_ELEMENTS, elements, | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
296 EXIF_ADVCOL_DESCRIPTION, utf8_description, -1); |
9 | 297 g_free(tag); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
298 g_free(utf8_text); |
9 | 299 g_free(elements); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
300 g_free(utf8_description); |
185 | 301 g_free(tag_name); |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
302 item = exif_get_next_item(exif); |
9 | 303 } |
304 } | |
305 | |
844 | 306 exif_free_fd(eb->fd, exif); |
9 | 307 } |
308 | |
309 static void bar_exif_clear(ExifBar *eb) | |
310 { | |
311 gint i; | |
312 | |
313 if (!GTK_WIDGET_SENSITIVE(eb->labels[0])) return; | |
314 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
315 for (i = 0; ExifUIList[i].key; i++) |
9 | 316 { |
317 gtk_label_set_text(GTK_LABEL(eb->labels[i]), ""); | |
318 } | |
319 for (i = 0; i < EXIF_BAR_CUSTOM_COUNT; i++) | |
320 { | |
321 gtk_label_set_text(GTK_LABEL(eb->custom_value[i]), ""); | |
322 } | |
323 | |
324 if (eb->listview) | |
325 { | |
326 GtkListStore *store; | |
327 | |
328 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(eb->listview))); | |
329 gtk_list_store_clear(store); | |
330 } | |
331 } | |
332 | |
138 | 333 void bar_exif_set(GtkWidget *bar, FileData *fd) |
9 | 334 { |
335 ExifBar *eb; | |
336 | |
337 eb = g_object_get_data(G_OBJECT(bar), "bar_exif_data"); | |
338 if (!eb) return; | |
339 | |
340 /* store this, advanced view toggle needs to reload data */ | |
138 | 341 file_data_unref(eb->fd); |
342 eb->fd = file_data_ref(fd); | |
9 | 343 |
344 bar_exif_clear(eb); | |
345 bar_exif_update(eb); | |
346 } | |
347 | |
348 static void bar_exif_row_toggled_cb(GtkCellRendererToggle *toggle, const gchar *path, gpointer data) | |
349 { | |
350 GtkWidget *listview = data; | |
351 GtkTreeModel *store; | |
352 GtkTreeIter iter; | |
353 GtkTreePath *tpath; | |
354 gchar *name = NULL; | |
355 gboolean active; | |
356 | |
357 store = gtk_tree_view_get_model(GTK_TREE_VIEW(listview)); | |
358 | |
359 tpath = gtk_tree_path_new_from_string(path); | |
360 gtk_tree_model_get_iter(store, &iter, tpath); | |
361 gtk_tree_path_free(tpath); | |
362 | |
363 gtk_tree_model_get(store, &iter, EXIF_ADVCOL_ENABLED, &active, | |
364 EXIF_ADVCOL_NAME, &name, -1); | |
365 active = (!active); | |
366 | |
367 if (active && | |
368 g_list_length(history_list_get_by_key("exif_extras")) >= EXIF_BAR_CUSTOM_COUNT) | |
369 { | |
370 active = FALSE; | |
371 } | |
372 | |
373 gtk_list_store_set(GTK_LIST_STORE(store), &iter, EXIF_ADVCOL_ENABLED, active, -1); | |
374 | |
375 if (active) | |
376 { | |
377 history_list_add_to_key("exif_extras", name, EXIF_BAR_CUSTOM_COUNT); | |
378 } | |
379 else | |
380 { | |
381 history_list_item_change("exif_extras", name, NULL); | |
382 } | |
383 | |
384 g_free(name); | |
385 } | |
386 | |
387 static void bar_exif_add_column_check(GtkWidget *listview, const gchar *title, gint n) | |
388 { | |
389 GtkTreeViewColumn *column; | |
390 GtkCellRenderer *renderer; | |
391 | |
392 column = gtk_tree_view_column_new(); | |
393 gtk_tree_view_column_set_title(column, title); | |
394 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); | |
395 | |
396 renderer = gtk_cell_renderer_toggle_new(); | |
397 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
398 gtk_tree_view_column_add_attribute(column, renderer, "active", n); | |
399 gtk_tree_view_append_column(GTK_TREE_VIEW(listview), column); | |
400 | |
401 g_signal_connect(G_OBJECT(renderer), "toggled", | |
402 G_CALLBACK(bar_exif_row_toggled_cb), listview); | |
403 } | |
404 | |
48
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
405 static void bar_exif_add_column(GtkWidget *listview, const gchar *title, gint n, gint sizable) |
9 | 406 { |
407 GtkTreeViewColumn *column; | |
408 GtkCellRenderer *renderer; | |
409 | |
410 column = gtk_tree_view_column_new(); | |
411 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
|
412 |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
413 if (sizable) |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
414 { |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
415 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
|
416 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
|
417 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
|
418 } |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
419 else |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
420 { |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
421 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
|
422 } |
9 | 423 |
424 renderer = gtk_cell_renderer_text_new(); | |
425 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
426 gtk_tree_view_column_add_attribute(column, renderer, "text", n); | |
427 gtk_tree_view_append_column(GTK_TREE_VIEW(listview), column); | |
428 } | |
429 | |
430 static void bar_exif_advanced_build_view(ExifBar *eb) | |
431 { | |
432 GtkListStore *store; | |
433 | |
434 if (eb->listview) return; | |
435 | |
436 store = gtk_list_store_new(7, G_TYPE_BOOLEAN, | |
437 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, | |
438 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); | |
439 eb->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | |
440 g_object_unref(store); | |
441 | |
442 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(eb->listview), TRUE); | |
443 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(eb->listview), TRUE); | |
444 | |
445 if (eb->allow_search) | |
446 { | |
447 gtk_tree_view_set_search_column(GTK_TREE_VIEW(eb->listview), EXIF_ADVCOL_NAME); | |
448 } | |
449 else | |
450 { | |
451 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(eb->listview), FALSE); | |
452 } | |
453 | |
454 bar_exif_add_column_check(eb->listview, "", EXIF_ADVCOL_ENABLED); | |
455 | |
48
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, _("Tag"), EXIF_ADVCOL_TAG, 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, _("Name"), EXIF_ADVCOL_NAME, 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, _("Value"), EXIF_ADVCOL_VALUE, TRUE); |
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, _("Format"), EXIF_ADVCOL_FORMAT, 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, _("Elements"), EXIF_ADVCOL_ELEMENTS, FALSE); |
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
461 bar_exif_add_column(eb->listview, _("Description"), EXIF_ADVCOL_DESCRIPTION, FALSE); |
9 | 462 |
463 eb->advanced_scrolled = gtk_scrolled_window_new(NULL, NULL); | |
464 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(eb->advanced_scrolled), GTK_SHADOW_IN); | |
465 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(eb->advanced_scrolled), | |
466 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
467 gtk_box_pack_start(GTK_BOX(eb->vbox), eb->advanced_scrolled, TRUE, TRUE, 0); | |
468 gtk_container_add(GTK_CONTAINER(eb->advanced_scrolled), eb->listview); | |
469 gtk_widget_show(eb->listview); | |
470 } | |
471 | |
472 static void bar_exif_advanced_cb(GtkWidget *widget, gpointer data) | |
473 { | |
474 ExifBar *eb = data; | |
475 gint advanced; | |
476 | |
477 advanced = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
478 | |
479 if (advanced) | |
480 { | |
481 gtk_widget_hide(eb->scrolled); | |
482 bar_exif_advanced_build_view(eb); | |
483 gtk_widget_show(eb->advanced_scrolled); | |
484 } | |
485 else | |
486 { | |
487 gtk_widget_hide(eb->advanced_scrolled); | |
488 gtk_widget_show(eb->scrolled); | |
489 } | |
490 | |
491 bar_exif_update(eb); | |
492 } | |
493 | |
494 gint bar_exif_is_advanced(GtkWidget *bar) | |
495 { | |
496 ExifBar *eb; | |
497 | |
498 eb = g_object_get_data(G_OBJECT(bar), "bar_exif_data"); | |
499 if (!eb) return FALSE; | |
500 | |
501 return (eb->advanced_scrolled && GTK_WIDGET_VISIBLE(eb->advanced_scrolled)); | |
502 } | |
503 | |
504 void bar_exif_close(GtkWidget *bar) | |
505 { | |
506 ExifBar *eb; | |
507 | |
508 eb = g_object_get_data(G_OBJECT(bar), "bar_exif_data"); | |
509 if (!eb) return; | |
510 | |
511 gtk_widget_destroy(eb->vbox); | |
512 } | |
513 | |
489
3809ffa3567b
Save state and width of exif, info and sort panels to rc file.
zas_
parents:
475
diff
changeset
|
514 static void bar_exif_width(ExifBar *eb, gint val) |
9 | 515 { |
516 gint size; | |
517 | |
518 size = eb->vbox->allocation.width; | |
519 size = CLAMP(size + val, EXIF_BAR_SIZE_INCREMENT * 2, EXIF_BAR_SIZE_INCREMENT * 16); | |
520 | |
521 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
|
522 options->panels.exif.width = eb->vbox->allocation.width; |
9 | 523 } |
524 | |
525 static void bar_exif_larger(GtkWidget *widget, gpointer data) | |
526 { | |
527 ExifBar *eb = data; | |
528 | |
489
3809ffa3567b
Save state and width of exif, info and sort panels to rc file.
zas_
parents:
475
diff
changeset
|
529 bar_exif_width(eb, EXIF_BAR_SIZE_INCREMENT); |
9 | 530 } |
531 | |
532 static void bar_exif_smaller(GtkWidget *widget, gpointer data) | |
533 { | |
534 ExifBar *eb = data; | |
535 | |
489
3809ffa3567b
Save state and width of exif, info and sort panels to rc file.
zas_
parents:
475
diff
changeset
|
536 bar_exif_width(eb, -EXIF_BAR_SIZE_INCREMENT); |
9 | 537 } |
538 | |
539 static void bar_exif_destroy(GtkWidget *widget, gpointer data) | |
540 { | |
541 ExifBar *eb = data; | |
542 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
543 g_free(eb->keys); |
9 | 544 g_free(eb->labels); |
138 | 545 file_data_unref(eb->fd); |
9 | 546 g_free(eb); |
547 } | |
548 | |
138 | 549 GtkWidget *bar_exif_new(gint show_title, FileData *fd, gint advanced, GtkWidget *bounding_widget) |
9 | 550 { |
551 ExifBar *eb; | |
552 GtkWidget *table; | |
553 GtkWidget *viewport; | |
554 GtkWidget *hbox; | |
555 GtkWidget *button; | |
556 gint i; | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
557 gint exif_len; |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
558 |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
559 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
|
560 ; |
9 | 561 |
562 eb = g_new0(ExifBar, 1); | |
563 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
564 eb->keys = g_new0(GtkWidget *, exif_len); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
565 eb->labels = g_new0(GtkWidget *, exif_len); |
9 | 566 |
567 eb->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); | |
568 g_object_set_data(G_OBJECT(eb->vbox), "bar_exif_data", eb); | |
569 g_signal_connect_after(G_OBJECT(eb->vbox), "destroy", | |
570 G_CALLBACK(bar_exif_destroy), eb); | |
571 | |
572 eb->allow_search = !show_title; | |
573 | |
574 if (show_title) | |
575 { | |
576 GtkWidget *box; | |
577 GtkWidget *label; | |
578 GtkWidget *button; | |
579 GtkWidget *arrow; | |
580 | |
581 box = gtk_hbox_new(FALSE, 0); | |
582 | |
583 label = sizer_new(eb->vbox, bounding_widget, SIZER_POS_LEFT); | |
584 sizer_set_limits(label, EXIF_BAR_SIZE_INCREMENT * 2, -1, -1 , -1); | |
585 gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); | |
586 gtk_widget_show(label); | |
587 | |
588 label = gtk_label_new(_("Exif")); | |
589 pref_label_bold(label, TRUE, FALSE); | |
590 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0); | |
591 gtk_widget_show(label); | |
592 | |
593 button = gtk_button_new(); | |
594 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
595 g_signal_connect(G_OBJECT(button), "clicked", | |
596 G_CALLBACK(bar_exif_smaller), eb); | |
597 gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0); | |
598 arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE); | |
599 gtk_widget_set_size_request(arrow, EXIF_BAR_ARROW_SIZE, EXIF_BAR_ARROW_SIZE); | |
600 gtk_container_add(GTK_CONTAINER(button), arrow); | |
601 gtk_widget_show(arrow); | |
602 gtk_widget_show(button); | |
603 | |
604 button = gtk_button_new(); | |
605 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
606 g_signal_connect(G_OBJECT(button), "clicked", | |
607 G_CALLBACK(bar_exif_larger), eb); | |
608 gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0); | |
609 arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE); | |
610 gtk_widget_set_size_request(arrow, EXIF_BAR_ARROW_SIZE, EXIF_BAR_ARROW_SIZE); | |
611 gtk_container_add(GTK_CONTAINER(button), arrow); | |
612 gtk_widget_show(arrow); | |
613 gtk_widget_show(button); | |
614 | |
615 gtk_box_pack_start(GTK_BOX(eb->vbox), box, FALSE, FALSE, 0); | |
616 gtk_widget_show(box); | |
617 } | |
618 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
619 |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
620 table = gtk_table_new(2, exif_len + 1 + EXIF_BAR_CUSTOM_COUNT, FALSE); |
9 | 621 |
622 eb->table = table; | |
623 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
624 for (i = 0; ExifUIList[i].key; i++) |
9 | 625 { |
626 const gchar *text; | |
627 | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
628 text = exif_get_description_by_key(ExifUIList[i].key); |
442 | 629 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
|
630 &eb->keys[i]); |
9 | 631 } |
632 | |
633 eb->custom_sep = gtk_hseparator_new(); | |
634 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
|
635 exif_len, exif_len + 1, |
9 | 636 GTK_FILL, GTK_FILL, 2, 2); |
637 | |
638 for (i = 0; i < EXIF_BAR_CUSTOM_COUNT; i++) | |
639 { | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
640 table_add_line_custom(table, 0, exif_len + 1 + i, |
9 | 641 "", "", &eb->custom_name[i], &eb->custom_value[i]); |
642 } | |
643 | |
644 eb->scrolled = gtk_scrolled_window_new(NULL, NULL); | |
645 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(eb->scrolled), | |
646 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
647 | |
648 viewport = gtk_viewport_new(NULL, NULL); | |
649 gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE); | |
650 gtk_container_add(GTK_CONTAINER(eb->scrolled), viewport); | |
651 gtk_widget_show(viewport); | |
652 | |
653 gtk_container_add(GTK_CONTAINER(viewport), table); | |
654 gtk_widget_show(table); | |
655 | |
656 gtk_box_pack_start(GTK_BOX(eb->vbox), eb->scrolled, TRUE, TRUE, 0); | |
657 | |
658 hbox = gtk_hbox_new(FALSE, PREF_PAD_SPACE); | |
659 gtk_box_pack_end(GTK_BOX(eb->vbox), hbox, FALSE, FALSE, 0); | |
660 gtk_widget_show(hbox); | |
661 | |
662 button = gtk_check_button_new_with_label(_("Advanced view")); | |
663 if (advanced) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); | |
664 g_signal_connect(G_OBJECT(button), "toggled", | |
665 G_CALLBACK(bar_exif_advanced_cb), eb); | |
666 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
667 gtk_widget_show(button); | |
668 | |
669 eb->advanced_scrolled = NULL; | |
670 eb->listview = NULL; | |
671 | |
672 if (advanced) | |
673 { | |
674 bar_exif_advanced_build_view(eb); | |
675 gtk_widget_show(eb->advanced_scrolled); | |
676 } | |
677 else | |
678 { | |
679 gtk_widget_show(eb->scrolled); | |
680 } | |
681 | |
138 | 682 eb->fd = file_data_ref(fd); |
9 | 683 bar_exif_update(eb); |
684 | |
685 return eb->vbox; | |
686 } |