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