Mercurial > geeqie
annotate src/bar_exif.c @ 902:c414002a1f27
Move history_list_*() functions to separate files:
history_list.c and history_list.h.
author | zas_ |
---|---|
date | Sun, 20 Jul 2008 14:56:32 +0000 |
parents | b48c366d5707 |
children | 9962b24b6b43 |
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" | |
902 | 18 #include "history_list.h" |
9 | 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 | |
895 | 153 if (!name) return FALSE; |
154 | |
9 | 155 list = history_list_get_by_key("exif_extras"); |
156 while (list) | |
157 { | |
895 | 158 if (strcmp(name, (gchar *)(list->data)) == 0) return TRUE; |
9 | 159 list = list->next; |
160 } | |
161 | |
162 return FALSE; | |
163 } | |
164 | |
165 static void bar_exif_update(ExifBar *eb) | |
166 { | |
167 ExifData *exif; | |
233 | 168 gint i; |
9 | 169 |
449 | 170 exif = exif_read_fd(eb->fd); |
9 | 171 |
172 if (!exif) | |
173 { | |
174 bar_exif_sensitive(eb, FALSE); | |
175 return; | |
176 } | |
177 | |
178 bar_exif_sensitive(eb, TRUE); | |
179 | |
180 if (GTK_WIDGET_VISIBLE(eb->scrolled)) | |
181 { | |
182 GList *list; | |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
183 for (i = 0; ExifUIList[i].key; i++) |
9 | 184 { |
185 gchar *text; | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
186 gchar *utf8_text; |
222
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 if (ExifUIList[i].current == EXIF_UI_OFF) |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
189 { |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
190 gtk_widget_hide(eb->labels[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
191 gtk_widget_hide(eb->keys[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
192 continue; |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
193 } |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
194 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
|
195 utf8_text = utf8_validate_or_convert(text); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
196 g_free(text); |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
197 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
|
198 && (!utf8_text || !*utf8_text)) |
442 | 199 { |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
200 gtk_widget_hide(eb->labels[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
201 gtk_widget_hide(eb->keys[i]); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
202 g_free(utf8_text); |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
203 continue; |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
204 } |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
205 gtk_widget_show(eb->labels[i]); |
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
206 gtk_widget_show(eb->keys[i]); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
207 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
|
208 g_free(utf8_text); |
9 | 209 } |
210 | |
211 list = g_list_last(history_list_get_by_key("exif_extras")); | |
212 if (list) | |
213 { | |
214 gtk_widget_show(eb->custom_sep); | |
215 } | |
216 else | |
217 { | |
218 gtk_widget_hide(eb->custom_sep); | |
219 } | |
220 i = 0; | |
221 while (list && i < EXIF_BAR_CUSTOM_COUNT) | |
222 { | |
223 gchar *text; | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
224 gchar *utf8_text; |
9 | 225 gchar *name; |
226 gchar *buf; | |
227 | |
228 name = list->data; | |
229 list = list->prev; | |
230 | |
231 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
|
232 utf8_text = utf8_validate_or_convert(text); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
233 g_free(text); |
9 | 234 |
235 buf = g_strconcat(name, ":", NULL); | |
236 gtk_label_set_text(GTK_LABEL(eb->custom_name[i]), buf); | |
237 g_free(buf); | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
238 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
|
239 g_free(utf8_text); |
9 | 240 |
241 gtk_widget_show(eb->custom_name[i]); | |
242 gtk_widget_show(eb->custom_value[i]); | |
243 | |
244 i++; | |
245 } | |
246 while (i < EXIF_BAR_CUSTOM_COUNT) | |
247 { | |
248 gtk_widget_hide(eb->custom_name[i]); | |
249 gtk_widget_hide(eb->custom_value[i]); | |
250 i++; | |
251 } | |
252 } | |
253 | |
254 if (eb->advanced_scrolled && GTK_WIDGET_VISIBLE(eb->advanced_scrolled)) | |
255 { | |
256 GtkListStore *store; | |
257 GtkTreeIter iter; | |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
258 ExifItem *item; |
442 | 259 |
9 | 260 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(eb->listview))); |
261 gtk_list_store_clear(store); | |
262 | |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
263 item = exif_get_first_item(exif); |
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
264 while (item) |
9 | 265 { |
266 gchar *tag; | |
185 | 267 gchar *tag_name; |
9 | 268 gchar *text; |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
269 gchar *utf8_text; |
9 | 270 const gchar *format; |
271 gchar *elements; | |
185 | 272 gchar *description; |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
273 gchar *utf8_description; |
9 | 274 |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
275 tag = g_strdup_printf("0x%04x", exif_item_get_tag_id(item)); |
9 | 276 tag_name = exif_item_get_tag_name(item); |
277 format = exif_item_get_format_name(item, TRUE); | |
278 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
|
279 utf8_text = utf8_validate_or_convert(text); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
280 g_free(text); |
176
695e1ad3b169
simplified exif.h, moved implementation-specific stuff to exif-int.h
nadvornik
parents:
138
diff
changeset
|
281 elements = g_strdup_printf("%d", exif_item_get_elements(item)); |
9 | 282 description = exif_item_get_description(item); |
182 | 283 if (!description) description = g_strdup(""); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
284 utf8_description = utf8_validate_or_convert(description); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
285 g_free(description); |
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
286 |
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, | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
292 EXIF_ADVCOL_VALUE, utf8_text, |
9 | 293 EXIF_ADVCOL_FORMAT, format, |
294 EXIF_ADVCOL_ELEMENTS, elements, | |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
295 EXIF_ADVCOL_DESCRIPTION, utf8_description, -1); |
9 | 296 g_free(tag); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
297 g_free(utf8_text); |
9 | 298 g_free(elements); |
767
e73d30e0c896
Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents:
680
diff
changeset
|
299 g_free(utf8_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 | |
844 | 305 exif_free_fd(eb->fd, exif); |
9 | 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 } |