annotate src/cache_maint.c @ 229:c44b98370dba

Use more generic names for some cache manager callback functions.
author zas_
date Thu, 03 Apr 2008 18:20:39 +0000
parents 343e560f8e15
children 9faf34f047b1
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
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
4 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * 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
10 */
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 #include "gqview.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13 #include "cache_maint.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #include "cache.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 #include "filelist.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include "thumb.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include "thumb_standard.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "ui_spinner.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include "ui_tabcomp.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "ui_utildlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 typedef struct _CMData CMData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 struct _CMData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 GList *done_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 gint idle_id;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 GtkWidget *spinner;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 GtkWidget *button_stop;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 GtkWidget *button_close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 gint clear;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 gint metadata;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 #define PURGE_DIALOG_WIDTH 400
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
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 * cache maintenance
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 */
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 static gint extension_truncate(gchar *path, const gchar *ext)
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 gint l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 gint el;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 if (!path || !ext) return FALSE;
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 l = strlen(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 el = strlen(ext);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 if (l < el || strcmp(path + (l - el), ext) != 0) return FALSE;
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 path[l - el] = '\0';
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 return TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 static gchar *extension_find_dot(gchar *path)
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 gchar *ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 if (!path || *path == '\0') return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 ptr = path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 while (*ptr != '\0') ptr++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 while (ptr > path && *ptr != '.') ptr--;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 if (ptr == path) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 return ptr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 }
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 static gint isempty(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 DIR *dp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 struct dirent *dir;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 pathl = path_from_utf8(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 dp = opendir(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 if (!dp) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 while ((dir = readdir(dp)) != NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 gchar *name = dir->d_name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97
69
31759d770628 Fri Oct 13 10:27:22 2006 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
98 if (!(name[0] == '.' && (name[1] == '\0' || (name[1] == '.' && name[2] == '\0'))) )
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 closedir(dp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 }
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 closedir(dp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 }
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 static void cache_maintain_home_close(CMData *cm)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 if (cm->idle_id != -1) g_source_remove(cm->idle_id);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 if (cm->gd) generic_dialog_close(cm->gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 path_list_free(cm->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 g_list_free(cm->done_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 g_free(cm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 }
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 static void cache_maintain_home_stop(CMData *cm)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 if (cm->idle_id != -1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 g_source_remove(cm->idle_id);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 cm->idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 }
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 gtk_entry_set_text(GTK_ENTRY(cm->entry), _("done"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 spinner_set_interval(cm->spinner, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 gtk_widget_set_sensitive(cm->button_stop, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 gtk_widget_set_sensitive(cm->button_close, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 }
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 static gint cache_maintain_home_cb(gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 CMData *cm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 GList *dlist = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 gint just_done = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 gint still_have_a_file = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 gint base_length;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 const gchar *cache_folder;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 if (cm->metadata)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 cache_folder = GQVIEW_CACHE_RC_METADATA;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 cache_folder = GQVIEW_CACHE_RC_THUMB;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 }
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 base_length = strlen(homedir()) + strlen("/") + strlen(cache_folder);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 if (!cm->list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 if (debug) printf("purge chk done.\n");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 cm->idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 cache_maintain_home_stop(cm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 }
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 path = cm->list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 if (debug) printf("purge chk (%d) \"%s\"\n", (cm->clear && !cm->metadata), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 if (g_list_find(cm->done_list, path) == NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169 cm->done_list = g_list_prepend(cm->done_list, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 if (path_list(path, &list, &dlist))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 just_done = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 still_have_a_file = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 gchar *path_buf = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 gchar *dot;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 dot = extension_find_dot(path_buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 if (dot) *dot = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 if ((!cm->metadata && cm->clear) ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 (strlen(path_buf) > base_length && !isfile(path_buf + base_length)) )
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 if (dot) *dot = '.';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 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
192 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 else
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 still_have_a_file = TRUE;
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 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 path_list_free(list);
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 cm->list = g_list_concat(dlist, cm->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 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
206 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 /* check if the dir is empty */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 if (cm->list->data == path && just_done)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 if (!still_have_a_file && !dlist && cm->list->next && !rmdir_utf8(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 printf("Unable to delete dir: %s\n", path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 else
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 /* must re-check for an empty dir */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 if (isempty(path) && cm->list->next && !rmdir_utf8(path))
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 printf("Unable to delete dir: %s\n", path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 path = cm->list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 cm->done_list = g_list_remove(cm->done_list, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 cm->list = g_list_remove(cm->list, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 if (cm->list)
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 const gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 path = cm->list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 if (strlen(path) > base_length)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 buf = path + base_length;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 buf = "...";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 gtk_entry_set_text(GTK_ENTRY(cm->entry), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 }
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 return TRUE;
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 static void cache_maintain_home_close_cb(GenericDialog *gd, gpointer data)
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 CMData *cm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 if (!GTK_WIDGET_SENSITIVE(cm->button_close)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 cache_maintain_home_close(cm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 }
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 static void cache_maintain_home_stop_cb(GenericDialog *gd, gpointer data)
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 CMData *cm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 cache_maintain_home_stop(cm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 }
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 /* 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
267 void cache_maintain_home(gint metadata, gint clear, GtkWidget *parent)
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 CMData *cm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 GList *dlist = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 const gchar *msg;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 const gchar *cache_folder;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 if (metadata)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 cache_folder = GQVIEW_CACHE_RC_METADATA;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 cache_folder = GQVIEW_CACHE_RC_THUMB;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 base = g_strconcat(homedir(), "/", cache_folder, NULL);
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 if (!path_list(base, NULL, &dlist))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 return;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 dlist = g_list_append(dlist, base);
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 cm = g_new0(CMData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 cm->list = dlist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 cm->done_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 cm->clear = clear;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 cm->metadata = metadata;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 if (metadata)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 msg = _("Removing old metadata...");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 else if (clear)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 msg = _("Clearing cached thumbnails...");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 msg = _("Removing old thumbnails...");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312 }
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 cm->gd = generic_dialog_new(_("Maintenance"),
228
343e560f8e15 Replace some occurences of gqview by Geeqie.
zas_
parents: 196
diff changeset
315 "Geeqie", "main_maintenance",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 parent, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 NULL, cm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 cm->gd->cancel_cb = cache_maintain_home_close_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 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
320 cache_maintain_home_close_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 gtk_widget_set_sensitive(cm->button_close, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 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
323 cache_maintain_home_stop_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 generic_dialog_add_message(cm->gd, NULL, msg, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 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
327
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 hbox = gtk_hbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 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
330 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 cm->entry = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 GTK_WIDGET_UNSET_FLAGS(cm->entry, GTK_CAN_FOCUS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 gtk_editable_set_editable(GTK_EDITABLE(cm->entry), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 gtk_box_pack_start(GTK_BOX(hbox), cm->entry, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 gtk_widget_show(cm->entry);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 cm->spinner = spinner_new(NULL, SPINNER_SPEED);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 gtk_box_pack_start(GTK_BOX(hbox), cm->spinner, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 gtk_widget_show(cm->spinner);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 gtk_widget_show(cm->gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 cm->idle_id = g_idle_add(cache_maintain_home_cb, cm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346
228
343e560f8e15 Replace some occurences of gqview by Geeqie.
zas_
parents: 196
diff changeset
347 /* This checks all files in ~/.geeqie/thumbnails and
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 * removes them if thay have no source counterpart.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 * (this assumes all cache files have an extension of 4 chars including '.')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 gint base_length;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 GList *dlist = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 GList *flist = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 gint still_have_a_file = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 if (debug) printf("maintainance check: %s\n", dir);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 base_length = strlen(homedir()) + strlen("/") + strlen(GQVIEW_CACHE_RC_THUMB);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 base = g_strconcat(homedir(), "/", GQVIEW_CACHE_RC_THUMB, dir, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 if (path_list(base, &flist, &dlist))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 work = dlist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 while(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 gchar *path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 if (recursive && strlen(path) > base_length &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 !cache_maintain_home_dir(path + base_length, recursive, clear))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 if (debug) printf("Deleting thumb dir: %s\n", path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 if (!rmdir_utf8(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 printf("Unable to delete dir: %s\n", path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 else
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 still_have_a_file = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 }
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 = flist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 while (work)
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 gchar *path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 gchar *dot;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 dot = extension_find_dot(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 if (dot) *dot = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 if (clear ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 (strlen(path) > base_length && !isfile(path + base_length)) )
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 = '.';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 if (!unlink_file(path)) printf("failed to delete:%s\n", path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 still_have_a_file = TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 path_list_free(dlist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 path_list_free(flist);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 g_free(base);
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 return still_have_a_file;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 /* This checks relative caches in dir/.thumbnails and
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 * removes them if they have no source counterpart.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 gint cache_maintain_dir(const gchar *dir, gint recursive, gint clear)
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 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 gchar *cachedir;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 gint still_have_a_file = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 GList *work;
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 cachedir = g_strconcat(dir, "/", GQVIEW_CACHE_LOCAL_THUMB, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 path_list(cachedir, &list, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 const gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 gchar *source;
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 path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 source = g_strconcat(dir, "/", filename_from_path(path), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 if (clear ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 extension_truncate(source, GQVIEW_CACHE_EXT_THUMB) ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 extension_truncate(source, GQVIEW_CACHE_EXT_SIM))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 if (!clear && isfile(source))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 still_have_a_file = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 if (!unlink_file(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 if (debug) printf("Failed to remove cache file %s\n", path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 still_have_a_file = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 still_have_a_file = TRUE;
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 g_free(source);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 }
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 path_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 g_free(cachedir);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 if (recursive)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 path_list(dir, NULL, &list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 const gchar *path = work->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 still_have_a_file |= cache_maintain_dir(path, recursive, clear);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 path_list_free(list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 return still_have_a_file;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 static void cache_file_move(const gchar *src, const gchar *dest)
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 if (!dest || !src || !isfile(src)) return;
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 if (!move_file(src, dest))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 if (debug) printf("Failed to move cache file %s\nto %s\n", src, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 /* we remove it anyway - it's stale */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 unlink_file(src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
503 void cache_maint_moved(FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 mode_t mode = 0755;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
507 const gchar *src = fd->change->source;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
508 const gchar *dest = fd->change->dest;
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 if (!src || !dest) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 base = cache_get_location(CACHE_TYPE_THUMB, dest, FALSE, &mode);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 if (cache_ensure_dir_exists(base, mode))
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 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516 gchar *d;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 buf = cache_find_location(CACHE_TYPE_THUMB, src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 d = cache_get_location(CACHE_TYPE_THUMB, dest, TRUE, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 cache_file_move(buf, d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 g_free(d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 buf = cache_find_location(CACHE_TYPE_SIM, src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 d = cache_get_location(CACHE_TYPE_SIM, dest, TRUE, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 cache_file_move(buf, d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 g_free(d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532 printf("Failed to create cache dir for move %s\n", base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 base = cache_get_location(CACHE_TYPE_METADATA, dest, FALSE, &mode);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 if (cache_ensure_dir_exists(base, mode))
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 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 gchar *d;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 buf = cache_find_location(CACHE_TYPE_METADATA, src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 d = cache_get_location(CACHE_TYPE_METADATA, dest, TRUE, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 cache_file_move(buf, d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 g_free(d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 if (enable_thumb_caching && thumbnail_spec_standard) thumb_std_maint_moved(src, dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 }
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 static void cache_file_remove(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 if (path && isfile(path) && !unlink_file(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 if (debug) printf("Failed to remove cache file %s\n", path);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
561 void cache_maint_removed(FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
565 buf = cache_find_location(CACHE_TYPE_THUMB, fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 cache_file_remove(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
569 buf = cache_find_location(CACHE_TYPE_SIM, fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 cache_file_remove(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
573 buf = cache_find_location(CACHE_TYPE_METADATA, fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 cache_file_remove(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
577 if (enable_thumb_caching && thumbnail_spec_standard) thumb_std_maint_removed(fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
580 void cache_maint_copied(FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 gchar *dest_base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 gchar *src_cache;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584 mode_t mode = 0755;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
586 src_cache = cache_find_location(CACHE_TYPE_METADATA, fd->change->source);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587 if (!src_cache) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
589 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
590 if (cache_ensure_dir_exists(dest_base, mode))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
594 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
595 if (!copy_file(src_cache, path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 if (debug) printf("failed to copy metadata %s to %s\n", src_cache, path);
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 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 g_free(dest_base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 g_free(src_cache);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 }
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 /*
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 * new cache maintenance utilities
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 */
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 typedef struct _CacheManager CacheManager;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 struct _CacheManager
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 GenericDialog *dialog;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 GtkWidget *folder_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 GtkWidget *progress;
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 GList *list_todo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 gint count_total;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 gint count_done;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 typedef struct _CleanData CleanData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 struct _CleanData
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 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 ThumbLoaderStd *tl;
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 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 GList *list_dir;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 gint days;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 gint clear;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 GtkWidget *button_close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 GtkWidget *button_stop;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 GtkWidget *button_start;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 GtkWidget *progress;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 GtkWidget *spinner;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
643 GtkWidget *group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
644 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
645
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 gint count_total;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 gint count_done;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 gint local;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 gint recurse;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652 gint idle_id;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655 static void cache_manager_render_reset(CleanData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 path_list_free(cd->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 cd->list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660 path_list_free(cd->list_dir);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 cd->list_dir = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 thumb_loader_free((ThumbLoader *)cd->tl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 cd->tl = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667 static void cache_manager_render_close_cb(GenericDialog *fd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 CleanData *cd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
671 if (!GTK_WIDGET_SENSITIVE(cd->button_close)) return;
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 cache_manager_render_reset(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674 generic_dialog_close(cd->gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
675 g_free(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
676 }
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 static void cache_manager_render_finish(CleanData *cd)
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682 gtk_entry_set_text(GTK_ENTRY(cd->progress), _("done"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 spinner_set_interval(cd->spinner, -1);
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 gtk_widget_set_sensitive(cd->group, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 gtk_widget_set_sensitive(cd->button_start, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 gtk_widget_set_sensitive(cd->button_stop, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 gtk_widget_set_sensitive(cd->button_close, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691 static void cache_manager_render_stop_cb(GenericDialog *fd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 CleanData *cd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695 cache_manager_render_finish(cd);
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_folder(CleanData *cd, const gchar *path)
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 GList *list_d = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 GList *list_f = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
702
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
703 if (cd->recurse)
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 path_list(path, &list_f, &list_d);
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
708 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 path_list(path, &list_f, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
711
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 list_f = path_list_filter(list_f, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 list_d = path_list_filter(list_d, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 cd->list = g_list_concat(list_f, cd->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 cd->list_dir = g_list_concat(list_d, cd->list_dir);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 static gint cache_manager_render_file(CleanData *cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 static void cache_manager_render_thumb_done_cb(ThumbLoader *tl, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 CleanData *cd = data;
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 thumb_loader_free((ThumbLoader *)cd->tl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 cd->tl = NULL;
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 while (cache_manager_render_file(cd));
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 static gint cache_manager_render_file(CleanData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
733 if (cd->list)
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 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 gint success;
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 path = cd->list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 cd->list = g_list_remove(cd->list, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 cd->tl = (ThumbLoaderStd *)thumb_loader_new(thumb_max_width, thumb_max_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742 thumb_loader_set_callbacks((ThumbLoader *)cd->tl,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 cache_manager_render_thumb_done_cb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 cache_manager_render_thumb_done_cb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745 NULL, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746 thumb_loader_set_cache((ThumbLoader *)cd->tl, TRUE, cd->local, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 success = thumb_loader_start((ThumbLoader *)cd->tl, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 if (success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 gtk_entry_set_text(GTK_ENTRY(cd->progress), path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754 thumb_loader_free((ThumbLoader *)cd->tl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 cd->tl = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 return (!success);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 else if (cd->list_dir)
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 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 path = cd->list_dir->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 cd->list_dir = g_list_remove(cd->list_dir, path);
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 cache_manager_render_folder(cd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 cache_manager_render_finish(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 return FALSE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 static void cache_manager_render_start_cb(GenericDialog *fd, gpointer data)
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 CleanData *cd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 if (cd->list || !GTK_WIDGET_SENSITIVE(cd->button_start)) return;
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 path = remove_trailing_slash((gtk_entry_get_text(GTK_ENTRY(cd->entry))));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 parse_out_relatives(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 if (!isdir(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 warning_dialog(_("Invalid folder"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 _("The specified folder can not be found."),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 GTK_STOCK_DIALOG_WARNING, cd->gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 gtk_widget_set_sensitive(cd->group, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800 gtk_widget_set_sensitive(cd->button_start, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 gtk_widget_set_sensitive(cd->button_stop, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 gtk_widget_set_sensitive(cd->button_close, FALSE);
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 spinner_set_interval(cd->spinner, SPINNER_SPEED);
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 cache_manager_render_folder(cd, path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807 while (cache_manager_render_file(cd));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811 }
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 static void cache_manager_render_dialog(GtkWidget *widget, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815 CleanData *cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818 GtkWidget *button;
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 cd = g_new0(CleanData, 1);
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 cd->gd = generic_dialog_new(_("Create thumbnails"),
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 138
diff changeset
823 "Geeqie", "create_thumbnails",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 widget, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 NULL, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 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
827 cd->gd->cancel_cb = cache_manager_render_close_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 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
829 cache_manager_render_close_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 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
831 cache_manager_render_start_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 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
833 cache_manager_render_stop_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 gtk_widget_set_sensitive(cd->button_stop, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 generic_dialog_add_message(cd->gd, NULL, _("Create thumbnails"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 hbox = pref_box_new(cd->gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839 pref_spacer(hbox, PREF_PAD_INDENT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 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
841
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 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
843 pref_label_new(hbox, _("Folder:"));
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 label = tab_completion_new(&cd->entry, path, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846 tab_completion_add_select_button(cd->entry,_("Select folder") , TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 pref_checkbox_new_int(cd->group, _("Include subfolders"), FALSE, &cd->recurse);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 button = pref_checkbox_new_int(cd->group, _("Store thumbnails local to source images"), FALSE, &cd->local);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 gtk_widget_set_sensitive(button, thumbnail_spec_standard);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 pref_line(cd->gd->vbox, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 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
856
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 cd->progress = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 GTK_WIDGET_UNSET_FLAGS(cd->progress, GTK_CAN_FOCUS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 gtk_editable_set_editable(GTK_EDITABLE(cd->progress), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 gtk_entry_set_text(GTK_ENTRY(cd->progress), _("click start to begin"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 gtk_box_pack_start(GTK_BOX(hbox), cd->progress, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 gtk_widget_show(cd->progress);
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->spinner = spinner_new(NULL, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 gtk_box_pack_start(GTK_BOX(hbox), cd->spinner, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866 gtk_widget_show(cd->spinner);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 cd->list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 gtk_widget_show(cd->gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 static void cache_manager_standard_clean_close_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 CleanData *cd = data;
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 if (!GTK_WIDGET_SENSITIVE(cd->button_close)) return;
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 generic_dialog_close(cd->gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884 thumb_loader_std_thumb_file_validate_cancel(cd->tl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 path_list_free(cd->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 g_free(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 }
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 static void cache_manager_standard_clean_done(CleanData *cd)
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 gtk_widget_set_sensitive(cd->button_stop, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892 gtk_widget_set_sensitive(cd->button_close, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(cd->progress), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("done"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897 if (cd->idle_id != -1)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 g_source_remove(cd->idle_id);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900 cd->idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 thumb_loader_std_thumb_file_validate_cancel(cd->tl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 cd->tl = NULL;
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 path_list_free(cd->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 cd->list = NULL;
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 static void cache_manager_standard_clean_stop_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 CleanData *cd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 cache_manager_standard_clean_done(cd);
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 gint cache_manager_standard_clean_clear_cb(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 if (cd->list)
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 gchar *next_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925 next_path = cd->list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926 cd->list = g_list_remove(cd->list, next_path);
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 (debug) printf("thumb removed: %s\n", next_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 unlink_file(next_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 g_free(next_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 cd->count_done++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 if (cd->count_total != 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(cd->progress),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 (gdouble)cd->count_done / cd->count_total);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 }
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941 }
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 cd->idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944 cache_manager_standard_clean_done(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945 return FALSE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948 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
949 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 CleanData *cd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 if (path)
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 if (!valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956 if (debug) printf("thumb cleaned: %s\n", path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 unlink_file(path);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 cd->count_done++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 if (cd->count_total != 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(cd->progress),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 (gdouble)cd->count_done / cd->count_total);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 cd->tl = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969 if (cd->list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971 gchar *next_path;
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 next_path = cd->list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974 cd->list = g_list_remove(cd->list, next_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 cd->tl = thumb_loader_std_thumb_file_validate(next_path, cd->days,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 cache_manager_standard_clean_valid_cb, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 g_free(next_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982 cache_manager_standard_clean_done(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 static void cache_manager_standard_clean_start_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 CleanData *cd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 gchar *path;
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 if (cd->list || !GTK_WIDGET_SENSITIVE(cd->button_start)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994 gtk_widget_set_sensitive(cd->button_start, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 gtk_widget_set_sensitive(cd->button_stop, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 gtk_widget_set_sensitive(cd->button_close, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("running..."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999
79
528e3432e0c0 Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents: 69
diff changeset
1000 path = g_strconcat(homedir(), "/", THUMB_FOLDER_GLOBAL, "/", THUMB_FOLDER_NORMAL, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002 path_list(path, &list, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 cd->list = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005
79
528e3432e0c0 Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents: 69
diff changeset
1006 path = g_strconcat(homedir(), "/", THUMB_FOLDER_GLOBAL, "/", THUMB_FOLDER_LARGE, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007 list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 path_list(path, &list, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 cd->list = g_list_concat(cd->list, list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011
79
528e3432e0c0 Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents: 69
diff changeset
1012 path = g_strconcat(homedir(), "/", THUMB_FOLDER_GLOBAL, "/", THUMB_FOLDER_FAIL, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013 list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014 path_list(path, &list, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015 cd->list = g_list_concat(cd->list, list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018 cd->count_total = g_list_length(cd->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 cd->count_done = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021 /* start iterating */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 if (cd->clear)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 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
1025 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 else
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 cache_manager_standard_clean_valid_cb(NULL, TRUE, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 static void cache_manager_standard_process(GtkWidget *widget, gint clear)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034 CleanData *cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035 const gchar *stock_id;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036 const gchar *msg;
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 cd = g_new0(CleanData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 cd->clear = 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 if (clear)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043 stock_id = GTK_STOCK_DELETE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 msg = _("Clearing thumbnails...");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046 else
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 stock_id = GTK_STOCK_CLEAR;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 msg = _("Removing old thumbnails...");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052 cd->gd = generic_dialog_new(_("Maintenance"),
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 138
diff changeset
1053 "Geeqie", "standard_maintenance",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054 widget, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 NULL, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 cd->gd->cancel_cb = cache_manager_standard_clean_close_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057 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
1058 cache_manager_standard_clean_close_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 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
1060 cache_manager_standard_clean_start_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 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
1062 cache_manager_standard_clean_stop_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 gtk_widget_set_sensitive(cd->button_stop, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 generic_dialog_add_message(cd->gd, stock_id, msg, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 cd->progress = gtk_progress_bar_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 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
1069 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
1070 gtk_widget_show(cd->progress);
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 cd->days = 30;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 cd->tl = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074 cd->idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 gtk_widget_show(cd->gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 }
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 static void cache_manager_standard_clean_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081 cache_manager_standard_process(widget, FALSE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084 static void cache_manager_standard_clear_cb(GtkWidget *widget, gpointer data)
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 cache_manager_standard_process(widget, TRUE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089
229
c44b98370dba Use more generic names for some cache manager callback functions.
zas_
parents: 228
diff changeset
1090 static void cache_manager_main_clean_cb(GtkWidget *widget, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092 cache_maintain_home(FALSE, FALSE, widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093 }
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 static void dummy_cancel_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1097 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1098 /* no op, only so cancel button appears */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1100
229
c44b98370dba Use more generic names for some cache manager callback functions.
zas_
parents: 228
diff changeset
1101 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
1102 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 cache_maintain_home(FALSE, TRUE, NULL);
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
229
c44b98370dba Use more generic names for some cache manager callback functions.
zas_
parents: 228
diff changeset
1106 void cache_manager_main_clear_confirm(GtkWidget *parent)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1107 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 GenericDialog *gd;
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 gd = generic_dialog_new(_("Clear cache"),
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 138
diff changeset
1111 "Geeqie", "clear_cache", parent, TRUE,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112 dummy_cancel_cb, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1113 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION, _("Clear cache"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 _("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
1115 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
1116
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1117 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1118 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1119
229
c44b98370dba Use more generic names for some cache manager callback functions.
zas_
parents: 228
diff changeset
1120 static void cache_manager_main_clear_cb(GtkWidget *widget, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1121 {
229
c44b98370dba Use more generic names for some cache manager callback functions.
zas_
parents: 228
diff changeset
1122 cache_manager_main_clear_confirm(widget);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1125 static void cache_manager_render_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127 cache_manager_render_dialog(widget, homedir());
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1129
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1130 static void cache_manager_metadata_clean_cb(GtkWidget *widget, gpointer data)
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 cache_maintain_home(TRUE, FALSE, widget);
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
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 static CacheManager *cache_manager = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1137
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 static void cache_manager_close_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 generic_dialog_close(gd);
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 g_free(cache_manager);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143 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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146 void cache_manager_show(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1148 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1149 GtkWidget *group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1151 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1153 GtkSizeGroup *sizegroup;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156 if (cache_manager)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1158 gtk_window_present(GTK_WINDOW(cache_manager->dialog->dialog));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1162 cache_manager = g_new0(CacheManager, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1163
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 138
diff changeset
1164 cache_manager->dialog = generic_dialog_new(_("Cache Maintenance - Geeqie"),
228
343e560f8e15 Replace some occurences of gqview by Geeqie.
zas_
parents: 196
diff changeset
1165 "Geeqie", "cache_manager",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166 NULL, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1167 NULL, cache_manager);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 gd = cache_manager->dialog;
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 gd->cancel_cb = cache_manager_close_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171 generic_dialog_add_button(gd, GTK_STOCK_CLOSE, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172 cache_manager_close_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1174 generic_dialog_add_message(gd, NULL, _("Cache and Data Maintenance"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1175
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1176 sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1177
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 138
diff changeset
1178 group = pref_group_new(gd->vbox, FALSE, _("Geeqie thumbnail cache"), GTK_ORIENTATION_VERTICAL);
9
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 buf = g_strconcat(_("Location:"), " ", homedir(), "/", GQVIEW_CACHE_RC_THUMB, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181 label = pref_label_new(group, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185 table = pref_table_new(group, 2, 2, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187 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
1188 G_CALLBACK(cache_manager_main_clean_cb), cache_manager);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 gtk_size_group_add_widget(sizegroup, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190 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
1191
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1192 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
1193 G_CALLBACK(cache_manager_main_clear_cb), cache_manager);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 gtk_size_group_add_widget(sizegroup, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195 pref_table_label(table, 1, 1, _("Delete all cached thumbnails."), 0.0);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1198 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
1199
79
528e3432e0c0 Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents: 69
diff changeset
1200 buf = g_strconcat(_("Location:"), " ", homedir(), "/", THUMB_FOLDER_GLOBAL, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1201 label = pref_label_new(group, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1202 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1203 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1204
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1205 table = pref_table_new(group, 2, 2, FALSE, FALSE);
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 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
1208 G_CALLBACK(cache_manager_standard_clean_cb), cache_manager);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1209 gtk_size_group_add_widget(sizegroup, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1210 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
1211
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 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
1213 G_CALLBACK(cache_manager_standard_clear_cb), cache_manager);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 gtk_size_group_add_widget(sizegroup, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 pref_table_label(table, 1, 1, _("Delete all cached thumbnails."), 0.0);
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 group = pref_group_new(gd->vbox, FALSE, _("Create thumbnails"), GTK_ORIENTATION_VERTICAL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219 table = pref_table_new(group, 2, 1, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221 button = pref_table_button(table, 0, 1, GTK_STOCK_EXECUTE, _("Render"), FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 G_CALLBACK(cache_manager_render_cb), cache_manager);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 gtk_size_group_add_widget(sizegroup, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224 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
1225
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1226 group = pref_group_new(gd->vbox, FALSE, _("Metadata"), GTK_ORIENTATION_VERTICAL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1228 buf = g_strconcat(_("Location:"), " ", homedir(), "/", GQVIEW_CACHE_RC_METADATA, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1229 label = pref_label_new(group, buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233 table = pref_table_new(group, 2, 1, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 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
1236 G_CALLBACK(cache_manager_metadata_clean_cb), cache_manager);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237 gtk_size_group_add_widget(sizegroup, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238 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
1239
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1240 gtk_widget_show(cache_manager->dialog->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1242