Continued to implement GUI::Program.
[aesalon.git] / src / gui / Program.cpp
blobd069e1fdd089dcb2479af2fbd5f6d056eedf3b9c
1 #include "Program.h"
2 #include "MainWindow.h"
3 #include "misc/String.h"
5 namespace Aesalon {
6 namespace GUI {
8 Program::Program(std::string executable, std::string arguments, bool in_xterm)
9 : executable(executable), arguments(arguments), in_xterm(in_xterm) {
11 if(in_xterm) {
12 arguments = "-e " + executable + " " + arguments;
13 executable = "/usr/bin/x-terminal-emulator";
16 arguments = Misc::StreamAsString() << "--gui-pid " << getpid() << " " << executable << " " << arguments;
17 executable = "/home/strange/c/aesalon/aesalon"; /* NOTE: hardcoded . . . */
19 Platform::ArgumentList argument_list;
21 Misc::SmartPointer<Platform::NamedPipe> gui_pipe
22 = new Aesalon::Platform::NamedPipe(Aesalon::Platform::NamedPipe::READ_PIPE, Misc::StreamAsString() << "/tmp/aesalon_gui-" << getpid(), true);
24 argument_list.from_string(arguments);
26 bi_pipe = new Platform::BidirectionalPipe(executable, argument_list, true);
28 std::string data;
29 while((data = gui_pipe->get_data()) == "") ;
31 gui_pipe = 0;
33 std::size_t aesalon_pid = 0;
35 Misc::String::to<std::size_t>(data, aesalon_pid);
37 memory = new Platform::Memory();
38 named_pipe = new Platform::NamedPipe(Aesalon::Platform::NamedPipe::READ_PIPE, Misc::StreamAsString() << "/tmp/aesalon-" << aesalon_pid);
41 } // namespace GUI
42 } // namespace Aesalon