Mercurial > geeqie.yaz
annotate src/bar_exif.c @ 1352:d9197358ec5a
do not use separate list of entries, rely on vbox
author | nadvornik |
---|---|
date | Sun, 01 Mar 2009 11:59:32 +0000 |
parents | 9d190c098b97 |
children | ff3cd67235af |
rev | line source |
---|---|
9 | 1 /* |
196 | 2 * Geeqie |
9 | 3 * (C) 2004 John Ellis |
1284 | 4 * Copyright (C) 2008 - 2009 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" | |
1288 | 18 #include "metadata.h" |
1022
9962b24b6b43
Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents:
902
diff
changeset
|
19 #include "filedata.h" |
902 | 20 #include "history_list.h" |
1022
9962b24b6b43
Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents:
902
diff
changeset
|
21 #include "misc.h" |
9 | 22 #include "ui_misc.h" |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
23 #include "bar.h" |
1309 | 24 #include "rcfile.h" |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
25 |
9 | 26 |
27 #include <math.h> | |
28 | |
29 /* | |
30 *------------------------------------------------------------------- | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
31 * EXIF widget |
9 | 32 *------------------------------------------------------------------- |
33 */ | |
34 | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
35 typedef struct _ExifEntry ExifEntry; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
36 struct _ExifEntry |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
37 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
38 GtkWidget *hbox; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
39 GtkWidget *title_label; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
40 GtkWidget *value_label; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
41 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
42 gchar *key; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
43 gchar *title; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
44 gboolean if_set; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
45 gboolean auto_title; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
46 }; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
47 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
48 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
49 typedef struct _PaneExifData PaneExifData; |
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
50 struct _PaneExifData |
9 | 51 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
52 PaneData pane; |
9 | 53 GtkWidget *vbox; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
54 GtkWidget *widget; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
55 GtkSizeGroup *size_group; |
9 | 56 |
138 | 57 FileData *fd; |
9 | 58 }; |
59 | |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
60 static void bar_pane_exif_update_entry(PaneExifData *ped, GtkWidget *entry, gboolean update_title); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
61 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
62 static void bar_pane_exif_entry_destroy(GtkWidget *widget, gpointer data) |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
63 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
64 ExifEntry *ee = data; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
65 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
66 g_free(ee->key); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
67 g_free(ee->title); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
68 g_free(ee); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
69 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
70 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
71 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
72 static void bar_pane_exif_add_entry(PaneExifData *ped, const gchar *key, const gchar *title, gint if_set) |
9 | 73 { |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
74 ExifEntry *ee = g_new0(ExifEntry, 1); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
75 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
76 ee->key = g_strdup(key); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
77 if (title && title[0]) |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
78 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
79 ee->title = g_strdup(title); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
80 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
81 else |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
82 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
83 ee->title = exif_get_description_by_key(key); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
84 ee->auto_title = TRUE; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
85 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
86 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
87 ee->if_set = if_set; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
88 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
89 ee->hbox = gtk_hbox_new(FALSE, 0); |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
90 g_object_set_data(G_OBJECT(ee->hbox), "entry_data", ee); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
91 g_signal_connect_after(G_OBJECT(ee->hbox), "destroy", |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
92 G_CALLBACK(bar_pane_exif_entry_destroy), ee); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
93 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
94 ee->title_label = gtk_label_new(NULL); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
95 gtk_misc_set_alignment(GTK_MISC(ee->title_label), 1.0, 0.0); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
96 gtk_size_group_add_widget(ped->size_group, ee->title_label); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
97 gtk_box_pack_start(GTK_BOX(ee->hbox), ee->title_label, FALSE, TRUE, 0); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
98 gtk_widget_show(ee->title_label); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
99 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
100 ee->value_label = gtk_label_new(NULL); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
101 // gtk_label_set_width_chars(GTK_LABEL(ee->value_label), 20); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
102 gtk_label_set_ellipsize(GTK_LABEL(ee->value_label), PANGO_ELLIPSIZE_END); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
103 // gtk_widget_set_size_request(ee->value_label, 100, -1); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
104 gtk_misc_set_alignment(GTK_MISC(ee->value_label), 0.0, 0.0); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
105 gtk_box_pack_start(GTK_BOX(ee->hbox), ee->value_label, TRUE, TRUE, 1); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
106 gtk_widget_show(ee->value_label); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
107 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
108 gtk_box_pack_start(GTK_BOX(ped->vbox), ee->hbox, TRUE, TRUE, 0); |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
109 bar_pane_exif_update_entry(ped, ee->hbox, TRUE); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
110 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
111 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
112 static void bar_pane_exif_entry_update_title(ExifEntry *ee) |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
113 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
114 gchar *markup; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
115 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
116 markup = g_markup_printf_escaped("<span size='small'>%s:</span>", (ee->title) ? ee->title : "fixme"); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
117 gtk_label_set_markup(GTK_LABEL(ee->title_label), markup); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
118 g_free(markup); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
119 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
120 |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
121 static void bar_pane_exif_update_entry(PaneExifData *ped, GtkWidget *entry, gboolean update_title) |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
122 { |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
123 gchar *text; |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
124 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data"); |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
125 if (!ee) return; |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
126 text = metadata_read_string(ped->fd, ee->key, METADATA_FORMATTED); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
127 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
128 if (ee->if_set && (!text || !*text)) |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
129 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
130 gtk_label_set_text(GTK_LABEL(ee->value_label), NULL); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
131 gtk_widget_hide(ee->hbox); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
132 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
133 else |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
134 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
135 gtk_label_set_text(GTK_LABEL(ee->value_label), text); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
136 #if GTK_CHECK_VERSION(2,12,0) |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
137 gtk_widget_set_tooltip_text(ee->hbox, text); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
138 #endif |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
139 gtk_widget_show(ee->hbox); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
140 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
141 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
142 g_free(text); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
143 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
144 if (update_title) bar_pane_exif_entry_update_title(ee); |
9 | 145 } |
146 | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
147 static void bar_pane_exif_update(PaneExifData *ped) |
9 | 148 { |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
149 GList *list, *work; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
150 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
151 #if 0 |
9 | 152 ExifData *exif; |
1288 | 153 /* do we have any exif at all ? */ |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
154 exif = exif_read_fd(ped->fd); |
9 | 155 |
1288 | 156 if (!exif) |
9 | 157 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
158 bar_pane_exif_sensitive(ped, FALSE); |
9 | 159 return; |
160 } | |
1069 | 161 else |
162 { | |
1288 | 163 /* we will use high level functions so we can release it for now. |
164 it will stay in the cache */ | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
165 exif_free_fd(ped->fd, exif); |
1288 | 166 exif = NULL; |
1069 | 167 } |
9 | 168 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
169 bar_pane_exif_sensitive(ped, TRUE); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
170 #endif |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
171 list = gtk_container_get_children(GTK_CONTAINER(ped->vbox)); |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
172 work = list; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
173 while (work) |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
174 { |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
175 GtkWidget *entry = work->data; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
176 work = work->next; |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
177 |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
178 bar_pane_exif_update_entry(ped, entry, FALSE); |
9 | 179 } |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
180 g_list_free(list); |
9 | 181 } |
182 | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
183 void bar_pane_exif_set_fd(GtkWidget *widget, FileData *fd) |
9 | 184 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
185 PaneExifData *ped; |
9 | 186 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
187 ped = g_object_get_data(G_OBJECT(widget), "pane_data"); |
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
188 if (!ped) return; |
9 | 189 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
190 file_data_unref(ped->fd); |
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
191 ped->fd = file_data_ref(fd); |
9 | 192 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
193 bar_pane_exif_update(ped); |
9 | 194 } |
195 | |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
196 static void bar_pane_exif_entry_write_config(GtkWidget *entry, GString *outstr, gint indent) |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
197 { |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
198 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data"); |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
199 if (!ee) return; |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
200 |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
201 WRITE_STRING("<entry\n"); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
202 indent++; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
203 WRITE_CHAR(*ee, key); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
204 if (!ee->auto_title) WRITE_CHAR(*ee, title); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
205 WRITE_BOOL(*ee, if_set); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
206 indent--; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
207 WRITE_STRING("/>\n"); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
208 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
209 |
1309 | 210 static void bar_pane_exif_write_config(GtkWidget *pane, GString *outstr, gint indent) |
211 { | |
212 PaneExifData *ped; | |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
213 GList *work, *list; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
214 |
1309 | 215 ped = g_object_get_data(G_OBJECT(pane), "pane_data"); |
216 if (!ped) return; | |
217 | |
1314 | 218 WRITE_STRING("<pane_exif\n"); |
1309 | 219 indent++; |
1343 | 220 write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(ped->pane.title))); |
1309 | 221 WRITE_BOOL(*ped, pane.expanded); |
222 indent--; | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
223 WRITE_STRING(">\n"); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
224 indent++; |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
225 |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
226 list = gtk_container_get_children(GTK_CONTAINER(ped->vbox)); |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
227 work = list; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
228 while (work) |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
229 { |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
230 GtkWidget *entry = work->data; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
231 work = work->next; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
232 |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
233 bar_pane_exif_entry_write_config(entry, outstr, indent); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
234 } |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
235 g_list_free(list); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
236 indent--; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
237 WRITE_STRING("</pane_exif>\n"); |
1309 | 238 } |
239 | |
240 | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
241 void bar_pane_exif_close(GtkWidget *widget) |
9 | 242 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
243 PaneExifData *ped; |
48
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
244 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
245 ped = g_object_get_data(G_OBJECT(widget), "pane_data"); |
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
246 if (!ped) return; |
9 | 247 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
248 gtk_widget_destroy(ped->vbox); |
9 | 249 } |
250 | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
251 static void bar_pane_exif_destroy(GtkWidget *widget, gpointer data) |
9 | 252 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
253 PaneExifData *ped = data; |
9 | 254 |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
255 g_object_unref(ped->size_group); |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
256 file_data_unref(ped->fd); |
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
257 g_free(ped); |
9 | 258 } |
259 | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
260 GtkWidget *bar_pane_exif_new(const gchar *title, gboolean expanded, gboolean populate) |
9 | 261 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
262 PaneExifData *ped; |
9 | 263 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
264 ped = g_new0(PaneExifData, 1); |
9 | 265 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
266 ped->pane.pane_set_fd = bar_pane_exif_set_fd; |
1309 | 267 ped->pane.pane_write_config = bar_pane_exif_write_config; |
1343 | 268 ped->pane.title = gtk_label_new(title); |
1309 | 269 ped->pane.expanded = expanded; |
9 | 270 |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
271 ped->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
272 ped->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
273 ped->widget = ped->vbox; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
274 g_object_set_data(G_OBJECT(ped->widget), "pane_data", ped); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
275 g_signal_connect_after(G_OBJECT(ped->widget), "destroy", |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
276 G_CALLBACK(bar_pane_exif_destroy), ped); |
9 | 277 |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
278 |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
279 if (populate) |
9 | 280 { |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
281 bar_pane_exif_add_entry(ped, EXIF_FORMATTED("Camera"), NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
282 bar_pane_exif_add_entry(ped, EXIF_FORMATTED("DateTime"), NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
283 bar_pane_exif_add_entry(ped, EXIF_FORMATTED("ShutterSpeed"), NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
284 bar_pane_exif_add_entry(ped, EXIF_FORMATTED("Aperture"), NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
285 bar_pane_exif_add_entry(ped, EXIF_FORMATTED("ExposureBias"), NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
286 bar_pane_exif_add_entry(ped, EXIF_FORMATTED("ISOSpeedRating"), NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
287 bar_pane_exif_add_entry(ped, EXIF_FORMATTED("FocalLength"), NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
288 bar_pane_exif_add_entry(ped, EXIF_FORMATTED("FocalLength35mmFilm"), NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
289 bar_pane_exif_add_entry(ped, EXIF_FORMATTED("Flash"), NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
290 bar_pane_exif_add_entry(ped, "Exif.Photo.ExposureProgram", NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
291 bar_pane_exif_add_entry(ped, "Exif.Photo.MeteringMode", NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
292 bar_pane_exif_add_entry(ped, "Exif.Photo.LightSource", NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
293 bar_pane_exif_add_entry(ped, EXIF_FORMATTED("ColorProfile"), NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
294 bar_pane_exif_add_entry(ped, EXIF_FORMATTED("SubjectDistance"), NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
295 bar_pane_exif_add_entry(ped, EXIF_FORMATTED("Resolution"), NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
296 bar_pane_exif_add_entry(ped, "Exif.Image.Orientation", NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
297 bar_pane_exif_add_entry(ped, EXIF_FORMATTED("GPSPosition"), NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
298 bar_pane_exif_add_entry(ped, EXIF_FORMATTED("GPSAltitude"), NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
299 bar_pane_exif_add_entry(ped, "Exif.Image.ImageDescription", NULL, TRUE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
300 bar_pane_exif_add_entry(ped, "Exif.Image.Copyright", NULL, TRUE); |
9 | 301 } |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
302 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
303 gtk_widget_show(ped->widget); |
9 | 304 |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
305 return ped->widget; |
9 | 306 } |
1309 | 307 |
308 GtkWidget *bar_pane_exif_new_from_config(const gchar **attribute_names, const gchar **attribute_values) | |
309 { | |
310 gchar *title = g_strdup(_("NoName")); | |
311 gboolean expanded = TRUE; | |
312 | |
313 while (*attribute_names) | |
314 { | |
315 const gchar *option = *attribute_names++; | |
316 const gchar *value = *attribute_values++; | |
317 | |
1315 | 318 if (READ_CHAR_FULL("pane.title", title)) continue; |
319 if (READ_BOOL_FULL("pane.expanded", expanded)) continue; | |
1309 | 320 |
321 | |
322 DEBUG_1("unknown attribute %s = %s", option, value); | |
323 } | |
324 | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
325 return bar_pane_exif_new(title, expanded, FALSE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
326 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
327 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
328 void bar_pane_exif_entry_add_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values) |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
329 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
330 PaneExifData *ped; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
331 gchar *key = NULL; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
332 gchar *title = NULL; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
333 gboolean if_set = TRUE; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
334 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
335 ped = g_object_get_data(G_OBJECT(pane), "pane_data"); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
336 if (!ped) return; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
337 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
338 while (*attribute_names) |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
339 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
340 const gchar *option = *attribute_names++; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
341 const gchar *value = *attribute_values++; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
342 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
343 if (READ_CHAR_FULL("key", key)) continue; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
344 if (READ_CHAR_FULL("title", title)) continue; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
345 if (READ_BOOL_FULL("if_set", if_set)) continue; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
346 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
347 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
348 DEBUG_1("unknown attribute %s = %s", option, value); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
349 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
350 if (key && key[0]) bar_pane_exif_add_entry(ped, key, title, if_set); |
1309 | 351 } |
352 | |
353 | |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1053
diff
changeset
|
354 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |