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
22 #include "assetremove.h"
23 #include "indexable.h"
25 #include "mainsession.h"
27 #include "mwindowgui.h"
31 AssetRemoveWindow::AssetRemoveWindow(MWindow *mwindow)
32 : BC_Window(_(PROGRAM_NAME ": Remove assets"),
33 mwindow->gui->get_abs_cursor_x(1),
34 mwindow->gui->get_abs_cursor_y(1),
43 this->mwindow = mwindow;
47 AssetRemoveWindow::~AssetRemoveWindow()
52 void AssetRemoveWindow::create_objects()
55 int margin = mwindow->theme->widget_border;
57 data = new ArrayList<BC_ListBoxItem*>;
60 for(int i = 0; i < mwindow->session->drag_assets->total; i++)
62 data->append(new BC_ListBoxItem(
63 mwindow->session->drag_assets->values[i]->path));
66 lock_window("AssetRemoveWindow::create_objects");
68 add_subwindow(title = new BC_Title(x, y, _("Permanently remove from disk?")));
69 y += title->get_h() + margin;
71 add_subwindow(list = new BC_ListBox(
75 get_h() - y - BC_OKButton::calculate_h() - margin * 2,
78 y += list->get_h() + margin;
79 add_subwindow(new BC_OKButton(this));
80 add_subwindow(new BC_CancelButton(this));
88 AssetRemoveThread::AssetRemoveThread(MWindow *mwindow)
91 this->mwindow = mwindow;
92 Thread::set_synchronous(0);
94 void AssetRemoveThread::run()
96 AssetRemoveWindow *window = new AssetRemoveWindow(mwindow);
97 window->create_objects();
98 int result = window->run_window();
103 mwindow->remove_assets_from_disk();