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,
38 int x, int y, const char *text, const char *filter)
39 : BC_GenericButton(x, y, text), Thread()
41 this->mwindow = mwindow;
42 this->pwindow = pwindow;
43 this->filter = filter;
46 DeleteAllIndexes::~DeleteAllIndexes()
50 int DeleteAllIndexes::handle_event()
56 void DeleteAllIndexes::run()
58 char string1[BCTEXTLEN], string2[BCTEXTLEN];
59 strcpy(string1, pwindow->thread->preferences->index_directory);
61 dir.update(pwindow->thread->preferences->index_directory);
62 dir.complete_path(string1);
64 for( int i=0; i<dir.dir_list.total; ++i ) {
65 const char *fn = dir.dir_list.values[i]->name;
66 if( FileSystem::test_filter(fn, filter) ) continue;
67 sprintf(string2, "%s%s", string1, dir.dir_list.values[i]->name);
69 printf("DeleteAllIndexes::run %s\n", string2);
72 pwindow->thread->redraw_indexes = 1;
76 ConfirmDeleteAllIndexes::ConfirmDeleteAllIndexes(MWindow *mwindow, char *string)
77 : BC_Window(_(PROGRAM_NAME ": Delete All Indexes"),
78 mwindow->gui->get_abs_cursor_x(1),
79 mwindow->gui->get_abs_cursor_y(1),
82 this->string = string;
85 ConfirmDeleteAllIndexes::~ConfirmDeleteAllIndexes()
89 void ConfirmDeleteAllIndexes::create_objects()
91 lock_window("ConfirmDeleteAllIndexes::create_objects");
92 int x = xS(10), y = yS(10);
93 add_subwindow(new BC_Title(x, y, string));
96 add_subwindow(new BC_OKButton(x, y));
97 x = get_w() - xS(100);
98 add_subwindow(new BC_CancelButton(x, y));