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