annotate src/bar_info.c @ 1158:616fae3a801f

Unify [Shift] and [Control] notation.
author zas_
date Wed, 19 Nov 2008 21:16:27 +0000
parents 95860439070b
children 0bea79d87065
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
475
48c8e49b571c updated copyright in source files
nadvornik
parents: 449
diff changeset
4 * Copyright (C) 2008 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
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: 254
diff changeset
14 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #include "bar_info.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 "cache.h"
1022
9962b24b6b43 Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents: 995
diff changeset
18 #include "exif.h"
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 516
diff changeset
19 #include "filedata.h"
902
c414002a1f27 Move history_list_*() functions to separate files:
zas_
parents: 844
diff changeset
20 #include "history_list.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "info.h"
1022
9962b24b6b43 Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents: 995
diff changeset
22 #include "misc.h"
314
f538bddc22f4 Use secure save in comment_file_write().
zas_
parents: 288
diff changeset
23 #include "secure_save.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 #include "ui_utildlg.h"
1022
9962b24b6b43 Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents: 995
diff changeset
27 #include "utilops.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29 #define BAR_KEYWORD_AUTOSAVE_TIME 10000
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 static const gchar *keyword_favorite_defaults[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 N_("Favorite"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 N_("Todo"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 N_("People"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 N_("Places"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 N_("Art"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 N_("Nature"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 N_("Possessions"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 NULL
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 static void bar_info_keyword_update_all(void);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 * keyword / comment utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
53 static gint comment_file_write(gchar *path, GList *keywords, const gchar *comment)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 {
314
f538bddc22f4 Use secure save in comment_file_write().
zas_
parents: 288
diff changeset
55 SecureSaveInfo *ssi;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56
314
f538bddc22f4 Use secure save in comment_file_write().
zas_
parents: 288
diff changeset
57 ssi = secure_open(path);
f538bddc22f4 Use secure save in comment_file_write().
zas_
parents: 288
diff changeset
58 if (!ssi) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59
314
f538bddc22f4 Use secure save in comment_file_write().
zas_
parents: 288
diff changeset
60 secure_fprintf(ssi, "#%s comment (%s)\n\n", GQ_APPNAME, VERSION);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61
314
f538bddc22f4 Use secure save in comment_file_write().
zas_
parents: 288
diff changeset
62 secure_fprintf(ssi, "[keywords]\n");
f538bddc22f4 Use secure save in comment_file_write().
zas_
parents: 288
diff changeset
63 while (keywords && secsave_errno == SS_ERR_NONE)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 const gchar *word = keywords->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 keywords = keywords->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67
314
f538bddc22f4 Use secure save in comment_file_write().
zas_
parents: 288
diff changeset
68 secure_fprintf(ssi, "%s\n", word);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 }
314
f538bddc22f4 Use secure save in comment_file_write().
zas_
parents: 288
diff changeset
70 secure_fputc(ssi, '\n');
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71
314
f538bddc22f4 Use secure save in comment_file_write().
zas_
parents: 288
diff changeset
72 secure_fprintf(ssi, "[comment]\n");
f538bddc22f4 Use secure save in comment_file_write().
zas_
parents: 288
diff changeset
73 secure_fprintf(ssi, "%s\n", (comment) ? comment : "");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74
314
f538bddc22f4 Use secure save in comment_file_write().
zas_
parents: 288
diff changeset
75 secure_fprintf(ssi, "#end\n");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76
314
f538bddc22f4 Use secure save in comment_file_write().
zas_
parents: 288
diff changeset
77 return (secure_close(ssi) == 0);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
80 static gint comment_legacy_write(FileData *fd, GList *keywords, const gchar *comment)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 gchar *comment_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 gint success = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 /* If an existing metadata file exists, we will try writing to
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 * it's location regardless of the user's preference.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 */
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
88 comment_path = cache_find_location(CACHE_TYPE_METADATA, fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 if (comment_path && !access_file(comment_path, W_OK))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 g_free(comment_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 comment_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 if (!comment_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 gchar *comment_dir;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 mode_t mode = 0755;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
100 comment_dir = cache_get_location(CACHE_TYPE_METADATA, fd->path, FALSE, &mode);
1148
95860439070b Replace cache_ensure_dir_exists() by new recursive_mkdir_if_not_exists().
zas_
parents: 1091
diff changeset
101 if (recursive_mkdir_if_not_exists(comment_dir, mode))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 {
700
b2eb4ff74d13 Use g_build_filename() to build paths.
zas_
parents: 671
diff changeset
103 gchar *filename = g_strconcat(fd->name, GQ_CACHE_EXT_METADATA, NULL);
b2eb4ff74d13 Use g_build_filename() to build paths.
zas_
parents: 671
diff changeset
104
b2eb4ff74d13 Use g_build_filename() to build paths.
zas_
parents: 671
diff changeset
105 comment_path = g_build_filename(comment_dir, filename, NULL);
b2eb4ff74d13 Use g_build_filename() to build paths.
zas_
parents: 671
diff changeset
106 g_free(filename);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 g_free(comment_dir);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 if (comment_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 gchar *comment_pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
115 DEBUG_1("Saving comment: %s", comment_path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 comment_pathl = path_from_utf8(comment_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
119 success = comment_file_write(comment_pathl, keywords, comment);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 g_free(comment_pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 g_free(comment_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 return success;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
128 typedef enum {
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
129 MK_NONE,
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
130 MK_KEYWORDS,
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
131 MK_COMMENT
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
132 } MetadataKey;
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
133
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
134 static gint comment_file_read(gchar *path, GList **keywords, gchar **comment)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 gchar s_buf[1024];
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
138 MetadataKey key = MK_NONE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 GString *comment_build = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 f = fopen(path, "r");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 if (!f) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144
767
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
145 while (fgets(s_buf, sizeof(s_buf), f))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 {
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
147 gchar *ptr = s_buf;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
149 if (*ptr == '#') continue;
1051
2a02fa29478b The comment section in the meta file is the last section. However it do
nadvornik
parents: 1022
diff changeset
150 if (*ptr == '[' && key != MK_COMMENT)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 {
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
152 gchar *keystr = ++ptr;
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
153
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
154 key = MK_NONE;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 512
diff changeset
155 while (*ptr != ']' && *ptr != '\n' && *ptr != '\0') ptr++;
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
156
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
157 if (*ptr == ']')
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 *ptr = '\0';
604
0b203af63dbf Use g_ascii_strcasecmp() instead of strcasecmp() where ascii-only strings
zas_
parents: 595
diff changeset
160 if (g_ascii_strcasecmp(keystr, "keywords") == 0)
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
161 key = MK_KEYWORDS;
604
0b203af63dbf Use g_ascii_strcasecmp() instead of strcasecmp() where ascii-only strings
zas_
parents: 595
diff changeset
162 else if (g_ascii_strcasecmp(keystr, "comment") == 0)
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
163 key = MK_COMMENT;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 }
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
165 continue;
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
166 }
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
167
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
168 switch(key)
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
169 {
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
170 case MK_NONE:
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
171 break;
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
172 case MK_KEYWORDS:
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 {
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
174 while (*ptr != '\n' && *ptr != '\0') ptr++;
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
175 *ptr = '\0';
647
42d36db921bc Ensure that we end with UTF8 encoded comment and keywords.
zas_
parents: 646
diff changeset
176 if (strlen(s_buf) > 0)
42d36db921bc Ensure that we end with UTF8 encoded comment and keywords.
zas_
parents: 646
diff changeset
177 {
767
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
178 gchar *kw = utf8_validate_or_convert(s_buf);
647
42d36db921bc Ensure that we end with UTF8 encoded comment and keywords.
zas_
parents: 646
diff changeset
179
42d36db921bc Ensure that we end with UTF8 encoded comment and keywords.
zas_
parents: 646
diff changeset
180 list = g_list_prepend(list, kw);
42d36db921bc Ensure that we end with UTF8 encoded comment and keywords.
zas_
parents: 646
diff changeset
181 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 }
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
183 break;
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
184 case MK_COMMENT:
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 if (!comment_build) comment_build = g_string_new("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 g_string_append(comment_build, s_buf);
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
187 break;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 }
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
190
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 fclose(f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 *keywords = g_list_reverse(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 if (comment_build)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 {
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
196 if (comment)
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
197 {
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
198 gint len;
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
199 gchar *ptr = comment_build->str;
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
200
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
201 /* strip leading and trailing newlines */
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
202 while (*ptr == '\n') ptr++;
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
203 len = strlen(ptr);
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
204 while (len > 0 && ptr[len - 1] == '\n') len--;
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
205 if (ptr[len] == '\n') len++; /* keep the last one */
647
42d36db921bc Ensure that we end with UTF8 encoded comment and keywords.
zas_
parents: 646
diff changeset
206 if (len > 0)
42d36db921bc Ensure that we end with UTF8 encoded comment and keywords.
zas_
parents: 646
diff changeset
207 {
767
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
208 gchar *text = g_strndup(ptr, len);
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
209
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
210 *comment = utf8_validate_or_convert(text);
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
211 g_free(text);
647
42d36db921bc Ensure that we end with UTF8 encoded comment and keywords.
zas_
parents: 646
diff changeset
212 }
445
89f8bffbce21 comment_file_read(): rewrite the parser, drop leading and trailing newlines
zas_
parents: 442
diff changeset
213 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 g_string_free(comment_build, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
220 static gint comment_delete_legacy(FileData *fd)
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
221 {
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
222 gchar *comment_path;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
223 gchar *comment_pathl;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
224 gint success = FALSE;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
225 if (!fd) return FALSE;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
226
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
227 comment_path = cache_find_location(CACHE_TYPE_METADATA, fd->path);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
228 if (!comment_path) return FALSE;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
229
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
230 comment_pathl = path_from_utf8(comment_path);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
231
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
232 success = !unlink(comment_pathl);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
233
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
234 g_free(comment_pathl);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
235 g_free(comment_path);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
236
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
237 return success;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
238 }
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
239
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
240 static gint comment_legacy_read(FileData *fd, GList **keywords, gchar **comment)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 gchar *comment_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 gchar *comment_pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 gint success = FALSE;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
245 if (!fd) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
247 comment_path = cache_find_location(CACHE_TYPE_METADATA, fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 if (!comment_path) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 comment_pathl = path_from_utf8(comment_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
252 success = comment_file_read(comment_pathl, keywords, comment);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 g_free(comment_pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 g_free(comment_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 return success;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259
642
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
260 static GList *remove_duplicate_strings_from_list(GList *list)
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
261 {
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
262 GList *work = list;
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
263 GHashTable *hashtable = g_hash_table_new(g_str_hash, g_str_equal);
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
264 GList *newlist = NULL;
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
265
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
266 while (work)
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
267 {
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
268 gchar *key = work->data;
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
269
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
270 if (g_hash_table_lookup(hashtable, key) == NULL)
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
271 {
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
272 g_hash_table_insert(hashtable, (gpointer) key, GINT_TO_POINTER(1));
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
273 newlist = g_list_prepend(newlist, key);
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
274 }
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 902
diff changeset
275 work = work->next;
642
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
276 }
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
277
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
278 g_hash_table_destroy(hashtable);
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
279 g_list_free(list);
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
280
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
281 return g_list_reverse(newlist);
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
282 }
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
283
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
284 #define COMMENT_KEY "Xmp.dc.description"
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
285 #define KEYWORD_KEY "Xmp.dc.subject"
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
286
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
287 static gint comment_xmp_read(FileData *fd, GList **keywords, gchar **comment)
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
288 {
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
289 ExifData *exif;
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
290
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
291 exif = exif_read_fd(fd);
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
292 if (!exif) return FALSE;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
293
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
294 if (comment)
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
295 {
767
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
296 gchar *text;
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
297 ExifItem *item = exif_get_item(exif, COMMENT_KEY);
646
91dfc98f3ca1 Reading of Iptc.Application2.Keywords should now be fixed.
zas_
parents: 643
diff changeset
298
767
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
299 text = exif_item_get_string(item, 0);
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
300 *comment = utf8_validate_or_convert(text);
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
301 g_free(text);
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
302 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
303
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
304 if (keywords)
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
305 {
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
306 ExifItem *item;
734
e6ebae313d46 Fix up some types, make some signed vs unsigned warnings quiet.
zas_
parents: 700
diff changeset
307 guint i;
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
308
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
309 *keywords = NULL;
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
310 item = exif_get_item(exif, KEYWORD_KEY);
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
311 for (i = 0; i < exif_item_get_elements(item); i++)
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
312 {
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
313 gchar *kw = exif_item_get_string(item, i);
767
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
314 gchar *utf8_kw;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
315
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
316 if (!kw) break;
767
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
317
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
318 utf8_kw = utf8_validate_or_convert(kw);
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
319 *keywords = g_list_append(*keywords, (gpointer) utf8_kw);
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
320 g_free(kw);
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
321 }
646
91dfc98f3ca1 Reading of Iptc.Application2.Keywords should now be fixed.
zas_
parents: 643
diff changeset
322
643
eaf94facc190 Disable non-working Iptc.Application2.Keywords reading introduced in revision 736.
zas_
parents: 642
diff changeset
323 /* FIXME:
eaf94facc190 Disable non-working Iptc.Application2.Keywords reading introduced in revision 736.
zas_
parents: 642
diff changeset
324 * Exiv2 handles Iptc keywords as multiple entries with the
eaf94facc190 Disable non-working Iptc.Application2.Keywords reading introduced in revision 736.
zas_
parents: 642
diff changeset
325 * same key, thus exif_get_item returns only the first keyword
eaf94facc190 Disable non-working Iptc.Application2.Keywords reading introduced in revision 736.
zas_
parents: 642
diff changeset
326 * and the only way to get all keywords is to iterate through
eaf94facc190 Disable non-working Iptc.Application2.Keywords reading introduced in revision 736.
zas_
parents: 642
diff changeset
327 * the item list.
eaf94facc190 Disable non-working Iptc.Application2.Keywords reading introduced in revision 736.
zas_
parents: 642
diff changeset
328 */
646
91dfc98f3ca1 Reading of Iptc.Application2.Keywords should now be fixed.
zas_
parents: 643
diff changeset
329 for (item = exif_get_first_item(exif);
91dfc98f3ca1 Reading of Iptc.Application2.Keywords should now be fixed.
zas_
parents: 643
diff changeset
330 item;
91dfc98f3ca1 Reading of Iptc.Application2.Keywords should now be fixed.
zas_
parents: 643
diff changeset
331 item = exif_get_next_item(exif))
642
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
332 {
646
91dfc98f3ca1 Reading of Iptc.Application2.Keywords should now be fixed.
zas_
parents: 643
diff changeset
333 guint tag;
91dfc98f3ca1 Reading of Iptc.Application2.Keywords should now be fixed.
zas_
parents: 643
diff changeset
334
91dfc98f3ca1 Reading of Iptc.Application2.Keywords should now be fixed.
zas_
parents: 643
diff changeset
335 tag = exif_item_get_tag_id(item);
651
ac87e9688188 Comparing tag id is not sufficient, check the tag name too.
zas_
parents: 647
diff changeset
336 if (tag == 0x0019)
646
91dfc98f3ca1 Reading of Iptc.Application2.Keywords should now be fixed.
zas_
parents: 643
diff changeset
337 {
651
ac87e9688188 Comparing tag id is not sufficient, check the tag name too.
zas_
parents: 647
diff changeset
338 gchar *tag_name = exif_item_get_tag_name(item);
ac87e9688188 Comparing tag id is not sufficient, check the tag name too.
zas_
parents: 647
diff changeset
339
ac87e9688188 Comparing tag id is not sufficient, check the tag name too.
zas_
parents: 647
diff changeset
340 if (strcmp(tag_name, "Iptc.Application2.Keywords") == 0)
ac87e9688188 Comparing tag id is not sufficient, check the tag name too.
zas_
parents: 647
diff changeset
341 {
ac87e9688188 Comparing tag id is not sufficient, check the tag name too.
zas_
parents: 647
diff changeset
342 gchar *kw;
767
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
343 gchar *utf8_kw;
642
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
344
651
ac87e9688188 Comparing tag id is not sufficient, check the tag name too.
zas_
parents: 647
diff changeset
345 kw = exif_item_get_data_as_text(item);
ac87e9688188 Comparing tag id is not sufficient, check the tag name too.
zas_
parents: 647
diff changeset
346 if (!kw) continue;
767
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
347
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
348 utf8_kw = utf8_validate_or_convert(kw);
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
349 *keywords = g_list_append(*keywords, (gpointer) utf8_kw);
e73d30e0c896 Make utf8_validate_or_convert() to always allocate a new string.
zas_
parents: 734
diff changeset
350 g_free(kw);
651
ac87e9688188 Comparing tag id is not sufficient, check the tag name too.
zas_
parents: 647
diff changeset
351 }
ac87e9688188 Comparing tag id is not sufficient, check the tag name too.
zas_
parents: 647
diff changeset
352 g_free(tag_name);
646
91dfc98f3ca1 Reading of Iptc.Application2.Keywords should now be fixed.
zas_
parents: 643
diff changeset
353 }
642
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
354 }
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
355 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
356
844
efed9a1520d6 implemented generic FileData cache
nadvornik
parents: 767
diff changeset
357 exif_free_fd(fd, exif);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
358
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
359 return (comment && *comment) || (keywords && *keywords);
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
360 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
361
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
362 static gint comment_xmp_write(FileData *fd, GList *keywords, const gchar *comment)
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
363 {
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
364 gint success;
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
365 gint write_comment = (comment && comment[0]);
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
366 ExifData *exif;
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
367 ExifItem *item;
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
368
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
369 exif = exif_read_fd(fd);
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
370 if (!exif) return FALSE;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
371
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
372 item = exif_get_item(exif, COMMENT_KEY);
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
373 if (item && !write_comment)
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
374 {
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
375 exif_item_delete(exif, item);
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
376 item = NULL;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
377 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
378
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
379 if (!item && write_comment) item = exif_add_item(exif, COMMENT_KEY);
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
380 if (item) exif_item_set_string(item, comment);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
381
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
382 while ((item = exif_get_item(exif, KEYWORD_KEY)))
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
383 {
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
384 exif_item_delete(exif, item);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
385 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
386
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
387 if (keywords)
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
388 {
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
389 GList *work;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
390
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
391 item = exif_add_item(exif, KEYWORD_KEY);
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
392
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
393 work = keywords;
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
394 while (work)
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
395 {
593
bb712693cad3 comment_xmp_read(), comment_xmp_write(): cleanup and improve readibility.
zas_
parents: 586
diff changeset
396 exif_item_set_string(item, (gchar *) work->data);
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
397 work = work->next;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
398 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
399 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
400
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
401 success = exif_write(exif);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
402
844
efed9a1520d6 implemented generic FileData cache
nadvornik
parents: 767
diff changeset
403 exif_free_fd(fd, exif);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
404
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
405 return success;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
406 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
407
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
408 gint comment_write(FileData *fd, GList *keywords, const gchar *comment)
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
409 {
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
410 if (!fd) return FALSE;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
411
594
4cfce4ed35e0 Use a dedicated option to enable keywords and comment saving as XMP tags
zas_
parents: 593
diff changeset
412 if (options->save_metadata_in_image_file &&
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
413 comment_xmp_write(fd, keywords, comment))
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
414 {
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
415 comment_delete_legacy(fd);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
416 return TRUE;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
417 }
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
418
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
419 return comment_legacy_write(fd, keywords, comment);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
420 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
421
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
422 gint comment_read(FileData *fd, GList **keywords, gchar **comment)
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
423 {
253
b932b6928e20 Initialize variables, clearing a gcc warning.
zas_
parents: 204
diff changeset
424 GList *keywords1 = NULL;
b932b6928e20 Initialize variables, clearing a gcc warning.
zas_
parents: 204
diff changeset
425 GList *keywords2 = NULL;
b932b6928e20 Initialize variables, clearing a gcc warning.
zas_
parents: 204
diff changeset
426 gchar *comment1 = NULL;
b932b6928e20 Initialize variables, clearing a gcc warning.
zas_
parents: 204
diff changeset
427 gchar *comment2 = NULL;
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
428 gint res1, res2;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
429
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
430 if (!fd) return FALSE;
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
431
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
432 res1 = comment_xmp_read(fd, &keywords1, &comment1);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
433 res2 = comment_legacy_read(fd, &keywords2, &comment2);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
434
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
435 if (!res1 && !res2)
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 902
diff changeset
436 {
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
437 return FALSE;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
438 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
439
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
440 if (keywords)
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
441 {
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
442 if (res1 && res2)
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
443 *keywords = g_list_concat(keywords1, keywords2);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
444 else
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
445 *keywords = res1 ? keywords1 : keywords2;
642
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
446
9c74ff4bf1cd Extract and append keywords from Iptc.Application2.Keywords tags.
zas_
parents: 604
diff changeset
447 *keywords = remove_duplicate_strings_from_list(*keywords);
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
448 }
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
449 else
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
450 {
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
451 if (res1) string_list_free(keywords1);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
452 if (res2) string_list_free(keywords2);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
453 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
454
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
455
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
456 if (comment)
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
457 {
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
458 if (res1 && res2 && comment1 && comment2 && comment1[0] && comment2[0])
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
459 *comment = g_strdup_printf("%s\n%s", comment1, comment2);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
460 else
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
461 *comment = res1 ? comment1 : comment2;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
462 }
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
463 if (res1 && (!comment || *comment != comment1)) g_free(comment1);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
464 if (res2 && (!comment || *comment != comment2)) g_free(comment2);
1090
6ca88a8380d4 Fix a segfault occuring when searching for comments in a directory where at least one photo doesn't have a comment. The fix modifies comment_read() function to return FALSE when a comment doesn't exist. Patch by Omari Stephens.
zas_
parents: 1055
diff changeset
465
1091
b6e7d5ce18a2 Previous patch (revision 1185) for the comments-related segfault was incomplete, and as such, it broke keywords in files whose metadata had keywords but no comments.
zas_
parents: 1090
diff changeset
466 // return FALSE in the following cases:
b6e7d5ce18a2 Previous patch (revision 1185) for the comments-related segfault was incomplete, and as such, it broke keywords in files whose metadata had keywords but no comments.
zas_
parents: 1090
diff changeset
467 // - only looking for a comment and didn't find one
b6e7d5ce18a2 Previous patch (revision 1185) for the comments-related segfault was incomplete, and as such, it broke keywords in files whose metadata had keywords but no comments.
zas_
parents: 1090
diff changeset
468 // - only looking for keywords and didn't find any
b6e7d5ce18a2 Previous patch (revision 1185) for the comments-related segfault was incomplete, and as such, it broke keywords in files whose metadata had keywords but no comments.
zas_
parents: 1090
diff changeset
469 // - looking for either a comment or keywords, but found nothing
b6e7d5ce18a2 Previous patch (revision 1185) for the comments-related segfault was incomplete, and as such, it broke keywords in files whose metadata had keywords but no comments.
zas_
parents: 1090
diff changeset
470 if ((!keywords && comment && !*comment) ||
b6e7d5ce18a2 Previous patch (revision 1185) for the comments-related segfault was incomplete, and as such, it broke keywords in files whose metadata had keywords but no comments.
zas_
parents: 1090
diff changeset
471 (!comment && keywords && !*keywords) ||
b6e7d5ce18a2 Previous patch (revision 1185) for the comments-related segfault was incomplete, and as such, it broke keywords in files whose metadata had keywords but no comments.
zas_
parents: 1090
diff changeset
472 ( comment && !*comment && keywords && !*keywords))
1090
6ca88a8380d4 Fix a segfault occuring when searching for comments in a directory where at least one photo doesn't have a comment. The fix modifies comment_read() function to return FALSE when a comment doesn't exist. Patch by Omari Stephens.
zas_
parents: 1055
diff changeset
473 return FALSE;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
474
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
475 return TRUE;
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
476 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
477
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
478
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 static gchar *comment_pull(GtkWidget *textview)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 GtkTextIter start, end;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
483
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 gtk_text_buffer_get_bounds(buffer, &start, &end);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
486
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489
427
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
490 static gint keyword_list_find(GList *list, const gchar *keyword)
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
491 {
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
492 while (list)
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
493 {
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
494 gchar *haystack = list->data;
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
495
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
496 if (haystack && keyword && strcmp(haystack, keyword) == 0) return TRUE;
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
497
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
498 list = list->next;
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
499 }
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
500
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
501 return FALSE;
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
502 }
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
503
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 GList *keyword_list_pull(GtkWidget *text_widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 gchar *ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 if (GTK_IS_TEXT_VIEW(text_widget))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 text = comment_pull(text_widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 else if (GTK_IS_ENTRY(text_widget))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516 text = g_strdup(gtk_entry_get_text(GTK_ENTRY(text_widget)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 ptr = text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 while (*ptr != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 gchar *begin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 gint l = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528
427
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
529 #define KEYWORDS_SEPARATOR(c) ((c) == ',' || (c) == ';' || (c) == '\n' || (c) == '\r' || (c) == '\b')
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
530 while (KEYWORDS_SEPARATOR(*ptr)) ptr++;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 begin = ptr;
427
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
532 while (*ptr != '\0' && !KEYWORDS_SEPARATOR(*ptr))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 {
427
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
534 ptr++;
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
535 l++;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 }
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
537
427
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
538 /* trim starting and ending whitespaces */
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
539 while (l > 0 && g_ascii_isspace(*begin)) begin++, l--;
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
540 while (l > 0 && g_ascii_isspace(begin[l-1])) l--;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541
427
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
542 if (l > 0)
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
543 {
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
544 gchar *keyword = g_strndup(begin, l);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
545
427
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
546 /* only add if not already in the list */
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
547 if (keyword_list_find(list, keyword) == FALSE)
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
548 list = g_list_append(list, keyword);
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
549 else
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
550 g_free(keyword);
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
551 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 void keyword_list_push(GtkWidget *textview, GList *list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 GtkTextIter start, end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565 gtk_text_buffer_get_bounds(buffer, &start, &end);
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 507
diff changeset
566 gtk_text_buffer_delete(buffer, &start, &end);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 while (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 const gchar *word = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 GtkTextIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 gtk_text_buffer_get_end_iter(buffer, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 if (word) gtk_text_buffer_insert(buffer, &iter, word, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 gtk_text_buffer_get_end_iter(buffer, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576 gtk_text_buffer_insert(buffer, &iter, "\n", -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 list = list->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
582 static void metadata_set_keywords(FileData *fd, GList *keywords_to_use, gchar *comment_to_use, gint add)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 gchar *comment = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 GList *keywords = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 GList *save_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
588 comment_read(fd, &keywords, &comment);
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
589
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
590 if (comment_to_use)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 {
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
592 if (add && comment && *comment)
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
593 {
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
594 gchar *tmp = comment;
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
596 comment = g_strconcat(tmp, comment_to_use, NULL);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
597 g_free(tmp);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
598 }
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
599 else
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 {
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
601 g_free(comment);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
602 comment = g_strdup(comment_to_use);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
603 }
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
604 }
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
605
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
606 if (keywords_to_use)
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
607 {
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
608 if (add && keywords && g_list_length(keywords) > 0)
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
609 {
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
610 GList *work;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
612 work = keywords_to_use;
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
613 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 {
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
615 gchar *key;
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
616 GList *p;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
618 key = work->data;
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
619 work = work->next;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
621 p = keywords;
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
622 while (p && key)
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
623 {
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
624 gchar *needle = p->data;
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
625 p = p->next;
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
626
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
627 if (strcmp(needle, key) == 0) key = NULL;
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
628 }
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
629
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
630 if (key) keywords = g_list_append(keywords, g_strdup(key));
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
631 }
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
632 save_list = keywords;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 }
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
634 else
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
635 {
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
636 save_list = keywords_to_use;
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
637 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 }
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
639
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
640 comment_write(fd, save_list, comment);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
642 string_list_free(keywords);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 g_free(comment);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 * keyword list dialog
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652 #define KEYWORD_DIALOG_WIDTH 200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 #define KEYWORD_DIALOG_HEIGHT 250
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 typedef struct _KeywordDlg KeywordDlg;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 struct _KeywordDlg
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 GtkWidget *treeview;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 static KeywordDlg *keyword_dialog = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 static void keyword_dialog_cancel_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667 g_free(keyword_dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668 keyword_dialog = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 static void keyword_dialog_ok_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673 KeywordDlg *kd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 history_list_free_key("keywords");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 store = gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 gtk_tree_model_get(store, &iter, 0, &key, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 history_list_add_to_key("keywords", key, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690 }
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 keyword_dialog_cancel_cb(gd, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 bar_info_keyword_update_all();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 static void keyword_dialog_add_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 KeywordDlg *kd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702 GtkTreeIter sibling;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
706 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(kd->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 if (gtk_tree_selection_get_selected(selection, &store, &sibling))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 gtk_list_store_insert_before(GTK_LIST_STORE(store), &iter, &sibling);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 store = gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 gtk_list_store_append(GTK_LIST_STORE(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 gtk_list_store_set(GTK_LIST_STORE(store), &iter, 1, TRUE, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 gtk_tree_view_set_cursor(GTK_TREE_VIEW(kd->treeview), tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 gtk_tree_view_get_column(GTK_TREE_VIEW(kd->treeview), 0), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 static void keyword_dialog_remove_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 KeywordDlg *kd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 GtkTreeIter next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(kd->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 if (!gtk_tree_selection_get_selected(selection, &store, &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 tpath = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 next = iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 if (gtk_tree_model_iter_next(store, &next))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 tpath = gtk_tree_model_get_path(store, &next);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746 if (!gtk_tree_path_prev(tpath))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749 tpath = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752 if (tpath)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754 gtk_tree_view_set_cursor(GTK_TREE_VIEW(kd->treeview), tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 gtk_tree_view_get_column(GTK_TREE_VIEW(kd->treeview), 0), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759 gtk_list_store_remove(GTK_LIST_STORE(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 static void keyword_dialog_edit_cb(GtkCellRendererText *renderer, const gchar *path,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 const gchar *new_text, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 KeywordDlg *kd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770 if (!new_text || strlen(new_text) == 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772 store = gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 tpath = gtk_tree_path_new_from_string(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 gtk_list_store_set(GTK_LIST_STORE(store), &iter, 0, new_text, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 static void keyword_dialog_populate(KeywordDlg *kd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 list = history_list_get_by_key("keywords");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 list = g_list_last(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 while (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 gtk_list_store_set(store, &iter, 0, list->data,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 1, TRUE, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 list = list->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 static void keyword_dialog_show(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 if (keyword_dialog)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 gtk_window_present(GTK_WINDOW(keyword_dialog->gd->dialog));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818 keyword_dialog = g_new0(KeywordDlg, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 keyword_dialog->gd = generic_dialog_new(_("Keyword Presets"),
254
9faf34f047b1 Make the wmclass value unique among the code by defining
zas_
parents: 253
diff changeset
821 GQ_WMCLASS, "keyword_presets", NULL, TRUE,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 keyword_dialog_cancel_cb, keyword_dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 generic_dialog_add_message(keyword_dialog->gd, NULL, _("Favorite keywords list"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 generic_dialog_add_button(keyword_dialog->gd, GTK_STOCK_OK, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 keyword_dialog_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829 gtk_widget_set_size_request(scrolled, KEYWORD_DIALOG_WIDTH, KEYWORD_DIALOG_HEIGHT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 gtk_box_pack_start(GTK_BOX(keyword_dialog->gd->vbox), scrolled, TRUE, TRUE, 5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 keyword_dialog->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(keyword_dialog->treeview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 gtk_tree_view_set_search_column(GTK_TREE_VIEW(keyword_dialog->treeview), 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(keyword_dialog->treeview), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 g_signal_connect(G_OBJECT(renderer), "edited",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848 G_CALLBACK(keyword_dialog_edit_cb), keyword_dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 gtk_tree_view_column_add_attribute(column, renderer, "text", 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 gtk_tree_view_column_add_attribute(column, renderer, "editable", 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 gtk_tree_view_append_column(GTK_TREE_VIEW(keyword_dialog->treeview), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 gtk_container_add(GTK_CONTAINER(scrolled), keyword_dialog->treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 gtk_widget_show(keyword_dialog->treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 hbox = gtk_hbox_new(FALSE, 5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 gtk_box_pack_start(GTK_BOX(keyword_dialog->gd->vbox), hbox, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 button = gtk_button_new_from_stock(GTK_STOCK_ADD);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 g_signal_connect(G_OBJECT(button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863 G_CALLBACK(keyword_dialog_add_cb), keyword_dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 g_signal_connect(G_OBJECT(button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 G_CALLBACK(keyword_dialog_remove_cb), keyword_dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 keyword_dialog_populate(keyword_dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 gtk_widget_show(keyword_dialog->gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879 static void bar_keyword_edit_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881 keyword_dialog_show();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 * info bar
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 typedef enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 BAR_SORT_COPY,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 BAR_SORT_MOVE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 BAR_SORT_LINK
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895 } SortActionType;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 KEYWORD_COLUMN_TOGGLE = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 KEYWORD_COLUMN_TEXT
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 typedef struct _BarInfoData BarInfoData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 struct _BarInfoData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 GtkWidget *group_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 GtkWidget *label_file_name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 GtkWidget *label_file_time;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 GtkWidget *keyword_view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 GtkWidget *keyword_treeview;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 GtkWidget *comment_view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915 GtkWidget *button_save;
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
916 GtkWidget *button_set_keywords_add;
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
917 GtkWidget *button_set_keywords_replace;
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
918 GtkWidget *button_set_comment_add;
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
919 GtkWidget *button_set_comment_replace;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
921 FileData *fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923 gint changed;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924 gint save_timeout_id;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 GList *(*list_func)(gpointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 gpointer list_data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 static GList *bar_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 static void bar_info_write(BarInfoData *bd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 gchar *comment;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
939 if (!bd->fd) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941 list = keyword_list_pull(bd->keyword_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942 comment = comment_pull(bd->comment_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
944 comment_write(bd->fd, list, comment);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
946 string_list_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947 g_free(comment);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949 bd->changed = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 gtk_widget_set_sensitive(bd->button_save, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 static gint bar_info_autosave(gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 BarInfoData *bd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 bar_info_write(bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 bd->save_timeout_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 static void bar_info_save_update(BarInfoData *bd, gint enable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
966 if (bd->save_timeout_id != -1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 g_source_remove(bd->save_timeout_id);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 bd->save_timeout_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971 if (enable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973 bd->save_timeout_id = g_timeout_add(BAR_KEYWORD_AUTOSAVE_TIME, bar_info_autosave, bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 static void bar_keyword_list_sync(BarInfoData *bd, GList *keywords)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 list = history_list_get_by_key("keywords");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 if (!list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 /* blank? set up a few example defaults */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 gint i = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 while (keyword_favorite_defaults[i] != NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
991 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992 history_list_add_to_key("keywords", _(keyword_favorite_defaults[i]), 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993 i++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 list = history_list_get_by_key("keywords");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(bd->keyword_treeview)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 list = g_list_last(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 while (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 gchar *key = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 gtk_list_store_append(store, &iter);
427
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
1009 gtk_list_store_set(store, &iter, KEYWORD_COLUMN_TOGGLE, keyword_list_find(keywords, key),
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 KEYWORD_COLUMN_TEXT, key, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012 list = list->prev;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016 static void bar_info_keyword_update_all(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020 work = bar_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 BarInfoData *bd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 GList *keywords;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 bd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 keywords = keyword_list_pull(bd->keyword_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030 bar_keyword_list_sync(bd, keywords);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1031 string_list_free(keywords);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035 static void bar_info_update(BarInfoData *bd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037 GList *keywords = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038 gchar *comment = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040 if (bd->label_file_name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1042 gtk_label_set_text(GTK_LABEL(bd->label_file_name), (bd->fd) ? bd->fd->name : "");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 if (bd->label_file_time)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1046 gtk_label_set_text(GTK_LABEL(bd->label_file_time), (bd->fd) ? text_from_time(bd->fd->date) : "");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
1049 if (comment_read(bd->fd, &keywords, &comment))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051 keyword_list_push(bd->keyword_view, keywords);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052 gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(bd->comment_view)),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053 (comment) ? comment : "", -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 bar_keyword_list_sync(bd, keywords);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1057 string_list_free(keywords);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058 g_free(comment);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(bd->keyword_view)), "", -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(bd->comment_view)), "", -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 bar_keyword_list_sync(bd, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 bar_info_save_update(bd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069 bd->changed = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 gtk_widget_set_sensitive(bd->button_save, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1072 gtk_widget_set_sensitive(bd->group_box, (bd->fd != NULL));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1075 void bar_info_set(GtkWidget *bar, FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 BarInfoData *bd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 if (!bd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1082 if (bd->changed) bar_info_write(bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1084 file_data_unref(bd->fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1085 bd->fd = file_data_ref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1087 bar_info_update(bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1088 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1090 void bar_info_maint_renamed(GtkWidget *bar, FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092 BarInfoData *bd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1094 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095 if (!bd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1097 file_data_unref(bd->fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1098 bd->fd = file_data_ref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100 if (bd->label_file_name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1102 gtk_label_set_text(GTK_LABEL(bd->label_file_name), (bd->fd) ? bd->fd->name : "");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 gint bar_info_event(GtkWidget *bar, GdkEvent *event)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 BarInfoData *bd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1109
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1110 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 if (!bd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1113 if (GTK_WIDGET_HAS_FOCUS(bd->keyword_view)) return gtk_widget_event(bd->keyword_view, event);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 if (GTK_WIDGET_HAS_FOCUS(bd->comment_view)) return gtk_widget_event(bd->comment_view, event);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119 static void bar_info_keyword_set(BarInfoData *bd, const gchar *keyword, gint active)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1120 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1121 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122 gint found;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1123
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1124 if (!keyword) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1125
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126 list = keyword_list_pull(bd->keyword_view);
427
134beb10d916 Accept keywords composed by two words ("Todo" = "A faire" in french).
zas_
parents: 318
diff changeset
1127 found = keyword_list_find(list, keyword);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 if (active != found)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1130 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 if (found)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 GList *work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1135 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1136 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137 gchar *key = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 if (key && keyword && strcmp(key, keyword) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142 list = g_list_remove(list, key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1144 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 list = g_list_append(list, g_strdup(keyword));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1151
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152 keyword_list_push(bd->keyword_view, list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1155 string_list_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 static void bar_info_keyword_toggle(GtkCellRendererToggle *toggle, const gchar *path, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 BarInfoData *bd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1164 gchar *key = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165 gboolean active;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167 store = gtk_tree_view_get_model(GTK_TREE_VIEW(bd->keyword_treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1169 tpath = gtk_tree_path_new_from_string(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173 gtk_tree_model_get(store, &iter, KEYWORD_COLUMN_TOGGLE, &active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174 KEYWORD_COLUMN_TEXT, &key, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175 active = (!active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 gtk_list_store_set(GTK_LIST_STORE(store), &iter, KEYWORD_COLUMN_TOGGLE, active, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 bar_info_keyword_set(bd, key, active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 static void bar_info_save(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184 BarInfoData *bd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186 bar_info_save_update(bd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187 bar_info_write(bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1190 static void bar_info_set_selection(BarInfoData *bd, gint set_keywords, gint set_comment, gint add)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191 {
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1192 GList *keywords = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 GList *work;
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1195 gchar *comment = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1196
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1197 if (!bd->list_func) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1199 if (set_keywords)
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1200 {
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1201 keywords = keyword_list_pull(bd->keyword_view);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1202 }
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1203
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1204 if (set_comment)
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1205 {
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1206 comment = comment_pull(bd->comment_view);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1207 }
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1208
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1209 if (add && !keywords && !comment) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211 list = bd->list_func(bd->list_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1215 FileData *fd = work->data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1218 metadata_set_keywords(fd, keywords, comment, add);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1221 filelist_free(list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1222 string_list_free(keywords);
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1223 g_free(comment);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1226 static void bar_info_set_keywords_add(GtkWidget *button, gpointer data)
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1227 {
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1228 BarInfoData *bd = data;
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1229
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1230 bar_info_set_selection(bd, TRUE, FALSE, TRUE);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1231 }
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1232
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1233 static void bar_info_set_keywords_replace(GtkWidget *button, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 BarInfoData *bd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1237 bar_info_set_selection(bd, TRUE, FALSE, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1239
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1240 static void bar_info_set_comment_add(GtkWidget *button, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1242 BarInfoData *bd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1244 bar_info_set_selection(bd, FALSE, TRUE, TRUE);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1245 }
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1246
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1247 static void bar_info_set_comment_replace(GtkWidget *button, gpointer data)
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1248 {
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1249 BarInfoData *bd = data;
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1250
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1251 bar_info_set_selection(bd, FALSE, TRUE, FALSE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1254 static void bar_info_changed(GtkTextBuffer *buffer, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256 BarInfoData *bd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258 bd->changed = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1259 gtk_widget_set_sensitive(bd->button_save, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1260
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1261 bar_info_save_update(bd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1262 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1263
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264 void bar_info_close(GtkWidget *bar)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1265 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266 BarInfoData *bd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269 if (!bd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271 gtk_widget_destroy(bd->vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274 static void bar_info_destroy(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1275 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1276 BarInfoData *bd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278 if (bd->changed) bar_info_write(bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 bar_info_save_update(bd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281 bar_list = g_list_remove(bar_list, bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1283 file_data_unref(bd->fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1285 g_free(bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1286 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1288 GtkWidget *bar_info_new(FileData *fd, gint metadata_only, GtkWidget *bounding_widget)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1289 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290 BarInfoData *bd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1291 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1294 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1297 GtkWidget *tbar;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1298 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1299 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1300 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1301
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1302 bd = g_new0(BarInfoData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1303
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1304 bd->list_func = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1305 bd->list_data = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1306
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1307 bd->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1308 g_object_set_data(G_OBJECT(bd->vbox), "bar_info_data", bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1309 g_signal_connect(G_OBJECT(bd->vbox), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1310 G_CALLBACK(bar_info_destroy), bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1311
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1312 if (!metadata_only)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1313 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1314 hbox = pref_box_new(bd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1315
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1316 label = sizer_new(bd->vbox, bounding_widget, SIZER_POS_LEFT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1317 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1318 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1319
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1320 label = gtk_label_new(_("Keywords"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1321 pref_label_bold(label, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1322 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1323 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1324 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1325
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1326 bd->group_box = pref_box_new(bd->vbox, TRUE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1327
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1328 if (!metadata_only)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1329 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1330 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1331
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1332 table = pref_table_new(bd->group_box, 2, 2, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1333
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1334 bd->label_file_name = table_add_line(table, 0, 0, _("Filename:"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1335 bd->label_file_time = table_add_line(table, 0, 1, _("File date:"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1336 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1337 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1338 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1339 bd->label_file_name = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1340 bd->label_file_time = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1341 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1342
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1343 table = gtk_table_new(3, 1, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1344 gtk_table_set_row_spacings(GTK_TABLE(table), PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1345 gtk_box_pack_start(GTK_BOX(bd->group_box), table, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1346 gtk_widget_show(table);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1347
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1348 /* keyword entry */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1349
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1350 box = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1351 gtk_table_attach(GTK_TABLE(table), box, 0, 1, 0, 2,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1352 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1353 gtk_widget_show(box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1354
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1355 label = pref_label_new(box, _("Keywords:"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1356 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1357 pref_label_bold(label, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1358
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1359 hbox = pref_box_new(box, TRUE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1360
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1361 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1362 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1363 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1364 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1365 gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1366 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1367
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1368 bd->keyword_view = gtk_text_view_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1369 gtk_container_add(GTK_CONTAINER(scrolled), bd->keyword_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1370 gtk_widget_show(bd->keyword_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1371
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1372 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(bd->keyword_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1373 g_signal_connect(G_OBJECT(buffer), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1374 G_CALLBACK(bar_info_changed), bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1375
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1376 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1377 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1378 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1379 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1380 gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1381 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1382
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1383 store = gtk_list_store_new(2, G_TYPE_BOOLEAN, G_TYPE_STRING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1384 bd->keyword_treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1385 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1386
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1387 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(bd->keyword_treeview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1388
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1389 if (metadata_only)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1390 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1391 gtk_tree_view_set_search_column(GTK_TREE_VIEW(bd->keyword_treeview), KEYWORD_COLUMN_TEXT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1392 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1393 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1394 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1395 gtk_tree_view_set_enable_search(GTK_TREE_VIEW(bd->keyword_treeview), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1396 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1397
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1398 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1399 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1400
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1401 renderer = gtk_cell_renderer_toggle_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1402 gtk_tree_view_column_pack_start(column, renderer, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1403 gtk_tree_view_column_add_attribute(column, renderer, "active", KEYWORD_COLUMN_TOGGLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1404 g_signal_connect(G_OBJECT(renderer), "toggled",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1405 G_CALLBACK(bar_info_keyword_toggle), bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1406
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1407 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1408 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1409 gtk_tree_view_column_add_attribute(column, renderer, "text", KEYWORD_COLUMN_TEXT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1410
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1411 gtk_tree_view_append_column(GTK_TREE_VIEW(bd->keyword_treeview), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1412
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1413 gtk_container_add(GTK_CONTAINER(scrolled), bd->keyword_treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1414 gtk_widget_show(bd->keyword_treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1415
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1416 /* comment entry */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1417
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1418 box = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1419 gtk_table_attach(GTK_TABLE(table), box, 0, 1, 2, 3,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1420 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1421 gtk_widget_show(box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1422
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1423 label = pref_label_new(box, _("Comment:"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1424 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1425 pref_label_bold(label, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1426
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1427 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1428 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1429 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1430 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1431 gtk_box_pack_start(GTK_BOX(box), scrolled, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1432 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1433
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1434 bd->comment_view = gtk_text_view_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1435 gtk_container_add(GTK_CONTAINER(scrolled), bd->comment_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1436 gtk_widget_show(bd->comment_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1437
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1438 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(bd->comment_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1439 g_signal_connect(G_OBJECT(buffer), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1440 G_CALLBACK(bar_info_changed), bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1441
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1442 /* toolbar */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1443
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1444 tbar = pref_toolbar_new(bd->group_box, GTK_TOOLBAR_ICONS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1445
41
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1446 pref_toolbar_button(tbar, GTK_STOCK_INDEX, NULL, FALSE,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1447 _("Edit favorite keywords list."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1448 G_CALLBACK(bar_keyword_edit_cb), bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1449 pref_toolbar_spacer(tbar);
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1450 bd->button_set_keywords_add = pref_toolbar_button(tbar, GTK_STOCK_ADD, NULL, FALSE,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1451 _("Add keywords to selected files"),
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1452 G_CALLBACK(bar_info_set_keywords_add), bd);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1453 bd->button_set_keywords_replace = pref_toolbar_button(tbar, GTK_STOCK_CONVERT, NULL, FALSE,
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1454 _("Add keywords to selected files, replacing existing ones"),
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1455 G_CALLBACK(bar_info_set_keywords_replace), bd);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1456 bd->button_set_comment_add = pref_toolbar_button(tbar, GTK_STOCK_DND_MULTIPLE, NULL, FALSE,
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1457 _("Add comment to selected files"),
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1458 G_CALLBACK(bar_info_set_comment_add), bd);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1459 bd->button_set_comment_replace = pref_toolbar_button(tbar, GTK_STOCK_DND, NULL, FALSE,
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1460 _("Add comment to selected files, replacing existing one"),
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1461 G_CALLBACK(bar_info_set_comment_replace), bd);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1462
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1463 pref_toolbar_spacer(tbar);
41
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1464 bd->button_save = pref_toolbar_button(tbar, GTK_STOCK_SAVE, NULL, FALSE,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1465 _("Save comment now"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1466 G_CALLBACK(bar_info_save), bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1467
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1468 bd->save_timeout_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1469
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1470 bd->fd = file_data_ref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1471 bar_info_update(bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1472
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1473 bar_info_selection(bd->vbox, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1474
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1475 bar_list = g_list_append(bar_list, bd);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 427
diff changeset
1476
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1477 return bd->vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1478 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1479
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1480 void bar_info_set_selection_func(GtkWidget *bar, GList *(*list_func)(gpointer data), gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1481 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1482 BarInfoData *bd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1483
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1484 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1485 if (!bd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1486
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1487 bd->list_func = list_func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1488 bd->list_data = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1489 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1490
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1491 void bar_info_selection(GtkWidget *bar, gint count)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1492 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1493 BarInfoData *bd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1494 gint enable;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1495
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1496 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1497 if (!bd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1498
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1499 enable = (count > 0 && bd->list_func != NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1500
595
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1501 gtk_widget_set_sensitive(bd->button_set_keywords_add, enable);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1502 gtk_widget_set_sensitive(bd->button_set_keywords_replace, enable);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1503 gtk_widget_set_sensitive(bd->button_set_comment_add, enable);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1504 gtk_widget_set_sensitive(bd->button_set_comment_replace, enable);
15766932414c Allow the user to append or replace comments for a group of selected files.
zas_
parents: 594
diff changeset
1505
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1506 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1051
diff changeset
1507 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */