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"),
48 this->mwindow = mwindow;
49 this->awindow = awindow;
52 NewFolder::~NewFolder()
57 void NewFolder::create_objects()
60 add_tool(new BC_Title(x, y, _("Enter the name of the folder:")));
62 add_subwindow(textbox = new BC_TextBox(x, y, 300, 1, _("Untitled")));
64 add_subwindow(new BC_OKButton(x, y));
66 add_subwindow(new BC_CancelButton(x, y));
70 const char* NewFolder::get_text()
72 return textbox->get_text();
76 NewFolderThread::NewFolderThread(MWindow *mwindow, AWindowGUI *awindow)
78 this->mwindow = mwindow;
79 this->awindow = awindow;
84 NewFolderThread::~NewFolderThread()
88 void NewFolderThread::run()
90 int result = window->run_window();
94 mwindow->new_folder(window->get_text());
97 change_lock.lock("NewFolderThread::run");
101 completion_lock.unlock();
104 int NewFolderThread::interrupt()
106 change_lock.lock("NewFolderThread::interrupt");
109 window->lock_window();
111 window->unlock_window();
114 change_lock.unlock();
116 completion_lock.lock("NewFolderThread::interrupt");
117 completion_lock.unlock();
121 int NewFolderThread::start_new_folder()
123 window = new NewFolder(mwindow,
125 awindow->get_abs_cursor_x(1),
126 awindow->get_abs_cursor_y(1) - 120);
127 window->create_objects();
129 change_lock.lock("NewFolderThread::start_new_folder");
131 change_lock.unlock();
135 completion_lock.lock("NewFolderThread::start_new_folder");