r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / deleteallindexes.C
blob03dd693fa778c0b89f3014c20967580e7e899ff1
1 #include "deleteallindexes.h"
2 #include "filesystem.h"
3 #include "mwindow.h"
4 #include "mwindowgui.h"
5 #include "preferences.h"
6 #include "preferencesthread.h"
7 #include "question.h"
8 #include "theme.h"
9 #include <string.h>
11 #include <libintl.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];
30 // prepare directory
31         strcpy(string1, pwindow->thread->preferences->index_directory);
32         FileSystem dir;
33         dir.update(pwindow->thread->preferences->index_directory);
34         dir.complete_path(string1);
35 // prepare filter
36         char *filter = ".idx";
38 //      pwindow->disable_window();
39         char string[1024];
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();
46         int result = 0;
47         if(!result)
48         {
49                 static int i, j, k;
51                 for(i = 0; i < dir.dir_list.total; i++)
52                 {
53                         result = 1;
54                         sprintf(string2, "%s%s", string1, dir.dir_list.values[i]->name);
55 // test filter
56                         for(j = strlen(string2) - 1, k = strlen(filter) - 1; 
57                         j > 0 && k > 0 && string2[j] == filter[k]; j--, k--)
58                         {
59                                 ;
60                         }
61                         if(k == 0) result = 0;
62                         if(!result) remove(string2);
63                 }
64         }
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(), 
75                 340, 
76                 140)
77
78         this->string = string; 
81 ConfirmDeleteAllIndexes::~ConfirmDeleteAllIndexes()
84         
85 int ConfirmDeleteAllIndexes::create_objects()
86
87         int x = 10, y = 10;
88         add_subwindow(new BC_Title(x, y, string));
89         
90         y += 20;
91         add_subwindow(new BC_OKButton(x, y));
92         x = get_w() - 100;
93         add_subwindow(new BC_CancelButton(x, y));
94         return 0;