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()
27 int DeleteAllIndexes::handle_event()
32 static int test_filter(char *string, char *filter)
34 return (strlen(string) > strlen(filter) &&
35 !strcmp(string + strlen(string) - strlen(filter), filter));
38 void DeleteAllIndexes::run()
40 char string[BCTEXTLEN], string1[BCTEXTLEN], string2[BCTEXTLEN];
42 strcpy(string1, pwindow->thread->preferences->index_directory);
44 dir.update(pwindow->thread->preferences->index_directory);
45 dir.complete_path(string1);
47 char *filter1 = ".idx";
48 char *filter2 = ".toc";
50 // pwindow->disable_window();
51 sprintf(string, _("Delete all indexes in %s?"), string1);
52 // QuestionWindow confirm(mwindow);
53 // confirm.create_objects(string, 0);
55 // int result = confirm.run_window();
62 for(i = 0; i < dir.dir_list.total; i++)
65 sprintf(string2, "%s%s", string1, dir.dir_list.values[i]->name);
67 if(test_filter(string2, filter1) ||
68 test_filter(string2, filter2))
71 printf("DeleteAllIndexes::run %s\n", string2);
76 pwindow->thread->redraw_indexes = 1;
77 // pwindow->enable_window();
81 ConfirmDeleteAllIndexes::ConfirmDeleteAllIndexes(MWindow *mwindow, char *string)
82 : BC_Window(PROGRAM_NAME ": Delete All Indexes",
83 mwindow->gui->get_abs_cursor_x(1),
84 mwindow->gui->get_abs_cursor_y(1),
88 this->string = string;
91 ConfirmDeleteAllIndexes::~ConfirmDeleteAllIndexes()
95 int ConfirmDeleteAllIndexes::create_objects()
98 add_subwindow(new BC_Title(x, y, string));
101 add_subwindow(new BC_OKButton(x, y));
103 add_subwindow(new BC_CancelButton(x, y));