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