Statistics
| Revision:

root / src / prefs_search_folder.c @ 1614

History | View | Annotate | Download (12.7 kB)

1 879 hiro
/*
2 879 hiro
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 912 hiro
 * Copyright (C) 1999-2006 Hiroyuki Yamamoto
4 879 hiro
 *
5 879 hiro
 * This program is free software; you can redistribute it and/or modify
6 879 hiro
 * it under the terms of the GNU General Public License as published by
7 879 hiro
 * the Free Software Foundation; either version 2 of the License, or
8 879 hiro
 * (at your option) any later version.
9 879 hiro
 *
10 879 hiro
 * This program is distributed in the hope that it will be useful,
11 879 hiro
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 879 hiro
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 879 hiro
 * GNU General Public License for more details.
14 879 hiro
 *
15 879 hiro
 * You should have received a copy of the GNU General Public License
16 879 hiro
 * along with this program; if not, write to the Free Software
17 879 hiro
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 879 hiro
 */
19 879 hiro
20 879 hiro
#ifdef HAVE_CONFIG_H
21 879 hiro
#  include "config.h"
22 879 hiro
#endif
23 879 hiro
24 879 hiro
#include "defs.h"
25 879 hiro
26 879 hiro
#include <glib.h>
27 879 hiro
#include <glib/gi18n.h>
28 879 hiro
#include <gdk/gdkkeysyms.h>
29 879 hiro
#include <gtk/gtkwidget.h>
30 879 hiro
#include <gtk/gtkwindow.h>
31 883 hiro
#include <gtk/gtkstyle.h>
32 879 hiro
#include <gtk/gtkvbox.h>
33 879 hiro
#include <gtk/gtkoptionmenu.h>
34 879 hiro
#include <gtk/gtkmenuitem.h>
35 879 hiro
#include <gtk/gtklabel.h>
36 879 hiro
#include <gtk/gtkentry.h>
37 879 hiro
#include <gtk/gtkhbox.h>
38 879 hiro
#include <gtk/gtkcheckbutton.h>
39 879 hiro
#include <gtk/gtkhbbox.h>
40 879 hiro
#include <gtk/gtkbutton.h>
41 879 hiro
#include <gtk/gtkstock.h>
42 879 hiro
#include <stdio.h>
43 879 hiro
#include <stdlib.h>
44 879 hiro
#include <string.h>
45 879 hiro
46 879 hiro
#include "prefs_search_folder.h"
47 879 hiro
#include "prefs_ui.h"
48 879 hiro
#include "mainwindow.h"
49 879 hiro
#include "manage_window.h"
50 879 hiro
#include "alertpanel.h"
51 879 hiro
#include "foldersel.h"
52 879 hiro
#include "folder.h"
53 879 hiro
#include "filter.h"
54 879 hiro
#include "prefs_filter.h"
55 879 hiro
#include "prefs_filter_edit.h"
56 879 hiro
#include "menu.h"
57 879 hiro
#include "utils.h"
58 879 hiro
#include "gtkutils.h"
59 879 hiro
60 879 hiro
typedef struct _PrefsSearchFolderDialog        PrefsSearchFolderDialog;
61 879 hiro
62 879 hiro
struct _PrefsSearchFolderDialog
63 879 hiro
{
64 879 hiro
        PrefsDialog *dialog;
65 879 hiro
        FolderItem *item;
66 879 hiro
67 883 hiro
        GtkWidget *name_entry;
68 883 hiro
69 879 hiro
        GtkWidget *bool_optmenu;
70 879 hiro
71 879 hiro
        FilterCondEdit *cond_edit;
72 879 hiro
73 879 hiro
        GtkWidget *folder_entry;
74 879 hiro
        GtkWidget *folder_btn;
75 879 hiro
76 879 hiro
        GtkWidget *subfolder_checkbtn;
77 879 hiro
        GtkWidget *case_checkbtn;
78 928 hiro
79 928 hiro
        gboolean finished;
80 928 hiro
        gboolean updated;
81 879 hiro
};
82 879 hiro
83 879 hiro
static PrefsSearchFolderDialog *prefs_search_folder_create(FolderItem *item);
84 879 hiro
static void prefs_search_folder_set_dialog(PrefsSearchFolderDialog *dialog);
85 928 hiro
static void prefs_search_folder_destroy          (PrefsSearchFolderDialog *dialog);
86 879 hiro
87 879 hiro
static gint prefs_search_folder_delete_cb(GtkWidget                  *widget,
88 879 hiro
                                          GdkEventAny                  *event,
89 879 hiro
                                          PrefsSearchFolderDialog *dialog);
90 879 hiro
static gint prefs_search_folder_key_press_cb
91 879 hiro
                                         (GtkWidget                  *widget,
92 879 hiro
                                          GdkEventKey                  *event,
93 879 hiro
                                          PrefsSearchFolderDialog *dialog);
94 879 hiro
95 880 hiro
static void prefs_search_folder_select_folder
96 880 hiro
                                         (GtkWidget                  *widget,
97 880 hiro
                                          PrefsSearchFolderDialog *dialog);
98 880 hiro
99 879 hiro
static void prefs_search_folder_ok_cb         (GtkWidget                  *widget,
100 879 hiro
                                          PrefsSearchFolderDialog *dialog);
101 879 hiro
static void prefs_search_folder_apply_cb (GtkWidget                  *widget,
102 879 hiro
                                          PrefsSearchFolderDialog *dialog);
103 879 hiro
static void prefs_search_folder_cancel_cb(GtkWidget                  *widget,
104 879 hiro
                                          PrefsSearchFolderDialog *dialog);
105 879 hiro
106 879 hiro
107 928 hiro
gboolean prefs_search_folder_open(FolderItem *item)
108 879 hiro
{
109 879 hiro
        PrefsSearchFolderDialog *dialog;
110 928 hiro
        gboolean updated;
111 879 hiro
112 928 hiro
        g_return_val_if_fail(item != NULL, FALSE);
113 879 hiro
114 879 hiro
        dialog = prefs_search_folder_create(item);
115 879 hiro
        manage_window_set_transient(GTK_WINDOW(dialog->dialog->window));
116 879 hiro
        prefs_search_folder_set_dialog(dialog);
117 879 hiro
        gtk_widget_show(dialog->dialog->window);
118 928 hiro
119 928 hiro
        while (dialog->finished == FALSE)
120 928 hiro
                gtk_main_iteration();
121 928 hiro
122 928 hiro
        updated = dialog->updated;
123 928 hiro
        prefs_search_folder_destroy(dialog);
124 928 hiro
125 928 hiro
        return updated;
126 879 hiro
}
127 879 hiro
128 879 hiro
static PrefsSearchFolderDialog *prefs_search_folder_create(FolderItem *item)
129 879 hiro
{
130 879 hiro
        PrefsSearchFolderDialog *new_dialog;
131 879 hiro
        PrefsDialog *dialog;
132 883 hiro
        gchar *title;
133 879 hiro
        GtkWidget *vbox;
134 883 hiro
135 883 hiro
        GtkWidget *name_hbox;
136 883 hiro
        GtkWidget *name_label;
137 883 hiro
        GtkWidget *name_entry;
138 883 hiro
        GtkStyle *style;
139 883 hiro
140 879 hiro
        GtkWidget *bool_hbox;
141 879 hiro
        GtkWidget *bool_optmenu;
142 879 hiro
        GtkWidget *bool_menu;
143 879 hiro
        GtkWidget *menuitem;
144 879 hiro
145 879 hiro
        GtkWidget *scrolledwin;
146 879 hiro
        FilterCondEdit *cond_edit;
147 879 hiro
148 879 hiro
        GtkWidget *folder_hbox;
149 879 hiro
        GtkWidget *folder_label;
150 879 hiro
        GtkWidget *folder_entry;
151 879 hiro
        GtkWidget *folder_btn;
152 879 hiro
153 879 hiro
        GtkWidget *checkbtn_hbox;
154 879 hiro
        GtkWidget *subfolder_checkbtn;
155 879 hiro
        GtkWidget *case_checkbtn;
156 879 hiro
157 879 hiro
        new_dialog = g_new0(PrefsSearchFolderDialog, 1);
158 879 hiro
159 879 hiro
        dialog = g_new0(PrefsDialog, 1);
160 879 hiro
        prefs_dialog_create(dialog);
161 883 hiro
        gtk_widget_hide(dialog->apply_btn);
162 879 hiro
163 879 hiro
        gtk_widget_set_size_request(dialog->window, 600, -1);
164 891 hiro
        title = g_strdup_printf(_("%s - Edit search condition"), item->name);
165 883 hiro
        gtk_window_set_title(GTK_WINDOW(dialog->window), title);
166 883 hiro
        g_free(title);
167 879 hiro
        gtk_notebook_set_show_border(GTK_NOTEBOOK(dialog->notebook), FALSE);
168 879 hiro
        gtk_notebook_set_show_tabs(GTK_NOTEBOOK(dialog->notebook), FALSE);
169 912 hiro
        gtk_widget_realize(dialog->window);
170 879 hiro
171 879 hiro
        g_signal_connect(G_OBJECT(dialog->window), "delete_event",
172 879 hiro
                         G_CALLBACK(prefs_search_folder_delete_cb), new_dialog);
173 879 hiro
        g_signal_connect(G_OBJECT(dialog->window), "key_press_event",
174 879 hiro
                         G_CALLBACK(prefs_search_folder_key_press_cb),
175 879 hiro
                         new_dialog);
176 879 hiro
177 879 hiro
        MANAGE_WINDOW_SIGNALS_CONNECT(dialog->window);
178 879 hiro
179 879 hiro
        vbox = gtk_vbox_new(FALSE, 6);
180 879 hiro
        gtk_widget_show(vbox);
181 879 hiro
        gtk_container_add(GTK_CONTAINER(dialog->notebook), vbox);
182 879 hiro
183 883 hiro
        name_hbox = gtk_hbox_new(FALSE, 8);
184 883 hiro
        gtk_widget_show(name_hbox);
185 883 hiro
        gtk_box_pack_start(GTK_BOX(vbox), name_hbox, FALSE, FALSE, 0);
186 883 hiro
187 883 hiro
        name_label = gtk_label_new(_("Name:"));
188 883 hiro
        gtk_widget_show(name_label);
189 883 hiro
        gtk_box_pack_start(GTK_BOX(name_hbox), name_label, FALSE, FALSE, 0);
190 883 hiro
191 883 hiro
        name_entry = gtk_entry_new();
192 883 hiro
        gtk_widget_show(name_entry);
193 883 hiro
        gtk_editable_set_editable(GTK_EDITABLE(name_entry), FALSE);
194 883 hiro
        gtk_box_pack_start(GTK_BOX(name_hbox), name_entry, TRUE, TRUE, 0);
195 883 hiro
196 912 hiro
        style = gtk_widget_get_style(dialog->window);
197 912 hiro
        gtk_widget_modify_base(name_entry, GTK_STATE_NORMAL,
198 912 hiro
                               &style->bg[GTK_STATE_NORMAL]);
199 883 hiro
200 879 hiro
        bool_hbox = gtk_hbox_new(FALSE, 12);
201 879 hiro
        gtk_widget_show(bool_hbox);
202 879 hiro
        gtk_box_pack_start(GTK_BOX(vbox), bool_hbox, FALSE, FALSE, 0);
203 879 hiro
204 879 hiro
        bool_optmenu = gtk_option_menu_new();
205 879 hiro
        gtk_widget_show(bool_optmenu);
206 879 hiro
        gtk_box_pack_start(GTK_BOX(bool_hbox), bool_optmenu, FALSE, FALSE, 0);
207 879 hiro
208 879 hiro
        bool_menu = gtk_menu_new();
209 879 hiro
        MENUITEM_ADD(bool_menu, menuitem, _("Match any of the following"),
210 879 hiro
                     FLT_OR);
211 879 hiro
        MENUITEM_ADD(bool_menu, menuitem, _("Match all of the following"),
212 879 hiro
                     FLT_AND);
213 879 hiro
        gtk_option_menu_set_menu(GTK_OPTION_MENU(bool_optmenu), bool_menu);
214 879 hiro
215 879 hiro
        scrolledwin = gtk_scrolled_window_new(NULL, NULL);
216 879 hiro
        gtk_widget_show(scrolledwin);
217 879 hiro
        gtk_widget_set_size_request(scrolledwin, -1, 150);
218 879 hiro
        gtk_box_pack_start(GTK_BOX(vbox), scrolledwin, TRUE, TRUE, 0);
219 879 hiro
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
220 879 hiro
                                       GTK_POLICY_AUTOMATIC,
221 879 hiro
                                       GTK_POLICY_AUTOMATIC);
222 879 hiro
223 879 hiro
        cond_edit = prefs_filter_edit_cond_edit_create();
224 879 hiro
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolledwin),
225 879 hiro
                                              cond_edit->cond_vbox);
226 879 hiro
227 883 hiro
        folder_hbox = gtk_hbox_new(FALSE, 8);
228 879 hiro
        gtk_widget_show(folder_hbox);
229 879 hiro
        gtk_box_pack_start(GTK_BOX(vbox), folder_hbox, FALSE, FALSE, 0);
230 879 hiro
231 879 hiro
        folder_label = gtk_label_new(_("Folder:"));
232 879 hiro
        gtk_widget_show(folder_label);
233 879 hiro
        gtk_box_pack_start(GTK_BOX(folder_hbox), folder_label, FALSE, FALSE, 0);
234 879 hiro
235 879 hiro
        folder_entry = gtk_entry_new();
236 879 hiro
        gtk_widget_show(folder_entry);
237 879 hiro
        gtk_box_pack_start(GTK_BOX(folder_hbox), folder_entry, TRUE, TRUE, 0);
238 879 hiro
239 879 hiro
        folder_btn = gtk_button_new_with_label("...");
240 879 hiro
        gtk_widget_show(folder_btn);
241 879 hiro
        gtk_box_pack_start(GTK_BOX(folder_hbox), folder_btn, FALSE, FALSE, 0);
242 879 hiro
243 879 hiro
        checkbtn_hbox = gtk_hbox_new(FALSE, 12);
244 879 hiro
        gtk_widget_show(checkbtn_hbox);
245 879 hiro
        gtk_box_pack_start(GTK_BOX(vbox), checkbtn_hbox, FALSE, FALSE, 0);
246 879 hiro
247 879 hiro
        subfolder_checkbtn =
248 879 hiro
                gtk_check_button_new_with_label(_("Search subfolders"));
249 879 hiro
        gtk_widget_show(subfolder_checkbtn);
250 879 hiro
        gtk_box_pack_start(GTK_BOX(checkbtn_hbox), subfolder_checkbtn,
251 879 hiro
                           FALSE, FALSE, 0);
252 879 hiro
253 879 hiro
        case_checkbtn = gtk_check_button_new_with_label(_("Case sensitive"));
254 879 hiro
        gtk_widget_show(case_checkbtn);
255 879 hiro
        gtk_box_pack_start(GTK_BOX(checkbtn_hbox), case_checkbtn,
256 879 hiro
                           FALSE, FALSE, 0);
257 879 hiro
258 880 hiro
        g_signal_connect(G_OBJECT(folder_btn), "clicked",
259 880 hiro
                         G_CALLBACK(prefs_search_folder_select_folder),
260 880 hiro
                         new_dialog);
261 879 hiro
        g_signal_connect(G_OBJECT(dialog->ok_btn), "clicked",
262 879 hiro
                         G_CALLBACK(prefs_search_folder_ok_cb), new_dialog);
263 879 hiro
        g_signal_connect(G_OBJECT(dialog->apply_btn), "clicked",
264 879 hiro
                         G_CALLBACK(prefs_search_folder_apply_cb), new_dialog);
265 879 hiro
        g_signal_connect(G_OBJECT(dialog->cancel_btn), "clicked",
266 879 hiro
                         G_CALLBACK(prefs_search_folder_cancel_cb), new_dialog);
267 879 hiro
268 883 hiro
        gtk_widget_grab_focus(dialog->ok_btn);
269 883 hiro
270 879 hiro
        new_dialog->dialog = dialog;
271 879 hiro
        new_dialog->item = item;
272 883 hiro
        new_dialog->name_entry = name_entry;
273 879 hiro
        new_dialog->bool_optmenu = bool_optmenu;
274 879 hiro
        new_dialog->cond_edit = cond_edit;
275 879 hiro
276 879 hiro
        new_dialog->folder_entry = folder_entry;
277 879 hiro
        new_dialog->folder_btn = folder_btn;
278 879 hiro
        new_dialog->subfolder_checkbtn = subfolder_checkbtn;
279 879 hiro
        new_dialog->case_checkbtn = case_checkbtn;
280 879 hiro
281 928 hiro
        new_dialog->finished = FALSE;
282 928 hiro
        new_dialog->updated = FALSE;
283 928 hiro
284 879 hiro
        return new_dialog;
285 879 hiro
}
286 879 hiro
287 879 hiro
static void prefs_search_folder_set_dialog(PrefsSearchFolderDialog *dialog)
288 879 hiro
{
289 879 hiro
        GSList *flist;
290 879 hiro
        FilterRule *rule;
291 880 hiro
        GSList *cur;
292 879 hiro
        gchar *path;
293 879 hiro
        gchar *rule_file;
294 879 hiro
        gint index;
295 880 hiro
        gboolean case_sens = FALSE;
296 879 hiro
297 879 hiro
        path = folder_item_get_path(dialog->item);
298 879 hiro
        rule_file = g_strconcat(path, G_DIR_SEPARATOR_S, "filter.xml", NULL);
299 879 hiro
        flist = filter_read_file(rule_file);
300 879 hiro
        g_free(rule_file);
301 879 hiro
        g_free(path);
302 879 hiro
303 879 hiro
        if (!flist) {
304 879 hiro
                g_warning("filter rule not found\n");
305 879 hiro
                return;
306 879 hiro
        }
307 879 hiro
308 883 hiro
        gtk_entry_set_text(GTK_ENTRY(dialog->name_entry), dialog->item->name);
309 883 hiro
310 879 hiro
        rule = (FilterRule *)flist->data;
311 879 hiro
312 879 hiro
        index = menu_find_option_menu_index
313 879 hiro
                (GTK_OPTION_MENU(dialog->bool_optmenu),
314 879 hiro
                 GINT_TO_POINTER(rule->bool_op), NULL);
315 879 hiro
        if (index < 0)
316 879 hiro
                index = 0;
317 879 hiro
        gtk_option_menu_set_history(GTK_OPTION_MENU(dialog->bool_optmenu),
318 879 hiro
                                    index);
319 879 hiro
320 880 hiro
        gtk_entry_set_text(GTK_ENTRY(dialog->folder_entry),
321 880 hiro
                           rule->target_folder);
322 880 hiro
        gtk_toggle_button_set_active
323 880 hiro
                (GTK_TOGGLE_BUTTON(dialog->subfolder_checkbtn),
324 880 hiro
                 rule->recursive);
325 880 hiro
        for (cur = rule->cond_list; cur != NULL; cur = cur->next) {
326 880 hiro
                FilterCond *cond = (FilterCond *)cur->data;
327 880 hiro
                if (FLT_IS_CASE_SENS(cond->match_flag)) {
328 880 hiro
                        case_sens = TRUE;
329 880 hiro
                        break;
330 880 hiro
                }
331 880 hiro
        }
332 880 hiro
        gtk_toggle_button_set_active
333 880 hiro
                (GTK_TOGGLE_BUTTON(dialog->case_checkbtn), case_sens);
334 880 hiro
335 879 hiro
        prefs_filter_set_header_list(NULL);
336 879 hiro
        prefs_filter_edit_set_header_list(dialog->cond_edit, rule);
337 879 hiro
        prefs_filter_edit_add_rule_cond(dialog->cond_edit, rule);
338 879 hiro
339 879 hiro
        filter_rule_list_free(flist);
340 879 hiro
}
341 879 hiro
342 879 hiro
static void prefs_search_folder_destroy(PrefsSearchFolderDialog *dialog)
343 879 hiro
{
344 879 hiro
        prefs_dialog_destroy(dialog->dialog);
345 879 hiro
        g_free(dialog->dialog);
346 879 hiro
        g_free(dialog);
347 879 hiro
348 879 hiro
        main_window_popup(main_window_get());
349 879 hiro
}
350 879 hiro
351 879 hiro
static gint prefs_search_folder_delete_cb(GtkWidget *widget, GdkEventAny *event,
352 879 hiro
                                          PrefsSearchFolderDialog *dialog)
353 879 hiro
{
354 928 hiro
        dialog->finished = TRUE;
355 879 hiro
        return TRUE;
356 879 hiro
}
357 879 hiro
358 879 hiro
static gint prefs_search_folder_key_press_cb(GtkWidget *widget,
359 879 hiro
                                             GdkEventKey *event,
360 879 hiro
                                             PrefsSearchFolderDialog *dialog)
361 879 hiro
{
362 879 hiro
        if (event && event->keyval == GDK_Escape) {
363 879 hiro
                prefs_search_folder_cancel_cb(widget, dialog);
364 879 hiro
                return TRUE;
365 879 hiro
        }
366 879 hiro
        return FALSE;
367 879 hiro
}
368 879 hiro
369 880 hiro
static void prefs_search_folder_select_folder(GtkWidget *widget,
370 880 hiro
                                              PrefsSearchFolderDialog *dialog)
371 880 hiro
{
372 880 hiro
        FolderItem *item;
373 880 hiro
        gchar *id;
374 880 hiro
375 880 hiro
        item = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
376 880 hiro
        if (!item || item->stype == F_VIRTUAL)
377 880 hiro
                return;
378 880 hiro
379 880 hiro
        id = folder_item_get_identifier(item);
380 880 hiro
        if (id) {
381 880 hiro
                gtk_entry_set_text(GTK_ENTRY(dialog->folder_entry), id);
382 880 hiro
                g_free(id);
383 880 hiro
        }
384 880 hiro
}
385 880 hiro
386 879 hiro
static void prefs_search_folder_ok_cb(GtkWidget *widget,
387 879 hiro
                                      PrefsSearchFolderDialog *dialog)
388 879 hiro
{
389 879 hiro
        prefs_search_folder_apply_cb(widget, dialog);
390 928 hiro
        dialog->finished = TRUE;
391 879 hiro
}
392 879 hiro
393 879 hiro
static void prefs_search_folder_apply_cb(GtkWidget *widget,
394 879 hiro
                                         PrefsSearchFolderDialog *dialog)
395 879 hiro
{
396 880 hiro
        const gchar *id;
397 880 hiro
        FolderItem *item;
398 880 hiro
        FilterBoolOp bool_op;
399 880 hiro
        gboolean recursive;
400 880 hiro
        gboolean case_sens;
401 880 hiro
        GSList *cond_list;
402 880 hiro
        FilterRule *rule;
403 880 hiro
        GSList list;
404 880 hiro
        gchar *file;
405 880 hiro
        gchar *path;
406 880 hiro
407 880 hiro
        id = gtk_entry_get_text(GTK_ENTRY(dialog->folder_entry));
408 880 hiro
        item = folder_find_item_from_identifier(id);
409 880 hiro
        if (!item)
410 880 hiro
                return;
411 880 hiro
412 880 hiro
        bool_op = menu_get_option_menu_active_index
413 880 hiro
                (GTK_OPTION_MENU(dialog->bool_optmenu));
414 880 hiro
        recursive = gtk_toggle_button_get_active
415 880 hiro
                (GTK_TOGGLE_BUTTON(dialog->subfolder_checkbtn));
416 880 hiro
        case_sens = gtk_toggle_button_get_active
417 880 hiro
                (GTK_TOGGLE_BUTTON(dialog->case_checkbtn));
418 880 hiro
419 880 hiro
        cond_list = prefs_filter_edit_cond_edit_to_list(dialog->cond_edit,
420 880 hiro
                                                        case_sens);
421 880 hiro
        if (!cond_list)
422 880 hiro
                return;
423 880 hiro
424 880 hiro
        rule = filter_rule_new(dialog->item->name, bool_op, cond_list, NULL);
425 880 hiro
        rule->target_folder = g_strdup(id);
426 880 hiro
        rule->recursive = recursive;
427 880 hiro
        list.data = rule;
428 880 hiro
        list.next = NULL;
429 880 hiro
430 880 hiro
        path = folder_item_get_path(dialog->item);
431 880 hiro
        file = g_strconcat(path, G_DIR_SEPARATOR_S, FILTER_LIST, NULL);
432 880 hiro
        filter_write_file(&list, file);
433 880 hiro
        g_free(file);
434 880 hiro
        file = g_strconcat(path, G_DIR_SEPARATOR_S, FILTER_LIST, ".bak", NULL);
435 880 hiro
        if (is_file_exist(file))
436 880 hiro
                g_unlink(file);
437 880 hiro
        g_free(file);
438 880 hiro
        file = g_strconcat(path, G_DIR_SEPARATOR_S, SEARCH_CACHE, NULL);
439 880 hiro
        if (is_file_exist(file))
440 880 hiro
                g_unlink(file);
441 880 hiro
        g_free(file);
442 880 hiro
        g_free(path);
443 880 hiro
444 880 hiro
        filter_rule_free(rule);
445 928 hiro
446 928 hiro
        dialog->updated = TRUE;
447 879 hiro
}
448 879 hiro
449 879 hiro
static void prefs_search_folder_cancel_cb(GtkWidget *widget,
450 879 hiro
                                          PrefsSearchFolderDialog *dialog)
451 879 hiro
{
452 928 hiro
        dialog->finished = TRUE;
453 879 hiro
}