add shuttle dev support, use dflt ff_a/v.png icons, mjpegtools typo patch
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / assetremove.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 "assetremove.h"
23 #include "indexable.h"
24 #include "language.h"
25 #include "mainsession.h"
26 #include "mwindow.h"
27 #include "mwindowgui.h"
28 #include "theme.h"
29
30
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),
35         320,
36         400,
37         -1,
38         -1,
39         0,
40         0,
41         1)
42 {
43         this->mwindow = mwindow;
44         data = 0;
45 }
46
47 AssetRemoveWindow::~AssetRemoveWindow()
48 {
49         if( data ) {
50                 data->remove_all_objects();
51                 delete data;
52         }
53 }
54
55 void AssetRemoveWindow::create_objects()
56 {
57         int x = 10, y = 10;
58         int margin = mwindow->theme->widget_border;
59
60         data = new ArrayList<BC_ListBoxItem*>;
61
62
63         for(int i = 0; i < mwindow->session->drag_assets->total; i++)
64         {
65                 data->append(new BC_ListBoxItem(
66                         mwindow->session->drag_assets->values[i]->path));
67         }
68
69         lock_window("AssetRemoveWindow::create_objects");
70         BC_Title *title;
71         add_subwindow(title = new BC_Title(x, y, _("Permanently remove from disk?")));
72         y += title->get_h() + margin;
73         BC_ListBox *list;
74         add_subwindow(list = new BC_ListBox(
75                 x,
76                 y,
77                 get_w() - x * 2,
78                 get_h() - y - BC_OKButton::calculate_h() - margin * 2,
79                 LISTBOX_TEXT,
80                 data));
81         y += list->get_h() + margin;
82         add_subwindow(new BC_OKButton(this));
83         add_subwindow(new BC_CancelButton(this));
84         show_window();
85         unlock_window();
86 }
87
88
89
90
91 AssetRemoveThread::AssetRemoveThread(MWindow *mwindow)
92  : Thread()
93 {
94         this->mwindow = mwindow;
95         Thread::set_synchronous(0);
96 }
97 void AssetRemoveThread::run()
98 {
99         AssetRemoveWindow *window = new AssetRemoveWindow(mwindow);
100         window->create_objects();
101         int result = window->run_window();
102         delete window;
103
104         if(!result)
105         {
106                 mwindow->remove_assets_from_disk();
107         }
108 }
109
110
111