r663: This commit was generated by cvs2svn to compensate for changes in r662,
[cinelerra_cv.git] / cinelerra / deleteallindexes.C
blob42c1ed7101af1c314fce112584a39f12d986ae75
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() 
27 int DeleteAllIndexes::handle_event() 
28
29         start(); 
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];
41 // prepare directory
42         strcpy(string1, pwindow->thread->preferences->index_directory);
43         FileSystem dir;
44         dir.update(pwindow->thread->preferences->index_directory);
45         dir.complete_path(string1);
46 // prepare filter
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();
57         int result = 0;
58         if(!result)
59         {
60                 static int i, j, k;
62                 for(i = 0; i < dir.dir_list.total; i++)
63                 {
64                         result = 1;
65                         sprintf(string2, "%s%s", string1, dir.dir_list.values[i]->name);
66 // test filter
67                         if(test_filter(string2, filter1) ||
68                                 test_filter(string2, filter2))
69                         {
70                                 remove(string2);
71 printf("DeleteAllIndexes::run %s\n", string2);
72                         }
73                 }
74         }
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), 
85                 340, 
86                 140)
87
88         this->string = string; 
91 ConfirmDeleteAllIndexes::~ConfirmDeleteAllIndexes()
94         
95 int ConfirmDeleteAllIndexes::create_objects()
96
97         int x = 10, y = 10;
98         add_subwindow(new BC_Title(x, y, string));
99         
100         y += 20;
101         add_subwindow(new BC_OKButton(x, y));
102         x = get_w() - 100;
103         add_subwindow(new BC_CancelButton(x, y));
104         return 0;