SysOptDialog::SysOptDialog(NCDialogParent *parent) : NCVertDialog(::createDialogAsChild, 0, parent, utf8_to_unicode( _LT("System settings") ).ptr(), bListOkCancel), iL(16, 3) ,askOpenExecButton(0, this, utf8_to_unicode( _LT("Ask user if Exec/Open conflict") ).ptr(), 0, wcmConfig.systemAskOpenExec) ,escPanelButton(0, this, utf8_to_unicode( _LT("Enable ESC key to show/hide panels") ).ptr(), 0, wcmConfig.systemEscPanel) ,backUpDirButton(0, this, utf8_to_unicode( _LT("Enable BACKSPACE key to go up dir") ).ptr(), 0, wcmConfig.systemBackSpaceUpDir) // ,intLocale(this, utf8_to_unicode( _LT("Interface localisation (save config and restart)") ).ptr(), 0, wcmConfig.systemIntLocale) ,langStatic(0, this, utf8_to_unicode( _LT("Language:") ).ptr()) ,langVal(0, this, utf8_to_unicode( "______________________" ).ptr()) ,langButton(0, this, utf8_to_unicode( ">" ).ptr(), 1000) { #ifndef _WIN32 iL.AddWin(&askOpenExecButton, 0, 0, 0, 2); askOpenExecButton.Enable(); askOpenExecButton.Show(); #endif iL.AddWin(&escPanelButton, 1, 0, 1, 2); escPanelButton.Enable(); escPanelButton.Show(); iL.AddWin(&backUpDirButton,2, 0, 2, 2); backUpDirButton.Enable(); backUpDirButton.Show(); // iL.AddWin(&intLocale, 2, 0, 2, 2); intLocale.Enable(); intLocale.Show(); iL.AddWin(&langStatic, 3, 0); langStatic.Enable(); langStatic.Show(); iL.AddWin(&langVal, 3, 2); langVal.Enable(); langVal.Show(); iL.AddWin(&langButton, 3, 1); langButton.Enable(); langButton.Show(); iL.SetColGrowth(2); AddLayout(&iL); SetEnterCmd(CMD_OK); #ifndef _WIN32 askOpenExecButton.SetFocus(); order.append(&askOpenExecButton); #endif order.append(&escPanelButton); // order.append(&intLocale); order.append(&langButton); SetPosition(); #ifdef _WIN32 LangListLoad( carray_cat<sys_char_t>(GetAppPath().ptr(), utf8_to_sys("\\lang\\list").ptr()).ptr(), list); #else if (!LangListLoad(utf8_to_sys("install-files/share/wcm/lang/list").ptr(), list)) LangListLoad(utf8_to_sys(UNIX_CONFIG_DIR_PATH "/lang/list").ptr(), list); #endif SetCurLang(wcmConfig.systemLang.ptr() ? wcmConfig.systemLang.ptr() : "+"); }
static bool InitLocale( const sys_char_t* dir, const char* id ) { if ( id[0] == '-' ) { return true; } std::vector<sys_char_t> fn = #ifdef _WIN32 carray_cat<sys_char_t>( dir, utf8_to_sys( "\\ltext." ).data() ); #else carray_cat<sys_char_t>( dir, utf8_to_sys( "/ltext." ).data() ); #endif if ( id[0] != '+' ) { return LTextLoad( LTPath( fn.data(), id ).data() ); } return LTextLoad( LTPath( fn.data(), sys_locale_lang_ter() ).data() ) || LTextLoad( LTPath( fn.data(), sys_locale_lang() ).data() ); };
int main( int argc, char** argv ) #endif { try { #ifdef _WIN32 SetHighDPIAware(); //disable system critical messageboxes (for example: no floppy disk :) ) SetErrorMode( SEM_FAILCRITICALERRORS ); Win32HInstance = hInstance; Win32HIconId = IDI_WCM; WSADATA wsaData; if ( WSAStartup( MAKEWORD( 2, 2 ), &wsaData ) ) { throw_syserr( 0, "WSAStartup failed" ); } std::string StartupDir; #else setlocale( LC_ALL, "" ); signal( SIGPIPE, SIG_IGN ); std::string StartupDir = GetStartupDir( argv[0] ); #endif try { InitConfigPath(); g_WcmConfig.Load( nullptr, StartupDir ); const char* langId = g_WcmConfig.systemLang.data() ? g_WcmConfig.systemLang.data() : "+"; #ifdef _WIN32 if ( !InitLocale( L"install-files/share/wcm/lang", langId ) ) { InitLocale( carray_cat<sys_char_t>( GetAppPath().data(), utf8_to_sys( "lang" ).data() ).data(), langId ); } #else if ( !InitLocale( "install-files/share/wcm/lang", langId ) ) { InitLocale( UNIX_CONFIG_DIR_PATH "/lang", langId ); } #endif // SetEditorColorStyle(g_WcmConfig.editColorMode); // SetViewerColorStyle(g_WcmConfig.viewColorMode); } catch ( cexception* ex ) { fprintf( stderr, "%s\n", ex->message() ); ex->destroy(); } InitSSH(); AppInit(); SetColorStyle( g_WcmConfig.styleColorTheme); OldSysGetFont = SysGetFont; SysGetFont = MSysGetFont; // cfont* defaultFont = SysGetFont( 0, 0 ); defaultGC = new wal::GC( ( Win* )0 ); #ifndef _WIN32 #include "icons/wcm.xpm" Win::SetIcon( wcm_xpm ); #endif InitFonts(); InitOperCharsets(); SetCmdIcons(); NCWin ncWin; g_MainWin = &ncWin; // reload config with a valid NCWin g_WcmConfig.Load( &ncWin, StartupDir ); ncWin.Enable(); ncWin.Show(); InitExtensionApp(); #if !defined( _WIN32 ) // don't bother with this on Windows if ( !ParseCommandLine( argc, argv, &ncWin ) ) { return 0; } #endif for ( auto i = g_Applets.begin(); i != g_Applets.end(); i++ ) { if ( !( *i )->Run() ) { return 0; } } g_Applets.clear(); AppRun(); // clean up RemoveAllWcmTempDirs(); dbg_printf( "App Quit!!!\n" ); } catch ( cexception* ex ) { #ifdef _WIN32 MessageBoxA( 0, ex->message(), "", MB_OK ); #else printf( "Error: %s\n", ex->message() ); #endif } return 0; }
inline std::vector<sys_char_t> LTPath( const sys_char_t* fn, const char* ext ) { return carray_cat<sys_char_t>( fn, utf8_to_sys( ext ).data() ); }
int main( int argc, char** argv ) #endif { try { #ifndef _WIN32 for ( int i = 1; i < argc; i++ ) { if ( argv[i][0] == '-' && argv[i][1] == '-' && !strcmp( argv[i] + 2, "dlg" ) ) { createDialogAsChild = false; } } #endif #ifdef _WIN32 //disable system critical messageboxes (for example: no floppy disk :) ) SetErrorMode( SEM_FAILCRITICALERRORS ); #endif #ifdef _WIN32 Win32HInstance = hInstance; Win32HIconId = IDI_WCM; #endif #ifdef _WIN32 WSADATA wsaData; if ( WSAStartup( MAKEWORD( 2, 2 ), &wsaData ) ) { throw_syserr( 0, "WSAStartup failed" ); } #else setlocale( LC_ALL, "" ); signal( SIGPIPE, SIG_IGN ); #endif try { InitConfigPath(); g_WcmConfig.Load( NULL ); const char* langId = g_WcmConfig.systemLang.data() ? g_WcmConfig.systemLang.data() : "+"; #ifdef _WIN32 InitLocale( carray_cat<sys_char_t>( GetAppPath().data(), utf8_to_sys( "lang" ).data() ).data(), langId ); #else if ( !InitLocale( "install-files/share/wcm/lang", langId ) ) { InitLocale( UNIX_CONFIG_DIR_PATH "/lang", langId ); } #endif // SetEditorColorStyle(g_WcmConfig.editColorMode); // SetViewerColorStyle(g_WcmConfig.viewColorMode); } catch ( cexception* ex ) { fprintf( stderr, "%s\n", ex->message() ); ex->destroy(); } InitSSH(); AppInit(); SetColorStyle( g_WcmConfig.styleColorMode ); OldSysGetFont = SysGetFont; SysGetFont = MSysGetFont; // cfont* defaultFont = SysGetFont( 0, 0 ); defaultGC = new wal::GC( ( Win* )0 ); #ifndef _WIN32 #include "icons/wcm.xpm" Win::SetIcon( wcm_xpm ); #endif InitFonts(); InitOperCharsets(); SetCmdIcons(); NCWin ncWin; // reload config with a valid NCWin g_WcmConfig.Load( &ncWin ); ncWin.Enable(); ncWin.Show(); InitExtensionApp(); AppRun(); dbg_printf( "App Quit!!!" ); } catch ( cexception* ex ) { #ifdef _WIN32 MessageBoxA( 0, ex->message(), "", MB_OK ); #else printf( "Error: %s\n", ex->message() ); #endif } return 0; }