p/s proxy icon, rework window locks, segv in close_mixers + exportedl, ffmpeg default...
[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, y, 320, 120, 0, 0, 0, 0, 1)
39 {
40         this->mwindow = mwindow;
41         this->awindow = awindow;
42 }
43
44 NewFolder::~NewFolder()
45 {
46 }
47
48
49 void NewFolder::create_objects()
50 {
51         lock_window("NewFolder::create_objects");
52         int x = 10, y = 10;
53         add_tool(new BC_Title(x, y, _("Enter the name of the folder:")));
54         y += 20;
55         add_subwindow(textbox = new BC_TextBox(x, y, 300, 1, _("Untitled")));
56         y += 30;
57         add_subwindow(new BC_OKButton(x, y));
58         x = get_w() - 100;
59         add_subwindow(new BC_CancelButton(x, y));
60         show_window();
61         unlock_window();
62 }
63
64 const char* NewFolder::get_text()
65 {
66         return textbox->get_text();
67 }
68
69
70 NewFolderThread::NewFolderThread(MWindow *mwindow, AWindowGUI *awindow)
71 {
72         this->mwindow = mwindow;
73         this->awindow = awindow;
74         active = 0;
75         set_synchronous(0);
76 }
77
78 NewFolderThread::~NewFolderThread()
79 {
80 }
81
82 void NewFolderThread::run()
83 {
84         int result = window->run_window();
85
86         if(!result)
87         {
88                 mwindow->new_folder(window->get_text());
89         }
90
91         change_lock.lock("NewFolderThread::run");
92         active = 0;
93         change_lock.unlock();
94         delete window;
95         completion_lock.unlock();
96 }
97
98 int NewFolderThread::interrupt()
99 {
100         change_lock.lock("NewFolderThread::interrupt");
101         if(active)
102         {
103                 window->lock_window();
104                 window->set_done(1);
105                 window->unlock_window();
106         }
107
108         change_lock.unlock();
109
110         completion_lock.lock("NewFolderThread::interrupt");
111         completion_lock.unlock();
112         return 0;
113 }
114
115 int NewFolderThread::start_new_folder()
116 {
117         window = new NewFolder(mwindow,
118                 awindow,
119                 awindow->get_abs_cursor_x(1),
120                 awindow->get_abs_cursor_y(1) - 120);
121         window->create_objects();
122
123         change_lock.lock("NewFolderThread::start_new_folder");
124         active = 1;
125         change_lock.unlock();
126
127         Thread::start();
128
129         completion_lock.lock("NewFolderThread::start_new_folder");
130         return 0;
131 }