4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
23 #include "bcsignals.h"
24 #include "filesystem.h"
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)
32 this->filebox = filebox;
36 BC_DeleteFile::~BC_DeleteFile()
41 void BC_DeleteFile::create_objects()
43 int x = xS(10), y = yS(10);
44 data = new ArrayList<BC_ListBoxItem*>;
50 lock_window("BC_DeleteFile::create_objects");
51 while((path = filebox->get_path(i)))
53 data->append(new BC_ListBoxItem(path));
58 add_subwindow(title = new BC_Title(x, y, _("Really delete the following files?")));
59 y += title->get_h() + yS(5);
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));
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)
76 this->filebox = filebox;
80 BC_DeleteThread::BC_DeleteThread(BC_FileBox *filebox)
83 this->filebox = filebox;
86 void BC_DeleteThread::handle_done_event(int result)
90 filebox->lock_window("BC_DeleteThread::handle_done_event");
91 filebox->delete_files();
92 filebox->unlock_window();
96 BC_Window* BC_DeleteThread::new_gui()
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();