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 "awindowgui.h"
26 #include "newfolder.h"
31 #define _(String) gettext(String)
32 #define gettext_noop(String) String
33 #define N_(String) gettext_noop (String)
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)
40 this->mwindow = mwindow;
41 this->awindow = awindow;
44 NewFolder::~NewFolder()
49 void NewFolder::create_objects()
51 lock_window("NewFolder::create_objects");
53 add_tool(new BC_Title(x, y, _("Enter the name of the folder:")));
55 add_subwindow(textbox = new BC_TextBox(x, y, 300, 1, _("Untitled")));
57 add_subwindow(new BC_OKButton(x, y));
59 add_subwindow(new BC_CancelButton(x, y));
64 const char* NewFolder::get_text()
66 return textbox->get_text();
70 NewFolderThread::NewFolderThread(MWindow *mwindow, AWindowGUI *awindow)
72 this->mwindow = mwindow;
73 this->awindow = awindow;
78 NewFolderThread::~NewFolderThread()
82 void NewFolderThread::run()
84 int result = window->run_window();
88 mwindow->new_folder(window->get_text());
91 change_lock.lock("NewFolderThread::run");
95 completion_lock.unlock();
98 int NewFolderThread::interrupt()
100 change_lock.lock("NewFolderThread::interrupt");
103 window->lock_window();
105 window->unlock_window();
108 change_lock.unlock();
110 completion_lock.lock("NewFolderThread::interrupt");
111 completion_lock.unlock();
115 int NewFolderThread::start_new_folder()
117 window = new NewFolder(mwindow,
119 awindow->get_abs_cursor_x(1),
120 awindow->get_abs_cursor_y(1) - 120);
121 window->create_objects();
123 change_lock.lock("NewFolderThread::start_new_folder");
125 change_lock.unlock();
129 completion_lock.lock("NewFolderThread::start_new_folder");