add bluray dv, misc fixes
[goodguy/history.git] / cinelerra-5.1 / cinelerra / newfolder.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 "assets.h"
23 #include "awindowgui.h"
24 #include "edl.h"
25 #include "mwindow.h"
26 #include "newfolder.h"
27
28 #include <string.h>
29
30 #include <libintl.h>
31 #define _(String) gettext(String)
32 #define gettext_noop(String) String
33 #define N_(String) gettext_noop (String)
34
35
36 NewFolder::NewFolder(MWindow *mwindow, AWindowGUI *awindow, int x, int y)
37  : BC_Window(_(PROGRAM_NAME ": New folder"),
38         x,
39         y,
40         320,
41         120,
42         0,
43         0,
44         0,
45         0,
46         1)
47 {
48         this->mwindow = mwindow;
49         this->awindow = awindow;
50 }
51
52 NewFolder::~NewFolder()
53 {
54 }
55
56
57 void NewFolder::create_objects()
58 {
59         int x = 10, y = 10;
60         add_tool(new BC_Title(x, y, _("Enter the name of the folder:")));
61         y += 20;
62         add_subwindow(textbox = new BC_TextBox(x, y, 300, 1, _("Untitled")));
63         y += 30;
64         add_subwindow(new BC_OKButton(x, y));
65         x = get_w() - 100;
66         add_subwindow(new BC_CancelButton(x, y));
67         show_window();
68 }
69
70 const char* NewFolder::get_text()
71 {
72         return textbox->get_text();
73 }
74
75
76 NewFolderThread::NewFolderThread(MWindow *mwindow, AWindowGUI *awindow)
77 {
78         this->mwindow = mwindow;
79         this->awindow = awindow;
80         active = 0;
81         set_synchronous(0);
82 }
83
84 NewFolderThread::~NewFolderThread()
85 {
86 }
87
88 void NewFolderThread::run()
89 {
90         int result = window->run_window();
91
92         if(!result)
93         {
94                 mwindow->new_folder(window->get_text());
95         }
96
97         change_lock.lock("NewFolderThread::run");
98         active = 0;
99         change_lock.unlock();
100         delete window;
101         completion_lock.unlock();
102 }
103
104 int NewFolderThread::interrupt()
105 {
106         change_lock.lock("NewFolderThread::interrupt");
107         if(active)
108         {
109                 window->lock_window();
110                 window->set_done(1);
111                 window->unlock_window();
112         }
113
114         change_lock.unlock();
115
116         completion_lock.lock("NewFolderThread::interrupt");
117         completion_lock.unlock();
118         return 0;
119 }
120
121 int NewFolderThread::start_new_folder()
122 {
123         window = new NewFolder(mwindow,
124                 awindow,
125                 awindow->get_abs_cursor_x(1),
126                 awindow->get_abs_cursor_y(1) - 120);
127         window->create_objects();
128
129         change_lock.lock("NewFolderThread::start_new_folder");
130         active = 1;
131         change_lock.unlock();
132
133         Thread::start();
134
135         completion_lock.lock("NewFolderThread::start_new_folder");
136         return 0;
137 }