Mercurial > geeqie.yaz
comparison src/editors.c @ 1407:57421a728682
Revert changeset 1502. It brokes the spec: hidden desktop files from user directory should hide files from system directory with the same name.
author | zas_ |
---|---|
date | Mon, 09 Mar 2009 19:34:26 +0000 |
parents | c0afd5cbaa23 |
children | 1cc4ea53c9a3 |
comparison
equal
deleted
inserted
replaced
1406:c0afd5cbaa23 | 1407:57421a728682 |
---|---|
150 gchar *extensions; | 150 gchar *extensions; |
151 gchar *type; | 151 gchar *type; |
152 const gchar *key = filename_from_path(path); | 152 const gchar *key = filename_from_path(path); |
153 gchar **categories, **only_show_in, **not_show_in; | 153 gchar **categories, **only_show_in, **not_show_in; |
154 gchar *try_exec; | 154 gchar *try_exec; |
155 gboolean hidden = FALSE; | |
156 | 155 |
157 if (g_hash_table_lookup(editors, key)) return FALSE; /* the file found earlier wins */ | 156 if (g_hash_table_lookup(editors, key)) return FALSE; /* the file found earlier wins */ |
158 | 157 |
159 key_file = g_key_file_new(); | 158 key_file = g_key_file_new(); |
160 if (!g_key_file_load_from_file(key_file, path, 0, NULL)) | 159 if (!g_key_file_load_from_file(key_file, path, 0, NULL)) |
168 { | 167 { |
169 /* We only consider desktop entries of Application type */ | 168 /* We only consider desktop entries of Application type */ |
170 return FALSE; | 169 return FALSE; |
171 } | 170 } |
172 | 171 |
172 editor = g_new0(EditorDescription, 1); | |
173 | |
174 editor->key = g_strdup(key); | |
175 editor->file = g_strdup(path); | |
176 | |
177 g_hash_table_insert(editors, editor->key, editor); | |
178 | |
173 if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "Hidden", NULL) | 179 if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "Hidden", NULL) |
174 || g_key_file_get_boolean(key_file, DESKTOP_GROUP, "NoDisplay", NULL)) | 180 || g_key_file_get_boolean(key_file, DESKTOP_GROUP, "NoDisplay", NULL)) |
175 { | 181 { |
176 hidden = TRUE; | 182 editor->hidden = TRUE; |
177 } | 183 } |
178 | 184 |
179 categories = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "Categories", NULL, NULL); | 185 categories = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "Categories", NULL, NULL); |
180 if (categories) | 186 if (categories) |
181 { | 187 { |
187 strcmp(categories[i], "X-Geeqie") == 0) | 193 strcmp(categories[i], "X-Geeqie") == 0) |
188 { | 194 { |
189 found = TRUE; | 195 found = TRUE; |
190 break; | 196 break; |
191 } | 197 } |
192 if (!found) hidden = TRUE; | 198 if (!found) editor->hidden = TRUE; |
193 g_strfreev(categories); | 199 g_strfreev(categories); |
194 } | 200 } |
195 else | 201 else |
196 { | 202 { |
197 hidden = TRUE; | 203 editor->hidden = TRUE; |
198 } | 204 } |
199 | 205 |
200 only_show_in = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "OnlyShowIn", NULL, NULL); | 206 only_show_in = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "OnlyShowIn", NULL, NULL); |
201 if (only_show_in) | 207 if (only_show_in) |
202 { | 208 { |
206 if (strcmp(only_show_in[i], "X-Geeqie") == 0) | 212 if (strcmp(only_show_in[i], "X-Geeqie") == 0) |
207 { | 213 { |
208 found = TRUE; | 214 found = TRUE; |
209 break; | 215 break; |
210 } | 216 } |
211 if (!found) hidden = TRUE; | 217 if (!found) editor->hidden = TRUE; |
212 g_strfreev(only_show_in); | 218 g_strfreev(only_show_in); |
213 } | 219 } |
214 | 220 |
215 not_show_in = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "NotShowIn", NULL, NULL); | 221 not_show_in = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "NotShowIn", NULL, NULL); |
216 if (not_show_in) | 222 if (not_show_in) |
221 if (strcmp(not_show_in[i], "X-Geeqie") == 0) | 227 if (strcmp(not_show_in[i], "X-Geeqie") == 0) |
222 { | 228 { |
223 found = TRUE; | 229 found = TRUE; |
224 break; | 230 break; |
225 } | 231 } |
226 if (found) hidden = TRUE; | 232 if (found) editor->hidden = TRUE; |
227 g_strfreev(not_show_in); | 233 g_strfreev(not_show_in); |
228 } | 234 } |
235 | |
229 | 236 |
230 try_exec = g_key_file_get_string(key_file, DESKTOP_GROUP, "TryExec", NULL); | 237 try_exec = g_key_file_get_string(key_file, DESKTOP_GROUP, "TryExec", NULL); |
231 if (try_exec && !editor->hidden) | 238 if (try_exec && !editor->hidden) |
232 { | 239 { |
233 gchar *try_exec_res = g_find_program_in_path(try_exec); | 240 gchar *try_exec_res = g_find_program_in_path(try_exec); |
234 if (!try_exec_res) hidden = TRUE; | 241 if (!try_exec_res) editor->hidden = TRUE; |
235 g_free(try_exec_res); | 242 g_free(try_exec_res); |
236 g_free(try_exec); | 243 g_free(try_exec); |
237 } | 244 } |
238 | 245 |
239 if (hidden) | 246 if (editor->hidden) |
240 { | 247 { |
241 /* hidden editors will be deleted, no need to parse the rest */ | 248 /* hidden editors will be deleted, no need to parse the rest */ |
242 g_key_file_free(key_file); | 249 g_key_file_free(key_file); |
243 return FALSE; | 250 return TRUE; |
244 } | 251 } |
245 | 252 |
246 editor = g_new0(EditorDescription, 1); | |
247 | |
248 editor->key = g_strdup(key); | |
249 editor->file = g_strdup(path); | |
250 editor->hidden = hidden; | |
251 | |
252 g_hash_table_insert(editors, editor->key, editor); | |
253 | |
254 editor->name = g_key_file_get_locale_string(key_file, DESKTOP_GROUP, "Name", NULL, NULL); | 253 editor->name = g_key_file_get_locale_string(key_file, DESKTOP_GROUP, "Name", NULL, NULL); |
255 editor->icon = g_key_file_get_string(key_file, DESKTOP_GROUP, "Icon", NULL); | 254 editor->icon = g_key_file_get_string(key_file, DESKTOP_GROUP, "Icon", NULL); |
256 | 255 |
257 editor->exec = g_key_file_get_string(key_file, DESKTOP_GROUP, "Exec", NULL); | 256 editor->exec = g_key_file_get_string(key_file, DESKTOP_GROUP, "Exec", NULL); |
258 | 257 |
569 | 568 |
570 static gchar *editor_command_path_parse(const FileData *fd, PathType type, const EditorDescription *editor) | 569 static gchar *editor_command_path_parse(const FileData *fd, PathType type, const EditorDescription *editor) |
571 { | 570 { |
572 GString *string; | 571 GString *string; |
573 gchar *pathl; | 572 gchar *pathl; |
574 const gchar *p = NULL; | 573 const gchar *p; |
575 | 574 |
576 string = g_string_new(""); | 575 string = g_string_new(""); |
577 | 576 |
578 if (type == PATH_FILE || type == PATH_FILE_URL) | 577 if (type == PATH_FILE || type == PATH_FILE_URL) |
579 { | 578 { |
619 p = fd->change->dest; | 618 p = fd->change->dest; |
620 else | 619 else |
621 p = ""; | 620 p = ""; |
622 } | 621 } |
623 | 622 |
623 g_assert(p); | |
624 while (*p != '\0') | 624 while (*p != '\0') |
625 { | 625 { |
626 /* must escape \, ", `, and $ to avoid problems, | 626 /* must escape \, ", `, and $ to avoid problems, |
627 * we assume system shell supports bash-like escaping | 627 * we assume system shell supports bash-like escaping |
628 */ | 628 */ |