annotate src/cache_maint.c @ 1587:5b59ccf95b2b

merged
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Fri, 01 May 2009 15:49:57 +0900
parents 24a12aa0cb54
children
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
1284
8b89e3ff286b Add year 2009 to copyright info everywhere.
zas_
parents: 1211
diff changeset
4 * Copyright (C) 2008 - 2009 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 254
diff changeset
13 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 #include "cache_maint.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 #include "cache.h"
586
905688aa2317 split filelist.c to filefilter.c and filedata.c
nadvornik
parents: 576
diff changeset
17 #include "filedata.h"
1074
ba2a41f053e6 Let Create thumbnails start in current directory (fallback to home directory if not available) as requested by Marcin Zajaczkowski (feature request 2166691).
zas_
parents: 1055
diff changeset
18 #include "layout.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "thumb.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "thumb_standard.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21 #include "ui_fileops.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include "ui_misc.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "ui_spinner.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include "ui_tabcomp.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 #include "ui_utildlg.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 typedef struct _CMData CMData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29 struct _CMData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 GList *done_list;
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1498
diff changeset
33 guint idle_id; /* event source id */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 GtkWidget *spinner;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 GtkWidget *button_stop;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 GtkWidget *button_close;
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1347
diff changeset
39 gboolean clear;
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1347
diff changeset
40 gboolean metadata;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 #define PURGE_DIALOG_WIDTH 400
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 * cache maintenance
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51
735
df6c11709106 Comment out unused static function extension_truncate().
zas_
parents: 734
diff changeset
52 #if 0
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 static gint extension_truncate(gchar *path, const gchar *ext)
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 gint l;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 gint el;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 if (!path || !ext) return FALSE;
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 l = strlen(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 el = strlen(ext);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 if (l < el || strcmp(path + (l - el), ext) != 0) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65 path[l - el] = '\0';
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 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 }
735
df6c11709106 Comment out unused static function extension_truncate().
zas_
parents: 734
diff changeset
69 #endif
9
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 static gchar *extension_find_dot(gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 {
533
e62b2e06ab7b Simplify and optimize extension_find_dot().
zas_
parents: 516
diff changeset
73 gchar *dot = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74
533
e62b2e06ab7b Simplify and optimize extension_find_dot().
zas_
parents: 516
diff changeset
75 if (!path) return NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76
533
e62b2e06ab7b Simplify and optimize extension_find_dot().
zas_
parents: 516
diff changeset
77 while (*path != '\0')
e62b2e06ab7b Simplify and optimize extension_find_dot().
zas_
parents: 516
diff changeset
78 {
e62b2e06ab7b Simplify and optimize extension_find_dot().
zas_
parents: 516
diff changeset
79 if (*path == '.') dot = path;
e62b2e06ab7b Simplify and optimize extension_find_dot().
zas_
parents: 516
diff changeset
80 path++;
e62b2e06ab7b Simplify and optimize extension_find_dot().
zas_
parents: 516
diff changeset
81 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82
533
e62b2e06ab7b Simplify and optimize extension_find_dot().
zas_
parents: 516
diff changeset
83 return dot;
9
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
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1347
diff changeset
86 static gboolean isempty(const gchar *path)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 DIR *dp;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 struct dirent *dir;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 pathl = path_from_utf8(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 dp = opendir(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 if (!dp) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 while ((dir = readdir(dp)) != NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 gchar *name = dir->d_name;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100
69
31759d770628 Fri Oct 13 10:27:22 2006 John Ellis <johne@verizon.net>
gqview
parents: 9
diff changeset
101 if (!(name[0] == '.' && (name[1] == '\0' || (name[1] == '.' && name[2] == '\0'))) )
9
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 closedir(dp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 }
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 closedir(dp);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 return TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 static void cache_maintain_home_close(CMData *cm)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113 {
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1498
diff changeset
114 if (cm->idle_id) g_source_remove(cm->idle_id);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 if (cm->gd) generic_dialog_close(cm->gd);
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
116 filelist_free(cm->list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 g_list_free(cm->done_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 g_free(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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 static void cache_maintain_home_stop(CMData *cm)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 {
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1498
diff changeset
123 if (cm->idle_id)
9
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 g_source_remove(cm->idle_id);
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1498
diff changeset
126 cm->idle_id = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 }
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_entry_set_text(GTK_ENTRY(cm->entry), _("done"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 spinner_set_interval(cm->spinner, -1);
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 gtk_widget_set_sensitive(cm->button_stop, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 gtk_widget_set_sensitive(cm->button_close, TRUE);
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
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1347
diff changeset
136 static gboolean cache_maintain_home_cb(gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 CMData *cm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 GList *dlist = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 GList *list = NULL;
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
141 FileData *fd;
734
e6ebae313d46 Fix up some types, make some signed vs unsigned warnings quiet.
zas_
parents: 710
diff changeset
142 gboolean just_done = FALSE;
e6ebae313d46 Fix up some types, make some signed vs unsigned warnings quiet.
zas_
parents: 710
diff changeset
143 gboolean still_have_a_file = TRUE;
e6ebae313d46 Fix up some types, make some signed vs unsigned warnings quiet.
zas_
parents: 710
diff changeset
144 gsize base_length;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 const gchar *cache_folder;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 if (cm->metadata)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 {
1145
3a7af6a8cd5f Use functions to return directories instead of constants.
zas_
parents: 1074
diff changeset
149 cache_folder = get_metadata_cache_dir();
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 {
1145
3a7af6a8cd5f Use functions to return directories instead of constants.
zas_
parents: 1074
diff changeset
153 cache_folder = get_thumbnails_cache_dir();
9
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
1145
3a7af6a8cd5f Use functions to return directories instead of constants.
zas_
parents: 1074
diff changeset
156 base_length = strlen(cache_folder);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 if (!cm->list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 {
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
160 DEBUG_1("purge chk done.");
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1498
diff changeset
161 cm->idle_id = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 cache_maintain_home_stop(cm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 return FALSE;
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
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
166 fd = cm->list->data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
168 DEBUG_1("purge chk (%d) \"%s\"", (cm->clear && !cm->metadata), fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
170 if (g_list_find(cm->done_list, fd) == NULL)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
172 cm->done_list = g_list_prepend(cm->done_list, fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
174 if (filelist_read(fd, &list, &dlist))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 GList *work;
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 just_done = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 still_have_a_file = FALSE;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 333
diff changeset
180
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
184 FileData *fd_list = work->data;
1307
e8f21b91885d Glibification again.
zas_
parents: 1284
diff changeset
185 gchar *path_buf = g_strdup(fd_list->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 gchar *dot;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 333
diff changeset
187
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 dot = extension_find_dot(path_buf);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 333
diff changeset
189
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 if (dot) *dot = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 if ((!cm->metadata && cm->clear) ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 (strlen(path_buf) > base_length && !isfile(path_buf + base_length)) )
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 if (dot) *dot = '.';
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
195 if (!unlink_file(path_buf)) log_printf("failed to delete:%s\n", path_buf);
9
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 else
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 still_have_a_file = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 }
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
201 g_free(path_buf);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 }
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 }
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
206 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 cm->list = g_list_concat(dlist, cm->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 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
211 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 /* check if the dir is empty */
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 333
diff changeset
213
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
214 if (cm->list->data == fd && just_done)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
216 if (!still_have_a_file && !dlist && cm->list->next && !rmdir_utf8(fd->path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
218 log_printf("Unable to delete dir: %s\n", fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 }
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 else
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 /* must re-check for an empty dir */
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
224 if (isempty(fd->path) && cm->list->next && !rmdir_utf8(fd->path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
226 log_printf("Unable to delete dir: %s\n", fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
230 fd = cm->list->data;
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
231 cm->done_list = g_list_remove(cm->done_list, fd);
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
232 cm->list = g_list_remove(cm->list, fd);
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
233 file_data_unref(fd);
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 if (cm->list)
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 const gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
240 fd = cm->list->data;
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
241 if (strlen(fd->path) > base_length)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
243 buf = fd->path + base_length;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 else
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 buf = "...";
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 gtk_entry_set_text(GTK_ENTRY(cm->entry), buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 }
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 return TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 static void cache_maintain_home_close_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 CMData *cm = data;
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 if (!GTK_WIDGET_SENSITIVE(cm->button_close)) return;
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 cache_maintain_home_close(cm);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 static void cache_maintain_home_stop_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 CMData *cm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 cache_maintain_home_stop(cm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 /* sorry for complexity (cm->done_list), but need it to remove empty dirs */
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1347
diff changeset
272 void cache_maintain_home(gboolean metadata, gboolean clear, GtkWidget *parent)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 CMData *cm;
780
44128da39e13 Drop initialization to NULL since filelist_read() will take care of it.
zas_
parents: 735
diff changeset
275 GList *dlist;
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
276 FileData *dir_fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 const gchar *msg;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 const gchar *cache_folder;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 if (metadata)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 {
1145
3a7af6a8cd5f Use functions to return directories instead of constants.
zas_
parents: 1074
diff changeset
283 cache_folder = get_metadata_cache_dir();
9
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 {
1145
3a7af6a8cd5f Use functions to return directories instead of constants.
zas_
parents: 1074
diff changeset
287 cache_folder = get_thumbnails_cache_dir();
9
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
1145
3a7af6a8cd5f Use functions to return directories instead of constants.
zas_
parents: 1074
diff changeset
290 dir_fd = file_data_new_simple(cache_folder);
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
291 if (!filelist_read(dir_fd, NULL, &dlist))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 {
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
293 file_data_unref(dir_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
297 dlist = g_list_append(dlist, dir_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 cm = g_new0(CMData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 cm->list = dlist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 cm->done_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 cm->clear = clear;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 cm->metadata = 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 if (metadata)
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 = _("Removing old metadata...");
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 if (clear)
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 = _("Clearing cached 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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 msg = _("Removing old thumbnails...");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318 cm->gd = generic_dialog_new(_("Maintenance"),
1174
0bea79d87065 Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents: 1148
diff changeset
319 "main_maintenance",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 parent, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 NULL, cm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 cm->gd->cancel_cb = cache_maintain_home_close_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 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
324 cache_maintain_home_close_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 gtk_widget_set_sensitive(cm->button_close, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 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
327 cache_maintain_home_stop_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 generic_dialog_add_message(cm->gd, NULL, msg, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 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
331
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332 hbox = gtk_hbox_new(FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 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
334 gtk_widget_show(hbox);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 cm->entry = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 GTK_WIDGET_UNSET_FLAGS(cm->entry, GTK_CAN_FOCUS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 gtk_editable_set_editable(GTK_EDITABLE(cm->entry), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 gtk_box_pack_start(GTK_BOX(hbox), cm->entry, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 gtk_widget_show(cm->entry);
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 cm->spinner = spinner_new(NULL, SPINNER_SPEED);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 gtk_box_pack_start(GTK_BOX(hbox), cm->spinner, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 gtk_widget_show(cm->spinner);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 333
diff changeset
345
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346 gtk_widget_show(cm->gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 cm->idle_id = g_idle_add(cache_maintain_home_cb, cm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350
710
a1e8c78a03ab Disable unused code:
zas_
parents: 709
diff changeset
351 #if 0
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
352 /* This checks all files in ~/GQ_RC_DIR/thumbnails and
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 * removes them if thay have no source counterpart.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 * (this assumes all cache files have an extension of 4 chars including '.')
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 gint base_length;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 GList *dlist = NULL;
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
361 FileData *dir_fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 GList *flist = NULL;
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1432
diff changeset
363 gboolean still_have_a_file = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
365 DEBUG_1("maintainance check: %s", dir);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366
283
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
367 base_length = strlen(homedir()) + strlen("/") + strlen(GQ_CACHE_RC_THUMB);
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
368 base = g_strconcat(homedir(), "/", GQ_CACHE_RC_THUMB, dir, NULL);
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
369 dir_fd = file_data_new_simple(base);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
370 g_free(base);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
372 if (filelist_read(dir_fd, &flist, &dlist))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 work = dlist;
516
b7e99bfeadc9 Convert the minority of while() to while ().
zas_
parents: 507
diff changeset
377 while (work)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
379 FileData *fd = work->data;
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
380 if (recursive && strlen(fd->path) > base_length &&
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
381 !cache_maintain_home_dir(fd->path + base_length, recursive, clear))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
383 DEBUG_1("Deleting thumb dir: %s", fd->path);
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
384 if (!rmdir_utf8(fd->path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
386 log_printf("Unable to delete dir: %s\n", fd->path);
9
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 else
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 still_have_a_file = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 }
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 work = flist;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
399 FileData *fd = work->data;
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
400 gchar *path = g_strdup(fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 gchar *dot;
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 dot = extension_find_dot(path);
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 if (dot) *dot = '\0';
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 if (clear ||
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 (strlen(path) > base_length && !isfile(path + base_length)) )
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 if (dot) *dot = '.';
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
410 if (!unlink_file(path)) log_printf("failed to delete:%s\n", path);
9
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 still_have_a_file = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 }
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
416 g_free(path);
9
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 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
422 filelist_free(dlist);
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
423 filelist_free(flist);
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
424 file_data_unref(dir_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426 return still_have_a_file;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 }
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 /* This checks relative caches in dir/.thumbnails and
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430 * removes them if they have no source counterpart.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 */
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
432 gint cache_maintain_dir(FileData *dir_fd, gint recursive, gint clear)
9
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 GList *list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 gchar *cachedir;
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
436 FileData *cachedir_fd;
1437
a3d3208b0c50 gint -> gboolean.
zas_
parents: 1432
diff changeset
437 gboolean still_have_a_file = FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 GList *work;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439
707
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
440 cachedir = g_build_filename(dir, GQ_CACHE_LOCAL_THUMB, NULL);
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
441 cachedir_fd = file_data_new_simple(cachedir);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
442 g_free(cachedir);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
444 filelist_read(cachedir_fd, &list, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
449 FileData *fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 gchar *source;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
452 fd = work->data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
455 source = g_build_filename(dir->path, fd->name, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 if (clear ||
283
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
458 extension_truncate(source, GQ_CACHE_EXT_THUMB) ||
e213fb025621 GQVIEW_* -> GQ_*
zas_
parents: 281
diff changeset
459 extension_truncate(source, GQ_CACHE_EXT_SIM))
9
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 if (!clear && isfile(source))
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 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
467 if (!unlink_file(fd->path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
469 DEBUG_1("Failed to remove cache file %s", fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 still_have_a_file = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 still_have_a_file = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 g_free(source);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
481 filelist_free(list);
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
482 file_data_unref(cachedir_fd);
9
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 if (recursive)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
488 filelist_read(dir_fd, NULL, &list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 work = list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 while (work)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
492 FileData *fd = work->data;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 work = work->next;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
495 still_have_a_file |= cache_maintain_dir(fd->path, recursive, clear);
9
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
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
498 filelist_free(list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 return still_have_a_file;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 }
710
a1e8c78a03ab Disable unused code:
zas_
parents: 709
diff changeset
503 #endif
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 static void cache_file_move(const gchar *src, const gchar *dest)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 if (!dest || !src || !isfile(src)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 if (!move_file(src, dest))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 {
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
511 DEBUG_1("Failed to move cache file \"%s\" to \"%s\"", src, dest);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 /* we remove it anyway - it's stale */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 unlink_file(src);
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 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516
793
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
517 static void cache_maint_moved(FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 gchar *base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 mode_t mode = 0755;
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
521 const gchar *src = fd->change->source;
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
522 const gchar *dest = fd->change->dest;
9
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 if (!src || !dest) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 base = cache_get_location(CACHE_TYPE_THUMB, dest, FALSE, &mode);
1148
95860439070b Replace cache_ensure_dir_exists() by new recursive_mkdir_if_not_exists().
zas_
parents: 1145
diff changeset
527 if (recursive_mkdir_if_not_exists(base, mode))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 gchar *d;
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 buf = cache_find_location(CACHE_TYPE_THUMB, src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 d = cache_get_location(CACHE_TYPE_THUMB, dest, TRUE, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 cache_file_move(buf, d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 g_free(d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 buf = cache_find_location(CACHE_TYPE_SIM, src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 d = cache_get_location(CACHE_TYPE_SIM, dest, TRUE, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 cache_file_move(buf, d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 g_free(d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 {
673
fbebf5cf4a55 Do not use printf() directly but use new wrapper function log_printf() instead.
zas_
parents: 671
diff changeset
546 log_printf("Failed to create cache dir for move %s\n", base);
9
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 base = cache_get_location(CACHE_TYPE_METADATA, dest, FALSE, &mode);
1148
95860439070b Replace cache_ensure_dir_exists() by new recursive_mkdir_if_not_exists().
zas_
parents: 1145
diff changeset
551 if (recursive_mkdir_if_not_exists(base, mode))
9
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 gchar *buf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 gchar *d;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 333
diff changeset
555
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 buf = cache_find_location(CACHE_TYPE_METADATA, src);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 d = cache_get_location(CACHE_TYPE_METADATA, dest, TRUE, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 cache_file_move(buf, d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 g_free(d);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
564 if (options->thumbnails.enable_caching && options->thumbnails.spec_standard)
318
b16b9b8979e5 Add a new struct ConfOptions to handle options.
zas_
parents: 288
diff changeset
565 thumb_std_maint_moved(src, dest);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 static void cache_file_remove(const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 if (path && isfile(path) && !unlink_file(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 {
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
572 DEBUG_1("Failed to remove cache file %s", path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575
793
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
576 static void cache_maint_removed(FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 gchar *buf;
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 buf = cache_find_location(CACHE_TYPE_THUMB, fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 cache_file_remove(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
584 buf = cache_find_location(CACHE_TYPE_SIM, fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 cache_file_remove(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
588 buf = cache_find_location(CACHE_TYPE_METADATA, fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 cache_file_remove(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 g_free(buf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
592 if (options->thumbnails.enable_caching && options->thumbnails.spec_standard)
318
b16b9b8979e5 Add a new struct ConfOptions to handle options.
zas_
parents: 288
diff changeset
593 thumb_std_maint_removed(fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595
793
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
596 static void cache_maint_copied(FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 gchar *dest_base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 gchar *src_cache;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 mode_t mode = 0755;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
602 src_cache = cache_find_location(CACHE_TYPE_METADATA, fd->change->source);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 if (!src_cache) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
605 dest_base = cache_get_location(CACHE_TYPE_METADATA, fd->change->dest, FALSE, &mode);
1148
95860439070b Replace cache_ensure_dir_exists() by new recursive_mkdir_if_not_exists().
zas_
parents: 1145
diff changeset
606 if (recursive_mkdir_if_not_exists(dest_base, mode))
9
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 gchar *path;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 333
diff changeset
609
138
71e1ebee420e replaced gchar* path with FileData *fd
nadvornik
parents: 79
diff changeset
610 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
611 if (!copy_file(src_cache, path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 {
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
613 DEBUG_1("failed to copy metadata %s to %s", src_cache, path);
9
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 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 g_free(dest_base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 g_free(src_cache);
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
793
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
622 void cache_notify_cb(FileData *fd, NotifyType type, gpointer data)
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
623 {
1432
cf4029d10d38 improved notification system
nadvornik
parents: 1420
diff changeset
624 if (!(type & NOTIFY_CHANGE) || !fd->change) return;
793
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
625
1498
5f49f305a6b6 improved debug messages
nadvornik
parents: 1437
diff changeset
626 DEBUG_1("Notify cache_maint: %s %04x", fd->path, type);
1347
79937bc55f3a Add missing space between switch and first parenthesis.
zas_
parents: 1307
diff changeset
627 switch (fd->change->type)
793
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
628 {
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
629 case FILEDATA_CHANGE_MOVE:
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
630 case FILEDATA_CHANGE_RENAME:
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
631 cache_maint_moved(fd);
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
632 break;
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
633 case FILEDATA_CHANGE_COPY:
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
634 cache_maint_copied(fd);
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
635 break;
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
636 case FILEDATA_CHANGE_DELETE:
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
637 cache_maint_removed(fd);
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
638 break;
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
639 case FILEDATA_CHANGE_UNSPECIFIED:
1211
e2bbe90b0dcd most of the metadata options now works
nadvornik
parents: 1174
diff changeset
640 case FILEDATA_CHANGE_WRITE_METADATA:
793
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
641 break;
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
642 }
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
643 }
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
644
baade53888be used new notification in cache_maint
nadvornik
parents: 783
diff changeset
645
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
646 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
647 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 * new cache maintenance utilities
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 *-------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 */
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 typedef struct _CacheManager CacheManager;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 struct _CacheManager
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 GenericDialog *dialog;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 GtkWidget *folder_entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 GtkWidget *progress;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 GList *list_todo;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
661 gint count_total;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 gint count_done;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665 typedef struct _CleanData CleanData;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
666 struct _CleanData
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669 ThumbLoaderStd *tl;
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 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
672 GList *list_dir;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
673
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
674 gint days;
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1347
diff changeset
675 gboolean clear;
9
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 GtkWidget *button_close;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 GtkWidget *button_stop;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 GtkWidget *button_start;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680 GtkWidget *progress;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
681 GtkWidget *spinner;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
682
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 GtkWidget *group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684 GtkWidget *entry;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
686 gint count_total;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 gint count_done;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1347
diff changeset
689 gboolean local;
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1347
diff changeset
690 gboolean recurse;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1498
diff changeset
692 guint idle_id; /* event source id */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 };
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 static void cache_manager_render_reset(CleanData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
697 filelist_free(cd->list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698 cd->list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
700 filelist_free(cd->list_dir);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701 cd->list_dir = 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 thumb_loader_free((ThumbLoader *)cd->tl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
704 cd->tl = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
705 }
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 static void cache_manager_render_close_cb(GenericDialog *fd, gpointer data)
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 CleanData *cd = data;
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 if (!GTK_WIDGET_SENSITIVE(cd->button_close)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 cache_manager_render_reset(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
714 generic_dialog_close(cd->gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 g_free(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 }
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 static void cache_manager_render_finish(CleanData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720 cache_manager_render_reset(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 gtk_entry_set_text(GTK_ENTRY(cd->progress), _("done"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 spinner_set_interval(cd->spinner, -1);
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 gtk_widget_set_sensitive(cd->group, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 gtk_widget_set_sensitive(cd->button_start, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 gtk_widget_set_sensitive(cd->button_stop, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728 gtk_widget_set_sensitive(cd->button_close, TRUE);
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 void cache_manager_render_stop_cb(GenericDialog *fd, gpointer data)
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 CleanData *cd = data;
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 cache_manager_render_finish(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
738 static void cache_manager_render_folder(CleanData *cd, FileData *dir_fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
740 GList *list_d = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 GList *list_f = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 if (cd->recurse)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 {
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
745 filelist_read(dir_fd, &list_f, &list_d);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 {
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
749 filelist_read(dir_fd, &list_f, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
752 list_f = filelist_filter(list_f, FALSE);
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
753 list_d = filelist_filter(list_d, TRUE);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 cd->list = g_list_concat(list_f, cd->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756 cd->list_dir = g_list_concat(list_d, cd->list_dir);
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
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1347
diff changeset
759 static gboolean cache_manager_render_file(CleanData *cd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 static void cache_manager_render_thumb_done_cb(ThumbLoader *tl, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 CleanData *cd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 thumb_loader_free((ThumbLoader *)cd->tl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766 cd->tl = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 while (cache_manager_render_file(cd));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1347
diff changeset
771 static gboolean cache_manager_render_file(CleanData *cd)
9
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 if (cd->list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
775 FileData *fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 gint success;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
778 fd = cd->list->data;
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
779 cd->list = g_list_remove(cd->list, fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
781 cd->tl = (ThumbLoaderStd *)thumb_loader_new(options->thumbnails.max_width, options->thumbnails.max_height);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782 thumb_loader_set_callbacks((ThumbLoader *)cd->tl,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 cache_manager_render_thumb_done_cb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784 cache_manager_render_thumb_done_cb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 NULL, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 thumb_loader_set_cache((ThumbLoader *)cd->tl, TRUE, cd->local, TRUE);
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 803
diff changeset
787 success = thumb_loader_start((ThumbLoader *)cd->tl, fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 if (success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
790 gtk_entry_set_text(GTK_ENTRY(cd->progress), fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
794 thumb_loader_free((ThumbLoader *)cd->tl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
795 cd->tl = NULL;
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
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
798 file_data_unref(fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800 return (!success);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 else if (cd->list_dir)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
804 FileData *fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
806 fd = cd->list_dir->data;
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
807 cd->list_dir = g_list_remove(cd->list_dir, fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
809 cache_manager_render_folder(cd, fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
811 file_data_unref(fd);
9
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 return TRUE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 cache_manager_render_finish(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818 return FALSE;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821 static void cache_manager_render_start_cb(GenericDialog *fd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
822 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823 CleanData *cd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 if (cd->list || !GTK_WIDGET_SENSITIVE(cd->button_start)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 path = remove_trailing_slash((gtk_entry_get_text(GTK_ENTRY(cd->entry))));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829 parse_out_relatives(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 if (!isdir(path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 warning_dialog(_("Invalid folder"),
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 333
diff changeset
834 _("The specified folder can not be found."),
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 GTK_STOCK_DIALOG_WARNING, cd->gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 {
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
839 FileData *dir_fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 gtk_widget_set_sensitive(cd->group, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 gtk_widget_set_sensitive(cd->button_start, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842 gtk_widget_set_sensitive(cd->button_stop, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843 gtk_widget_set_sensitive(cd->button_close, FALSE);
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 spinner_set_interval(cd->spinner, SPINNER_SPEED);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
847 dir_fd = file_data_new_simple(path);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
848 cache_manager_render_folder(cd, dir_fd);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
849 file_data_unref(dir_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 while (cache_manager_render_file(cd));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856 static void cache_manager_render_dialog(GtkWidget *widget, const gchar *path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 CleanData *cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859 GtkWidget *hbox;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 GtkWidget *label;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863 cd = g_new0(CleanData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865 cd->gd = generic_dialog_new(_("Create thumbnails"),
1174
0bea79d87065 Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents: 1148
diff changeset
866 "create_thumbnails",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867 widget, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 NULL, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 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
870 cd->gd->cancel_cb = cache_manager_render_close_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 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
872 cache_manager_render_close_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 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
874 cache_manager_render_start_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875 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
876 cache_manager_render_stop_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877 gtk_widget_set_sensitive(cd->button_stop, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879 generic_dialog_add_message(cd->gd, NULL, _("Create thumbnails"), NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
881 hbox = pref_box_new(cd->gd->vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 pref_spacer(hbox, PREF_PAD_INDENT);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883 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
884
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 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
886 pref_label_new(hbox, _("Folder:"));
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 label = tab_completion_new(&cd->entry, path, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889 tab_completion_add_select_button(cd->entry,_("Select folder") , TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 gtk_widget_show(label);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 pref_checkbox_new_int(cd->group, _("Include subfolders"), FALSE, &cd->recurse);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 button = pref_checkbox_new_int(cd->group, _("Store thumbnails local to source images"), FALSE, &cd->local);
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
895 gtk_widget_set_sensitive(button, options->thumbnails.spec_standard);
9
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 pref_line(cd->gd->vbox, PREF_PAD_SPACE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 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
899
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900 cd->progress = gtk_entry_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901 GTK_WIDGET_UNSET_FLAGS(cd->progress, GTK_CAN_FOCUS);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 gtk_editable_set_editable(GTK_EDITABLE(cd->progress), FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
903 gtk_entry_set_text(GTK_ENTRY(cd->progress), _("click start to begin"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 gtk_box_pack_start(GTK_BOX(hbox), cd->progress, TRUE, TRUE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 gtk_widget_show(cd->progress);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 cd->spinner = spinner_new(NULL, -1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908 gtk_box_pack_start(GTK_BOX(hbox), cd->spinner, FALSE, FALSE, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 gtk_widget_show(cd->spinner);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 cd->list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 gtk_widget_show(cd->gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914 }
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
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 static void cache_manager_standard_clean_close_cb(GenericDialog *gd, gpointer 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 CleanData *cd = data;
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 if (!GTK_WIDGET_SENSITIVE(cd->button_close)) return;
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 generic_dialog_close(cd->gd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 thumb_loader_std_thumb_file_validate_cancel(cd->tl);
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
928 filelist_free(cd->list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929 g_free(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 static void cache_manager_standard_clean_done(CleanData *cd)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 gtk_widget_set_sensitive(cd->button_stop, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935 gtk_widget_set_sensitive(cd->button_close, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(cd->progress), 1.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("done"));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1498
diff changeset
940 if (cd->idle_id)
9
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 g_source_remove(cd->idle_id);
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1498
diff changeset
943 cd->idle_id = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946 thumb_loader_std_thumb_file_validate_cancel(cd->tl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947 cd->tl = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
949 filelist_free(cd->list);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950 cd->list = NULL;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 static void cache_manager_standard_clean_stop_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955 CleanData *cd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
956
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
957 cache_manager_standard_clean_done(cd);
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 static gint cache_manager_standard_clean_clear_cb(gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962 CleanData *cd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 if (cd->list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
966 FileData *next_fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
968 next_fd = cd->list->data;
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
969 cd->list = g_list_remove(cd->list, next_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
971 DEBUG_1("thumb removed: %s", next_fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
973 unlink_file(next_fd->path);
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
974 file_data_unref(next_fd);
9
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->count_done++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 if (cd->count_total != 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
979 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(cd->progress),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
980 (gdouble)cd->count_done / cd->count_total);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
983 return TRUE;
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
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1498
diff changeset
986 cd->idle_id = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 cache_manager_standard_clean_done(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1347
diff changeset
991 static void cache_manager_standard_clean_valid_cb(const gchar *path, gboolean valid, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
993 CleanData *cd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 if (path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997 if (!valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
998 {
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
999 DEBUG_1("thumb cleaned: %s", path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1000 unlink_file(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 cd->count_done++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 if (cd->count_total != 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(cd->progress),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007 (gdouble)cd->count_done / cd->count_total);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011 cd->tl = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012 if (cd->list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013 {
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
1014 FileData *next_fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
1016 next_fd = cd->list->data;
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
1017 cd->list = g_list_remove(cd->list, next_fd);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 333
diff changeset
1018
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
1019 cd->tl = thumb_loader_std_thumb_file_validate(next_fd->path, cd->days,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020 cache_manager_standard_clean_valid_cb, cd);
576
9dc0513837b5 dropped path_list functions, use filelist functions everywhere
nadvornik
parents: 533
diff changeset
1021 file_data_unref(next_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025 cache_manager_standard_clean_done(cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026 }
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 static void cache_manager_standard_clean_start_cb(GenericDialog *gd, gpointer data)
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 CleanData *cd = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 GList *list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 gchar *path;
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
1034 FileData *dir_fd;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036 if (cd->list || !GTK_WIDGET_SENSITIVE(cd->button_start)) return;
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 gtk_widget_set_sensitive(cd->button_start, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039 gtk_widget_set_sensitive(cd->button_stop, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040 gtk_widget_set_sensitive(cd->button_close, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("running..."));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043
707
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1044 path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_NORMAL, NULL);
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
1045 dir_fd = file_data_new_simple(path);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
1046 filelist_read(dir_fd, &list, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 cd->list = list;
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
1048 file_data_unref(dir_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050
707
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1051 path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_LARGE, NULL);
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
1052 dir_fd = file_data_new_simple(path);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
1053 filelist_read(dir_fd, &list, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054 cd->list = g_list_concat(cd->list, list);
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
1055 file_data_unref(dir_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 g_free(path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057
707
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1058 path = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, THUMB_FOLDER_FAIL, NULL);
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
1059 dir_fd = file_data_new_simple(path);
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
1060 filelist_read(dir_fd, &list, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 cd->list = g_list_concat(cd->list, list);
783
d6a7fb4b8e7c replaced directory path with FileData* dir_fd
nadvornik
parents: 780
diff changeset
1062 file_data_unref(dir_fd);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 g_free(path);
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 cd->count_total = g_list_length(cd->list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 cd->count_done = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 /* start iterating */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069 if (cd->clear)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 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
1072 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 cache_manager_standard_clean_valid_cb(NULL, TRUE, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076 }
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
1420
3a9fb1b52559 Use gboolean where applicable, for the sake of consistency.
zas_
parents: 1347
diff changeset
1079 static void cache_manager_standard_process(GtkWidget *widget, gboolean clear)
9
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 CleanData *cd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1082 const gchar *stock_id;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1083 const gchar *msg;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1084
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1085 cd = g_new0(CleanData, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1086 cd->clear = clear;
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 if (clear)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1089 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1090 stock_id = GTK_STOCK_DELETE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1091 msg = _("Clearing thumbnails...");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1093 else
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 stock_id = GTK_STOCK_CLEAR;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1096 msg = _("Removing old thumbnails...");
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1099 cd->gd = generic_dialog_new(_("Maintenance"),
1174
0bea79d87065 Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents: 1148
diff changeset
1100 "standard_maintenance",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1101 widget, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1102 NULL, cd);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1103 cd->gd->cancel_cb = cache_manager_standard_clean_close_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1104 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
1105 cache_manager_standard_clean_close_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1106 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
1107 cache_manager_standard_clean_start_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1108 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
1109 cache_manager_standard_clean_stop_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1110 gtk_widget_set_sensitive(cd->button_stop, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1111
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1112 generic_dialog_add_message(cd->gd, stock_id, msg, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1113
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1114 cd->progress = gtk_progress_bar_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1115 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
1116 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
1117 gtk_widget_show(cd->progress);
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 cd->days = 30;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1120 cd->tl = NULL;
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1498
diff changeset
1121 cd->idle_id = 0;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1122
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1123 gtk_widget_show(cd->gd->dialog);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1126 static void cache_manager_standard_clean_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1127 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1128 cache_manager_standard_process(widget, FALSE);
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1131 static void cache_manager_standard_clear_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1132 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1133 cache_manager_standard_process(widget, TRUE);
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
229
c44b98370dba Use more generic names for some cache manager callback functions.
zas_
parents: 228
diff changeset
1137 static void cache_manager_main_clean_cb(GtkWidget *widget, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1138 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1139 cache_maintain_home(FALSE, FALSE, widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1140 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1141
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1142
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1143 static void dummy_cancel_cb(GenericDialog *gd, gpointer data)
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 /* no op, only so cancel button appears */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1146 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1147
229
c44b98370dba Use more generic names for some cache manager callback functions.
zas_
parents: 228
diff changeset
1148 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
1149 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1150 cache_maintain_home(FALSE, TRUE, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1151 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1152
229
c44b98370dba Use more generic names for some cache manager callback functions.
zas_
parents: 228
diff changeset
1153 void cache_manager_main_clear_confirm(GtkWidget *parent)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1154 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1155 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1156
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1157 gd = generic_dialog_new(_("Clear cache"),
1174
0bea79d87065 Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents: 1148
diff changeset
1158 "clear_cache", parent, TRUE,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1159 dummy_cancel_cb, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1160 generic_dialog_add_message(gd, GTK_STOCK_DIALOG_QUESTION, _("Clear cache"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1161 _("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
1162 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
1163
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1164 gtk_widget_show(gd->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1165 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1166
229
c44b98370dba Use more generic names for some cache manager callback functions.
zas_
parents: 228
diff changeset
1167 static void cache_manager_main_clear_cb(GtkWidget *widget, gpointer data)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1168 {
229
c44b98370dba Use more generic names for some cache manager callback functions.
zas_
parents: 228
diff changeset
1169 cache_manager_main_clear_confirm(widget);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1170 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1171
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1172 static void cache_manager_render_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1173 {
1074
ba2a41f053e6 Let Create thumbnails start in current directory (fallback to home directory if not available) as requested by Marcin Zajaczkowski (feature request 2166691).
zas_
parents: 1055
diff changeset
1174 const gchar *path = layout_get_path(NULL);
ba2a41f053e6 Let Create thumbnails start in current directory (fallback to home directory if not available) as requested by Marcin Zajaczkowski (feature request 2166691).
zas_
parents: 1055
diff changeset
1175
ba2a41f053e6 Let Create thumbnails start in current directory (fallback to home directory if not available) as requested by Marcin Zajaczkowski (feature request 2166691).
zas_
parents: 1055
diff changeset
1176 if (!path || !*path) path = homedir();
ba2a41f053e6 Let Create thumbnails start in current directory (fallback to home directory if not available) as requested by Marcin Zajaczkowski (feature request 2166691).
zas_
parents: 1055
diff changeset
1177 cache_manager_render_dialog(widget, path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1178 }
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 static void cache_manager_metadata_clean_cb(GtkWidget *widget, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1181 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1182 cache_maintain_home(TRUE, FALSE, widget);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1183 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1184
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1185
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1186 static CacheManager *cache_manager = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1187
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1188 static void cache_manager_close_cb(GenericDialog *gd, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1189 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1190 generic_dialog_close(gd);
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 g_free(cache_manager);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1193 cache_manager = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1194 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1195
707
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1196 static GtkWidget *cache_manager_location_label(GtkWidget *group, const gchar *subdir)
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1197 {
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1198 GtkWidget *label;
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1199 gchar *buf;
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1200 gchar *path;
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1201
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1202 path = g_build_filename(homedir(), subdir, NULL);
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1203 buf = g_strdup_printf(_("Location: %s"), path);
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1204 g_free(path);
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1205 label = pref_label_new(group, buf);
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1206 g_free(buf);
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1207 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1208
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1209 return label;
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1210 }
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1211
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1212 void cache_manager_show(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1213 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1214 GenericDialog *gd;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1215 GtkWidget *group;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1216 GtkWidget *button;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1217 GtkWidget *table;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1218 GtkSizeGroup *sizegroup;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1219
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1220 if (cache_manager)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1221 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1222 gtk_window_present(GTK_WINDOW(cache_manager->dialog->dialog));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1223 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1224 }
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 cache_manager = g_new0(CacheManager, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1227
675
cca86176bf81 Fix redundant application name in window titles.
zas_
parents: 673
diff changeset
1228 cache_manager->dialog = generic_dialog_new(_("Cache Maintenance"),
1174
0bea79d87065 Drop useless wmclass stuff. Gtk will take care of it and as said in the documentation using gtk_window_set_wmclass() is sort of pointless.
zas_
parents: 1148
diff changeset
1229 "cache_manager",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1230 NULL, FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1231 NULL, cache_manager);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1232 gd = cache_manager->dialog;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1233
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1234 gd->cancel_cb = cache_manager_close_cb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1235 generic_dialog_add_button(gd, GTK_STOCK_CLOSE, NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1236 cache_manager_close_cb, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1237
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1238 generic_dialog_add_message(gd, NULL, _("Cache and Data Maintenance"), NULL);
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 sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1241
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1242 group = pref_group_new(gd->vbox, FALSE, _("Thumbnail cache"), GTK_ORIENTATION_VERTICAL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1243
1145
3a7af6a8cd5f Use functions to return directories instead of constants.
zas_
parents: 1074
diff changeset
1244 cache_manager_location_label(group, get_thumbnails_cache_dir());
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1245
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1246 table = pref_table_new(group, 2, 2, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1247
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1248 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
1249 G_CALLBACK(cache_manager_main_clean_cb), cache_manager);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1250 gtk_size_group_add_widget(sizegroup, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1251 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
1252
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1253 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
1254 G_CALLBACK(cache_manager_main_clear_cb), cache_manager);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1255 gtk_size_group_add_widget(sizegroup, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1256 pref_table_label(table, 1, 1, _("Delete all cached thumbnails."), 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1257
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1258
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1259 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
1260
707
41c17c66e63b Use g_build_filename() and move location label creation from cache_manager_show() to new cache_manager_location_label().
zas_
parents: 675
diff changeset
1261 cache_manager_location_label(group, THUMB_FOLDER_GLOBAL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1262
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1263 table = pref_table_new(group, 2, 2, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1264
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1265 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
1266 G_CALLBACK(cache_manager_standard_clean_cb), cache_manager);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1267 gtk_size_group_add_widget(sizegroup, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1268 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
1269
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1270 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
1271 G_CALLBACK(cache_manager_standard_clear_cb), cache_manager);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1272 gtk_size_group_add_widget(sizegroup, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1273 pref_table_label(table, 1, 1, _("Delete all cached thumbnails."), 0.0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1274
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1275 group = pref_group_new(gd->vbox, FALSE, _("Create thumbnails"), GTK_ORIENTATION_VERTICAL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1276
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1277 table = pref_table_new(group, 2, 1, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1278
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1279 button = pref_table_button(table, 0, 1, GTK_STOCK_EXECUTE, _("Render"), FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1280 G_CALLBACK(cache_manager_render_cb), cache_manager);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1281 gtk_size_group_add_widget(sizegroup, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1282 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
1283
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1284 group = pref_group_new(gd->vbox, FALSE, _("Metadata"), GTK_ORIENTATION_VERTICAL);
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 283
diff changeset
1285
1145
3a7af6a8cd5f Use functions to return directories instead of constants.
zas_
parents: 1074
diff changeset
1286 cache_manager_location_label(group, get_metadata_cache_dir());
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1287
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1288 table = pref_table_new(group, 2, 1, FALSE, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1289
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1290 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
1291 G_CALLBACK(cache_manager_metadata_clean_cb), cache_manager);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1292 gtk_size_group_add_widget(sizegroup, button);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1293 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
1294
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1295 gtk_widget_show(cache_manager->dialog->dialog);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1296 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 838
diff changeset
1297 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */