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