4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "deleteallindexes.h"
23 #include "filesystem.h"
25 #include "mwindowgui.h"
26 #include "preferences.h"
27 #include "preferencesthread.h"
33 #define _(String) gettext(String)
34 #define gettext_noop(String) String
35 #define N_(String) gettext_noop (String)
37 DeleteAllIndexes::DeleteAllIndexes(MWindow *mwindow, PreferencesWindow *pwindow, int x, int y)
38 : BC_GenericButton(x, y, _("Delete existing indexes")), Thread()
40 this->mwindow = mwindow;
41 this->pwindow = pwindow;
44 DeleteAllIndexes::~DeleteAllIndexes()
48 int DeleteAllIndexes::handle_event()
54 static int test_filter(const char *string, const char *filter)
56 return (strlen(string) > strlen(filter) &&
57 !strcmp(string + strlen(string) - strlen(filter), filter));
60 void DeleteAllIndexes::run()
62 char string[BCTEXTLEN], string1[BCTEXTLEN], string2[BCTEXTLEN];
64 strcpy(string1, pwindow->thread->preferences->index_directory);
66 dir.update(pwindow->thread->preferences->index_directory);
67 dir.complete_path(string1);
69 const char *filter1 = ".idx";
70 const char *filter2 = ".toc";
71 const char *filter3 = ".mkr";
73 // pwindow->disable_window();
74 sprintf(string, _("Delete all indexes in %s?"), string1);
75 // QuestionWindow confirm(mwindow);
76 // confirm.create_objects(string, 0);
78 // int result = confirm.run_window();
83 for(int i = 0; i < dir.dir_list.total; i++)
86 sprintf(string2, "%s%s", string1, dir.dir_list.values[i]->name);
88 if(test_filter(string2, filter1) ||
89 test_filter(string2, filter2) ||
90 test_filter(string2, filter3))
93 printf("DeleteAllIndexes::run %s\n", string2);
98 pwindow->thread->redraw_indexes = 1;
99 // pwindow->enable_window();
103 ConfirmDeleteAllIndexes::ConfirmDeleteAllIndexes(MWindow *mwindow, char *string)
104 : BC_Window(_(PROGRAM_NAME ": Delete All Indexes"),
105 mwindow->gui->get_abs_cursor_x(1),
106 mwindow->gui->get_abs_cursor_y(1),
110 this->string = string;
113 ConfirmDeleteAllIndexes::~ConfirmDeleteAllIndexes()
117 void ConfirmDeleteAllIndexes::create_objects()
120 add_subwindow(new BC_Title(x, y, string));
123 add_subwindow(new BC_OKButton(x, y));
125 add_subwindow(new BC_CancelButton(x, y));