annotate src/cache_maint.c @ 618:b1a922a32d9c

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