// Called by Thread toUIThr. This updates the UI with data got from the UI Q. // We dont update the UI directly, as fox is not thread safe. // We create a pipe, we write to it on one side. // the app->addInput() is done on it, waiting for a read. // We write a char as soon as we get a line. we dont delete it. // the Fox routine, reads the char, reads and deletes the line, processes it // and returns. Hence each character we write is equivalent to one // line to be read and processed. // In fromUI(), before we create the application, we create a pipe. // We put the reading end and writing end in XGlobal. // The TabBookwindow constructor should addInput on the read descriptor. void toUI(XChange *XGlobal) { char IRC_Line[1024]; TabBookWindow *UI; FXApp *App; bool retvalb; TRACE(); // Lets wait for the UI object to exist. while (true) { if (XGlobal->isIRC_QUIT()) break; if (XGlobal->UI != NULL) break; sleep(1); } UI = (TabBookWindow*) XGlobal->UI; App = UI->getApp(); FXMutex &AppMutex = App->mutex(); // Add mutex for calls to UI funcitons. while (true) { if (XGlobal->isIRC_QUIT()) break; #ifdef UI_SEM COUT(cout << "ToUI: Waiting on Sem" << endl;) WaitForSemaphore(XGlobal->UpdateUI_Sem); COUT(cout << "ToUI: Dec Sem" << endl;) if (XGlobal->isIRC_QUIT()) break;
/** * Application entry point. */ int main ( int argc, char **argv ) { for ( int i = 0;i < argc;i++ ) { if ( !strcmp( argv[ i ], "-v" ) || !strcmp( argv[ i ], "--version" ) ) { fxmessage( "\n%s\n", PACKAGE_STRING ); return 0; } if ( !strcmp( argv[ i ], "-h" ) || !strcmp( argv[ i ], "--help" ) ) { fxmessage( "\n-h, --help print this help\n" ); fxmessage( "-v, --version print version\n" ); return 0; } } string tmpdir = "/tmp/nao"; if ( !FXFile::exists( tmpdir.c_str() ) ) { FXFile::createDirectory( tmpdir.c_str(), 493 ); } string dir = FXFile::getUserDirectory ( "" ).text (); dir = dir + "/.nao"; string file = dir + "/nao.conf"; if ( !FXFile::exists( file.c_str() ) ) { FXFile::createDirectory( dir.c_str(), 493 ); string dir2 = dir + "/icons"; FXFile::createDirectory( dir2.c_str(), 493 ); dir += "/plugins"; FXFile::createDirectory( dir.c_str(), 493 ); dir2 = dir + "/cmddialog"; FXFile::createDirectory( dir2.c_str(), 493 ); dir2 = dir + "/filelist"; FXFile::createDirectory( dir2.c_str(), 493 ); string src = PATH_CFG + string( "/nao.conf" ); FXFile::copy( src.c_str(), file.c_str() ); } fxTraceLevel = 0; FXApp *application = new FXApp ( "nao", NULL ); application->init ( argc, argv ); new OSMainWindow ( application ); application->create (); return application->run (); }
static OSStatus EventLoopEventHandler(EventHandlerCallRef callref, EventRef event, void *userdata) { FXApp *app = (FXApp*)userdata; if (nil != event) ReleaseEvent(event); app->run(); // Start FOX GUI QuitApplicationEventLoop(); return noErr; }
// =========================================================================== // method definitions // =========================================================================== void GUIUserIO::copyToClipboard(const FXApp& app, const std::string& text) { FXDragType types[] = {FXWindow::stringType, FXWindow::textType}; if (app.getActiveWindow()->acquireClipboard(types, 2)) { clipped = text; } }