1 #include "deleteallindexes.h"
2 #include "filesystem.h"
4 #include "mwindowgui.h"
5 #include "preferences.h"
6 #include "preferencesthread.h"
12 #define _(String) gettext(String)
13 #define gettext_noop(String) String
14 #define N_(String) gettext_noop (String)
16 DeleteAllIndexes::DeleteAllIndexes(MWindow *mwindow, PreferencesWindow *pwindow, int x, int y)
17 : BC_GenericButton(x, y, _("Delete existing indexes")), Thread()
19 this->mwindow = mwindow;
20 this->pwindow = pwindow;
23 DeleteAllIndexes::~DeleteAllIndexes() { }
25 int DeleteAllIndexes::handle_event() { start(); }
27 void DeleteAllIndexes::run()
29 char string1[1024], string2[1024];
31 strcpy(string1, pwindow->thread->preferences->index_directory);
33 dir.update(pwindow->thread->preferences->index_directory);
34 dir.complete_path(string1);
36 char *filter = ".idx";
38 // pwindow->disable_window();
40 sprintf(string, _("Delete all indexes in %s?"), string1);
41 // QuestionWindow confirm(mwindow);
42 // confirm.create_objects(string, 0);
44 // int result = confirm.run_window();
51 for(i = 0; i < dir.dir_list.total; i++)
54 sprintf(string2, "%s%s", string1, dir.dir_list.values[i]->name);
56 for(j = strlen(string2) - 1, k = strlen(filter) - 1;
57 j > 0 && k > 0 && string2[j] == filter[k]; j--, k--)
61 if(k == 0) result = 0;
62 if(!result) remove(string2);
66 pwindow->thread->redraw_indexes = 1;
67 // pwindow->enable_window();
71 ConfirmDeleteAllIndexes::ConfirmDeleteAllIndexes(MWindow *mwindow, char *string)
72 : BC_Window(PROGRAM_NAME ": Delete All Indexes",
73 mwindow->gui->get_abs_cursor_x(),
74 mwindow->gui->get_abs_cursor_y(),
78 this->string = string;
81 ConfirmDeleteAllIndexes::~ConfirmDeleteAllIndexes()
85 int ConfirmDeleteAllIndexes::create_objects()
88 add_subwindow(new BC_Title(x, y, string));
91 add_subwindow(new BC_OKButton(x, y));
93 add_subwindow(new BC_CancelButton(x, y));