annotate src/bar_info.c @ 232:985a9a09c9d1

Fix missing header include (filelist.h).
author zas_
date Thu, 03 Apr 2008 20:24:20 +0000
parents d662d680250d
children b932b6928e20
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
4 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * 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
10 */
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 #include "gqview.h"
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
14 #include "exif.h"
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
15
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 #include "bar_info.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include "cache.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "filelist.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "info.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "utilops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include "ui_bookmark.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include "ui_utildlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 #define BAR_KEYWORD_AUTOSAVE_TIME 10000
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 static const gchar *keyword_favorite_defaults[] = {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 N_("Favorite"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 N_("Todo"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 N_("People"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 N_("Places"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 N_("Art"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 N_("Nature"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 N_("Possessions"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 NULL
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 };
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 static void bar_info_keyword_update_all(void);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44
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 * keyword / comment utils
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 *-------------------------------------------------------------------
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
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
52 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
53 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 f = fopen(path, "w");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 if (!f) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 188
diff changeset
59 fprintf(f, "#Geeqie comment (%s)\n\n", VERSION);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 fprintf(f, "[keywords]\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 while (keywords)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 const gchar *word = keywords->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 keywords = keywords->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 fprintf(f, "%s\n", word);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 fprintf(f, "\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 fprintf(f, "[comment]\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 fprintf(f, "%s\n", (comment) ? comment : "");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 fprintf(f, "#end\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 fclose(f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
81 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
82 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 gchar *comment_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 gint success = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 /* If an existing metadata file exists, we will try writing to
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 * it's location regardless of the user's preference.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 */
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
89 comment_path = cache_find_location(CACHE_TYPE_METADATA, fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 if (comment_path && !access_file(comment_path, W_OK))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 g_free(comment_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 comment_path = NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 if (!comment_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 gchar *comment_dir;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 mode_t mode = 0755;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
101 comment_dir = cache_get_location(CACHE_TYPE_METADATA, fd->path, FALSE, &mode);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 if (cache_ensure_dir_exists(comment_dir, mode))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
104 comment_path = g_strconcat(comment_dir, "/", fd->name,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 GQVIEW_CACHE_EXT_METADATA, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 g_free(comment_dir);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 }
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 if (comment_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 gchar *comment_pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 if (debug) printf("Saving comment: %s\n", comment_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 comment_pathl = path_from_utf8(comment_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
118 success = comment_file_write(comment_pathl, keywords, comment);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 g_free(comment_pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 g_free(comment_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 }
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 return success;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
127 static gint comment_file_read(gchar *path, GList **keywords, gchar **comment)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 FILE *f;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 gchar s_buf[1024];
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 gchar *key = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 GString *comment_build = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 f = fopen(path, "r");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 if (!f) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 while (fgets(s_buf,sizeof(s_buf), f))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 if (s_buf[0]=='#') continue;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 if (s_buf[0]=='[')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 gint c = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 gchar *ptr = s_buf + 1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 while(ptr[c] != ']' && ptr[c] != '\n' && ptr[c] != '\0') c++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 key = g_strndup(ptr, c);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 else if (key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 gint newline = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 gchar *ptr = s_buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 while (*ptr != '\n' && *ptr != '\0') ptr++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 if (*ptr == '\n')
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';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 newline = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 if (strcasecmp(key, "keywords") == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 if (strlen(s_buf) > 0) list = g_list_prepend(list, g_strdup(s_buf));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 else if (strcasecmp(key, "comment") == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169 if (!comment_build) comment_build = g_string_new("");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 g_string_append(comment_build, s_buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 if (strlen(s_buf) > 0 && newline) g_string_append_c(comment_build, '\n');
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 fclose(f);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 *keywords = g_list_reverse(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 if (comment_build)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 if (comment) *comment = g_strdup(comment_build->str);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 g_string_free(comment_build, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
189 static gint comment_delete_legacy(FileData *fd)
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
190 {
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
191 gchar *comment_path;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
192 gchar *comment_pathl;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
193 gint success = FALSE;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
194 if (!fd) return FALSE;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
195
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
196 comment_path = cache_find_location(CACHE_TYPE_METADATA, fd->path);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
197 if (!comment_path) return FALSE;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
198
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
199 comment_pathl = path_from_utf8(comment_path);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
200
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
201 success = !unlink(comment_pathl);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
202
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
203 g_free(comment_pathl);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
204 g_free(comment_path);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
205
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
206 return success;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
207 }
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
208
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
209 static gint comment_legacy_read(FileData *fd, GList **keywords, gchar **comment)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 gchar *comment_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 gchar *comment_pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 gint success = FALSE;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
214 if (!fd) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
216 comment_path = cache_find_location(CACHE_TYPE_METADATA, fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 if (!comment_path) return FALSE;
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 comment_pathl = path_from_utf8(comment_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
221 success = comment_file_read(comment_pathl, keywords, comment);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 g_free(comment_pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 g_free(comment_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 return success;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
229 gchar *comment_key = "Xmp.dc.description";
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
230 gchar *keyword_key = "Xmp.dc.subject";
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
231
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
232 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
233 {
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
234 ExifData *exif = exif_read_fd(fd, FALSE);
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
235 gint success;
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
236 if (!exif) return FALSE;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
237
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
238 if (comment)
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
239 {
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
240 ExifItem *item = exif_get_item(exif, comment_key);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
241 *comment = exif_item_get_string(item, 0);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
242 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
243
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
244 if (keywords)
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
245 {
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
246 ExifItem *item = exif_get_item(exif, keyword_key);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
247 int count = exif_item_get_elements(item);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
248 int i = 0;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
249 GList *work = NULL;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
250 char *kw = NULL;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
251
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
252 while (i < count && (kw = exif_item_get_string(item, i++)))
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
253 {
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
254 work = g_list_append(work, (gpointer) kw);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
255 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
256
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
257 *keywords = work;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
258 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
259
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
260 exif_free(exif);
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
261
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
262 success = *comment || *keywords;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
263
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
264 return success;
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
265 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
266
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
267 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
268 {
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
269 gint success = FALSE;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
270 GList *work = keywords;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
271 ExifData *exif = exif_read_fd(fd, FALSE);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
272 if (!exif) return FALSE;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
273
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
274 ExifItem *item = exif_get_item(exif, comment_key);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
275
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
276 if (item && !(comment && comment[0]))
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
277 {
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
278 exif_item_delete(exif, item);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
279 item = NULL;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
280 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
281
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
282 if (!item && comment && comment[0]) item = exif_add_item(exif, comment_key);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
283 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
284
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
285
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 while ((item = exif_get_item(exif, keyword_key)))
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
288 {
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
289 exif_item_delete(exif, item);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
290 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
291
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
292 if (work)
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 item = exif_add_item(exif, keyword_key);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
295
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
296 while (work)
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
297 {
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
298 gchar *kw = (gchar *) work->data;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
299 work = work->next;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
300
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
301 exif_item_set_string(item, kw);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
302 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
303 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
304
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
305 success = exif_write(exif);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
306
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
307 exif_free(exif);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
308
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
309 return success;
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
310 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
311
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
312 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
313 {
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
314 if (!fd) return FALSE;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
315
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
316 if (enable_metadata_dirs && /* FIXME - use dedicated option */
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
317 comment_xmp_write(fd, keywords, comment))
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
318 {
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
319 comment_delete_legacy(fd);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
320 return TRUE;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
321 }
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
322
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
323 return comment_legacy_write(fd, keywords, comment);
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
324 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
325
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
326 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
327 {
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
328 GList *keywords1, *keywords2;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
329 gchar *comment1, *comment2;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
330 gint res1, res2;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
331
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
332 if (!fd) return FALSE;
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
333
204
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
334 res1 = comment_xmp_read(fd, &keywords1, &comment1);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
335 res2 = comment_legacy_read(fd, &keywords2, &comment2);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
336
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
337 if (!res1 && !res2)
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
338 {
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
339 return FALSE;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
340 }
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
341
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
342 if (keywords)
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
343 {
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
344 if (res1 && res2)
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
345 *keywords = g_list_concat(keywords1, keywords2);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
346 else
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
347 *keywords = res1 ? keywords1 : keywords2;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
348 }
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
349 else
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
350 {
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
351 if (res1) string_list_free(keywords1);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
352 if (res2) string_list_free(keywords2);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
353 }
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
354
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
355
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
356 if (comment)
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
357 {
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
358 if (res1 && res2 && comment1 && comment2 && comment1[0] && comment2[0])
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
359 *comment = g_strdup_printf("%s\n%s", comment1, comment2);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
360 else
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
361 *comment = res1 ? comment1 : comment2;
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
362 }
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
363 if (res1 && (!comment || *comment != comment1)) g_free(comment1);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
364 if (res2 && (!comment || *comment != comment2)) g_free(comment2);
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
365
d662d680250d improved xmp vs. legacy metadata handling
nadvornik
parents: 196
diff changeset
366 return TRUE;
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
367 }
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
368
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
369
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 static gchar *comment_pull(GtkWidget *textview)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 GtkTextIter start, end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 gtk_text_buffer_get_bounds(buffer, &start, &end);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 GList *keyword_list_pull(GtkWidget *text_widget)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 gchar *ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 if (GTK_IS_TEXT_VIEW(text_widget))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 text = comment_pull(text_widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 else if (GTK_IS_ENTRY(text_widget))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 text = g_strdup(gtk_entry_get_text(GTK_ENTRY(text_widget)));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 ptr = text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 while (*ptr != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 gchar *begin;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 gint l = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 while (*ptr == ' ' || *ptr == ',' || *ptr == '\n' || *ptr == '\r' || *ptr == '\b') ptr++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 begin = ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 if (*ptr != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 while (*ptr != ' ' && *ptr != ',' &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 *ptr != '\n' && *ptr != '\r' && *ptr != '\b' &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 *ptr != '\0')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 ptr++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 l++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 if (l > 0) list = g_list_append(list, g_strndup(begin, l));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 return list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 void keyword_list_push(GtkWidget *textview, GList *list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 GtkTextIter start, end;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433 gtk_text_buffer_get_bounds(buffer, &start, &end);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 gtk_text_buffer_delete (buffer, &start, &end);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 while (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 const gchar *word = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 GtkTextIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 gtk_text_buffer_get_end_iter(buffer, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 if (word) gtk_text_buffer_insert(buffer, &iter, word, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 gtk_text_buffer_get_end_iter(buffer, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 gtk_text_buffer_insert(buffer, &iter, "\n", -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 list = list->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
450 static void metadata_set_keywords(FileData *fd, GList *list, gint add)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 gchar *comment = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 GList *keywords = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 GList *save_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
456 comment_read(fd, &keywords, &comment);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 if (add)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 GList *p;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 key = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 p = keywords;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 while (p && key)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 gchar *needle = p->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 p = p->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 if (strcmp(needle, key) == 0) key = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 if (key) keywords = g_list_append(keywords, g_strdup(key));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 save_list = keywords;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 save_list = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
489 comment_write(fd, save_list, comment);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
491 string_list_free(keywords);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 g_free(comment);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 * keyword list dialog
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 #define KEYWORD_DIALOG_WIDTH 200
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 #define KEYWORD_DIALOG_HEIGHT 250
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 typedef struct _KeywordDlg KeywordDlg;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 struct _KeywordDlg
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 GtkWidget *treeview;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 static KeywordDlg *keyword_dialog = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512
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 static void keyword_dialog_cancel_cb(GenericDialog *gd, gpointer data)
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 g_free(keyword_dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 keyword_dialog = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 }
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 static void keyword_dialog_ok_cb(GenericDialog *gd, gpointer data)
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 KeywordDlg *kd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 gint valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 history_list_free_key("keywords");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 store = gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 valid = gtk_tree_model_get_iter_first(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 while (valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 gchar *key;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 gtk_tree_model_get(store, &iter, 0, &key, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 valid = gtk_tree_model_iter_next(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 history_list_add_to_key("keywords", key, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 keyword_dialog_cancel_cb(gd, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 bar_info_keyword_update_all();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 static void keyword_dialog_add_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 KeywordDlg *kd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 GtkTreeIter sibling;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(kd->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 if (gtk_tree_selection_get_selected(selection, &store, &sibling))
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 gtk_list_store_insert_before(GTK_LIST_STORE(store), &iter, &sibling);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 store = gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 gtk_list_store_append(GTK_LIST_STORE(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 gtk_list_store_set(GTK_LIST_STORE(store), &iter, 1, TRUE, -1);
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 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 gtk_tree_view_set_cursor(GTK_TREE_VIEW(kd->treeview), tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 gtk_tree_view_get_column(GTK_TREE_VIEW(kd->treeview), 0), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 gtk_tree_path_free(tpath);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 static void keyword_dialog_remove_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576 KeywordDlg *kd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 GtkTreeSelection *selection;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 GtkTreeIter next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(kd->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 if (!gtk_tree_selection_get_selected(selection, &store, &iter)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 tpath = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587 next = iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588 if (gtk_tree_model_iter_next(store, &next))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 tpath = gtk_tree_model_get_path(store, &next);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 tpath = gtk_tree_model_get_path(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 if (!gtk_tree_path_prev(tpath))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 tpath = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 if (tpath)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 gtk_tree_view_set_cursor(GTK_TREE_VIEW(kd->treeview), tpath,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 gtk_tree_view_get_column(GTK_TREE_VIEW(kd->treeview), 0), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608 gtk_list_store_remove(GTK_LIST_STORE(store), &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 static void keyword_dialog_edit_cb(GtkCellRendererText *renderer, const gchar *path,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 const gchar *new_text, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 KeywordDlg *kd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 if (!new_text || strlen(new_text) == 0) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 store = gtk_tree_view_get_model(GTK_TREE_VIEW(kd->treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 tpath = gtk_tree_path_new_from_string(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 gtk_tree_path_free(tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 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
628 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 static void keyword_dialog_populate(KeywordDlg *kd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 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
636 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 list = history_list_get_by_key("keywords");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 list = g_list_last(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 while (list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645 gtk_list_store_set(store, &iter, 0, list->data,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 1, TRUE, -1);
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 list = list->prev;
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 static void keyword_dialog_show(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 GtkWidget *button;
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 if (keyword_dialog)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 gtk_window_present(GTK_WINDOW(keyword_dialog->gd->dialog));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 }
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 keyword_dialog = g_new0(KeywordDlg, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 keyword_dialog->gd = generic_dialog_new(_("Keyword Presets"),
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 188
diff changeset
670 "Geeqie", "keyword_presets", NULL, TRUE,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 keyword_dialog_cancel_cb, keyword_dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 generic_dialog_add_message(keyword_dialog->gd, NULL, _("Favorite keywords list"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674 generic_dialog_add_button(keyword_dialog->gd, GTK_STOCK_OK, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675 keyword_dialog_ok_cb, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 gtk_widget_set_size_request(scrolled, KEYWORD_DIALOG_WIDTH, KEYWORD_DIALOG_HEIGHT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 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
680 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 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
683 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685 store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 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
687 g_object_unref(store);
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 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
690 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
691 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(keyword_dialog->treeview), TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 g_signal_connect(G_OBJECT(renderer), "edited",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 G_CALLBACK(keyword_dialog_edit_cb), keyword_dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 gtk_tree_view_column_add_attribute(column, renderer, "text", 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
700 gtk_tree_view_column_add_attribute(column, renderer, "editable", 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 gtk_tree_view_append_column(GTK_TREE_VIEW(keyword_dialog->treeview), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 gtk_container_add(GTK_CONTAINER(scrolled), keyword_dialog->treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 gtk_widget_show(keyword_dialog->treeview);
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 hbox = gtk_hbox_new(FALSE, 5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
707 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
708 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 button = gtk_button_new_from_stock(GTK_STOCK_ADD);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711 g_signal_connect(G_OBJECT(button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 G_CALLBACK(keyword_dialog_add_cb), keyword_dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 gtk_widget_show(button);
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 button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717 g_signal_connect(G_OBJECT(button), "clicked",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718 G_CALLBACK(keyword_dialog_remove_cb), keyword_dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 gtk_widget_show(button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 keyword_dialog_populate(keyword_dialog);
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 gtk_widget_show(keyword_dialog->gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 static void bar_keyword_edit_cb(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
729 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 keyword_dialog_show();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732
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 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
735 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 * info bar
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 typedef enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 BAR_SORT_COPY,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742 BAR_SORT_MOVE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 BAR_SORT_LINK
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 } SortActionType;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 KEYWORD_COLUMN_TOGGLE = 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 KEYWORD_COLUMN_TEXT
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749 };
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 typedef struct _BarInfoData BarInfoData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752 struct _BarInfoData
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 GtkWidget *vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 GtkWidget *group_box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 GtkWidget *label_file_name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757 GtkWidget *label_file_time;
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 GtkWidget *keyword_view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 GtkWidget *keyword_treeview;
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 GtkWidget *comment_view;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 GtkWidget *button_save;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 GtkWidget *button_set_add;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 GtkWidget *button_set_replace;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
768 FileData *fd;
9
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 gint changed;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 gint save_timeout_id;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 GList *(*list_func)(gpointer);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 gpointer list_data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776
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 static GList *bar_list = NULL;
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 bar_info_write(BarInfoData *bd)
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 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 gchar *comment;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
786 if (!bd->fd) return;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 list = keyword_list_pull(bd->keyword_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 comment = comment_pull(bd->comment_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
791 comment_write(bd->fd, list, comment);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
793 string_list_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 g_free(comment);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 bd->changed = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 gtk_widget_set_sensitive(bd->button_save, FALSE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800 static gint bar_info_autosave(gpointer data)
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 BarInfoData *bd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 bar_info_write(bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 bd->save_timeout_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811 static void bar_info_save_update(BarInfoData *bd, gint enable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813 if (bd->save_timeout_id != -1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815 g_source_remove(bd->save_timeout_id);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 bd->save_timeout_id = -1;
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 if (enable)
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 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
821 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 static gint bar_keyword_list_find(GList *list, const gchar *keyword)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 while (list)
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 gchar *haystack = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 if (haystack && keyword && strcmp(haystack, keyword) == 0) return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 list = list->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 static void bar_keyword_list_sync(BarInfoData *bd, GList *keywords)
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 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 GtkTreeIter iter;
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 list = history_list_get_by_key("keywords");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 if (!list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 /* blank? set up a few example defaults */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849 gint i = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 while (keyword_favorite_defaults[i] != NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853 history_list_add_to_key("keywords", _(keyword_favorite_defaults[i]), 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 i++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 }
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 list = history_list_get_by_key("keywords");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 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
861
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 gtk_list_store_clear(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 list = g_list_last(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 while (list)
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 gchar *key = list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 gtk_list_store_append(store, &iter);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 gtk_list_store_set(store, &iter, KEYWORD_COLUMN_TOGGLE, bar_keyword_list_find(keywords, key),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 KEYWORD_COLUMN_TEXT, key, -1);
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 list = list->prev;
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 }
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 static void bar_info_keyword_update_all(void)
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 GList *work;
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 work = bar_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 while (work)
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 BarInfoData *bd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 GList *keywords;
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 bd = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 work = work->next;
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 keywords = keyword_list_pull(bd->keyword_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 bar_keyword_list_sync(bd, keywords);
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
892 string_list_free(keywords);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896 static void bar_info_update(BarInfoData *bd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 GList *keywords = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 gchar *comment = NULL;
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 if (bd->label_file_name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
903 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
904 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 if (bd->label_file_time)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
907 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
908 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909
188
0584cb78aa14 write comment and keywords to xmp, sidecars are used if exist
nadvornik
parents: 138
diff changeset
910 if (comment_read(bd->fd, &keywords, &comment))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 keyword_list_push(bd->keyword_view, keywords);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 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
914 (comment) ? comment : "", -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 bar_keyword_list_sync(bd, keywords);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
918 string_list_free(keywords);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 g_free(comment);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 else
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 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
924 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
925
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 bar_keyword_list_sync(bd, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 }
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 bar_info_save_update(bd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 bd->changed = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 gtk_widget_set_sensitive(bd->button_save, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
933 gtk_widget_set_sensitive(bd->group_box, (bd->fd != NULL));
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
936 void bar_info_set(GtkWidget *bar, FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 BarInfoData *bd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941 if (!bd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 if (bd->changed) bar_info_write(bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
945 file_data_unref(bd->fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
946 bd->fd = file_data_ref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948 bar_info_update(bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
951 void bar_info_maint_renamed(GtkWidget *bar, FileData *fd)
9
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 BarInfoData *bd;
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 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 if (!bd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
958 file_data_unref(bd->fd);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
959 bd->fd = file_data_ref(fd);
9
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 if (bd->label_file_name)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
963 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
964 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967 gint bar_info_event(GtkWidget *bar, GdkEvent *event)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 BarInfoData *bd;
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 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 if (!bd) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974 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
975 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
976
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 return FALSE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 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
981 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 gint found;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 if (!keyword) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 list = keyword_list_pull(bd->keyword_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 found = bar_keyword_list_find(list, keyword);
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 if (active != found)
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 if (found)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 GList *work = list;
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 while (work)
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 gchar *key = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 work = work->next;
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 if (key && keyword && strcmp(key, keyword) == 0)
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_remove(list, key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 g_free(key);
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 }
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 list = g_list_append(list, g_strdup(keyword));
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013 keyword_list_push(bd->keyword_view, list);
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
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1016 string_list_free(list);
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 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
1020 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021 BarInfoData *bd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 GtkTreeModel *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 GtkTreeIter iter;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 GtkTreePath *tpath;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025 gchar *key = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 gboolean active;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1028 store = gtk_tree_view_get_model(GTK_TREE_VIEW(bd->keyword_treeview));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030 tpath = gtk_tree_path_new_from_string(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031 gtk_tree_model_get_iter(store, &iter, tpath);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 gtk_tree_path_free(tpath);
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 gtk_tree_model_get(store, &iter, KEYWORD_COLUMN_TOGGLE, &active,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035 KEYWORD_COLUMN_TEXT, &key, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036 active = (!active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037 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
1038
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 bar_info_keyword_set(bd, key, active);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040 g_free(key);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 static void bar_info_save(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 BarInfoData *bd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 bar_info_save_update(bd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 bar_info_write(bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 }
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 static void bar_info_set_selection(BarInfoData *bd, gint add)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053 GList *keywords;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057 if (!bd->list_func) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 keywords = keyword_list_pull(bd->keyword_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 if (!keywords && add) return;
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 list = bd->list_func(bd->list_data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 {
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1066 FileData *fd = work->data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1069 metadata_set_keywords(fd, keywords, add);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 }
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 filelist_free(list);
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1073 string_list_free(keywords);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 static void bar_info_set_add(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078 BarInfoData *bd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 bar_info_set_selection(bd, TRUE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083 static void bar_info_set_replace(GtkWidget *button, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085 BarInfoData *bd = data;
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_set_selection(bd, FALSE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 static void bar_info_changed(GtkTextBuffer *buffer, gpointer data)
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 = data;
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->changed = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1095 gtk_widget_set_sensitive(bd->button_save, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1097 bar_info_save_update(bd, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098 }
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 void bar_info_close(GtkWidget *bar)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102 BarInfoData *bd;
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 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1105 if (!bd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107 gtk_widget_destroy(bd->vbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 }
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 static void bar_info_destroy(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112 BarInfoData *bd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1113
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 if (bd->changed) bar_info_write(bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115 bar_info_save_update(bd, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1116
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117 bar_list = g_list_remove(bar_list, bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1119 file_data_unref(bd->fd);
9
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 g_free(bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1123
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1124 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
1125 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126 BarInfoData *bd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127 GtkWidget *box;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1130 GtkWidget *scrolled;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 GtkTextBuffer *buffer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 GtkWidget *tbar;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1134 GtkListStore *store;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1135 GtkTreeViewColumn *column;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1136 GtkCellRenderer *renderer;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 bd = g_new0(BarInfoData, 1);
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 bd->list_func = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141 bd->list_data = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143 bd->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1144 g_object_set_data(G_OBJECT(bd->vbox), "bar_info_data", bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1145 g_signal_connect(G_OBJECT(bd->vbox), "destroy",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146 G_CALLBACK(bar_info_destroy), bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148 if (!metadata_only)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 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
1151
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152 label = sizer_new(bd->vbox, bounding_widget, SIZER_POS_LEFT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156 label = gtk_label_new(_("Keywords"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157 pref_label_bold(label, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 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
1163
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1164 if (!metadata_only)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 table = pref_table_new(bd->group_box, 2, 2, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1169
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170 bd->label_file_name = table_add_line(table, 0, 0, _("Filename:"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171 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
1172 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175 bd->label_file_name = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 bd->label_file_time = NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1179 table = gtk_table_new(3, 1, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1180 gtk_table_set_row_spacings(GTK_TABLE(table), PREF_PAD_GAP);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181 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
1182 gtk_widget_show(table);
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 /* keyword entry */
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 box = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187 gtk_table_attach(GTK_TABLE(table), box, 0, 1, 0, 2,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 gtk_widget_show(box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1191 label = pref_label_new(box, _("Keywords:"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 pref_label_bold(label, TRUE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 hbox = pref_box_new(box, TRUE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_GAP);
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 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198 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
1199 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1200 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1203
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204 bd->keyword_view = gtk_text_view_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 gtk_container_add(GTK_CONTAINER(scrolled), bd->keyword_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1206 gtk_widget_show(bd->keyword_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1208 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(bd->keyword_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209 g_signal_connect(G_OBJECT(buffer), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210 G_CALLBACK(bar_info_changed), bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1211
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213 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
1214 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216 gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 store = gtk_list_store_new(2, G_TYPE_BOOLEAN, G_TYPE_STRING);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220 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
1221 g_object_unref(store);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 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
1224
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1225 if (metadata_only)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227 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
1228 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231 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
1232 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234 column = gtk_tree_view_column_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237 renderer = gtk_cell_renderer_toggle_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238 gtk_tree_view_column_pack_start(column, renderer, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1239 gtk_tree_view_column_add_attribute(column, renderer, "active", KEYWORD_COLUMN_TOGGLE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240 g_signal_connect(G_OBJECT(renderer), "toggled",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241 G_CALLBACK(bar_info_keyword_toggle), bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1242
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243 renderer = gtk_cell_renderer_text_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1244 gtk_tree_view_column_pack_start(column, renderer, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245 gtk_tree_view_column_add_attribute(column, renderer, "text", KEYWORD_COLUMN_TEXT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247 gtk_tree_view_append_column(GTK_TREE_VIEW(bd->keyword_treeview), column);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1249 gtk_container_add(GTK_CONTAINER(scrolled), bd->keyword_treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1250 gtk_widget_show(bd->keyword_treeview);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1251
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1252 /* comment entry */
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 box = gtk_vbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255 gtk_table_attach(GTK_TABLE(table), box, 0, 1, 2, 3,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257 gtk_widget_show(box);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1259 label = pref_label_new(box, _("Comment:"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1260 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1261 pref_label_bold(label, TRUE, FALSE);
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 scrolled = gtk_scrolled_window_new(NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264 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
1265 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1266 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267 gtk_box_pack_start(GTK_BOX(box), scrolled, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268 gtk_widget_show(scrolled);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1269
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270 bd->comment_view = gtk_text_view_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1271 gtk_container_add(GTK_CONTAINER(scrolled), bd->comment_view);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 gtk_widget_show(bd->comment_view);
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 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(bd->comment_view));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1275 g_signal_connect(G_OBJECT(buffer), "changed",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1276 G_CALLBACK(bar_info_changed), bd);
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 /* toolbar */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280 tbar = pref_toolbar_new(bd->group_box, GTK_TOOLBAR_ICONS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281
41
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1282 pref_toolbar_button(tbar, GTK_STOCK_INDEX, NULL, FALSE,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1283 _("Edit favorite keywords list."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284 G_CALLBACK(bar_keyword_edit_cb), bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1285 pref_toolbar_spacer(tbar);
41
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1286 bd->button_set_add = pref_toolbar_button(tbar, GTK_STOCK_ADD, NULL, FALSE,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287 _("Add keywords to selected files"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1288 G_CALLBACK(bar_info_set_add), bd);
41
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1289 bd->button_set_replace = pref_toolbar_button(tbar, GTK_STOCK_CONVERT, NULL, FALSE,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290 _("Add keywords to selected files, replacing the existing ones."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1291 G_CALLBACK(bar_info_set_replace), bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 pref_toolbar_spacer(tbar);
41
6281cc38e5ca Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
1293 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
1294 _("Save comment now"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 G_CALLBACK(bar_info_save), bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1297 bd->save_timeout_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1298
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 41
diff changeset
1299 bd->fd = file_data_ref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1300 bar_info_update(bd);
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 bar_info_selection(bd->vbox, 0);
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 bar_list = g_list_append(bar_list, bd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1305
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1306 return bd->vbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1307 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1308
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1309 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
1310 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1311 BarInfoData *bd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1312
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1313 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1314 if (!bd) return;
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 bd->list_func = list_func;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1317 bd->list_data = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1318 }
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 void bar_info_selection(GtkWidget *bar, gint count)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1321 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1322 BarInfoData *bd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1323 gint enable;
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 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1326 if (!bd) return;
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 enable = (count > 0 && bd->list_func != NULL);
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 gtk_widget_set_sensitive(bd->button_set_add, enable);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1331 gtk_widget_set_sensitive(bd->button_set_replace, enable);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1332 }
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 void bar_info_size_request(GtkWidget *bar, gint width)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1335 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1336 BarInfoData *bd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1337
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1338 bd = g_object_get_data(G_OBJECT(bar), "bar_info_data");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1339 if (!bd) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1340
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1341 if (bd->label_file_name)
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 gtk_widget_set_size_request(bd->vbox, width, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1344 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1345 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1346