annotate src/bar_exif.c @ 1804:2cc889b20a9e

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