Mercurial > geeqie
annotate src/cache_maint.c @ 327:049d6b00cc14
Rename color profile options.
author | zas_ |
---|---|
date | Sat, 12 Apr 2008 08:05:44 +0000 |
parents | b16b9b8979e5 |
children | 767b53cd9ab7 |
rev | line source |
---|---|
9 | 1 /* |
196 | 2 * Geeqie |
69
31759d770628
Fri Oct 13 10:27:22 2006 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
3 * (C) 2006 John Ellis |
9 | 4 * |
5 * Author: John Ellis | |
6 * | |
7 * This software is released under the GNU General Public License (GNU GPL). | |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
10 */ | |
11 | |
281 | 12 #include "main.h" |
9 | 13 #include "cache_maint.h" |
14 | |
15 #include "cache.h" | |
16 #include "filelist.h" | |
17 #include "thumb.h" | |
18 #include "thumb_standard.h" | |
19 #include "ui_fileops.h" | |
20 #include "ui_misc.h" | |
21 #include "ui_spinner.h" | |
22 #include "ui_tabcomp.h" | |
23 #include "ui_utildlg.h" | |
24 | |
25 | |
26 typedef struct _CMData CMData; | |
27 struct _CMData | |
28 { | |
29 GList *list; | |
30 GList *done_list; | |
31 gint idle_id; | |
32 GenericDialog *gd; | |
33 GtkWidget *entry; | |
34 GtkWidget *spinner; | |
35 GtkWidget *button_stop; | |
36 GtkWidget *button_close; | |
37 gint clear; | |
38 gint metadata; | |
39 }; | |
40 | |
41 #define PURGE_DIALOG_WIDTH 400 | |
42 | |
43 | |
44 /* | |
45 *------------------------------------------------------------------- | |
46 * cache maintenance | |
47 *------------------------------------------------------------------- | |
48 */ | |
49 | |
50 static gint extension_truncate(gchar *path, const gchar *ext) | |
51 { | |
52 gint l; | |
53 gint el; | |
54 | |
55 if (!path || !ext) return FALSE; | |
56 | |
57 l = strlen(path); | |
58 el = strlen(ext); | |
59 | |
60 if (l < el || strcmp(path + (l - el), ext) != 0) return FALSE; | |
61 | |
62 path[l - el] = '\0'; | |
63 | |
64 return TRUE; | |
65 } | |
66 | |
67 static gchar *extension_find_dot(gchar *path) | |
68 { | |
69 gchar *ptr; | |
70 | |
71 if (!path || *path == '\0') return NULL; | |
72 | |
73 ptr = path; | |
74 while (*ptr != '\0') ptr++; | |
75 | |
76 while (ptr > path && *ptr != '.') ptr--; | |
77 | |
78 if (ptr == path) return NULL; | |
79 | |
80 return ptr; | |
81 } | |
82 | |
83 static gint isempty(const gchar *path) | |
84 { | |
85 DIR *dp; | |
86 struct dirent *dir; | |
87 gchar *pathl; | |
88 | |
89 pathl = path_from_utf8(path); | |
90 dp = opendir(pathl); | |
91 g_free(pathl); | |
92 if (!dp) return FALSE; | |
93 | |
94 while ((dir = readdir(dp)) != NULL) | |
95 { | |
96 gchar *name = dir->d_name; | |
97 | |
69
31759d770628
Fri Oct 13 10:27:22 2006 John Ellis <johne@verizon.net>
gqview
parents:
9
diff
changeset
|
98 if (!(name[0] == '.' && (name[1] == '\0' || (name[1] == '.' && name[2] == '\0'))) ) |
9 | 99 { |
100 closedir(dp); | |
101 return FALSE; | |
102 } | |
103 } | |
104 | |
105 closedir(dp); | |
106 return TRUE; | |
107 } | |
108 | |
109 static void cache_maintain_home_close(CMData *cm) | |
110 { | |
111 if (cm->idle_id != -1) g_source_remove(cm->idle_id); | |
112 if (cm->gd) generic_dialog_close(cm->gd); | |
113 path_list_free(cm->list); | |
114 g_list_free(cm->done_list); | |
115 g_free(cm); | |
116 } | |
117 | |
118 static void cache_maintain_home_stop(CMData *cm) | |
119 { | |
120 if (cm->idle_id != -1) | |
121 { | |
122 g_source_remove(cm->idle_id); | |
123 cm->idle_id = -1; | |
124 } | |
125 | |
126 gtk_entry_set_text(GTK_ENTRY(cm->entry), _("done")); | |
127 spinner_set_interval(cm->spinner, -1); | |
128 | |
129 gtk_widget_set_sensitive(cm->button_stop, FALSE); | |
130 gtk_widget_set_sensitive(cm->button_close, TRUE); | |
131 } | |
132 | |
133 static gint cache_maintain_home_cb(gpointer data) | |
134 { | |
135 CMData *cm = data; | |
136 GList *dlist = NULL; | |
137 GList *list = NULL; | |
138 gchar *path; | |
139 gint just_done = FALSE; | |
140 gint still_have_a_file = TRUE; | |
141 gint base_length; | |
142 const gchar *cache_folder; | |
143 | |
144 if (cm->metadata) | |
145 { | |
283 | 146 cache_folder = GQ_CACHE_RC_METADATA; |
9 | 147 } |
148 else | |
149 { | |
283 | 150 cache_folder = GQ_CACHE_RC_THUMB; |
9 | 151 } |
152 | |
153 base_length = strlen(homedir()) + strlen("/") + strlen(cache_folder); | |
154 | |
155 if (!cm->list) | |
156 { | |
157 if (debug) printf("purge chk done.\n"); | |
158 cm->idle_id = -1; | |
159 cache_maintain_home_stop(cm); | |
160 return FALSE; | |
161 } | |
162 | |
163 path = cm->list->data; | |
164 | |
165 if (debug) printf("purge chk (%d) \"%s\"\n", (cm->clear && !cm->metadata), path); | |
166 | |
167 if (g_list_find(cm->done_list, path) == NULL) | |
168 { | |
169 cm->done_list = g_list_prepend(cm->done_list, path); | |
170 | |
171 if (path_list(path, &list, &dlist)) | |
172 { | |
173 GList *work; | |
174 | |
175 just_done = TRUE; | |
176 still_have_a_file = FALSE; | |
177 | |
178 work = list; | |
179 while (work) | |
180 { | |
181 gchar *path_buf = work->data; | |
182 gchar *dot; | |
183 | |
184 dot = extension_find_dot(path_buf); | |
185 | |
186 if (dot) *dot = '\0'; | |
187 if ((!cm->metadata && cm->clear) || | |
188 (strlen(path_buf) > base_length && !isfile(path_buf + base_length)) ) | |
189 { | |
190 if (dot) *dot = '.'; | |
191 if (!unlink_file(path_buf)) printf("failed to delete:%s\n", path_buf); | |
192 } | |
193 else | |
194 { | |
195 still_have_a_file = TRUE; | |
196 } | |
197 work = work->next; | |
198 } | |
199 } | |
200 } | |
201 path_list_free(list); | |
202 | |
203 cm->list = g_list_concat(dlist, cm->list); | |
204 | |
205 if (cm->list && g_list_find(cm->done_list, cm->list->data) != NULL) | |
206 { | |
207 /* check if the dir is empty */ | |
208 | |
209 if (cm->list->data == path && just_done) | |
210 { | |
211 if (!still_have_a_file && !dlist && cm->list->next && !rmdir_utf8(path)) | |
212 { | |
213 printf("Unable to delete dir: %s\n", path); | |
214 } | |
215 } | |
216 else | |
217 { | |
218 /* must re-check for an empty dir */ | |
219 if (isempty(path) && cm->list->next && !rmdir_utf8(path)) | |
220 { | |
221 printf("Unable to delete dir: %s\n", path); | |
222 } | |
223 } | |
224 | |
225 path = cm->list->data; | |
226 cm->done_list = g_list_remove(cm->done_list, path); | |
227 cm->list = g_list_remove(cm->list, path); | |
228 g_free(path); | |
229 } | |
230 | |
231 if (cm->list) | |
232 { | |
233 const gchar *buf; | |
234 | |
235 path = cm->list->data; | |
236 if (strlen(path) > base_length) | |
237 { | |
238 buf = path + base_length; | |
239 } | |
240 else | |
241 { | |
242 buf = "..."; | |
243 } | |
244 gtk_entry_set_text(GTK_ENTRY(cm->entry), buf); | |
245 } | |
246 | |
247 return TRUE; | |
248 } | |
249 | |
250 static void cache_maintain_home_close_cb(GenericDialog *gd, gpointer data) | |
251 { | |
252 CMData *cm = data; | |
253 | |
254 if (!GTK_WIDGET_SENSITIVE(cm->button_close)) return; | |
255 | |
256 cache_maintain_home_close(cm); | |
257 } | |
258 | |
259 static void cache_maintain_home_stop_cb(GenericDialog *gd, gpointer data) | |
260 { | |
261 CMData *cm = data; | |
262 | |
263 cache_maintain_home_stop(cm); | |
264 } | |
265 | |
266 /* sorry for complexity (cm->done_list), but need it to remove empty dirs */ | |
267 void cache_maintain_home(gint metadata, gint clear, GtkWidget *parent) | |
268 { | |
269 CMData *cm; | |
270 GList *dlist = NULL; | |
271 gchar *base; | |
272 const gchar *msg; | |
273 const gchar *cache_folder; | |
274 GtkWidget *hbox; | |
275 | |
276 if (metadata) | |
277 { | |
283 | 278 cache_folder = GQ_CACHE_RC_METADATA; |
9 | 279 } |
280 else | |
281 { | |
283 | 282 cache_folder = GQ_CACHE_RC_THUMB; |
9 | 283 } |
284 | |
285 base = g_strconcat(homedir(), "/", cache_folder, NULL); | |
286 | |
287 if (!path_list(base, NULL, &dlist)) | |
288 { | |
289 g_free(base); | |
290 return; | |
291 } | |
292 | |
293 dlist = g_list_append(dlist, base); | |
294 | |
295 cm = g_new0(CMData, 1); | |
296 cm->list = dlist; | |
297 cm->done_list = NULL; | |
298 cm->clear = clear; | |
299 cm->metadata = metadata; | |
300 | |
301 if (metadata) | |
302 { | |
303 msg = _("Removing old metadata..."); | |
304 } | |
305 else if (clear) | |
306 { | |
307 msg = _("Clearing cached thumbnails..."); | |
308 } | |
309 else | |
310 { | |
311 msg = _("Removing old thumbnails..."); | |
312 } | |
313 | |
314 cm->gd = generic_dialog_new(_("Maintenance"), | |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
229
diff
changeset
|
315 GQ_WMCLASS, "main_maintenance", |
9 | 316 parent, FALSE, |
317 NULL, cm); | |
318 cm->gd->cancel_cb = cache_maintain_home_close_cb; | |
319 cm->button_close = generic_dialog_add_button(cm->gd, GTK_STOCK_CLOSE, NULL, | |
320 cache_maintain_home_close_cb, FALSE); | |
321 gtk_widget_set_sensitive(cm->button_close, FALSE); | |
322 cm->button_stop = generic_dialog_add_button(cm->gd, GTK_STOCK_STOP, NULL, | |
323 cache_maintain_home_stop_cb, FALSE); | |
324 | |
325 generic_dialog_add_message(cm->gd, NULL, msg, NULL); | |
326 gtk_window_set_default_size(GTK_WINDOW(cm->gd->dialog), PURGE_DIALOG_WIDTH, -1); | |
327 | |
328 hbox = gtk_hbox_new(FALSE, 0); | |
329 gtk_box_pack_start(GTK_BOX(cm->gd->vbox), hbox, FALSE, FALSE, 5); | |
330 gtk_widget_show(hbox); | |
331 | |
332 cm->entry = gtk_entry_new(); | |
333 GTK_WIDGET_UNSET_FLAGS(cm->entry, GTK_CAN_FOCUS); | |
334 gtk_editable_set_editable(GTK_EDITABLE(cm->entry), FALSE); | |
335 gtk_box_pack_start(GTK_BOX(hbox), cm->entry, TRUE, TRUE, 0); | |
336 gtk_widget_show(cm->entry); | |
337 | |
338 cm->spinner = spinner_new(NULL, SPINNER_SPEED); | |
339 gtk_box_pack_start(GTK_BOX(hbox), cm->spinner, FALSE, FALSE, 0); | |
340 gtk_widget_show(cm->spinner); | |
341 | |
342 gtk_widget_show(cm->gd->dialog); | |
343 | |
344 cm->idle_id = g_idle_add(cache_maintain_home_cb, cm); | |
345 } | |
346 | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
347 /* This checks all files in ~/GQ_RC_DIR/thumbnails and |
9 | 348 * removes them if thay have no source counterpart. |
349 * (this assumes all cache files have an extension of 4 chars including '.') | |
350 */ | |
351 gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear) | |
352 { | |
353 gchar *base; | |
354 gint base_length; | |
355 GList *dlist = NULL; | |
356 GList *flist = NULL; | |
357 gint still_have_a_file = FALSE; | |
358 | |
359 if (debug) printf("maintainance check: %s\n", dir); | |
360 | |
283 | 361 base_length = strlen(homedir()) + strlen("/") + strlen(GQ_CACHE_RC_THUMB); |
362 base = g_strconcat(homedir(), "/", GQ_CACHE_RC_THUMB, dir, NULL); | |
9 | 363 |
364 if (path_list(base, &flist, &dlist)) | |
365 { | |
366 GList *work; | |
367 | |
368 work = dlist; | |
369 while(work) | |
370 { | |
371 gchar *path = work->data; | |
372 if (recursive && strlen(path) > base_length && | |
373 !cache_maintain_home_dir(path + base_length, recursive, clear)) | |
374 { | |
375 if (debug) printf("Deleting thumb dir: %s\n", path); | |
376 if (!rmdir_utf8(path)) | |
377 { | |
378 printf("Unable to delete dir: %s\n", path); | |
379 } | |
380 } | |
381 else | |
382 { | |
383 still_have_a_file = TRUE; | |
384 } | |
385 work = work->next; | |
386 } | |
387 | |
388 work = flist; | |
389 while (work) | |
390 { | |
391 gchar *path = work->data; | |
392 gchar *dot; | |
393 | |
394 dot = extension_find_dot(path); | |
395 | |
396 if (dot) *dot = '\0'; | |
397 if (clear || | |
398 (strlen(path) > base_length && !isfile(path + base_length)) ) | |
399 { | |
400 if (dot) *dot = '.'; | |
401 if (!unlink_file(path)) printf("failed to delete:%s\n", path); | |
402 } | |
403 else | |
404 { | |
405 still_have_a_file = TRUE; | |
406 } | |
407 | |
408 work = work->next; | |
409 } | |
410 } | |
411 | |
412 path_list_free(dlist); | |
413 path_list_free(flist); | |
414 g_free(base); | |
415 | |
416 return still_have_a_file; | |
417 } | |
418 | |
419 /* This checks relative caches in dir/.thumbnails and | |
420 * removes them if they have no source counterpart. | |
421 */ | |
422 gint cache_maintain_dir(const gchar *dir, gint recursive, gint clear) | |
423 { | |
424 GList *list = NULL; | |
425 gchar *cachedir; | |
426 gint still_have_a_file = FALSE; | |
427 GList *work; | |
428 | |
283 | 429 cachedir = g_strconcat(dir, "/", GQ_CACHE_LOCAL_THUMB, NULL); |
9 | 430 |
431 path_list(cachedir, &list, NULL); | |
432 work = list; | |
433 | |
434 while (work) | |
435 { | |
436 const gchar *path; | |
437 gchar *source; | |
438 | |
439 path = work->data; | |
440 work = work->next; | |
441 | |
442 source = g_strconcat(dir, "/", filename_from_path(path), NULL); | |
443 | |
444 if (clear || | |
283 | 445 extension_truncate(source, GQ_CACHE_EXT_THUMB) || |
446 extension_truncate(source, GQ_CACHE_EXT_SIM)) | |
9 | 447 { |
448 if (!clear && isfile(source)) | |
449 { | |
450 still_have_a_file = TRUE; | |
451 } | |
452 else | |
453 { | |
454 if (!unlink_file(path)) | |
455 { | |
456 if (debug) printf("Failed to remove cache file %s\n", path); | |
457 still_have_a_file = TRUE; | |
458 } | |
459 } | |
460 } | |
461 else | |
462 { | |
463 still_have_a_file = TRUE; | |
464 } | |
465 g_free(source); | |
466 } | |
467 | |
468 path_list_free(list); | |
469 g_free(cachedir); | |
470 | |
471 if (recursive) | |
472 { | |
473 list = NULL; | |
474 | |
475 path_list(dir, NULL, &list); | |
476 work = list; | |
477 while (work) | |
478 { | |
479 const gchar *path = work->data; | |
480 work = work->next; | |
481 | |
482 still_have_a_file |= cache_maintain_dir(path, recursive, clear); | |
483 } | |
484 | |
485 path_list_free(list); | |
486 } | |
487 | |
488 return still_have_a_file; | |
489 } | |
490 | |
491 static void cache_file_move(const gchar *src, const gchar *dest) | |
492 { | |
493 if (!dest || !src || !isfile(src)) return; | |
494 | |
495 if (!move_file(src, dest)) | |
496 { | |
497 if (debug) printf("Failed to move cache file %s\nto %s\n", src, dest); | |
498 /* we remove it anyway - it's stale */ | |
499 unlink_file(src); | |
500 } | |
501 } | |
502 | |
138 | 503 void cache_maint_moved(FileData *fd) |
9 | 504 { |
505 gchar *base; | |
506 mode_t mode = 0755; | |
138 | 507 const gchar *src = fd->change->source; |
508 const gchar *dest = fd->change->dest; | |
9 | 509 |
510 if (!src || !dest) return; | |
511 | |
512 base = cache_get_location(CACHE_TYPE_THUMB, dest, FALSE, &mode); | |
513 if (cache_ensure_dir_exists(base, mode)) | |
514 { | |
515 gchar *buf; | |
516 gchar *d; | |
517 | |
518 buf = cache_find_location(CACHE_TYPE_THUMB, src); | |
519 d = cache_get_location(CACHE_TYPE_THUMB, dest, TRUE, NULL); | |
520 cache_file_move(buf, d); | |
521 g_free(d); | |
522 g_free(buf); | |
523 | |
524 buf = cache_find_location(CACHE_TYPE_SIM, src); | |
525 d = cache_get_location(CACHE_TYPE_SIM, dest, TRUE, NULL); | |
526 cache_file_move(buf, d); | |
527 g_free(d); | |
528 g_free(buf); | |
529 } | |
530 else | |
531 { | |
532 printf("Failed to create cache dir for move %s\n", base); | |
533 } | |
534 g_free(base); | |
535 | |
536 base = cache_get_location(CACHE_TYPE_METADATA, dest, FALSE, &mode); | |
537 if (cache_ensure_dir_exists(base, mode)) | |
538 { | |
539 gchar *buf; | |
540 gchar *d; | |
541 | |
542 buf = cache_find_location(CACHE_TYPE_METADATA, src); | |
543 d = cache_get_location(CACHE_TYPE_METADATA, dest, TRUE, NULL); | |
544 cache_file_move(buf, d); | |
545 g_free(d); | |
546 g_free(buf); | |
547 } | |
548 g_free(base); | |
549 | |
318 | 550 if (options->enable_thumb_caching && options->thumbnail_spec_standard) |
551 thumb_std_maint_moved(src, dest); | |
9 | 552 } |
553 | |
554 static void cache_file_remove(const gchar *path) | |
555 { | |
556 if (path && isfile(path) && !unlink_file(path)) | |
557 { | |
558 if (debug) printf("Failed to remove cache file %s\n", path); | |
559 } | |
560 } | |
561 | |
138 | 562 void cache_maint_removed(FileData *fd) |
9 | 563 { |
564 gchar *buf; | |
565 | |
138 | 566 buf = cache_find_location(CACHE_TYPE_THUMB, fd->path); |
9 | 567 cache_file_remove(buf); |
568 g_free(buf); | |
569 | |
138 | 570 buf = cache_find_location(CACHE_TYPE_SIM, fd->path); |
9 | 571 cache_file_remove(buf); |
572 g_free(buf); | |
573 | |
138 | 574 buf = cache_find_location(CACHE_TYPE_METADATA, fd->path); |
9 | 575 cache_file_remove(buf); |
576 g_free(buf); | |
577 | |
318 | 578 if (options->enable_thumb_caching && options->thumbnail_spec_standard) |
579 thumb_std_maint_removed(fd->path); | |
9 | 580 } |
581 | |
138 | 582 void cache_maint_copied(FileData *fd) |
9 | 583 { |
584 gchar *dest_base; | |
585 gchar *src_cache; | |
586 mode_t mode = 0755; | |
587 | |
138 | 588 src_cache = cache_find_location(CACHE_TYPE_METADATA, fd->change->source); |
9 | 589 if (!src_cache) return; |
590 | |
138 | 591 dest_base = cache_get_location(CACHE_TYPE_METADATA, fd->change->dest, FALSE, &mode); |
9 | 592 if (cache_ensure_dir_exists(dest_base, mode)) |
593 { | |
594 gchar *path; | |
595 | |
138 | 596 path = cache_get_location(CACHE_TYPE_METADATA, fd->change->dest, TRUE, NULL); |
9 | 597 if (!copy_file(src_cache, path)) |
598 { | |
599 if (debug) printf("failed to copy metadata %s to %s\n", src_cache, path); | |
600 } | |
601 g_free(path); | |
602 } | |
603 | |
604 g_free(dest_base); | |
605 g_free(src_cache); | |
606 } | |
607 | |
608 /* | |
609 *------------------------------------------------------------------- | |
610 * new cache maintenance utilities | |
611 *------------------------------------------------------------------- | |
612 */ | |
613 | |
614 typedef struct _CacheManager CacheManager; | |
615 struct _CacheManager | |
616 { | |
617 GenericDialog *dialog; | |
618 GtkWidget *folder_entry; | |
619 GtkWidget *progress; | |
620 | |
621 GList *list_todo; | |
622 | |
623 gint count_total; | |
624 gint count_done; | |
625 }; | |
626 | |
627 typedef struct _CleanData CleanData; | |
628 struct _CleanData | |
629 { | |
630 GenericDialog *gd; | |
631 ThumbLoaderStd *tl; | |
632 | |
633 GList *list; | |
634 GList *list_dir; | |
635 | |
636 gint days; | |
637 gint clear; | |
638 | |
639 GtkWidget *button_close; | |
640 GtkWidget *button_stop; | |
641 GtkWidget *button_start; | |
642 GtkWidget *progress; | |
643 GtkWidget *spinner; | |
644 | |
645 GtkWidget *group; | |
646 GtkWidget *entry; | |
647 | |
648 gint count_total; | |
649 gint count_done; | |
650 | |
651 gint local; | |
652 gint recurse; | |
653 | |
654 gint idle_id; | |
655 }; | |
656 | |
657 static void cache_manager_render_reset(CleanData *cd) | |
658 { | |
659 path_list_free(cd->list); | |
660 cd->list = NULL; | |
661 | |
662 path_list_free(cd->list_dir); | |
663 cd->list_dir = NULL; | |
664 | |
665 thumb_loader_free((ThumbLoader *)cd->tl); | |
666 cd->tl = NULL; | |
667 } | |
668 | |
669 static void cache_manager_render_close_cb(GenericDialog *fd, gpointer data) | |
670 { | |
671 CleanData *cd = data; | |
672 | |
673 if (!GTK_WIDGET_SENSITIVE(cd->button_close)) return; | |
674 | |
675 cache_manager_render_reset(cd); | |
676 generic_dialog_close(cd->gd); | |
677 g_free(cd); | |
678 } | |
679 | |
680 static void cache_manager_render_finish(CleanData *cd) | |
681 { | |
682 cache_manager_render_reset(cd); | |
683 | |
684 gtk_entry_set_text(GTK_ENTRY(cd->progress), _("done")); | |
685 spinner_set_interval(cd->spinner, -1); | |
686 | |
687 gtk_widget_set_sensitive(cd->group, TRUE); | |
688 gtk_widget_set_sensitive(cd->button_start, TRUE); | |
689 gtk_widget_set_sensitive(cd->button_stop, FALSE); | |
690 gtk_widget_set_sensitive(cd->button_close, TRUE); | |
691 } | |
692 | |
693 static void cache_manager_render_stop_cb(GenericDialog *fd, gpointer data) | |
694 { | |
695 CleanData *cd = data; | |
696 | |
697 cache_manager_render_finish(cd); | |
698 } | |
699 | |
700 static void cache_manager_render_folder(CleanData *cd, const gchar *path) | |
701 { | |
702 GList *list_d = NULL; | |
703 GList *list_f = NULL; | |
704 | |
705 if (cd->recurse) | |
706 { | |
707 path_list(path, &list_f, &list_d); | |
708 } | |
709 else | |
710 { | |
711 path_list(path, &list_f, NULL); | |
712 } | |
713 | |
714 list_f = path_list_filter(list_f, FALSE); | |
715 list_d = path_list_filter(list_d, TRUE); | |
716 | |
717 cd->list = g_list_concat(list_f, cd->list); | |
718 cd->list_dir = g_list_concat(list_d, cd->list_dir); | |
719 } | |
720 | |
721 static gint cache_manager_render_file(CleanData *cd); | |
722 | |
723 static void cache_manager_render_thumb_done_cb(ThumbLoader *tl, gpointer data) | |
724 { | |
725 CleanData *cd = data; | |
726 | |
727 thumb_loader_free((ThumbLoader *)cd->tl); | |
728 cd->tl = NULL; | |
729 | |
730 while (cache_manager_render_file(cd)); | |
731 } | |
732 | |
733 static gint cache_manager_render_file(CleanData *cd) | |
734 { | |
735 if (cd->list) | |
736 { | |
737 gchar *path; | |
738 gint success; | |
739 | |
740 path = cd->list->data; | |
741 cd->list = g_list_remove(cd->list, path); | |
742 | |
318 | 743 cd->tl = (ThumbLoaderStd *)thumb_loader_new(options->thumb_max_width, options->thumb_max_height); |
9 | 744 thumb_loader_set_callbacks((ThumbLoader *)cd->tl, |
745 cache_manager_render_thumb_done_cb, | |
746 cache_manager_render_thumb_done_cb, | |
747 NULL, cd); | |
748 thumb_loader_set_cache((ThumbLoader *)cd->tl, TRUE, cd->local, TRUE); | |
749 success = thumb_loader_start((ThumbLoader *)cd->tl, path); | |
750 if (success) | |
751 { | |
752 gtk_entry_set_text(GTK_ENTRY(cd->progress), path); | |
753 } | |
754 else | |
755 { | |
756 thumb_loader_free((ThumbLoader *)cd->tl); | |
757 cd->tl = NULL; | |
758 } | |
759 | |
760 g_free(path); | |
761 | |
762 return (!success); | |
763 } | |
764 else if (cd->list_dir) | |
765 { | |
766 gchar *path; | |
767 | |
768 path = cd->list_dir->data; | |
769 cd->list_dir = g_list_remove(cd->list_dir, path); | |
770 | |
771 cache_manager_render_folder(cd, path); | |
772 | |
773 g_free(path); | |
774 | |
775 return TRUE; | |
776 } | |
777 | |
778 cache_manager_render_finish(cd); | |
779 | |
780 return FALSE; | |
781 } | |
782 | |
783 static void cache_manager_render_start_cb(GenericDialog *fd, gpointer data) | |
784 { | |
785 CleanData *cd = data; | |
786 gchar *path; | |
787 | |
788 if (cd->list || !GTK_WIDGET_SENSITIVE(cd->button_start)) return; | |
789 | |
790 path = remove_trailing_slash((gtk_entry_get_text(GTK_ENTRY(cd->entry)))); | |
791 parse_out_relatives(path); | |
792 | |
793 if (!isdir(path)) | |
794 { | |
795 warning_dialog(_("Invalid folder"), | |
796 _("The specified folder can not be found."), | |
797 GTK_STOCK_DIALOG_WARNING, cd->gd->dialog); | |
798 } | |
799 else | |
800 { | |
801 gtk_widget_set_sensitive(cd->group, FALSE); | |
802 gtk_widget_set_sensitive(cd->button_start, FALSE); | |
803 gtk_widget_set_sensitive(cd->button_stop, TRUE); | |
804 gtk_widget_set_sensitive(cd->button_close, FALSE); | |
805 | |
806 spinner_set_interval(cd->spinner, SPINNER_SPEED); | |
807 | |
808 cache_manager_render_folder(cd, path); | |
809 while (cache_manager_render_file(cd)); | |
810 } | |
811 | |
812 g_free(path); | |
813 } | |
814 | |
815 static void cache_manager_render_dialog(GtkWidget *widget, const gchar *path) | |
816 { | |
817 CleanData *cd; | |
818 GtkWidget *hbox; | |
819 GtkWidget *label; | |
820 GtkWidget *button; | |
821 | |
822 cd = g_new0(CleanData, 1); | |
823 | |
824 cd->gd = generic_dialog_new(_("Create thumbnails"), | |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
229
diff
changeset
|
825 GQ_WMCLASS, "create_thumbnails", |
9 | 826 widget, FALSE, |
827 NULL, cd); | |
828 gtk_window_set_default_size(GTK_WINDOW(cd->gd->dialog), PURGE_DIALOG_WIDTH, -1); | |
829 cd->gd->cancel_cb = cache_manager_render_close_cb; | |
830 cd->button_close = generic_dialog_add_button(cd->gd, GTK_STOCK_CLOSE, NULL, | |
831 cache_manager_render_close_cb, FALSE); | |
832 cd->button_start = generic_dialog_add_button(cd->gd, GTK_STOCK_OK, _("S_tart"), | |
833 cache_manager_render_start_cb, FALSE); | |
834 cd->button_stop = generic_dialog_add_button(cd->gd, GTK_STOCK_STOP, NULL, | |
835 cache_manager_render_stop_cb, FALSE); | |
836 gtk_widget_set_sensitive(cd->button_stop, FALSE); | |
837 | |
838 generic_dialog_add_message(cd->gd, NULL, _("Create thumbnails"), NULL); | |
839 | |
840 hbox = pref_box_new(cd->gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, 0); | |
841 pref_spacer(hbox, PREF_PAD_INDENT); | |
842 cd->group = pref_box_new(hbox, TRUE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP); | |
843 | |
844 hbox = pref_box_new(cd->group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); | |
845 pref_label_new(hbox, _("Folder:")); | |
846 | |
847 label = tab_completion_new(&cd->entry, path, NULL, NULL); | |
848 tab_completion_add_select_button(cd->entry,_("Select folder") , TRUE); | |
849 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); | |
850 gtk_widget_show(label); | |
851 | |
852 pref_checkbox_new_int(cd->group, _("Include subfolders"), FALSE, &cd->recurse); | |
853 button = pref_checkbox_new_int(cd->group, _("Store thumbnails local to source images"), FALSE, &cd->local); | |
318 | 854 gtk_widget_set_sensitive(button, options->thumbnail_spec_standard); |
9 | 855 |
856 pref_line(cd->gd->vbox, PREF_PAD_SPACE); | |
857 hbox = pref_box_new(cd->gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); | |
858 | |
859 cd->progress = gtk_entry_new(); | |
860 GTK_WIDGET_UNSET_FLAGS(cd->progress, GTK_CAN_FOCUS); | |
861 gtk_editable_set_editable(GTK_EDITABLE(cd->progress), FALSE); | |
862 gtk_entry_set_text(GTK_ENTRY(cd->progress), _("click start to begin")); | |
863 gtk_box_pack_start(GTK_BOX(hbox), cd->progress, TRUE, TRUE, 0); | |
864 gtk_widget_show(cd->progress); | |
865 | |
866 cd->spinner = spinner_new(NULL, -1); | |
867 gtk_box_pack_start(GTK_BOX(hbox), cd->spinner, FALSE, FALSE, 0); | |
868 gtk_widget_show(cd->spinner); | |
869 | |
870 cd->list = NULL; | |
871 | |
872 gtk_widget_show(cd->gd->dialog); | |
873 } | |
874 | |
875 | |
876 | |
877 | |
878 static void cache_manager_standard_clean_close_cb(GenericDialog *gd, gpointer data) | |
879 { | |
880 CleanData *cd = data; | |
881 | |
882 if (!GTK_WIDGET_SENSITIVE(cd->button_close)) return; | |
883 | |
884 generic_dialog_close(cd->gd); | |
885 | |
886 thumb_loader_std_thumb_file_validate_cancel(cd->tl); | |
887 path_list_free(cd->list); | |
888 g_free(cd); | |
889 } | |
890 | |
891 static void cache_manager_standard_clean_done(CleanData *cd) | |
892 { | |
893 gtk_widget_set_sensitive(cd->button_stop, FALSE); | |
894 gtk_widget_set_sensitive(cd->button_close, TRUE); | |
895 | |
896 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(cd->progress), 1.0); | |
897 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("done")); | |
898 | |
899 if (cd->idle_id != -1) | |
900 { | |
901 g_source_remove(cd->idle_id); | |
902 cd->idle_id = -1; | |
903 } | |
904 | |
905 thumb_loader_std_thumb_file_validate_cancel(cd->tl); | |
906 cd->tl = NULL; | |
907 | |
908 path_list_free(cd->list); | |
909 cd->list = NULL; | |
910 } | |
911 | |
912 static void cache_manager_standard_clean_stop_cb(GenericDialog *gd, gpointer data) | |
913 { | |
914 CleanData *cd = data; | |
915 | |
916 cache_manager_standard_clean_done(cd); | |
917 } | |
918 | |
919 static gint cache_manager_standard_clean_clear_cb(gpointer data) | |
920 { | |
921 CleanData *cd = data; | |
922 | |
923 if (cd->list) | |
924 { | |
925 gchar *next_path; | |
926 | |
927 next_path = cd->list->data; | |
928 cd->list = g_list_remove(cd->list, next_path); | |
929 | |
930 if (debug) printf("thumb removed: %s\n", next_path); | |
931 | |
932 unlink_file(next_path); | |
933 g_free(next_path); | |
934 | |
935 cd->count_done++; | |
936 if (cd->count_total != 0) | |
937 { | |
938 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(cd->progress), | |
939 (gdouble)cd->count_done / cd->count_total); | |
940 } | |
941 | |
942 return TRUE; | |
943 } | |
944 | |
945 cd->idle_id = -1; | |
946 cache_manager_standard_clean_done(cd); | |
947 return FALSE; | |
948 } | |
949 | |
950 static void cache_manager_standard_clean_valid_cb(const gchar *path, gint valid, gpointer data) | |
951 { | |
952 CleanData *cd = data; | |
953 | |
954 if (path) | |
955 { | |
956 if (!valid) | |
957 { | |
958 if (debug) printf("thumb cleaned: %s\n", path); | |
959 unlink_file(path); | |
960 } | |
961 | |
962 cd->count_done++; | |
963 if (cd->count_total != 0) | |
964 { | |
965 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(cd->progress), | |
966 (gdouble)cd->count_done / cd->count_total); | |
967 } | |
968 } | |
969 | |
970 cd->tl = NULL; | |
971 if (cd->list) | |
972 { | |
973 gchar *next_path; | |
974 | |
975 next_path = cd->list->data; | |
976 cd->list = g_list_remove(cd->list, next_path); | |
977 | |
978 cd->tl = thumb_loader_std_thumb_file_validate(next_path, cd->days, | |
979 cache_manager_standard_clean_valid_cb, cd); | |
980 g_free(next_path); | |
981 } | |
982 else | |
983 { | |
984 cache_manager_standard_clean_done(cd); | |
985 } | |
986 } | |
987 | |
988 static void cache_manager_standard_clean_start_cb(GenericDialog *gd, gpointer data) | |
989 { | |
990 CleanData *cd = data; | |
991 GList *list; | |
992 gchar *path; | |
993 | |
994 if (cd->list || !GTK_WIDGET_SENSITIVE(cd->button_start)) return; | |
995 | |
996 gtk_widget_set_sensitive(cd->button_start, FALSE); | |
997 gtk_widget_set_sensitive(cd->button_stop, TRUE); | |
998 gtk_widget_set_sensitive(cd->button_close, FALSE); | |
999 | |
1000 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("running...")); | |
1001 | |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
69
diff
changeset
|
1002 path = g_strconcat(homedir(), "/", THUMB_FOLDER_GLOBAL, "/", THUMB_FOLDER_NORMAL, NULL); |
9 | 1003 list = NULL; |
1004 path_list(path, &list, NULL); | |
1005 cd->list = list; | |
1006 g_free(path); | |
1007 | |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
69
diff
changeset
|
1008 path = g_strconcat(homedir(), "/", THUMB_FOLDER_GLOBAL, "/", THUMB_FOLDER_LARGE, NULL); |
9 | 1009 list = NULL; |
1010 path_list(path, &list, NULL); | |
1011 cd->list = g_list_concat(cd->list, list); | |
1012 g_free(path); | |
1013 | |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
69
diff
changeset
|
1014 path = g_strconcat(homedir(), "/", THUMB_FOLDER_GLOBAL, "/", THUMB_FOLDER_FAIL, NULL); |
9 | 1015 list = NULL; |
1016 path_list(path, &list, NULL); | |
1017 cd->list = g_list_concat(cd->list, list); | |
1018 g_free(path); | |
1019 | |
1020 cd->count_total = g_list_length(cd->list); | |
1021 cd->count_done = 0; | |
1022 | |
1023 /* start iterating */ | |
1024 if (cd->clear) | |
1025 { | |
1026 cd->idle_id = g_idle_add(cache_manager_standard_clean_clear_cb, cd); | |
1027 } | |
1028 else | |
1029 { | |
1030 cache_manager_standard_clean_valid_cb(NULL, TRUE, cd); | |
1031 } | |
1032 } | |
1033 | |
1034 static void cache_manager_standard_process(GtkWidget *widget, gint clear) | |
1035 { | |
1036 CleanData *cd; | |
1037 const gchar *stock_id; | |
1038 const gchar *msg; | |
1039 | |
1040 cd = g_new0(CleanData, 1); | |
1041 cd->clear = clear; | |
1042 | |
1043 if (clear) | |
1044 { | |
1045 stock_id = GTK_STOCK_DELETE; | |
1046 msg = _("Clearing thumbnails..."); | |
1047 } | |
1048 else | |
1049 { | |
1050 stock_id = GTK_STOCK_CLEAR; | |
1051 msg = _("Removing old thumbnails..."); | |
1052 } | |
1053 | |
1054 cd->gd = generic_dialog_new(_("Maintenance"), | |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
229
diff
changeset
|
1055 GQ_WMCLASS, "standard_maintenance", |
9 | 1056 widget, FALSE, |
1057 NULL, cd); | |
1058 cd->gd->cancel_cb = cache_manager_standard_clean_close_cb; | |
1059 cd->button_close = generic_dialog_add_button(cd->gd, GTK_STOCK_CLOSE, NULL, | |
1060 cache_manager_standard_clean_close_cb, FALSE); | |
1061 cd->button_start = generic_dialog_add_button(cd->gd, GTK_STOCK_OK, _("S_tart"), | |
1062 cache_manager_standard_clean_start_cb, FALSE); | |
1063 cd->button_stop = generic_dialog_add_button(cd->gd, GTK_STOCK_STOP, NULL, | |
1064 cache_manager_standard_clean_stop_cb, FALSE); | |
1065 gtk_widget_set_sensitive(cd->button_stop, FALSE); | |
1066 | |
1067 generic_dialog_add_message(cd->gd, stock_id, msg, NULL); | |
1068 | |
1069 cd->progress = gtk_progress_bar_new(); | |
1070 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("click start to begin")); | |
1071 gtk_box_pack_start(GTK_BOX(cd->gd->vbox), cd->progress, FALSE, FALSE, 0); | |
1072 gtk_widget_show(cd->progress); | |
1073 | |
1074 cd->days = 30; | |
1075 cd->tl = NULL; | |
1076 cd->idle_id = -1; | |
1077 | |
1078 gtk_widget_show(cd->gd->dialog); | |
1079 } | |
1080 | |
1081 static void cache_manager_standard_clean_cb(GtkWidget *widget, gpointer data) | |
1082 { | |
1083 cache_manager_standard_process(widget, FALSE); | |
1084 } | |
1085 | |
1086 static void cache_manager_standard_clear_cb(GtkWidget *widget, gpointer data) | |
1087 { | |
1088 cache_manager_standard_process(widget, TRUE); | |
1089 } | |
1090 | |
1091 | |
229
c44b98370dba
Use more generic names for some cache manager callback functions.
zas_
parents:
228
diff
changeset
|
1092 static void cache_manager_main_clean_cb(GtkWidget *widget, gpointer data) |
9 | 1093 { |
1094 cache_maintain_home(FALSE, FALSE, widget); | |
1095 } | |
1096 | |
1097 | |
1098 static void dummy_cancel_cb(GenericDialog *gd, gpointer data) | |
1099 { | |
1100 /* no op, only so cancel button appears */ | |
1101 } | |
1102 | |
229
c44b98370dba
Use more generic names for some cache manager callback functions.
zas_
parents:
228
diff
changeset
|
1103 static void cache_manager_main_clear_ok_cb(GenericDialog *gd, gpointer data) |
9 | 1104 { |
1105 cache_maintain_home(FALSE, TRUE, NULL); | |
1106 } | |
1107 | |
229
c44b98370dba
Use more generic names for some cache manager callback functions.
zas_
parents:
228
diff
changeset
|
1108 void cache_manager_main_clear_confirm(GtkWidget *parent) |
9 | 1109 { |
1110 GenericDialog *gd; | |
1111 | |
1112 gd = generic_dialog_new(_("Clear cache"), | |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
229
diff
changeset
|
1113 GQ_WMCLASS, "clear_cache", parent, TRUE, |
9 | 1114 dummy_cancel_cb, NULL); |
1115 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION, _("Clear cache"), | |
1116 _("This will remove all thumbnails that have\nbeen saved to disk, continue?")); | |
229
c44b98370dba
Use more generic names for some cache manager callback functions.
zas_
parents:
228
diff
changeset
|
1117 generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, cache_manager_main_clear_ok_cb, TRUE); |
9 | 1118 |
1119 gtk_widget_show(gd->dialog); | |
1120 } | |
1121 | |
229
c44b98370dba
Use more generic names for some cache manager callback functions.
zas_
parents:
228
diff
changeset
|
1122 static void cache_manager_main_clear_cb(GtkWidget *widget, gpointer data) |
9 | 1123 { |
229
c44b98370dba
Use more generic names for some cache manager callback functions.
zas_
parents:
228
diff
changeset
|
1124 cache_manager_main_clear_confirm(widget); |
9 | 1125 } |
1126 | |
1127 static void cache_manager_render_cb(GtkWidget *widget, gpointer data) | |
1128 { | |
1129 cache_manager_render_dialog(widget, homedir()); | |
1130 } | |
1131 | |
1132 static void cache_manager_metadata_clean_cb(GtkWidget *widget, gpointer data) | |
1133 { | |
1134 cache_maintain_home(TRUE, FALSE, widget); | |
1135 } | |
1136 | |
1137 | |
1138 static CacheManager *cache_manager = NULL; | |
1139 | |
1140 static void cache_manager_close_cb(GenericDialog *gd, gpointer data) | |
1141 { | |
1142 generic_dialog_close(gd); | |
1143 | |
1144 g_free(cache_manager); | |
1145 cache_manager = NULL; | |
1146 } | |
1147 | |
1148 void cache_manager_show(void) | |
1149 { | |
1150 GenericDialog *gd; | |
1151 GtkWidget *group; | |
1152 GtkWidget *button; | |
1153 GtkWidget *label; | |
1154 GtkWidget *table; | |
1155 GtkSizeGroup *sizegroup; | |
1156 gchar *buf; | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1157 gchar *title; |
9 | 1158 |
1159 if (cache_manager) | |
1160 { | |
1161 gtk_window_present(GTK_WINDOW(cache_manager->dialog->dialog)); | |
1162 return; | |
1163 } | |
1164 | |
1165 cache_manager = g_new0(CacheManager, 1); | |
1166 | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1167 title = g_strdup_printf("%s - %s", _("Cache Maintenance"), GQ_APPNAME); |
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1168 cache_manager->dialog = generic_dialog_new(title, |
254
9faf34f047b1
Make the wmclass value unique among the code by defining
zas_
parents:
229
diff
changeset
|
1169 GQ_WMCLASS, "cache_manager", |
9 | 1170 NULL, FALSE, |
1171 NULL, cache_manager); | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1172 g_free(title); |
9 | 1173 gd = cache_manager->dialog; |
1174 | |
1175 gd->cancel_cb = cache_manager_close_cb; | |
1176 generic_dialog_add_button(gd, GTK_STOCK_CLOSE, NULL, | |
1177 cache_manager_close_cb, FALSE); | |
1178 | |
1179 generic_dialog_add_message(gd, NULL, _("Cache and Data Maintenance"), NULL); | |
1180 | |
1181 sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
1182 | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1183 group = pref_group_new(gd->vbox, FALSE, _("Thumbnail cache"), GTK_ORIENTATION_VERTICAL); |
9 | 1184 |
283 | 1185 buf = g_strconcat(_("Location:"), " ", homedir(), "/", GQ_CACHE_RC_THUMB, NULL); |
9 | 1186 label = pref_label_new(group, buf); |
1187 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
1188 g_free(buf); | |
1189 | |
1190 table = pref_table_new(group, 2, 2, FALSE, FALSE); | |
1191 | |
1192 button = pref_table_button(table, 0, 0, GTK_STOCK_CLEAR, _("Clean up"), FALSE, | |
229
c44b98370dba
Use more generic names for some cache manager callback functions.
zas_
parents:
228
diff
changeset
|
1193 G_CALLBACK(cache_manager_main_clean_cb), cache_manager); |
9 | 1194 gtk_size_group_add_widget(sizegroup, button); |
1195 pref_table_label(table, 1, 0, _("Remove orphaned or outdated thumbnails."), 0.0); | |
1196 | |
1197 button = pref_table_button(table, 0, 1, GTK_STOCK_DELETE, _("Clear cache"), FALSE, | |
229
c44b98370dba
Use more generic names for some cache manager callback functions.
zas_
parents:
228
diff
changeset
|
1198 G_CALLBACK(cache_manager_main_clear_cb), cache_manager); |
9 | 1199 gtk_size_group_add_widget(sizegroup, button); |
1200 pref_table_label(table, 1, 1, _("Delete all cached thumbnails."), 0.0); | |
1201 | |
1202 | |
1203 group = pref_group_new(gd->vbox, FALSE, _("Shared thumbnail cache"), GTK_ORIENTATION_VERTICAL); | |
1204 | |
79
528e3432e0c0
Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents:
69
diff
changeset
|
1205 buf = g_strconcat(_("Location:"), " ", homedir(), "/", THUMB_FOLDER_GLOBAL, NULL); |
9 | 1206 label = pref_label_new(group, buf); |
1207 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
1208 g_free(buf); | |
1209 | |
1210 table = pref_table_new(group, 2, 2, FALSE, FALSE); | |
1211 | |
1212 button = pref_table_button(table, 0, 0, GTK_STOCK_CLEAR, _("Clean up"), FALSE, | |
1213 G_CALLBACK(cache_manager_standard_clean_cb), cache_manager); | |
1214 gtk_size_group_add_widget(sizegroup, button); | |
1215 pref_table_label(table, 1, 0, _("Remove orphaned or outdated thumbnails."), 0.0); | |
1216 | |
1217 button = pref_table_button(table, 0, 1, GTK_STOCK_DELETE, _("Clear cache"), FALSE, | |
1218 G_CALLBACK(cache_manager_standard_clear_cb), cache_manager); | |
1219 gtk_size_group_add_widget(sizegroup, button); | |
1220 pref_table_label(table, 1, 1, _("Delete all cached thumbnails."), 0.0); | |
1221 | |
1222 group = pref_group_new(gd->vbox, FALSE, _("Create thumbnails"), GTK_ORIENTATION_VERTICAL); | |
1223 | |
1224 table = pref_table_new(group, 2, 1, FALSE, FALSE); | |
1225 | |
1226 button = pref_table_button(table, 0, 1, GTK_STOCK_EXECUTE, _("Render"), FALSE, | |
1227 G_CALLBACK(cache_manager_render_cb), cache_manager); | |
1228 gtk_size_group_add_widget(sizegroup, button); | |
1229 pref_table_label(table, 1, 1, _("Render thumbnails for a specific folder."), 0.0); | |
1230 | |
1231 group = pref_group_new(gd->vbox, FALSE, _("Metadata"), GTK_ORIENTATION_VERTICAL); | |
288
d1f74154463e
Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents:
283
diff
changeset
|
1232 |
283 | 1233 buf = g_strconcat(_("Location:"), " ", homedir(), "/", GQ_CACHE_RC_METADATA, NULL); |
9 | 1234 label = pref_label_new(group, buf); |
1235 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
1236 g_free(buf); | |
1237 | |
1238 table = pref_table_new(group, 2, 1, FALSE, FALSE); | |
1239 | |
1240 button = pref_table_button(table, 0, 0, GTK_STOCK_CLEAR, _("Clean up"), FALSE, | |
1241 G_CALLBACK(cache_manager_metadata_clean_cb), cache_manager); | |
1242 gtk_size_group_add_widget(sizegroup, button); | |
1243 pref_table_label(table, 1, 0, _("Remove orphaned keywords and comments."), 0.0); | |
1244 | |
1245 gtk_widget_show(cache_manager->dialog->dialog); | |
1246 } | |
1247 |