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