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