Mercurial > geeqie
annotate src/bar_exif.c @ 1373:168e5597ddc7
overlay now survives image split
author | nadvornik |
---|---|
date | Mon, 02 Mar 2009 22:48:04 +0000 |
parents | dc1768a8af01 |
children | 27ba259d3496 |
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 | |
1366
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
29 #define MIN_HEIGHT 25 |
9 | 30 /* |
31 *------------------------------------------------------------------- | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
32 * EXIF widget |
9 | 33 *------------------------------------------------------------------- |
34 */ | |
35 | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
36 typedef struct _ExifEntry ExifEntry; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
37 struct _ExifEntry |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
38 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
39 GtkWidget *hbox; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
40 GtkWidget *title_label; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
41 GtkWidget *value_label; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
42 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
43 gchar *key; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
44 gchar *title; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
45 gboolean if_set; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
46 gboolean auto_title; |
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 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
49 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
50 typedef struct _PaneExifData PaneExifData; |
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
51 struct _PaneExifData |
9 | 52 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
53 PaneData pane; |
9 | 54 GtkWidget *vbox; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
55 GtkWidget *widget; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
56 GtkSizeGroup *size_group; |
9 | 57 |
1366
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
58 gint min_height; |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
59 |
138 | 60 FileData *fd; |
9 | 61 }; |
62 | |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
63 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
|
64 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
65 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
|
66 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
67 ExifEntry *ee = data; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
68 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
69 g_free(ee->key); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
70 g_free(ee->title); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
71 g_free(ee); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
72 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
73 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
74 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
75 static void bar_pane_exif_add_entry(PaneExifData *ped, const gchar *key, const gchar *title, gint if_set) |
9 | 76 { |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
77 ExifEntry *ee = g_new0(ExifEntry, 1); |
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->key = g_strdup(key); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
80 if (title && title[0]) |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
81 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
82 ee->title = g_strdup(title); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
83 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
84 else |
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 ee->title = exif_get_description_by_key(key); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
87 ee->auto_title = TRUE; |
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 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
90 ee->if_set = if_set; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
91 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
92 ee->hbox = gtk_hbox_new(FALSE, 0); |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
93 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
|
94 g_signal_connect_after(G_OBJECT(ee->hbox), "destroy", |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
95 G_CALLBACK(bar_pane_exif_entry_destroy), ee); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
96 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
97 ee->title_label = gtk_label_new(NULL); |
1369
dc1768a8af01
Align exif labels vertically (visually better since name is now smaller than value).
zas_
parents:
1366
diff
changeset
|
98 gtk_misc_set_alignment(GTK_MISC(ee->title_label), 1.0, 0.5); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
99 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
|
100 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
|
101 gtk_widget_show(ee->title_label); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
102 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
103 ee->value_label = gtk_label_new(NULL); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
104 // 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
|
105 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
|
106 // gtk_widget_set_size_request(ee->value_label, 100, -1); |
1369
dc1768a8af01
Align exif labels vertically (visually better since name is now smaller than value).
zas_
parents:
1366
diff
changeset
|
107 gtk_misc_set_alignment(GTK_MISC(ee->value_label), 0.0, 0.5); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
108 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
|
109 gtk_widget_show(ee->value_label); |
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 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
|
112 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
|
113 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
114 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
115 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
|
116 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
117 gchar *markup; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
118 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
119 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
|
120 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
|
121 g_free(markup); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
122 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
123 |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
124 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
|
125 { |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
126 gchar *text; |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
127 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
|
128 if (!ee) return; |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
129 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
|
130 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
131 if (ee->if_set && (!text || !*text)) |
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 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
|
134 gtk_widget_hide(ee->hbox); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
135 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
136 else |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
137 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
138 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
|
139 #if GTK_CHECK_VERSION(2,12,0) |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
140 gtk_widget_set_tooltip_text(ee->hbox, text); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
141 #endif |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
142 gtk_widget_show(ee->hbox); |
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 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
145 g_free(text); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
146 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
147 if (update_title) bar_pane_exif_entry_update_title(ee); |
9 | 148 } |
149 | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
150 static void bar_pane_exif_update(PaneExifData *ped) |
9 | 151 { |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
152 GList *list, *work; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
153 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
154 #if 0 |
9 | 155 ExifData *exif; |
1288 | 156 /* 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
|
157 exif = exif_read_fd(ped->fd); |
9 | 158 |
1288 | 159 if (!exif) |
9 | 160 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
161 bar_pane_exif_sensitive(ped, FALSE); |
9 | 162 return; |
163 } | |
1069 | 164 else |
165 { | |
1288 | 166 /* we will use high level functions so we can release it for now. |
167 it will stay in the cache */ | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
168 exif_free_fd(ped->fd, exif); |
1288 | 169 exif = NULL; |
1069 | 170 } |
9 | 171 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
172 bar_pane_exif_sensitive(ped, TRUE); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
173 #endif |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
174 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
|
175 work = list; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
176 while (work) |
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 GtkWidget *entry = work->data; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
179 work = work->next; |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
180 |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
181 bar_pane_exif_update_entry(ped, entry, FALSE); |
9 | 182 } |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
183 g_list_free(list); |
9 | 184 } |
185 | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
186 void bar_pane_exif_set_fd(GtkWidget *widget, FileData *fd) |
9 | 187 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
188 PaneExifData *ped; |
9 | 189 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
190 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
|
191 if (!ped) return; |
9 | 192 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
193 file_data_unref(ped->fd); |
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
194 ped->fd = file_data_ref(fd); |
9 | 195 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
196 bar_pane_exif_update(ped); |
9 | 197 } |
198 | |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
199 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
|
200 { |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
201 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
|
202 if (!ee) return; |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
203 |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
204 WRITE_STRING("<entry\n"); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
205 indent++; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
206 WRITE_CHAR(*ee, key); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
207 if (!ee->auto_title) WRITE_CHAR(*ee, title); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
208 WRITE_BOOL(*ee, if_set); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
209 indent--; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
210 WRITE_STRING("/>\n"); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
211 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
212 |
1309 | 213 static void bar_pane_exif_write_config(GtkWidget *pane, GString *outstr, gint indent) |
214 { | |
215 PaneExifData *ped; | |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
216 GList *work, *list; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
217 |
1309 | 218 ped = g_object_get_data(G_OBJECT(pane), "pane_data"); |
219 if (!ped) return; | |
220 | |
1314 | 221 WRITE_STRING("<pane_exif\n"); |
1309 | 222 indent++; |
1343 | 223 write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(ped->pane.title))); |
1309 | 224 WRITE_BOOL(*ped, pane.expanded); |
225 indent--; | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
226 WRITE_STRING(">\n"); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
227 indent++; |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
228 |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
229 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
|
230 work = list; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
231 while (work) |
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 GtkWidget *entry = work->data; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
234 work = work->next; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
235 |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
236 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
|
237 } |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
238 g_list_free(list); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
239 indent--; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
240 WRITE_STRING("</pane_exif>\n"); |
1309 | 241 } |
242 | |
243 | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
244 void bar_pane_exif_close(GtkWidget *widget) |
9 | 245 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
246 PaneExifData *ped; |
48
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
247 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
248 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
|
249 if (!ped) return; |
9 | 250 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
251 gtk_widget_destroy(ped->vbox); |
9 | 252 } |
253 | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
254 static void bar_pane_exif_destroy(GtkWidget *widget, gpointer data) |
9 | 255 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
256 PaneExifData *ped = data; |
9 | 257 |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
258 g_object_unref(ped->size_group); |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
259 file_data_unref(ped->fd); |
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
260 g_free(ped); |
9 | 261 } |
262 | |
1366
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
263 static void bar_pane_exif_size_request(GtkWidget *pane, GtkRequisition *requisition, gpointer data) |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
264 { |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
265 PaneExifData *ped = data; |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
266 if (requisition->height < ped->min_height) |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
267 { |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
268 requisition->height = ped->min_height; |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
269 } |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
270 } |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
271 |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
272 static void bar_pane_exif_size_allocate(GtkWidget *pane, GtkAllocation *alloc, gpointer data) |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
273 { |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
274 PaneExifData *ped = data; |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
275 ped->min_height = alloc->height; |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
276 } |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
277 |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
278 GtkWidget *bar_pane_exif_new(const gchar *title, gboolean expanded, gboolean populate) |
9 | 279 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
280 PaneExifData *ped; |
9 | 281 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
282 ped = g_new0(PaneExifData, 1); |
9 | 283 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
284 ped->pane.pane_set_fd = bar_pane_exif_set_fd; |
1309 | 285 ped->pane.pane_write_config = bar_pane_exif_write_config; |
1343 | 286 ped->pane.title = gtk_label_new(title); |
1309 | 287 ped->pane.expanded = expanded; |
9 | 288 |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
289 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
|
290 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
|
291 ped->widget = ped->vbox; |
1366
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
292 ped->min_height = MIN_HEIGHT; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
293 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
|
294 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
|
295 G_CALLBACK(bar_pane_exif_destroy), ped); |
1366
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
296 g_signal_connect(G_OBJECT(ped->widget), "size-request", |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
297 G_CALLBACK(bar_pane_exif_size_request), ped); |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
298 g_signal_connect(G_OBJECT(ped->widget), "size-allocate", |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
299 G_CALLBACK(bar_pane_exif_size_allocate), ped); |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
300 |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
301 if (populate) |
9 | 302 { |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
303 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
|
304 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
|
305 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
|
306 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
|
307 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
|
308 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
|
309 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
|
310 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
|
311 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
|
312 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
|
313 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
|
314 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
|
315 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
|
316 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
|
317 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
|
318 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
|
319 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
|
320 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
|
321 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
|
322 bar_pane_exif_add_entry(ped, "Exif.Image.Copyright", NULL, TRUE); |
9 | 323 } |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
324 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
325 gtk_widget_show(ped->widget); |
9 | 326 |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
327 return ped->widget; |
9 | 328 } |
1309 | 329 |
330 GtkWidget *bar_pane_exif_new_from_config(const gchar **attribute_names, const gchar **attribute_values) | |
331 { | |
332 gchar *title = g_strdup(_("NoName")); | |
333 gboolean expanded = TRUE; | |
334 | |
335 while (*attribute_names) | |
336 { | |
337 const gchar *option = *attribute_names++; | |
338 const gchar *value = *attribute_values++; | |
339 | |
1315 | 340 if (READ_CHAR_FULL("pane.title", title)) continue; |
341 if (READ_BOOL_FULL("pane.expanded", expanded)) continue; | |
1309 | 342 |
343 | |
344 DEBUG_1("unknown attribute %s = %s", option, value); | |
345 } | |
346 | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
347 return bar_pane_exif_new(title, expanded, FALSE); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
348 } |
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 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
|
351 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
352 PaneExifData *ped; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
353 gchar *key = NULL; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
354 gchar *title = NULL; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
355 gboolean if_set = TRUE; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
356 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
357 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
|
358 if (!ped) return; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
359 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
360 while (*attribute_names) |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
361 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
362 const gchar *option = *attribute_names++; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
363 const gchar *value = *attribute_values++; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
364 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
365 if (READ_CHAR_FULL("key", key)) continue; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
366 if (READ_CHAR_FULL("title", title)) continue; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
367 if (READ_BOOL_FULL("if_set", if_set)) continue; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
368 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
369 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
370 DEBUG_1("unknown attribute %s = %s", option, value); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
371 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
372 if (key && key[0]) bar_pane_exif_add_entry(ped, key, title, if_set); |
1309 | 373 } |
374 | |
375 | |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1053
diff
changeset
|
376 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |