add select all/none, layout shortcuts from all guis, docs tweaks + cv->gg
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / deleteallindexes.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include "deleteallindexes.h"
23 #include "filesystem.h"
24 #include "mwindow.h"
25 #include "mwindowgui.h"
26 #include "preferences.h"
27 #include "preferencesthread.h"
28 #include "question.h"
29 #include "theme.h"
30 #include <string.h>
31
32 #include <libintl.h>
33 #define _(String) gettext(String)
34 #define gettext_noop(String) String
35 #define N_(String) gettext_noop (String)
36
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()
40 {
41         this->mwindow = mwindow;
42         this->pwindow = pwindow;
43         this->filter = filter;
44 }
45
46 DeleteAllIndexes::~DeleteAllIndexes()
47 {
48 }
49
50 int DeleteAllIndexes::handle_event()
51 {
52         start();
53         return 1;
54 }
55
56 void DeleteAllIndexes::run()
57 {
58         char string1[BCTEXTLEN], string2[BCTEXTLEN];
59         strcpy(string1, pwindow->thread->preferences->index_directory);
60         FileSystem dir;
61         dir.update(pwindow->thread->preferences->index_directory);
62         dir.complete_path(string1);
63
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);
68                 remove(string2);
69 printf("DeleteAllIndexes::run %s\n", string2);
70         }
71
72         pwindow->thread->redraw_indexes = 1;
73 }
74
75
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),
80                 340,
81                 140)
82 {
83         this->string = string;
84 }
85
86 ConfirmDeleteAllIndexes::~ConfirmDeleteAllIndexes()
87 {
88 }
89
90 void ConfirmDeleteAllIndexes::create_objects()
91 {
92         lock_window("ConfirmDeleteAllIndexes::create_objects");
93         int x = 10, y = 10;
94         add_subwindow(new BC_Title(x, y, string));
95
96         y += 20;
97         add_subwindow(new BC_OKButton(x, y));
98         x = get_w() - 100;
99         add_subwindow(new BC_CancelButton(x, y));
100         unlock_window();
101 }
102
103