Mercurial > geeqie.yaz
annotate src/bar_exif.c @ 1542:ddb7aefb45cb
improved default keyword tree
author | nadvornik |
---|---|
date | Sat, 11 Apr 2009 21:28:46 +0000 |
parents | 1e2737565cb7 |
children | c8ac214a2fca |
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 * |
1380 | 6 * Author: Vladimir Nadvornik |
9 | 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" |
1378 | 23 #include "ui_menu.h" |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
24 #include "bar.h" |
1309 | 25 #include "rcfile.h" |
1374 | 26 #include "dnd.h" |
1380 | 27 #include "ui_utildlg.h" |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
28 |
9 | 29 |
30 #include <math.h> | |
31 | |
1366
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
32 #define MIN_HEIGHT 25 |
9 | 33 /* |
34 *------------------------------------------------------------------- | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
35 * EXIF widget |
9 | 36 *------------------------------------------------------------------- |
37 */ | |
38 | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
39 typedef struct _ExifEntry ExifEntry; |
1459 | 40 typedef struct _PaneExifData PaneExifData; |
41 | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
42 struct _ExifEntry |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
43 { |
1374 | 44 GtkWidget *ebox; |
1459 | 45 GtkWidget *box; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
46 GtkWidget *title_label; |
1459 | 47 GtkWidget *value_widget; |
1350
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 gchar *key; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
50 gchar *title; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
51 gboolean if_set; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
52 gboolean auto_title; |
1459 | 53 gboolean editable; |
54 | |
55 PaneExifData *ped; | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
56 }; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
57 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
58 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
59 struct _PaneExifData |
9 | 60 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
61 PaneData pane; |
9 | 62 GtkWidget *vbox; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
63 GtkWidget *widget; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
64 GtkSizeGroup *size_group; |
9 | 65 |
1366
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
66 gint min_height; |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
67 |
1379 | 68 gboolean all_hidden; |
1380 | 69 gboolean show_all; |
1379 | 70 |
138 | 71 FileData *fd; |
9 | 72 }; |
73 | |
1380 | 74 typedef struct _ConfDialogData ConfDialogData; |
75 struct _ConfDialogData | |
76 { | |
77 GtkWidget *widget; /* pane or entry, devidet by presenceof "pane_data" or "entry_data" */ | |
78 | |
79 /* dialog parts */ | |
1381
94eb664a7da1
do not crash if an exif entry is deleted during editing
nadvornik
parents:
1380
diff
changeset
|
80 GenericDialog *gd; |
1380 | 81 GtkWidget *key_entry; |
82 GtkWidget *title_entry; | |
83 gboolean if_set; | |
1459 | 84 gboolean editable; |
1380 | 85 }; |
86 | |
1374 | 87 static void bar_pane_exif_entry_dnd_init(GtkWidget *entry); |
1379 | 88 static void bar_pane_exif_entry_update_title(ExifEntry *ee); |
89 static void bar_pane_exif_update(PaneExifData *ped); | |
1380 | 90 static gboolean bar_pane_exif_menu_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data); |
1459 | 91 static void bar_pane_exif_notify_cb(FileData *fd, NotifyType type, gpointer data); |
92 | |
93 | |
94 static void bar_pane_exif_entry_changed(GtkEntry *text_entry, gpointer data) | |
95 { | |
96 ExifEntry *ee = data; | |
97 gchar *text; | |
98 if (!ee->ped->fd) return; | |
99 | |
100 text = text_widget_text_pull(ee->value_widget); | |
101 metadata_write_string(ee->ped->fd, ee->key, text); | |
102 g_free(text); | |
103 } | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
104 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
105 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
|
106 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
107 ExifEntry *ee = data; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
108 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
109 g_free(ee->key); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
110 g_free(ee->title); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
111 g_free(ee); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
112 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
113 |
1459 | 114 static void bar_pane_exif_setup_entry_box(PaneExifData *ped, ExifEntry *ee) |
115 { | |
116 gboolean horizontal = !ee->editable; | |
117 gboolean editable = ee->editable; | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
118 |
1459 | 119 if (ee->box) gtk_widget_destroy(ee->box); |
120 | |
121 ee->box = horizontal ? gtk_hbox_new(FALSE, 0) : gtk_vbox_new(FALSE, 0); | |
122 gtk_container_add(GTK_CONTAINER(ee->ebox), ee->box); | |
123 gtk_widget_show(ee->box); | |
124 | |
125 ee->title_label = gtk_label_new(NULL); | |
126 gtk_misc_set_alignment(GTK_MISC(ee->title_label), horizontal ? 1.0 : 0.0, 0.5); | |
127 gtk_size_group_add_widget(ped->size_group, ee->title_label); | |
128 gtk_box_pack_start(GTK_BOX(ee->box), ee->title_label, FALSE, TRUE, 0); | |
129 gtk_widget_show(ee->title_label); | |
130 | |
131 if (editable) | |
132 { | |
133 ee->value_widget = gtk_entry_new(); | |
134 g_signal_connect(G_OBJECT(ee->value_widget), "changed", | |
135 G_CALLBACK(bar_pane_exif_entry_changed), ee); | |
136 | |
137 } | |
138 else | |
139 { | |
140 ee->value_widget = gtk_label_new(NULL); | |
141 // gtk_label_set_width_chars(GTK_LABEL(ee->value_widget), 20); | |
142 gtk_label_set_ellipsize(GTK_LABEL(ee->value_widget), PANGO_ELLIPSIZE_END); | |
143 // gtk_widget_set_size_request(ee->value_widget, 100, -1); | |
144 gtk_misc_set_alignment(GTK_MISC(ee->value_widget), 0.0, 0.5); | |
145 } | |
146 | |
147 gtk_box_pack_start(GTK_BOX(ee->box), ee->value_widget, TRUE, TRUE, 1); | |
148 gtk_widget_show(ee->value_widget); | |
149 } | |
150 | |
151 static GtkWidget *bar_pane_exif_add_entry(PaneExifData *ped, const gchar *key, const gchar *title, gboolean if_set, gboolean editable) | |
9 | 152 { |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
153 ExifEntry *ee = g_new0(ExifEntry, 1); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
154 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
155 ee->key = g_strdup(key); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
156 if (title && title[0]) |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
157 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
158 ee->title = g_strdup(title); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
159 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
160 else |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
161 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
162 ee->title = exif_get_description_by_key(key); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
163 ee->auto_title = TRUE; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
164 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
165 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
166 ee->if_set = if_set; |
1459 | 167 ee->editable = editable; |
168 | |
169 ee->ped = ped; | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
170 |
1374 | 171 ee->ebox = gtk_event_box_new(); |
172 g_object_set_data(G_OBJECT(ee->ebox), "entry_data", ee); | |
173 g_signal_connect_after(G_OBJECT(ee->ebox), "destroy", | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
174 G_CALLBACK(bar_pane_exif_entry_destroy), ee); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
175 |
1378 | 176 gtk_box_pack_start(GTK_BOX(ped->vbox), ee->ebox, FALSE, FALSE, 0); |
1374 | 177 |
178 bar_pane_exif_entry_dnd_init(ee->ebox); | |
1380 | 179 g_signal_connect(ee->ebox, "button_press_event", G_CALLBACK(bar_pane_exif_menu_cb), ped); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
180 |
1459 | 181 bar_pane_exif_setup_entry_box(ped, ee); |
182 | |
1379 | 183 bar_pane_exif_entry_update_title(ee); |
184 bar_pane_exif_update(ped); | |
185 | |
1374 | 186 return ee->ebox; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
187 } |
1374 | 188 |
189 static void bar_pane_exif_reparent_entry(GtkWidget *entry, GtkWidget *pane) | |
190 { | |
191 PaneExifData *ped = g_object_get_data(G_OBJECT(pane), "pane_data"); | |
1459 | 192 PaneExifData *old_ped; |
1374 | 193 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data"); |
1419 | 194 |
1459 | 195 if (!ped || !ee) return; |
196 | |
197 old_ped = ee->ped; | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
198 |
1374 | 199 g_object_ref(entry); |
200 | |
201 gtk_size_group_remove_widget(old_ped->size_group, ee->title_label); | |
202 gtk_container_remove(GTK_CONTAINER(old_ped->vbox), entry); | |
203 | |
1459 | 204 ee->ped = ped; |
1374 | 205 gtk_size_group_add_widget(ped->size_group, ee->title_label); |
1378 | 206 gtk_box_pack_start(GTK_BOX(ped->vbox), entry, FALSE, FALSE, 0); |
1374 | 207 } |
208 | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
209 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
|
210 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
211 gchar *markup; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
212 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
213 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
|
214 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
|
215 g_free(markup); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
216 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
217 |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
218 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
|
219 { |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
220 gchar *text; |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
221 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data"); |
1419 | 222 |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
223 if (!ee) return; |
1459 | 224 text = metadata_read_string(ped->fd, ee->key, ee->editable ? METADATA_PLAIN : METADATA_FORMATTED); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
225 |
1459 | 226 if (!ped->show_all && ee->if_set && !ee->editable && (!text || !*text)) |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
227 { |
1459 | 228 gtk_label_set_text(GTK_LABEL(ee->value_widget), NULL); |
1374 | 229 gtk_widget_hide(entry); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
230 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
231 else |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
232 { |
1459 | 233 if (ee->editable) |
234 { | |
235 g_signal_handlers_block_by_func(ee->value_widget, bar_pane_exif_entry_changed, ee); | |
236 gtk_entry_set_text(GTK_ENTRY(ee->value_widget), text ? text : ""); | |
237 g_signal_handlers_unblock_by_func(ee->value_widget, bar_pane_exif_entry_changed, ee); | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
238 #if GTK_CHECK_VERSION(2,12,0) |
1459 | 239 gtk_widget_set_tooltip_text(ee->box, NULL); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
240 #endif |
1459 | 241 } |
242 else | |
243 { | |
244 gtk_label_set_text(GTK_LABEL(ee->value_widget), text); | |
245 #if GTK_CHECK_VERSION(2,12,0) | |
246 gtk_widget_set_tooltip_text(ee->box, text); | |
247 #endif | |
248 } | |
1374 | 249 gtk_widget_show(entry); |
1379 | 250 ped->all_hidden = FALSE; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
251 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
252 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
253 g_free(text); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
254 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
255 if (update_title) bar_pane_exif_entry_update_title(ee); |
9 | 256 } |
257 | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
258 static void bar_pane_exif_update(PaneExifData *ped) |
9 | 259 { |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
260 GList *list, *work; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
261 |
1379 | 262 ped->all_hidden = TRUE; |
9 | 263 |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
264 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
|
265 work = list; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
266 while (work) |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
267 { |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
268 GtkWidget *entry = work->data; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
269 work = work->next; |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
270 |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
271 bar_pane_exif_update_entry(ped, entry, FALSE); |
9 | 272 } |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
273 g_list_free(list); |
1379 | 274 |
275 gtk_widget_set_sensitive(ped->pane.title, !ped->all_hidden); | |
9 | 276 } |
277 | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
278 void bar_pane_exif_set_fd(GtkWidget *widget, FileData *fd) |
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_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
|
283 if (!ped) return; |
9 | 284 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
285 file_data_unref(ped->fd); |
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
286 ped->fd = file_data_ref(fd); |
9 | 287 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
288 bar_pane_exif_update(ped); |
9 | 289 } |
290 | |
1459 | 291 gint bar_pane_exif_event(GtkWidget *bar, GdkEvent *event) |
292 { | |
293 PaneExifData *ped; | |
294 gboolean ret = FALSE; | |
295 GList *list, *work; | |
296 | |
297 ped = g_object_get_data(G_OBJECT(bar), "pane_data"); | |
298 if (!ped) return FALSE; | |
299 | |
300 list = gtk_container_get_children(GTK_CONTAINER(ped->vbox)); | |
301 work = list; | |
302 while (!ret && work) | |
303 { | |
304 GtkWidget *entry = work->data; | |
305 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data"); | |
306 work = work->next; | |
307 | |
308 if (ee->editable && GTK_WIDGET_HAS_FOCUS(ee->value_widget)) ret = gtk_widget_event(ee->value_widget, event); | |
309 } | |
310 g_list_free(list); | |
311 return ret; | |
312 } | |
313 | |
1441 | 314 static void bar_pane_exif_notify_cb(FileData *fd, NotifyType type, gpointer data) |
315 { | |
316 PaneExifData *ped = data; | |
1498 | 317 if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE | NOTIFY_METADATA)) && fd == ped->fd) |
318 { | |
319 DEBUG_1("Notify pane_exif: %s %04x", fd->path, type); | |
320 bar_pane_exif_update(ped); | |
321 } | |
1441 | 322 } |
323 | |
1459 | 324 |
1374 | 325 /* |
326 *------------------------------------------------------------------- | |
327 * dnd | |
328 *------------------------------------------------------------------- | |
329 */ | |
330 | |
331 static GtkTargetEntry bar_pane_exif_drag_types[] = { | |
332 { TARGET_APP_EXIF_ENTRY_STRING, GTK_TARGET_SAME_APP, TARGET_APP_EXIF_ENTRY }, | |
333 { "text/plain", 0, TARGET_TEXT_PLAIN } | |
334 }; | |
335 static gint n_exif_entry_drag_types = 2; | |
336 | |
337 static GtkTargetEntry bar_pane_exif_drop_types[] = { | |
338 { TARGET_APP_EXIF_ENTRY_STRING, GTK_TARGET_SAME_APP, TARGET_APP_EXIF_ENTRY }, | |
339 { "text/plain", 0, TARGET_TEXT_PLAIN } | |
340 }; | |
341 static gint n_exif_entry_drop_types = 2; | |
342 | |
343 | |
344 static void bar_pane_exif_entry_dnd_get(GtkWidget *entry, GdkDragContext *context, | |
345 GtkSelectionData *selection_data, guint info, | |
346 guint time, gpointer data) | |
347 { | |
348 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data"); | |
349 | |
350 switch (info) | |
351 { | |
352 case TARGET_APP_EXIF_ENTRY: | |
353 gtk_selection_data_set(selection_data, selection_data->target, | |
354 8, (gpointer) &entry, sizeof(entry)); | |
355 break; | |
356 | |
357 case TARGET_TEXT_PLAIN: | |
358 default: | |
359 gtk_selection_data_set_text(selection_data, ee->key, -1); | |
360 break; | |
361 } | |
362 | |
363 } | |
364 | |
365 static void bar_pane_exif_dnd_receive(GtkWidget *pane, GdkDragContext *context, | |
366 gint x, gint y, | |
367 GtkSelectionData *selection_data, guint info, | |
368 guint time, gpointer data) | |
369 { | |
370 PaneExifData *ped; | |
371 GList *work, *list; | |
372 gint pos; | |
373 GtkWidget *new_entry = NULL; | |
1419 | 374 |
1374 | 375 ped = g_object_get_data(G_OBJECT(pane), "pane_data"); |
376 if (!ped) return; | |
377 | |
378 switch (info) | |
379 { | |
380 case TARGET_APP_EXIF_ENTRY: | |
381 new_entry = *(gpointer *)selection_data->data; | |
382 | |
383 if (new_entry->parent && new_entry->parent != ped->vbox) bar_pane_exif_reparent_entry(new_entry, pane); | |
384 | |
385 break; | |
386 default: | |
387 /* FIXME: this needs a check for valid exif keys */ | |
1459 | 388 new_entry = bar_pane_exif_add_entry(ped, (gchar *)selection_data->data, NULL, TRUE, FALSE); |
1374 | 389 break; |
390 } | |
391 | |
392 list = gtk_container_get_children(GTK_CONTAINER(ped->vbox)); | |
393 work = list; | |
394 pos = 0; | |
395 while (work) | |
396 { | |
397 gint nx, ny; | |
398 GtkWidget *entry = work->data; | |
399 work = work->next; | |
400 | |
401 if (entry == new_entry) continue; | |
402 | |
403 if (GTK_WIDGET_DRAWABLE(entry) && | |
404 gtk_widget_translate_coordinates(pane, entry, x, y, &nx, &ny) && | |
405 ny < entry->allocation.height / 2) break; | |
406 pos++; | |
407 } | |
408 g_list_free(list); | |
409 | |
410 gtk_box_reorder_child(GTK_BOX(ped->vbox), new_entry, pos); | |
411 } | |
412 | |
1393 | 413 static void bar_pane_exif_entry_dnd_begin(GtkWidget *entry, GdkDragContext *context, gpointer data) |
1374 | 414 { |
1393 | 415 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data"); |
1419 | 416 |
1393 | 417 if (!ee) return; |
418 dnd_set_drag_label(entry, context, ee->key); | |
1374 | 419 } |
420 | |
421 static void bar_pane_exif_entry_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) | |
422 { | |
423 } | |
424 | |
425 static void bar_pane_exif_entry_dnd_init(GtkWidget *entry) | |
426 { | |
427 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data"); | |
428 | |
429 gtk_drag_source_set(entry, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, | |
430 bar_pane_exif_drag_types, n_exif_entry_drag_types, | |
431 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); | |
432 g_signal_connect(G_OBJECT(entry), "drag_data_get", | |
433 G_CALLBACK(bar_pane_exif_entry_dnd_get), ee); | |
434 | |
435 g_signal_connect(G_OBJECT(entry), "drag_begin", | |
436 G_CALLBACK(bar_pane_exif_entry_dnd_begin), ee); | |
437 g_signal_connect(G_OBJECT(entry), "drag_end", | |
438 G_CALLBACK(bar_pane_exif_entry_dnd_end), ee); | |
439 } | |
440 | |
441 static void bar_pane_exif_dnd_init(GtkWidget *pane) | |
442 { | |
443 gtk_drag_dest_set(pane, | |
444 GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, | |
445 bar_pane_exif_drop_types, n_exif_entry_drop_types, | |
1392 | 446 GDK_ACTION_COPY | GDK_ACTION_MOVE); |
1374 | 447 g_signal_connect(G_OBJECT(pane), "drag_data_received", |
448 G_CALLBACK(bar_pane_exif_dnd_receive), NULL); | |
449 } | |
450 | |
1381
94eb664a7da1
do not crash if an exif entry is deleted during editing
nadvornik
parents:
1380
diff
changeset
|
451 static void bar_pane_exif_edit_close_cb(GtkWidget *widget, gpointer data) |
94eb664a7da1
do not crash if an exif entry is deleted during editing
nadvornik
parents:
1380
diff
changeset
|
452 { |
94eb664a7da1
do not crash if an exif entry is deleted during editing
nadvornik
parents:
1380
diff
changeset
|
453 GenericDialog *gd = data; |
94eb664a7da1
do not crash if an exif entry is deleted during editing
nadvornik
parents:
1380
diff
changeset
|
454 generic_dialog_close(gd); |
94eb664a7da1
do not crash if an exif entry is deleted during editing
nadvornik
parents:
1380
diff
changeset
|
455 } |
1374 | 456 |
1380 | 457 static void bar_pane_exif_edit_destroy_cb(GtkWidget *widget, gpointer data) |
458 { | |
459 ConfDialogData *cdd = data; | |
1381
94eb664a7da1
do not crash if an exif entry is deleted during editing
nadvornik
parents:
1380
diff
changeset
|
460 g_signal_handlers_disconnect_by_func(cdd->widget, G_CALLBACK(bar_pane_exif_edit_close_cb), cdd->gd); |
1380 | 461 g_free(cdd); |
462 } | |
1378 | 463 |
1380 | 464 static void bar_pane_exif_edit_cancel_cb(GenericDialog *gd, gpointer data) |
465 { | |
466 } | |
467 | |
468 static void bar_pane_exif_edit_ok_cb(GenericDialog *gd, gpointer data) | |
469 { | |
470 ConfDialogData *cdd = data; | |
471 | |
472 /* either one or the other */ | |
473 PaneExifData *ped = g_object_get_data(G_OBJECT(cdd->widget), "pane_data"); | |
474 ExifEntry *ee = g_object_get_data(G_OBJECT(cdd->widget), "entry_data"); | |
475 | |
476 if (ped) | |
477 { | |
478 bar_pane_exif_add_entry(ped, | |
479 gtk_entry_get_text(GTK_ENTRY(cdd->key_entry)), | |
480 gtk_entry_get_text(GTK_ENTRY(cdd->title_entry)), | |
1459 | 481 cdd->if_set, cdd->editable); |
1380 | 482 } |
1419 | 483 |
1380 | 484 if (ee) |
485 { | |
486 const gchar *title; | |
487 GtkWidget *pane = cdd->widget->parent; | |
1419 | 488 |
1380 | 489 while (pane) |
490 { | |
491 ped = g_object_get_data(G_OBJECT(pane), "pane_data"); | |
492 if (ped) break; | |
493 pane = pane->parent; | |
494 } | |
495 | |
496 if (!pane) return; | |
497 | |
498 g_free(ee->key); | |
499 ee->key = g_strdup(gtk_entry_get_text(GTK_ENTRY(cdd->key_entry))); | |
500 title = gtk_entry_get_text(GTK_ENTRY(cdd->title_entry)); | |
501 if (strcmp(ee->title, title) != 0) | |
502 { | |
503 g_free(ee->title); | |
504 ee->title = g_strdup(title); | |
505 ee->auto_title = FALSE; | |
506 } | |
507 | |
508 ee->if_set = cdd->if_set; | |
1459 | 509 ee->editable = cdd->editable; |
510 | |
511 bar_pane_exif_setup_entry_box(ped, ee); | |
1380 | 512 |
513 bar_pane_exif_entry_update_title(ee); | |
514 bar_pane_exif_update(ped); | |
515 } | |
516 } | |
517 | |
518 static void bar_pane_exif_conf_dialog(GtkWidget *widget) | |
519 { | |
520 ConfDialogData *cdd; | |
521 GenericDialog *gd; | |
522 GtkWidget *table; | |
523 | |
524 /* the widget can be either ExifEntry (for editing) or Pane (for new entry) | |
525 we can decide it by the attached data */ | |
526 ExifEntry *ee = g_object_get_data(G_OBJECT(widget), "entry_data"); | |
527 | |
528 cdd = g_new0(ConfDialogData, 1); | |
529 | |
530 cdd->widget = widget; | |
531 | |
532 | |
533 cdd->if_set = ee ? ee->if_set : TRUE; | |
1459 | 534 cdd->editable = ee ? ee->editable : FALSE; |
535 | |
1381
94eb664a7da1
do not crash if an exif entry is deleted during editing
nadvornik
parents:
1380
diff
changeset
|
536 cdd->gd = gd = generic_dialog_new(ee ? _("Configure entry") : _("Add entry"), "exif_entry_edit", |
1380 | 537 widget, TRUE, |
538 bar_pane_exif_edit_cancel_cb, cdd); | |
539 g_signal_connect(G_OBJECT(gd->dialog), "destroy", | |
540 G_CALLBACK(bar_pane_exif_edit_destroy_cb), cdd); | |
541 | |
1381
94eb664a7da1
do not crash if an exif entry is deleted during editing
nadvornik
parents:
1380
diff
changeset
|
542 /* in case the entry is deleted during editing */ |
94eb664a7da1
do not crash if an exif entry is deleted during editing
nadvornik
parents:
1380
diff
changeset
|
543 g_signal_connect(G_OBJECT(widget), "destroy", |
94eb664a7da1
do not crash if an exif entry is deleted during editing
nadvornik
parents:
1380
diff
changeset
|
544 G_CALLBACK(bar_pane_exif_edit_close_cb), gd); |
94eb664a7da1
do not crash if an exif entry is deleted during editing
nadvornik
parents:
1380
diff
changeset
|
545 |
1380 | 546 generic_dialog_add_message(gd, NULL, ee ? _("Configure entry") : _("Add entry"), NULL); |
547 | |
548 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, | |
549 bar_pane_exif_edit_ok_cb, TRUE); | |
550 | |
551 table = pref_table_new(gd->vbox, 3, 2, FALSE, TRUE); | |
552 pref_table_label(table, 0, 0, _("Key:"), 1.0); | |
553 | |
554 cdd->key_entry = gtk_entry_new(); | |
555 gtk_widget_set_size_request(cdd->key_entry, 300, -1); | |
556 if (ee) gtk_entry_set_text(GTK_ENTRY(cdd->key_entry), ee->key); | |
557 gtk_table_attach_defaults(GTK_TABLE(table), cdd->key_entry, 1, 2, 0, 1); | |
558 generic_dialog_attach_default(gd, cdd->key_entry); | |
559 gtk_widget_show(cdd->key_entry); | |
560 | |
561 pref_table_label(table, 0, 1, _("Title:"), 1.0); | |
562 | |
563 cdd->title_entry = gtk_entry_new(); | |
564 gtk_widget_set_size_request(cdd->title_entry, 300, -1); | |
565 if (ee) gtk_entry_set_text(GTK_ENTRY(cdd->title_entry), ee->title); | |
566 gtk_table_attach_defaults(GTK_TABLE(table), cdd->title_entry, 1, 2, 1, 2); | |
567 generic_dialog_attach_default(gd, cdd->title_entry); | |
568 gtk_widget_show(cdd->title_entry); | |
569 | |
570 pref_checkbox_new_int(gd->vbox, _("Show only if set"), cdd->if_set, &cdd->if_set); | |
1459 | 571 pref_checkbox_new_int(gd->vbox, _("Editable (supported only for XMP)"), cdd->editable, &cdd->editable); |
1380 | 572 |
573 gtk_widget_show(gd->dialog); | |
574 } | |
575 | |
576 static void bar_pane_exif_conf_dialog_cb(GtkWidget *menu_widget, gpointer data) | |
577 { | |
578 GtkWidget *widget = data; | |
579 bar_pane_exif_conf_dialog(widget); | |
580 } | |
581 | |
582 static void bar_pane_exif_delete_entry_cb(GtkWidget *menu_widget, gpointer data) | |
583 { | |
584 GtkWidget *entry = data; | |
585 gtk_widget_destroy(entry); | |
586 } | |
587 | |
588 static void bar_pane_exif_toggle_show_all_cb(GtkWidget *menu_widget, gpointer data) | |
589 { | |
590 PaneExifData *ped = data; | |
591 ped->show_all = !ped->show_all; | |
592 bar_pane_exif_update(ped); | |
593 } | |
594 | |
595 static void bar_pane_exif_menu_popup(GtkWidget *widget, PaneExifData *ped) | |
1378 | 596 { |
597 GtkWidget *menu; | |
1380 | 598 /* the widget can be either ExifEntry (for editing) or Pane (for new entry) |
599 we can decide it by the attached data */ | |
600 ExifEntry *ee = g_object_get_data(G_OBJECT(widget), "entry_data"); | |
1378 | 601 |
602 menu = popup_menu_short_lived(); | |
603 | |
1380 | 604 if (ee) |
605 { | |
606 /* for the entry */ | |
607 gchar *conf = g_strdup_printf(_("Configure \"%s\""), ee->title); | |
608 gchar *del = g_strdup_printf(_("Delete \"%s\""), ee->title); | |
1419 | 609 |
1380 | 610 menu_item_add_stock(menu, conf, GTK_STOCK_EDIT, G_CALLBACK(bar_pane_exif_conf_dialog_cb), widget); |
611 menu_item_add_stock(menu, del, GTK_STOCK_DELETE, G_CALLBACK(bar_pane_exif_delete_entry_cb), widget); | |
612 menu_item_add_divider(menu); | |
1419 | 613 |
1380 | 614 g_free(conf); |
615 g_free(del); | |
616 } | |
1419 | 617 |
1380 | 618 /* for the pane */ |
619 menu_item_add_stock(menu, _("Add entry"), GTK_STOCK_ADD, G_CALLBACK(bar_pane_exif_conf_dialog_cb), ped->widget); | |
620 menu_item_add_check(menu, _("Show hidden entries"), ped->show_all, G_CALLBACK(bar_pane_exif_toggle_show_all_cb), ped); | |
621 | |
622 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME); | |
1378 | 623 } |
624 | |
625 static gboolean bar_pane_exif_menu_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) | |
626 { | |
1380 | 627 PaneExifData *ped = data; |
1378 | 628 if (bevent->button == MOUSE_BUTTON_RIGHT) |
629 { | |
1380 | 630 bar_pane_exif_menu_popup(widget, ped); |
1378 | 631 return TRUE; |
632 } | |
633 return FALSE; | |
634 } | |
635 | |
1459 | 636 |
637 | |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
638 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
|
639 { |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
640 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
|
641 if (!ee) return; |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
642 |
1461 | 643 WRITE_NL(); WRITE_STRING("<entry "); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
644 WRITE_CHAR(*ee, key); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
645 if (!ee->auto_title) WRITE_CHAR(*ee, title); |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
646 WRITE_BOOL(*ee, if_set); |
1459 | 647 WRITE_BOOL(*ee, editable); |
1461 | 648 WRITE_STRING("/>"); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
649 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
650 |
1309 | 651 static void bar_pane_exif_write_config(GtkWidget *pane, GString *outstr, gint indent) |
652 { | |
653 PaneExifData *ped; | |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
654 GList *work, *list; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
655 |
1309 | 656 ped = g_object_get_data(G_OBJECT(pane), "pane_data"); |
657 if (!ped) return; | |
658 | |
1461 | 659 WRITE_NL(); WRITE_STRING("<pane_exif "); |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
660 write_char_option(outstr, indent, "id", ped->pane.id); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
661 write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(ped->pane.title))); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
662 WRITE_BOOL(ped->pane, expanded); |
1461 | 663 WRITE_STRING(">"); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
664 indent++; |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
665 |
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
666 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
|
667 work = list; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
668 while (work) |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
669 { |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
670 GtkWidget *entry = work->data; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
671 work = work->next; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
672 |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
673 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
|
674 } |
1352
d9197358ec5a
do not use separate list of entries, rely on vbox
nadvornik
parents:
1350
diff
changeset
|
675 g_list_free(list); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
676 indent--; |
1461 | 677 WRITE_NL(); WRITE_STRING("</pane_exif>"); |
1309 | 678 } |
679 | |
680 | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
681 void bar_pane_exif_close(GtkWidget *widget) |
9 | 682 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
683 PaneExifData *ped; |
48
6948407f52a5
Fri Jun 3 18:43:46 2005 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
684 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
685 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
|
686 if (!ped) return; |
9 | 687 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
688 gtk_widget_destroy(ped->vbox); |
9 | 689 } |
690 | |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
691 static void bar_pane_exif_destroy(GtkWidget *widget, gpointer data) |
9 | 692 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
693 PaneExifData *ped = data; |
9 | 694 |
1441 | 695 file_data_unregister_notify_func(bar_pane_exif_notify_cb, ped); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
696 g_object_unref(ped->size_group); |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
697 file_data_unref(ped->fd); |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
698 g_free(ped->pane.id); |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
699 g_free(ped); |
9 | 700 } |
701 | |
1366
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
702 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
|
703 { |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
704 PaneExifData *ped = data; |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
705 if (requisition->height < ped->min_height) |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
706 { |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
707 requisition->height = ped->min_height; |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
708 } |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
709 } |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
710 |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
711 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
|
712 { |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
713 PaneExifData *ped = data; |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
714 ped->min_height = alloc->height; |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
715 } |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
716 |
1485 | 717 static GtkWidget *bar_pane_exif_new(const gchar *id, const gchar *title, gboolean expanded) |
9 | 718 { |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
719 PaneExifData *ped; |
9 | 720 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
721 ped = g_new0(PaneExifData, 1); |
9 | 722 |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
723 ped->pane.pane_set_fd = bar_pane_exif_set_fd; |
1309 | 724 ped->pane.pane_write_config = bar_pane_exif_write_config; |
1459 | 725 ped->pane.pane_event = bar_pane_exif_event; |
1389
c44f21235ffe
Use a common function bar_pane_expander_title() to set expanders title widget.
zas_
parents:
1387
diff
changeset
|
726 ped->pane.title = bar_pane_expander_title(title); |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
727 ped->pane.id = g_strdup(id); |
1309 | 728 ped->pane.expanded = expanded; |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
729 ped->pane.type = PANE_EXIF; |
9 | 730 |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
731 ped->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
1419 | 732 ped->widget = gtk_event_box_new(); |
1293
48e064b37ba6
separated "normal" and advanced exif, "Normal" exif is now in the
nadvornik
parents:
1288
diff
changeset
|
733 ped->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); |
1378 | 734 gtk_container_add(GTK_CONTAINER(ped->widget), ped->vbox); |
735 gtk_widget_show(ped->vbox); | |
736 | |
1366
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
737 ped->min_height = MIN_HEIGHT; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
738 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
|
739 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
|
740 G_CALLBACK(bar_pane_exif_destroy), ped); |
1366
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
741 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
|
742 G_CALLBACK(bar_pane_exif_size_request), ped); |
ff3cd67235af
make the exif pane grow-only - this reduces sidebar jumping
nadvornik
parents:
1352
diff
changeset
|
743 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
|
744 G_CALLBACK(bar_pane_exif_size_allocate), ped); |
1374 | 745 |
746 bar_pane_exif_dnd_init(ped->widget); | |
1378 | 747 g_signal_connect(ped->widget, "button_press_event", G_CALLBACK(bar_pane_exif_menu_cb), ped); |
222
77f1bcc6c161
various exif improvements based on patch by Uwe Ohse
nadvornik
parents:
204
diff
changeset
|
748 |
1441 | 749 file_data_register_notify_func(bar_pane_exif_notify_cb, ped, NOTIFY_PRIORITY_LOW); |
750 | |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
751 gtk_widget_show(ped->widget); |
9 | 752 |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
753 return ped->widget; |
9 | 754 } |
1309 | 755 |
756 GtkWidget *bar_pane_exif_new_from_config(const gchar **attribute_names, const gchar **attribute_values) | |
757 { | |
1471 | 758 gchar *title = NULL; |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
759 gchar *id = g_strdup("exif"); |
1309 | 760 gboolean expanded = TRUE; |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
761 GtkWidget *ret; |
1309 | 762 |
763 while (*attribute_names) | |
764 { | |
765 const gchar *option = *attribute_names++; | |
766 const gchar *value = *attribute_values++; | |
767 | |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
768 if (READ_CHAR_FULL("id", id)) continue; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
769 if (READ_CHAR_FULL("title", title)) continue; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
770 if (READ_BOOL_FULL("expanded", expanded)) continue; |
1309 | 771 |
1464 | 772 log_printf("unknown attribute %s = %s\n", option, value); |
1309 | 773 } |
774 | |
1471 | 775 bar_pane_translate_title(PANE_EXIF, id, &title); |
1485 | 776 ret = bar_pane_exif_new(id, title, expanded); |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
777 g_free(title); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
778 g_free(id); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
779 return ret; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
780 } |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
781 |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
782 void bar_pane_exif_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
783 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
784 PaneExifData *ped; |
1504 | 785 gchar *title = NULL; |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
786 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
787 ped = g_object_get_data(G_OBJECT(pane), "pane_data"); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
788 if (!ped) return; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
789 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
790 while (*attribute_names) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
791 { |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
792 const gchar *option = *attribute_names++; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
793 const gchar *value = *attribute_values++; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
794 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
795 if (READ_CHAR_FULL("title", title)) continue; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
796 if (READ_BOOL_FULL("expanded", ped->pane.expanded)) continue; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
797 if (READ_CHAR_FULL("id", ped->pane.id)) continue; |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
798 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
799 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
800 log_printf("unknown attribute %s = %s\n", option, value); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
801 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
802 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
803 if (title) |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
804 { |
1471 | 805 bar_pane_translate_title(PANE_EXIF, ped->pane.id, &title); |
1469
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
806 gtk_label_set_text(GTK_LABEL(ped->pane.title), title); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
807 g_free(title); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
808 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
809 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
810 bar_update_expander(pane); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
811 bar_pane_exif_update(ped); |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
812 } |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
813 |
607c60506863
added a possibility to update existing bars from config
nadvornik
parents:
1464
diff
changeset
|
814 |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
815 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
|
816 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
817 PaneExifData *ped; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
818 gchar *key = NULL; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
819 gchar *title = NULL; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
820 gboolean if_set = TRUE; |
1459 | 821 gboolean editable = FALSE; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
822 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
823 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
|
824 if (!ped) return; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
825 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
826 while (*attribute_names) |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
827 { |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
828 const gchar *option = *attribute_names++; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
829 const gchar *value = *attribute_values++; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
830 |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
831 if (READ_CHAR_FULL("key", key)) continue; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
832 if (READ_CHAR_FULL("title", title)) continue; |
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
833 if (READ_BOOL_FULL("if_set", if_set)) continue; |
1459 | 834 if (READ_BOOL_FULL("editable", editable)) continue; |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
835 |
1464 | 836 log_printf("unknown attribute %s = %s\n", option, value); |
1350
9d190c098b97
rewritten exif pane to support arbitrary number of entries
nadvornik
parents:
1343
diff
changeset
|
837 } |
1419 | 838 |
1459 | 839 if (key && key[0]) bar_pane_exif_add_entry(ped, key, title, if_set, editable); |
1309 | 840 } |
841 | |
842 | |
1055
1646720364cf
Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents:
1053
diff
changeset
|
843 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |