additional Andrew provided Termux mods +
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / bcdelete.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 "bcdelete.h"
23 #include "bcsignals.h"
24 #include "filesystem.h"
25 #include "language.h"
26
27
28 BC_DeleteFile::BC_DeleteFile(BC_FileBox *filebox, int x, int y)
29  : BC_Window(filebox->get_delete_title(),
30         x, y, xS(320), yS(480), 0, 0, 0, 0, 1)
31 {
32         this->filebox = filebox;
33         data = 0;
34 }
35
36 BC_DeleteFile::~BC_DeleteFile()
37 {
38         delete data;
39 }
40
41 void BC_DeleteFile::create_objects()
42 {
43         int x = xS(10), y = yS(10);
44         data = new ArrayList<BC_ListBoxItem*>;
45         int i = 1;
46         char *path;
47         FileSystem fs;
48
49
50         lock_window("BC_DeleteFile::create_objects");
51         while((path = filebox->get_path(i)))
52         {
53                 data->append(new BC_ListBoxItem(path));
54                 i++;
55         }
56
57         BC_Title *title;
58         add_subwindow(title = new BC_Title(x, y, _("Really delete the following files?")));
59         y += title->get_h() + yS(5);
60         BC_DeleteList *list;
61         add_subwindow(list = new BC_DeleteList(filebox, x, y,
62                 get_w() - x * 2, get_h() - y - BC_OKButton::calculate_h() - xS(20), data));
63         y += list->get_h() + yS(5);
64         add_subwindow(new BC_OKButton(this));
65         add_subwindow(new BC_CancelButton(this));
66         show_window();
67         unlock_window();
68 }
69
70
71 BC_DeleteList::BC_DeleteList(BC_FileBox *filebox,
72         int x, int y, int w, int h,
73         ArrayList<BC_ListBoxItem*> *data)
74  : BC_ListBox(x, y, w, h, LISTBOX_TEXT, data)
75 {
76         this->filebox = filebox;
77 }
78
79
80 BC_DeleteThread::BC_DeleteThread(BC_FileBox *filebox)
81  : BC_DialogThread()
82 {
83         this->filebox = filebox;
84 }
85
86 void BC_DeleteThread::handle_done_event(int result)
87 {
88         if(!result)
89         {
90                 filebox->lock_window("BC_DeleteThread::handle_done_event");
91                 filebox->delete_files();
92                 filebox->unlock_window();
93         }
94 }
95
96 BC_Window* BC_DeleteThread::new_gui()
97 {
98         int x = filebox->get_abs_cursor_x(1);
99         int y = filebox->get_abs_cursor_y(1);
100         BC_DeleteFile *result = new BC_DeleteFile(filebox, x, y);
101         result->create_objects();
102         return result;
103 }
104