void CGameDialog::Init() { InitGlobalPrefPath(); LoadPrefs(); ScanForGames(); if (mGames.empty()) { Error("Didn't find any valid game file descriptions, aborting\n"); } else { std::list<CGameDescription *>::iterator iGame, iPrevGame; for(iGame=mGames.begin(), iPrevGame = mGames.end(); iGame!=mGames.end(); iPrevGame = iGame, ++iGame) { if(iPrevGame != mGames.end()) if(strcmp((*iGame)->getRequiredKeyValue("name"), (*iPrevGame)->getRequiredKeyValue("name")) < 0) { CGameDescription *h = *iGame; *iGame = *iPrevGame; *iPrevGame = h; } } } CGameDescription* currentGameDescription = 0; if (!m_bGamePrompt) { // search by .game name std::list<CGameDescription *>::iterator iGame; for(iGame=mGames.begin(); iGame!=mGames.end(); ++iGame) { if ((*iGame)->mGameFile == m_sGameFile) { currentGameDescription = (*iGame); break; } } } if (m_bGamePrompt || !currentGameDescription) { Create(); DoGameDialog(); // use m_nComboSelect to identify the game to run as and set the globals currentGameDescription = GameDescriptionForComboItem(); ASSERT_NOTNULL(currentGameDescription); } g_pGameDescription = currentGameDescription; g_pGameDescription->Dump(); }
LRESULT WinConsole::TrayWndProc(HWND hwndWin, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == m_taskbarCreatedMessage) { ApplyPrefs(); return 0; } switch (uMsg) { case UM_TRAYICON: if (lParam == WM_LBUTTONUP && !m_doubleClick) { g_Options->SetPauseDownload(!g_Options->GetPauseDownload()); g_Options->SetPausePostProcess(g_Options->GetPauseDownload()); g_Options->SetPauseScan(g_Options->GetPauseDownload()); g_Options->SetResumeTime(0); UpdateTrayIcon(); } else if (lParam == WM_LBUTTONDBLCLK && m_doubleClick) { ShowWebUI(); } else if (lParam == WM_RBUTTONDOWN) { ShowMenu(); } return 0; case UM_QUIT: case WM_ENDSESSION: ExitProc(); return 0; case UM_SHOWWEBUI: ShowWebUI(); return 0; case UM_PREFSCHANGED: LoadPrefs(); ApplyPrefs(); return 0; default: return DefWindowProc(hwndWin, uMsg, wParam, lParam); } }
INT_PTR WinConsole::PrefsDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: LoadPrefs(); SendDlgItemMessage(hwndDlg, IDC_PREF_AUTOSTART, BM_SETCHECK, m_autostart, 0); SendDlgItemMessage(hwndDlg, IDC_PREF_TRAY, BM_SETCHECK, m_showTrayIcon, 0); SendDlgItemMessage(hwndDlg, IDC_PREF_CONSOLE, BM_SETCHECK, m_showConsole, 0); SendDlgItemMessage(hwndDlg, IDC_PREF_WEBUI, BM_SETCHECK, m_showWebUI, 0); SendDlgItemMessage(hwndDlg, IDC_PREF_TRAYPAUSE, BM_SETCHECK, !m_doubleClick, 0); SendDlgItemMessage(hwndDlg, IDC_PREF_TRAYWEBUI, BM_SETCHECK, m_doubleClick, 0); return FALSE; case WM_CLOSE: EndDialog(hwndDlg, 0); return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK) { m_autostart = SendDlgItemMessage(hwndDlg, IDC_PREF_AUTOSTART, BM_GETCHECK, 0, 0) == BST_CHECKED; m_showTrayIcon = SendDlgItemMessage(hwndDlg, IDC_PREF_TRAY, BM_GETCHECK, 0, 0) == BST_CHECKED; m_showConsole = SendDlgItemMessage(hwndDlg, IDC_PREF_CONSOLE, BM_GETCHECK, 0, 0) == BST_CHECKED; m_showWebUI = SendDlgItemMessage(hwndDlg, IDC_PREF_WEBUI, BM_GETCHECK, 0, 0) == BST_CHECKED; m_doubleClick = SendDlgItemMessage(hwndDlg, IDC_PREF_TRAYWEBUI, BM_GETCHECK, 0, 0) == BST_CHECKED; SavePrefs(); if (!m_running) { ApplyPrefs(); } EndDialog(hwndDlg, 0); } else if (LOWORD(wParam) == IDCANCEL) { EndDialog(hwndDlg, 0); } return TRUE; default: return FALSE; } }
/* Get preferences, open (or create) app database */ static UInt16 StartApplication(void) { UInt32 romversion; UInt16 err; err = FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romversion); /* We *must* be version 2 or greater */ if( err || (romversion < 0x02003000) ) { FrmAlert(alertVersion); return(1); } FrmGotoForm(MainForm); LoadPrefs(); return 0; }
void WinConsole::Run() { if (!m_appMode || m_addParam) { return; } CreateTrayIcon(); LoadPrefs(); ApplyPrefs(); BuildMenu(); if (m_showWebUI && !m_autoParam && mayStartBrowser) { ShowWebUI(); } mayStartBrowser = false; int counter = 0; while (!IsStopped()) { MSG msg; if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { usleep(20 * 1000); counter += 20; if (counter >= 200) { UpdateTrayIcon(); counter = 0; } } } Shell_NotifyIcon(NIM_DELETE, m_iconData); }
void PrefsInit(void) { // Start with empty list the_prefs = NULL; // Set defaults SysAddSerialPrefs(); PrefsAddInt16("bootdriver", 0); PrefsAddInt16("bootdrive", 0); PrefsAddInt32("ramsize", 8 * 1024 * 1024); PrefsAddInt32("frameskip", 6); PrefsAddInt32("modelid", 5); // Mac IIci PrefsAddInt32("cpu", 3); // 68030 PrefsAddBool("fpu", false); PrefsAddBool("nocdrom", false); PrefsAddBool("nosound", false); PrefsAddBool("nogui", false); AddPlatformPrefsDefaults(); // Load preferences from settings file LoadPrefs(); }
CMusikPrefs::CMusikPrefs( CString filename ) { config = new CIniFile( filename.GetBuffer() ); if ( !config->ReadFile() ) config->WriteFile(); m_ActiveCaptionDef = false; m_CaptionDef = false; m_InactiveCaptionDef = false; m_InactiveCaptionTextDef = false; m_BtnFaceDef = false; m_BtnTextDef = false; m_BtnHilightDef = false; m_BtnShadowDef = false; m_ListCtrlDef = false; m_ListCtrlTextDef = false; m_HilightDef = false; m_HilightTextDef = false; LoadPrefs(); }
ULONG InitPrefs(STRPTR filename, BOOL use, BOOL save) { D(bug("[serial prefs] InitPrefs\n")); mempool = CreatePool(MEMF_PUBLIC | MEMF_CLEAR, 2048, 2048); if (!mempool) { ShowMsg("Out of memory!"); return 0; } if (!LoadPrefs(filename)) { if (!DefaultPrefs()) { CleanupPrefs(); ShowMsg("Panic! Cannot setup default prefs!"); return 0; } } restore_prefs = serialprefs; if (use || save) { SavePrefs((CONST STRPTR) CONFIGNAME_ENV); } if (save) { SavePrefs((CONST STRPTR) CONFIGNAME_ENVARC); } if (use || save) CleanupPrefs(); return 1; }
/* Runs the host editor. Another big use for this is to open sites * that are in your host list. */ int HostWindow(void) { int c; char cmd[256]; volatile BookmarkPtr toOpen; vsigproc_t si; int maxy, maxx; int lmaxy; si = (sigproc_t) (-1); if (gWinInit) { gHostListWin = NULL; gHostWin = NULL; gHostWin = newwin(LINES, COLS, 0, 0); if (gHostWin == NULL) return (-1); curs_set(0); cbreak(); /* Set the clear flag for the first update. */ wclear(gHostWin); keypad(gHostWin, TRUE); /* For arrow keys. */ #ifdef HAVE_NOTIMEOUT notimeout(gHostWin, TRUE); #endif #ifdef HAVE_SIGSETJMP if (sigsetjmp(gHostWinJmp, 1) == 0) { #else /* HAVE_SIGSETJMP */ if (setjmp(gHostWinJmp) == 0) { #endif /* HAVE_SIGSETJMP */ /* Gracefully cleanup the screen if the user ^C's. */ si = NcSignal(SIGINT, SigIntHostWin); /* Initialize the page start and select a host to be * the current one. */ gHostListWinStart = 0; gHilitedHost = 0; if (gNumBookmarks == 0) gCurHostListItem = NULL; else gCurHostListItem = &gBookmarkTable[gHilitedHost]; /* Initially, we don't want to connect to any site in * the host list. */ toOpen = NULL; getmaxyx(gHostWin, maxy, maxx); WAttr(gHostWin, kBold, 1); WAddCenteredStr(gHostWin, 0, "NcFTP Bookmark Editor"); WAttr(gHostWin, kBold, 0); DrawStrAt(gHostWin, 3, 2, "Open selected site: <enter>"); DrawStrAt(gHostWin, 4, 2, "Edit selected site: /ed"); DrawStrAt(gHostWin, 5, 2, "Delete selected site: /del"); DrawStrAt(gHostWin, 6, 2, "Duplicate selected site: /dup"); DrawStrAt(gHostWin, 7, 2, "Add a new site: /new"); DrawStrAt(gHostWin, 9, 2, "Up one: <u>"); DrawStrAt(gHostWin, 10, 2, "Down one: <d>"); DrawStrAt(gHostWin, 11, 2, "Previous page: <p>"); DrawStrAt(gHostWin, 12, 2, "Next page: <n>"); DrawStrAt(gHostWin, 14, 2, "Capital letters selects first"); DrawStrAt(gHostWin, 15, 2, " site starting with the letter."); DrawStrAt(gHostWin, 17, 2, "Exit the bookmark editor: <x>"); /* Initialize the scrolling host list window. */ if (maxx < 110) { gHostListWinWide = 0; gHostListWin = subwin( gHostWin, LINES - 7, 40, 3, COLS - 40 - 2 ); } else { gHostListWinWide = COLS - 42; gHostListWin = subwin( gHostWin, LINES - 7, gHostListWinWide, 3, 38 ); } if (gHostListWin == NULL) return (-1); lmaxy = getmaxy(gHostListWin); gHostListPageSize = lmaxy; DrawHostList(); wmove(gHostWin, maxy - 1, 0); UpdateHostWindows(1); for (;;) { c = HostWinGetKey(); if (gNeedToClearMsg) { wmove(gHostWin, maxy - 2, 0); wclrtoeol(gHostWin); wrefresh(gHostWin); } if ((c >= 'A') && (c <= 'Z')) { /* isupper can coredump if wgetch returns a meta key. */ HostWinZoomTo(c); } else if (c == '/') { /* Get an "extended" command. Sort of like vi's * :colon commands. */ HostWinGetStr(cmd, sizeof(cmd)); if (ISTREQ(cmd, "ed")) HostWinEdit(); else if (ISTREQ(cmd, "dup")) HostWinDup(); else if (ISTREQ(cmd, "del")) HostWinDelete(); else if (ISTREQ(cmd, "new")) HostWinNew(); else HostWinMsg("Invalid bookmark editor command."); } else switch(c) { case 10: /* ^J == newline */ goto enter; case 13: /* ^M == carriage return */ goto enter; #ifdef KEY_ENTER case KEY_ENTER: Trace(1, " [0x%04X, %s]\n", c, "ENTER"); #endif enter: if (gCurHostListItem == NULL) HostWinMsg("Nothing to open. Try 'open sitename' from the main screen."); else { toOpen = (BookmarkPtr) gCurHostListItem; goto done; } break; case kControl_L: UpdateHostWindows(1); break; case 'u': case 'k': /* vi up key */ case 'h': /* vi left key */ HostListLineUp(); break; #ifdef KEY_UP case KEY_UP: Trace(1, " [0x%04X, %s]\n", c, "UP"); HostListLineUp(); break; #endif #ifdef KEY_LEFT case KEY_LEFT: Trace(1, " [0x%04X, %s]\n", c, "LEFT"); HostListLineUp(); break; #endif case 'd': case 'j': /* vi down key */ case 'l': /* vi right key */ HostListLineDown(); break; #ifdef KEY_DOWN case KEY_DOWN: Trace(1, " [0x%04X, %s]\n", c, "DOWN"); HostListLineDown(); break; #endif #ifdef KEY_RIGHT case KEY_RIGHT: Trace(1, " [0x%04X, %s]\n", c, "RIGHT"); HostListLineDown(); break; #endif case 'p': HostListPageUp(); break; #ifdef KEY_PPAGE case KEY_PPAGE: Trace(1, " [0x%04X, %s]\n", c, "PPAGE"); HostListPageUp(); break; #endif case 'n': HostListPageDown(); break; #ifdef KEY_NPAGE case KEY_NPAGE: Trace(1, " [0x%04X, %s]\n", c, "NPAGE"); HostListPageDown(); break; #endif case 'x': case 'q': goto done; default: HostWinMsg("Invalid key."); Trace(1, " [0x%04X, %s]\n", c, "<invalid>"); break; } } } NcSignal(SIGINT, (FTPSigProc) SIG_IGN); done: if (gHostListWin != NULL) delwin(gHostListWin); if (gHostWin != NULL) delwin(gHostWin); gHostListWin = gHostWin = NULL; if (si != (sigproc_t) (-1)) NcSignal(SIGINT, si); if (toOpen != (BookmarkPtr) 0) { /* If the user selected a site to open, connect to it now. */ if (gStandAlone != 0) { LaunchNcFTP(toOpen->bookmarkName); /*NOTREACHED*/ Exit(0); } else if (gBookmarkSelectionFile != NULL) { WriteSelectedBMToFile(toOpen->bookmarkName); } return (kNoErr); } } return (kNoErr); } /* HostWindow */ main_void_return_t main(int argc, const char **argv) { int result; int argi; gStandAlone = 1; gBookmarkSelectionFile = NULL; InitUserInfo(); if (LoadBookmarkTable() < 0) { exit(7); } if (argc > 1) { /* The following hack is used by NcFTP * to get the number of columns without * having to link with curses/termcap. * This simplifies things since the * system may or may not have a good * curses implementation, and we don't * want to complicate NcFTP itself with * that. */ argi = 1; if (strcmp(argv[1], "--dimensions") == 0) { result = PrintDimensions(0); exit((result == 0) ? 0 : 1); } else if (strcmp(argv[1], "--dimensions-terse") == 0) { result = PrintDimensions(1); exit((result == 0) ? 0 : 1); } else if (strcmp(argv[1], "--debug") == 0) { SetDebug(1); argi++; } /* Requested that we were run from ncftp. */ gStandAlone = 0; if ((argc > argi) && (argv[argi][0] == '/')) gBookmarkSelectionFile = (const char *) argv[argi]; if (gNumBookmarks < 1) exit(7); } result = FTPInitLibrary(&gLib); if (result < 0) { (void) fprintf(stderr, "ncftp: init library error %d (%s).\n", result, FTPStrError(result)); exit(1); } result = FTPInitConnectionInfo(&gLib, &gConn, kDefaultFTPBufSize); if (result < 0) { (void) fprintf(stderr, "ncftp: init connection info error %d (%s).\n", result, FTPStrError(result)); exit(1); } if (gDebug > 0) OpenTrace(); InitPrefs(); LoadFirewallPrefs(0); LoadPrefs(); InitWindows(); Trace(1, "Terminal size is %d columns by %d rows.\n", gScreenWidth, gScreenHeight); HostWindow(); if (gDebug > 0) CloseTrace(); EndWin(); exit(0); } /* main */
int fontforge_main( int argc, char **argv ) { extern const char *source_modtime_str; extern const char *source_version_str; const char *load_prefs = getenv("FONTFORGE_LOADPREFS"); int i; int recover=2; int any; int next_recent=0; GRect pos; GWindowAttrs wattrs; char *display = NULL; FontRequest rq; int ds, ld; int openflags=0; int doopen=0, quit_request=0; bool use_cairo = true; #if !(GLIB_CHECK_VERSION(2, 35, 0)) g_type_init(); #endif /* Must be done before we cache the current directory */ /* Change to HOME dir if specified on the commandline */ for ( i=1; i<argc; ++i ) { char *pt = argv[i]; if ( pt[0]=='-' && pt[1]=='-' ) ++pt; if (strcmp(pt,"-home")==0 || strncmp(pt,"-psn_",5)==0) { /* OK, I don't know what _-psn_ means, but to GW it means */ /* we've been started on the mac from the FontForge.app */ /* structure, and the current directory is (shudder) "/" */ if (getenv("HOME")!=NULL) chdir(getenv("HOME")); break; /* Done - Unnecessary to check more arguments */ } if (strcmp(pt,"-quiet")==0) quiet = 1; } if (!quiet) { fprintf( stderr, "Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.\n" ); fprintf( stderr, " License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n" ); fprintf( stderr, " with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.\n" ); fprintf( stderr, " Based on sources from %s" "-ML" #ifdef FREETYPE_HAS_DEBUGGER "-TtfDb" #endif #ifdef _NO_PYTHON "-NoPython" #endif #ifdef FONTFORGE_CONFIG_USE_DOUBLE "-D" #endif ".\n", FONTFORGE_MODTIME_STR ); fprintf( stderr, " Based on source from git with hash: %s\n", FONTFORGE_GIT_VERSION ); } #if defined(__Mac) /* Start X if they haven't already done so. Well... try anyway */ /* Must be before we change DYLD_LIBRARY_PATH or X won't start */ /* (osascript depends on a libjpeg which isn't found if we look in /sw/lib first */ int local_x = uses_local_x(argc,argv); if ( local_x==1 && getenv("DISPLAY")==NULL ) { /* Don't start X if we're just going to quit. */ /* if X exists, it isn't needed. If X doesn't exist it's wrong */ if ( !hasquit(argc,argv)) { /* This sequence is supposed to bring up an app without a window */ /* but X still opens an xterm */ system( "osascript -e 'tell application \"X11\" to launch'" ); system( "osascript -e 'tell application \"X11\" to activate'" ); } setenv("DISPLAY",":0.0",0); } else if ( local_x==1 && *getenv("DISPLAY")!='/' && strcmp(getenv("DISPLAY"),":0.0")!=0 && strcmp(getenv("DISPLAY"),":0")!=0 ) /* 10.5.7 uses a named socket or something "/tmp/launch-01ftWX:0" */ local_x = 0; #endif #if defined(__MINGW32__) if( getenv("DISPLAY")==NULL ) { putenv("DISPLAY=127.0.0.1:0.0"); } if( getenv("LC_ALL")==NULL ){ char lang[8]; char env[32]; if( GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, lang, 8) > 0 ){ strcpy(env, "LC_ALL="); strcat(env, lang); putenv(env); } } #endif FF_SetUiInterface(&gdraw_ui_interface); FF_SetPrefsInterface(&gdraw_prefs_interface); FF_SetSCInterface(&gdraw_sc_interface); FF_SetCVInterface(&gdraw_cv_interface); FF_SetBCInterface(&gdraw_bc_interface); FF_SetFVInterface(&gdraw_fv_interface); FF_SetFIInterface(&gdraw_fi_interface); FF_SetMVInterface(&gdraw_mv_interface); FF_SetClipInterface(&gdraw_clip_interface); #ifndef _NO_PYTHON PythonUI_Init(); #endif FindProgDir(argv[0]); InitSimpleStuff(); #if defined(__MINGW32__) { char path[MAX_PATH]; unsigned int len = GetModuleFileNameA(NULL, path, MAX_PATH); path[len] = '\0'; //The '.exe' must be removed as resources presumes it's not there. GResourceSetProg(GFileRemoveExtension(GFileNormalizePath(path))); } #else GResourceSetProg(argv[0]); #endif #if defined(__Mac) /* The mac seems to default to the "C" locale, LANG and LC_MESSAGES are not*/ /* defined. This means that gettext will not bother to look up any message*/ /* files -- even if we have a "C" or "POSIX" entry in the locale diretory */ /* Now if X11 gives us the command key, I want to force a rebinding to use */ /* Cmd rather than Control key -- more mac-like. But I can't do that if */ /* there is no locale. So I force a locale if there is none specified */ /* I force the US English locale, because that's the what the messages are */ /* by default so I'm changing as little as I can. I think. */ /* Now the locale command will treat a LANG which is "" as undefined, but */ /* gettext will not. So I don't bother to check for null strings or "C" */ /* or "POSIX". If they've mucked with the locale perhaps they know what */ /* they are doing */ { int did_keybindings = 0; int useCommandKey = get_mac_x11_prop("enable_key_equivalents") <= 0; if ( local_x && useCommandKey ) { hotkeySystemSetCanUseMacCommand( 1 ); /* Ok, we get the command key */ if ( getenv("LANG")==NULL && getenv("LC_MESSAGES")==NULL ) { setenv("LC_MESSAGES","en_US.UTF-8",0); } /* Can we find a set of keybindings designed for the mac with cmd key? */ bind_textdomain_codeset("Mac-FontForge-MenuShortCuts","UTF-8"); bindtextdomain("Mac-FontForge-MenuShortCuts", getLocaleDir()); if ( *dgettext("Mac-FontForge-MenuShortCuts","Flag0x10+")!='F' ) { GMenuSetShortcutDomain("Mac-FontForge-MenuShortCuts"); did_keybindings = 1; } } if ( !did_keybindings ) { /* Nope. we can't. Fall back to the normal stuff */ #endif GMenuSetShortcutDomain("FontForge-MenuShortCuts"); bind_textdomain_codeset("FontForge-MenuShortCuts","UTF-8"); bindtextdomain("FontForge-MenuShortCuts", getLocaleDir()); #if defined(__Mac) } } #endif bind_textdomain_codeset("FontForge","UTF-8"); bindtextdomain("FontForge", getLocaleDir()); textdomain("FontForge"); GResourceUseGetText(); { char shareDir[PATH_MAX]; char* sd = getShareDir(); strncpy( shareDir, sd, PATH_MAX ); shareDir[PATH_MAX-1] = '\0'; if(!sd) { strcpy( shareDir, SHAREDIR ); } char path[PATH_MAX]; snprintf(path, PATH_MAX, "%s%s", shareDir, "/pixmaps" ); GGadgetSetImageDir( path ); snprintf(path, PATH_MAX, "%s%s", shareDir, "/resources/fontforge.resource" ); GResourceAddResourceFile(path, GResourceProgramName,false); } hotkeysLoad(); // loadPrefsFiles(); Prefs_LoadDefaultPreferences(); if ( load_prefs!=NULL && strcasecmp(load_prefs,"Always")==0 ) LoadPrefs(); if ( default_encoding==NULL ) default_encoding=FindOrMakeEncoding("ISO8859-1"); if ( default_encoding==NULL ) default_encoding=&custom; /* In case iconv is broken */ // This no longer starts embedded Python unless control passes to the Python executors, // which exit independently rather than returning here. CheckIsScript(argc,argv); /* Will run the script and exit if it is a script */ /* If there is no UI, there is always a script */ /* and we will never return from the above */ if ( load_prefs==NULL || (strcasecmp(load_prefs,"Always")!=0 && /* Already loaded */ strcasecmp(load_prefs,"Never")!=0 )) LoadPrefs(); GrokNavigationMask(); for ( i=1; i<argc; ++i ) { char *pt = argv[i]; if ( pt[0]=='-' && pt[1]=='-' ) ++pt; if ( strcmp(pt,"-sync")==0 ) GResourceAddResourceString("Gdraw.Synchronize: true",argv[0]); else if ( strcmp(pt,"-depth")==0 && i<argc-1 ) AddR(argv[0],"Gdraw.Depth", argv[++i]); else if ( strcmp(pt,"-vc")==0 && i<argc-1 ) AddR(argv[0],"Gdraw.VisualClass", argv[++i]); else if ( (strcmp(pt,"-cmap")==0 || strcmp(pt,"-colormap")==0) && i<argc-1 ) AddR(argv[0],"Gdraw.Colormap", argv[++i]); else if ( (strcmp(pt,"-dontopenxdevices")==0) ) AddR(argv[0],"Gdraw.DontOpenXDevices", "true"); else if ( strcmp(pt,"-keyboard")==0 && i<argc-1 ) AddR(argv[0],"Gdraw.Keyboard", argv[++i]); else if ( strcmp(pt,"-display")==0 && i<argc-1 ) display = argv[++i]; # if MyMemory else if ( strcmp(pt,"-memory")==0 ) __malloc_debug(5); # endif else if ( strncmp(pt,"-usecairo",strlen("-usecairo"))==0 ) { if ( strcmp(pt,"-usecairo=no")==0 ) use_cairo = false; else use_cairo = true; GDrawEnableCairo(use_cairo); } else if ( strcmp(pt,"-nosplash")==0 ) splash = 0; else if ( strcmp(pt,"-quiet")==0 ) /* already checked for this earlier, no need to do it again */; else if ( strcmp(pt,"-unique")==0 ) unique = 1; else if ( strcmp(pt,"-forceuihidden")==0 ) cmdlinearg_forceUIHidden = 0; else if ( strcmp(pt,"-recover")==0 && i<argc-1 ) { ++i; if ( strcmp(argv[i],"none")==0 ) recover=0; else if ( strcmp(argv[i],"clean")==0 ) recover= -1; else if ( strcmp(argv[i],"auto")==0 ) recover= 1; else if ( strcmp(argv[i],"inquire")==0 ) recover= 2; else { fprintf( stderr, "Invalid argument to -recover, must be none, auto, inquire or clean\n" ); dousage(); } } else if ( strcmp(pt,"-recover=none")==0 ) { recover = 0; } else if ( strcmp(pt,"-recover=clean")==0 ) { recover = -1; } else if ( strcmp(pt,"-recover=auto")==0 ) { recover = 1; } else if ( strcmp(pt,"-recover=inquire")==0 ) { recover = 2; } else if ( strcmp(pt,"-docs")==0 ) dohelp(); else if ( strcmp(pt,"-help")==0 ) dousage(); else if ( strcmp(pt,"-version")==0 || strcmp(pt,"-v")==0 || strcmp(pt,"-V")==0 ) doversion(FONTFORGE_MODTIME_STR); else if ( strcmp(pt,"-quit")==0 ) quit_request = true; else if ( strcmp(pt,"-home")==0 ) /* already did a chdir earlier, don't need to do it again */; #if defined(__Mac) else if ( strncmp(pt,"-psn_",5)==0 ) { /* OK, I don't know what _-psn_ means, but to GW it means */ /* we've been started on the mac from the FontForge.app */ /* structure, and the current directory was (shudder) "/" */ /* (however, we changed to HOME earlier in main routine). */ unique = 1; listen_to_apple_events = true; // This has been problematic on Mavericks and later. } #endif } ensureDotFontForgeIsSetup(); #if defined(__MINGW32__) && !defined(_NO_LIBCAIRO) //Load any custom fonts for the user interface if (use_cairo) { char *system_load = getGResourceProgramDir(); char *user_load = getFontForgeUserDir(Data); char lbuf[MAX_PATH]; int lret; if (system_load != NULL) { //Follow the FontConfig APPSHAREFONTDIR location lret = snprintf(lbuf, MAX_PATH, "%s/../share/fonts", system_load); if (lret > 0 && lret < MAX_PATH) { WinLoadUserFonts(lbuf); } } if (user_load != NULL) { lret = snprintf(lbuf, MAX_PATH, "%s/%s", user_load, "ui-fonts"); if (lret > 0 && lret < MAX_PATH) { WinLoadUserFonts(lbuf); } free(user_load); } } #endif InitImageCache(); // This is in gtextinfo.c. It zeroes imagecache for us. atexit(&ClearImageCache); // We register the destructor, which is also in gtextinfo.c. GDrawCreateDisplays(display,argv[0]); atexit(&GDrawDestroyDisplays); // We register the destructor so that it runs even if we call exit without finishing this function. default_background = GDrawGetDefaultBackground(screen_display); InitToolIconClut(default_background); InitToolIcons(); InitCursors(); /** * we have to do a quick sniff of argv[] here to see if the user * wanted to skip loading these python init files. */ for ( i=1; i<argc; ++i ) { char *pt = argv[i]; if ( !strcmp(pt,"-SkipPythonInitFiles")) { ProcessPythonInitFiles = 0; } } #ifndef _NO_PYTHON /*# ifndef GWW_TEST*/ FontForge_InitializeEmbeddedPython(); /* !!!!!! debug (valgrind doesn't like python) */ /*# endif*/ #endif #ifndef _NO_PYTHON if( ProcessPythonInitFiles ) PyFF_ProcessInitFiles(); #endif /* the splash screen used not to have a title bar (wam_nodecor) */ /* but I found I needed to know how much the window manager moved */ /* the window around, which I can determine if I have a positioned */ /* decorated window created at the begining */ /* Actually I don't care any more */ wattrs.mask = wam_events|wam_cursor|wam_bordwidth|wam_backcol|wam_positioned|wam_utf8_wtitle|wam_isdlg; wattrs.event_masks = ~(1<<et_charup); wattrs.positioned = 1; wattrs.cursor = ct_pointer; wattrs.utf8_window_title = "FontForge"; wattrs.border_width = 2; wattrs.background_color = 0xffffff; wattrs.is_dlg = !listen_to_apple_events; pos.x = pos.y = 200; pos.width = splashimage.u.image->width; pos.height = splashimage.u.image->height-56; /* 54 */ GDrawBindSelection(NULL,sn_user1,"FontForge"); if ( unique && GDrawSelectionOwned(NULL,sn_user1)) { /* Different event handler, not a dialog */ wattrs.is_dlg = false; splashw = GDrawCreateTopWindow(NULL,&pos,request_e_h,NULL,&wattrs); PingOtherFontForge(argc,argv); } else { if ( quit_request ) exit( 0 ); splashw = GDrawCreateTopWindow(NULL,&pos,splash_e_h,NULL,&wattrs); } memset(&rq,0,sizeof(rq)); rq.utf8_family_name = SERIF_UI_FAMILIES; rq.point_size = 12; rq.weight = 400; splash_font = GDrawInstanciateFont(NULL,&rq); splash_font = GResourceFindFont("Splash.Font",splash_font); GDrawDecomposeFont(splash_font, &rq); rq.style = fs_italic; splash_italic = GDrawInstanciateFont(NULL,&rq); splash_italic = GResourceFindFont("Splash.ItalicFont",splash_italic); GDrawSetFont(splashw,splash_font); SplashLayout(); localsplash = splash; if ( localsplash && !listen_to_apple_events ) start_splash_screen(); // // The below call will initialize the fontconfig cache if required. // That can take a while the first time it happens. // GDrawWindowFontMetrics(splashw,splash_font,&as,&ds,&ld); fh = as+ds+ld; if ( AutoSaveFrequency>0 ) autosave_timer=GDrawRequestTimer(splashw,2*AutoSaveFrequency*1000,AutoSaveFrequency*1000,NULL); GDrawProcessPendingEvents(NULL); GDrawSetBuildCharHooks(BuildCharHook,InsCharHook); any = 0; if ( recover==-1 ) CleanAutoRecovery(); else if ( recover ) any = DoAutoRecoveryExtended( recover-1 ); openflags = 0; for ( i=1; i<argc; ++i ) { char buffer[1025]; char *pt = argv[i]; GDrawProcessPendingEvents(NULL); if ( pt[0]=='-' && pt[1]=='-' && pt[2]!='\0') ++pt; if ( strcmp(pt,"-new")==0 ) { FontNew(); any = 1; # if HANYANG } else if ( strcmp(pt,"-newkorean")==0 ) { MenuNewComposition(NULL,NULL,NULL); any = 1; # endif } else if ( !strcmp(pt,"-SkipPythonInitFiles")) { // already handled above. } else if ( strcmp(pt,"-last")==0 ) { if ( next_recent<RECENT_MAX && RecentFiles[next_recent]!=NULL ) if ( ViewPostScriptFont(RecentFiles[next_recent++],openflags)) any = 1; } else if ( strcmp(pt,"-sync")==0 || strcmp(pt,"-memory")==0 || strcmp(pt,"-nosplash")==0 || strcmp(pt,"-recover=none")==0 || strcmp(pt,"-recover=clean")==0 || strcmp(pt,"-recover=auto")==0 || strcmp(pt,"-dontopenxdevices")==0 || strcmp(pt,"-unique")==0 || strncmp(pt,"-usecairo",strlen("-usecairo"))==0 || strcmp(pt,"-home")==0 || strcmp(pt,"-quiet")==0 || strcmp(pt,"-forceuihidden")==0 ) /* Already done, needed to be before display opened */; else if ( strncmp(pt,"-psn_",5)==0 ) /* Already done */; else if ( (strcmp(pt,"-depth")==0 || strcmp(pt,"-vc")==0 || strcmp(pt,"-cmap")==0 || strcmp(pt,"-colormap")==0 || strcmp(pt,"-keyboard")==0 || strcmp(pt,"-display")==0 || strcmp(pt,"-recover")==0 ) && i<argc-1 ) ++i; /* Already done, needed to be before display opened */ else if ( strcmp(pt,"-allglyphs")==0 ) openflags |= of_all_glyphs_in_ttc; else if ( strcmp(pt,"-open")==0 ) doopen = true; else { printf("else argv[i]:%s\n", argv[i] ); if ( strstr(argv[i],"://")!=NULL ) { /* Assume an absolute URL */ strncpy(buffer,argv[i],sizeof(buffer)); buffer[sizeof(buffer)-1]= '\0'; } else GFileGetAbsoluteName(argv[i],buffer,sizeof(buffer)); if ( GFileIsDir(buffer) || (strstr(buffer,"://")!=NULL && buffer[strlen(buffer)-1]=='/')) { char *fname; fname = malloc(strlen(buffer)+strlen("/glyphs/contents.plist")+1); strcpy(fname,buffer); strcat(fname,"/glyphs/contents.plist"); if ( GFileExists(fname)) { /* It's probably a Unified Font Object directory */ free(fname); if ( ViewPostScriptFont(buffer,openflags) ) any = 1; } else { strcpy(fname,buffer); strcat(fname,"/font.props"); if ( GFileExists(fname)) { /* It's probably a sf dir collection */ free(fname); if ( ViewPostScriptFont(buffer,openflags) ) any = 1; } else { free(fname); if ( buffer[strlen(buffer)-1]!='/' ) { /* If dirname doesn't end in "/" we'll be looking in parent dir */ buffer[strlen(buffer)+1]='\0'; buffer[strlen(buffer)] = '/'; } fname = GetPostScriptFontName(buffer,false); if ( fname!=NULL ) ViewPostScriptFont(fname,openflags); any = 1; /* Even if we didn't get a font, don't bring up dlg again */ free(fname); } } } else if ( ViewPostScriptFont(buffer,openflags)!=0 ) any = 1; } } if ( !any && !doopen ) any = ReopenLastFonts(); collabclient_ensureClientBeacon(); collabclient_sniffForLocalServer(); #ifndef _NO_PYTHON PythonUI_namedpipe_Init(); #endif #if defined(__Mac) if ( listen_to_apple_events ) { install_apple_event_handlers(); install_mac_timer(); setup_cocoa_app(); // WARNING: See declaration of RunApplicationEventLoop() above as to // why you might not want to call that function anymore. // RunApplicationEventLoop(); } else #endif if ( doopen || !any ) _FVMenuOpen(NULL); GDrawEventLoop(NULL); GDrawDestroyDisplays(); #ifndef _NO_PYTHON /*# ifndef GWW_TEST*/ FontForge_FinalizeEmbeddedPython(); /* !!!!!! debug (valgrind doesn't like python) */ /*# endif*/ #endif // These free menu translations, mostly. BitmapViewFinishNonStatic(); MetricsViewFinishNonStatic(); CharViewFinishNonStatic(); FontViewFinishNonStatic(); ClearImageCache(); // This frees the contents of imagecache. hotkeysSave(); LastFonts_Save(); #ifndef _NO_LIBUNICODENAMES uninm_names_db_close(names_db); /* close this database before exiting */ uninm_blocks_db_close(blocks_db); #endif lt_dlexit(); return( 0 ); }
WaveformSettings::WaveformSettings() { LoadPrefs(); }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { int retCode = 1; // by default it's error #ifdef DEBUG // Memory leak detection (only enable _CRTDBG_LEAK_CHECK_DF for // regular termination so that leaks aren't checked on exceptions, // aborts, etc. where some clean-up might not take place) _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF); //_CrtSetBreakAlloc(421); TryLoadMemTrace(); #endif DisableDataExecution(); // ensure that C functions behave consistently under all OS locales // (use Win32 functions where localized input or output is desired) setlocale(LC_ALL, "C"); // don't show system-provided dialog boxes when accessing files on drives // that are not mounted (e.g. a: drive without floppy or cd rom drive // without a cd). SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); #if defined(DEBUG) || defined(SVN_PRE_RELEASE_VER) if (str::StartsWith(lpCmdLine, "/tester")) { extern int TesterMain(); // in Tester.cpp return TesterMain(); } if (str::StartsWith(lpCmdLine, "/regress")) { extern int RegressMain(); // in Regress.cpp return RegressMain(); } #endif #ifdef SUPPORTS_AUTO_UPDATE if (str::StartsWith(lpCmdLine, "-autoupdate")) { bool quit = AutoUpdateMain(); if (quit) return 0; } #endif RunUnitTests(); srand((unsigned int)time(NULL)); { ScopedMem<WCHAR> symDir; ScopedMem<WCHAR> tmpDir(path::GetTempPath()); if (tmpDir) symDir.Set(path::Join(tmpDir, L"SumatraPDF-symbols")); else symDir.Set(AppGenDataFilename(L"SumatraPDF-symbols")); ScopedMem<WCHAR> crashDumpPath(AppGenDataFilename(CRASH_DUMP_FILE_NAME)); InstallCrashHandler(crashDumpPath, symDir); } ScopedOle ole; InitAllCommonControls(); ScopedGdiPlus gdiPlus(true); mui::Initialize(); uitask::Initialize(); LoadPrefs(); CommandLineInfo i; GetCommandLineInfo(i); SetCurrentLang(i.lang ? i.lang : gGlobalPrefs->currLangCode); if (i.showConsole) RedirectIOToConsole(); if (i.makeDefault) AssociateExeWithPdfExtension(); if (i.pathsToBenchmark.Count() > 0) { BenchFileOrDir(i.pathsToBenchmark); if (i.showConsole) system("pause"); } if (i.exitImmediately) goto Exit; gCrashOnOpen = i.crashOnOpen; gUserPrefs->mainWindowBackground = i.bgColor; if (gUserPrefs->forwardSearch.highlightColor != i.forwardSearch.highlightColor || gUserPrefs->forwardSearch.highlightOffset != i.forwardSearch.highlightOffset || gUserPrefs->forwardSearch.highlightPermanent != i.forwardSearch.highlightPermanent || gUserPrefs->forwardSearch.highlightWidth != i.forwardSearch.highlightWidth) { gGlobalPrefs->enableTeXEnhancements = true; } gUserPrefs->forwardSearch = i.forwardSearch; gUserPrefs->escToExit = i.escToExit; gGlobalPrefs->cbxR2L = i.cbxR2L; gPolicyRestrictions = GetPolicies(i.restrictedUse); gRenderCache.colorRange[0] = i.colorRange[0]; gRenderCache.colorRange[1] = i.colorRange[1]; DebugGdiPlusDevice(gUseGdiRenderer); DebugAlternateChmEngine(gUserPrefs->ebookUI.traditionalEbookUI); if (i.inverseSearchCmdLine) { str::ReplacePtr(&gGlobalPrefs->inverseSearchCmdLine, i.inverseSearchCmdLine); gGlobalPrefs->enableTeXEnhancements = true; } if (!RegisterWinClass(hInstance)) goto Exit; if (!InstanceInit(hInstance, nCmdShow)) goto Exit; if (i.hwndPluginParent) { if (!SetupPluginMode(i)) goto Exit; } if (i.printerName) { // note: this prints all PDF files. Another option would be to // print only the first one for (size_t n = 0; n < i.fileNames.Count(); n++) { bool ok = PrintFile(i.fileNames.At(n), i.printerName, !i.silent, i.printSettings); if (!ok) retCode++; } --retCode; // was 1 if no print failures, turn 1 into 0 goto Exit; } if (i.fileNames.Count() == 0 && gGlobalPrefs->rememberOpenedFiles && gGlobalPrefs->showStartPage) { // make the shell prepare the image list, so that it's ready when the first window's loaded SHFILEINFO sfi; SHGetFileInfo(L".pdf", 0, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES); } if (!i.reuseInstance && gUserPrefs->reuseInstance && FindWindow(FRAME_CLASS_NAME, 0)) i.reuseInstance = true; WindowInfo *win = NULL; bool isFirstWin = true; for (size_t n = 0; n < i.fileNames.Count(); n++) { if (i.reuseInstance && !i.printDialog) { OpenUsingDde(i.fileNames.At(n), i, isFirstWin); } else { win = LoadOnStartup(i.fileNames.At(n), i, isFirstWin); if (!win) { retCode++; continue; } if (i.printDialog) OnMenuPrint(win, i.exitWhenDone); } isFirstWin = false; } if (i.fileNames.Count() > 0 && isFirstWin) { // failed to create any window, even though there // were files to load (or show a failure message for) goto Exit; } if (i.reuseInstance && !i.printDialog || i.printDialog && i.exitWhenDone) goto Exit; if (isFirstWin) { win = CreateAndShowWindowInfo(); if (!win) goto Exit; } UpdateUITextForLanguage(); // needed for RTL languages if (isFirstWin) UpdateToolbarAndScrollbarState(*win); // Make sure that we're still registered as default, // if the user has explicitly told us to be if (gGlobalPrefs->pdfAssociateShouldAssociate && win) RegisterForPdfExtentions(win->hwndFrame); if (gGlobalPrefs->enableAutoUpdate && gWindows.Count() > 0) AutoUpdateCheckAsync(gWindows.At(0)->hwndFrame, true); if (i.stressTestPath) StartStressTest(&i, win, &gRenderCache); if (gFileHistory.Get(0)) { gFileExistenceChecker = new FileExistenceChecker(); gFileExistenceChecker->Start(); } retCode = RunMessageLoop(); CleanUpThumbnailCache(gFileHistory); Exit: while (gWindows.Count() > 0) { DeleteWindowInfo(gWindows.At(0)); } while (gEbookWindows.Count() > 0) { DeleteEbookWindow(gEbookWindows.At(0), true); } #ifndef DEBUG // leave all the remaining clean-up to the OS // (as recommended for a quick exit) ExitProcess(retCode); #else CrashIf(gFileExistenceChecker); DeleteObject(gBrushNoDocBg); DeleteObject(gBrushLogoBg); DeleteObject(gBrushAboutBg); DeleteObject(gDefaultGuiFont); DeleteBitmap(gBitmapReloadingCue); gFileHistory.UpdateStatesSource(NULL); DeleteGlobalPrefs(gGlobalPrefs); mui::Destroy(); uitask::Destroy(); trans::Destroy(); // it's still possible to crash after this (destructors of static classes, // atexit() code etc.) point, but it's very unlikely UninstallCrashHandler(); // output leaks after all destructors of static objects have run _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); return retCode; #endif }
int main(int argc, char *argv[]) { // Initialize the SDL library // This is required to avoid _main errors at runtime. #ifdef UseSDLMixer if ( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0 ) { #else if ( SDL_Init(SDL_INIT_VIDEO ) < 0 ) { #endif fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } // Init SDL_Image - only applies above 1.2.7 // load support for the JPG and PNG image formats int IMGflags=IMG_INIT_JPG|IMG_INIT_PNG; int initted=IMG_Init(IMGflags); if(initted && IMGflags != IMGflags) { printf("IMG_Init: Failed to init required jpg and png support!\n"); printf("IMG_Init: %s\n", IMG_GetError()); // handle error } #ifdef UseSDLMixer // Initialize SDL mixer. if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) != 0) { fprintf(stderr, "Unable to initialize audio: %s\n", Mix_GetError()); exit(1); } #endif // Retrieve display gamma for reference in fade in/fade out routines. SDL_GetGammaRamp(redGamma, greenGamma, blueGamma); // printf("%u", *redGamma); Initialize( ); LoadPrefs( ); ReserveMonitor( ); ShowTitle( ); ChooseMusic( 13 ); while( !finished ) { if( showStartMenu ) { GameStartMenu( ); showStartMenu = false; } if( !finished ) { DoFullRepaint = NeedRefresh; CheckKeys( ); HandlePlayers( ); UpdateOpponent( ); UpdateBalloon( ); UpdateSound( ); DoFullRepaint = NoPaint; if( needsRefresh ) { RefreshAll(); needsRefresh = false; } if( !showStartMenu && pauseKey ) { FreezeGameTickCount( ); PauseMusic( ); MaskRect( &playerWindowRect[0] ); MaskRect( &playerWindowRect[1] ); WaitForRelease( ); HandleDialog( kPauseDialog ); WaitForRelease( ); RefreshPlayerWindow( 0 ); RefreshPlayerWindow( 1 ); ResumeMusic( ); UnfreezeGameTickCount( ); } } } SavePrefs( ); ReleaseMonitor( ); return 0; } void NoPaint( void ) { } void MaskRect( MRect *r ) { SDL_Rect sdlRect; SDLU_MRectToSDLRect( r, &sdlRect ); SDLU_BlitFrontSurface( backdropSurface, &sdlRect, &sdlRect ); }
WaveformSettings::Globals::Globals() { LoadPrefs(); }
int main( int argc, char **argv ) { extern const char *source_modtime_str, *source_version_str; const char *load_prefs = getenv("FONTFORGE_LOADPREFS"); int i; extern int splash; int recover=1; GtkWidget *notices, *ffsplash; gchar *home_dir, *rc_path; struct argcontext args; #ifdef FONTFORGE_CONFIG_TYPE3 fprintf( stderr, "Copyright (c) 2000-2012 by George Williams.\n Executable based on sources from %s-ML.\n", source_modtime_str ); #else fprintf( stderr, "Copyright (c) 2000-2012 by George Williams.\n Executable based on sources from %s.\n", source_modtime_str ); #endif fprintf( stderr, " Library based on sources from %s.\n", library_version_configuration.library_source_modtime_string ); gtk_set_locale (); home_dir = (gchar*) g_get_home_dir(); rc_path = g_strdup_printf("%s/.fontforgerc", home_dir); gtk_rc_add_default_file(rc_path); g_free(rc_path); gtk_init (&argc, &argv); #if defined(SHAREDIR) add_pixmap_directory( SHAREDIR "/pixmaps"); #elif defined(PREFIX) add_pixmap_directory( PREFIX "/share/fontforge/pixmaps" ); #else add_pixmap_directory( "./pixmaps" ); #endif bind_textdomain_codeset("FontForge","UTF-8"); bindtextdomain("FontForge", getLocaleDir()); textdomain("FontForge"); #if defined(__Mac) /* Start X if they haven't already done so. Well... try anyway */ /* Must be before we change DYLD_LIBRARY_PATH or X won't start */ if ( uses_local_x(argc,argv) && getenv("DISPLAY")==NULL ) { system( "open /Applications/Utilities/X11.app/" ); setenv("DISPLAY",":0.0",0); } #endif FF_SetUiInterface(>k_ui_interface); FF_SetPrefsInterface(>k_prefs_interface); /*FF_SetSCInterface(>k_sc_interface);*/ /*FF_SetCVInterface(>k_cv_interface);*/ /*FF_SetBCInterface(>k_bc_interface);*/ FF_SetFVInterface(>k_fv_interface); /*FF_SetFIInterface(>k_fi_interface);*/ /*FF_SetMVInterface(>k_mv_interface);*/ /*FF_SetClipInterface(>k_clip_interface);*/ #ifndef _NO_PYTHON PythonUI_Init(); #endif InitSimpleStuff(); if ( load_prefs!=NULL && strcasecmp(load_prefs,"Always")==0 ) LoadPrefs(); if ( default_encoding==NULL ) default_encoding=FindOrMakeEncoding("ISO8859-1"); if ( default_encoding==NULL ) default_encoding=&custom; /* In case iconv is broken */ CheckIsScript(argc,argv); /* Will run the script and exit if it is a script */ /* If there is no UI, there is always a script */ /* and we will never return from the above */ if ( load_prefs==NULL || (strcasecmp(load_prefs,"Always")!=0 && /* Already loaded */ strcasecmp(load_prefs,"Never")!=0 )) LoadPrefs(); for ( i=1; i<argc; ++i ) { char *pt = argv[i]; if ( pt[0]=='-' && pt[1]=='-' ) ++pt; if ( strcmp(pt,"-nosplash")==0 ) splash = 0; else if ( strcmp(pt,"-recover")==0 && i<argc-1 ) { ++i; if ( strcmp(argv[i],"none")==0 ) recover=0; else if ( strcmp(argv[i],"clean")==0 ) recover= -1; else if ( strcmp(argv[i],"auto")==0 ) recover= 1; else if ( strcmp(argv[i],"inquire")==0 ) recover= 2; else { fprintf( stderr, "Invalid argument to -recover, must be none, auto, inquire or clean\n" ); dousage(); } } else if ( strcmp(pt,"-recover=none")==0 ) { recover = 0; } else if ( strcmp(pt,"-recover=clean")==0 ) { recover = -1; } else if ( strcmp(pt,"-recover=auto")==0 ) { recover = 1; } else if ( strcmp(pt,"-recover=inquire")==0 ) { recover = 2; } else if ( strcmp(pt,"-help")==0 ) dohelp(); else if ( strcmp(pt,"-usage")==0 ) dousage(); else if ( strcmp(pt,"-version")==0 ) doversion(source_version_str); else if ( strcmp(pt,"-library-status")==0 ) dolibrary(); } InitCursors(); #ifndef _NO_PYTHON PyFF_ProcessInitFiles(); #endif if ( splash ) { splashw = create_FontForgeSplash (); splash_window_tooltip_fun( splashw ); notices = lookup_widget(splashw,"Notices"); if ( notices!=NULL ) gtk_widget_hide(notices); ffsplash = lookup_widget(splashw,"ffsplash2"); if ( ffsplash!=NULL ) gtk_widget_hide(ffsplash); ffsplash = lookup_widget(splashw,"ffsplash3"); if ( ffsplash!=NULL ) gtk_widget_hide(ffsplash); gtk_window_set_position(GTK_WINDOW(splashw),GTK_WIN_POS_CENTER_ALWAYS); gtk_widget_show (splashw); ff_progress_allow_events(); gtk_timeout_add(1000,Splash_Changes,splashw); } gtk_timeout_add(30*1000,__DoAutoSaves,NULL); /* Check for autosave every 30 seconds */ args.argc = argc; args.argv = argv; args.recover = recover; gtk_timeout_add(100,ParseArgs,&args); /* Parse arguments within the main loop */ gtk_main (); return( 0 ); }
int fontforge_main( int argc, char **argv ) { extern const char *source_modtime_str; extern const char *source_version_str; const char *load_prefs = getenv("FONTFORGE_LOADPREFS"); int i; int recover=2; int any; int next_recent=0; GRect pos; GWindowAttrs wattrs; char *display = NULL; FontRequest rq; int ds, ld; int openflags=0; int doopen=0, quit_request=0; #if defined(__Mac) int local_x; #endif fprintf( stderr, "Copyright (c) 2000-2012 by George Williams.\n Executable based on sources from %s" "-ML" #ifdef FREETYPE_HAS_DEBUGGER "-TtfDb" #endif #ifdef _NO_PYTHON "-NoPython" #endif #ifdef FONTFORGE_CONFIG_USE_DOUBLE "-D" #endif ".\n", source_modtime_str ); fprintf( stderr, " Library based on sources from %s.\n", library_version_configuration.library_source_modtime_string ); /* Must be done before we cache the current directory */ /* Change to HOME dir if specified on the commandline */ for ( i=1; i<argc; ++i ) { char *pt = argv[i]; if ( pt[0]=='-' && pt[1]=='-' ) ++pt; #ifndef __Mac if (strcmp(pt,"-home")==0) { #else if (strcmp(pt,"-home")==0 || strncmp(pt,"-psn_",5)==0) { /* OK, I don't know what _-psn_ means, but to GW it means */ /* we've been started on the mac from the FontForge.app */ /* structure, and the current directory is (shudder) "/" */ #endif if (getenv("HOME")!=NULL) chdir(getenv("HOME")); break; /* Done - Unnecessary to check more arguments */ } } #if defined(__Mac) /* Start X if they haven't already done so. Well... try anyway */ /* Must be before we change DYLD_LIBRARY_PATH or X won't start */ /* (osascript depends on a libjpeg which isn't found if we look in /sw/lib first */ local_x = uses_local_x(argc,argv); if ( local_x==1 && getenv("DISPLAY")==NULL ) { /* Don't start X if we're just going to quit. */ /* if X exists, it isn't needed. If X doesn't exist it's wrong */ if ( !hasquit(argc,argv)) { #if 1 /* This sequence is supposed to bring up an app without a window */ /* but X still opens an xterm */ system( "osascript -e 'tell application \"X11\" to launch'" ); system( "osascript -e 'tell application \"X11\" to activate'" ); #else system( "open /Applications/Utilities/X11.app/" ); #endif } setenv("DISPLAY",":0.0",0); } else if ( local_x==1 && *getenv("DISPLAY")!='/' && strcmp(getenv("DISPLAY"),":0.0")!=0 && strcmp(getenv("DISPLAY"),":0")!=0 ) /* 10.5.7 uses a named socket or something "/tmp/launch-01ftWX:0" */ local_x = 0; #endif #if defined(__MINGW32__) if( getenv("DISPLAY")==NULL ) { putenv("DISPLAY=127.0.0.1:0.0"); } if( getenv("LC_ALL")==NULL ){ char lang[8]; char env[32]; if( GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, lang, 8) > 0 ){ strcpy(env, "LC_ALL="); strcat(env, lang); putenv(env); } } #endif FF_SetUiInterface(&gdraw_ui_interface); FF_SetPrefsInterface(&gdraw_prefs_interface); FF_SetSCInterface(&gdraw_sc_interface); FF_SetCVInterface(&gdraw_cv_interface); FF_SetBCInterface(&gdraw_bc_interface); FF_SetFVInterface(&gdraw_fv_interface); FF_SetFIInterface(&gdraw_fi_interface); FF_SetMVInterface(&gdraw_mv_interface); FF_SetClipInterface(&gdraw_clip_interface); #ifndef _NO_PYTHON PythonUI_Init(); #endif InitSimpleStuff(); FindProgDir(argv[0]); #if defined(__MINGW32__) { char path[MAX_PATH+4]; char *c = path; unsigned int len = GetModuleFileNameA(NULL, path, MAX_PATH); path[len] = '\0'; for(; *c; *c++) /* backslash to slash */ if(*c == '\\') *c = '/'; GResourceSetProg(path); } #else GResourceSetProg(argv[0]); #endif #if defined(__Mac) /* The mac seems to default to the "C" locale, LANG and LC_MESSAGES are not*/ /* defined. This means that gettext will not bother to look up any message*/ /* files -- even if we have a "C" or "POSIX" entry in the locale diretory */ /* Now if X11 gives us the command key, I want to force a rebinding to use */ /* Cmd rather than Control key -- more mac-like. But I can't do that if */ /* there is no locale. So I force a locale if there is none specified */ /* I force the US English locale, because that's the what the messages are */ /* by default so I'm changing as little as I can. I think. */ /* Now the locale command will treat a LANG which is "" as undefined, but */ /* gettext will not. So I don't bother to check for null strings or "C" */ /* or "POSIX". If they've mucked with the locale perhaps they know what */ /* they are doing */ { int did_keybindings = 0; if ( local_x && !get_mac_x11_prop("enable_key_equivalents") ) { /* Ok, we get the command key */ if ( getenv("LANG")==NULL && getenv("LC_MESSAGES")==NULL ) { setenv("LC_MESSAGES","en_US.UTF-8",0); } /* Can we find a set of keybindings designed for the mac with cmd key? */ bind_textdomain_codeset("Mac-FontForge-MenuShortCuts","UTF-8"); bindtextdomain("Mac-FontForge-MenuShortCuts", getLocaleDir()); if ( *dgettext("Mac-FontForge-MenuShortCuts","Flag0x10+")!='F' ) { GMenuSetShortcutDomain("Mac-FontForge-MenuShortCuts"); did_keybindings = 1; } } if ( !did_keybindings ) { /* Nope. we can't. Fall back to the normal stuff */ #endif GMenuSetShortcutDomain("FontForge-MenuShortCuts"); bind_textdomain_codeset("FontForge-MenuShortCuts","UTF-8"); bindtextdomain("FontForge-MenuShortCuts", getLocaleDir()); #if defined(__Mac) }} #endif bind_textdomain_codeset("FontForge","UTF-8"); bindtextdomain("FontForge", getLocaleDir()); textdomain("FontForge"); GResourceUseGetText(); #if defined(__MINGW32__) { size_t len = strlen(GResourceProgramDir); char* path = galloc(len + 64); strcpy(path, GResourceProgramDir); strcpy(path+len, "/share/fontforge/pixmaps"); /* PixmapDir */ GGadgetSetImageDir(path); strcpy(path+len, "/share/fontforge/resources/fontforge.resource"); /* Resource File */ GResourceAddResourceFile(path, GResourceProgramName, false); gfree(path); } #elif defined(SHAREDIR) GGadgetSetImageDir(SHAREDIR "/pixmaps"); GResourceAddResourceFile(SHAREDIR "/resources/fontforge.resource",GResourceProgramName,false); #endif hotkeysLoad(); if ( load_prefs!=NULL && strcasecmp(load_prefs,"Always")==0 ) LoadPrefs(); if ( default_encoding==NULL ) default_encoding=FindOrMakeEncoding("ISO8859-1"); if ( default_encoding==NULL ) default_encoding=&custom; /* In case iconv is broken */ CheckIsScript(argc,argv); /* Will run the script and exit if it is a script */ /* If there is no UI, there is always a script */ /* and we will never return from the above */ if ( load_prefs==NULL || (strcasecmp(load_prefs,"Always")!=0 && /* Already loaded */ strcasecmp(load_prefs,"Never")!=0 )) LoadPrefs(); GrokNavigationMask(); for ( i=1; i<argc; ++i ) { char *pt = argv[i]; if ( pt[0]=='-' && pt[1]=='-' ) ++pt; if ( strcmp(pt,"-sync")==0 ) GResourceAddResourceString("Gdraw.Synchronize: true",argv[0]); else if ( strcmp(pt,"-depth")==0 && i<argc-1 ) AddR(argv[0],"Gdraw.Depth", argv[++i]); else if ( strcmp(pt,"-vc")==0 && i<argc-1 ) AddR(argv[0],"Gdraw.VisualClass", argv[++i]); else if ( (strcmp(pt,"-cmap")==0 || strcmp(pt,"-colormap")==0) && i<argc-1 ) AddR(argv[0],"Gdraw.Colormap", argv[++i]); else if ( (strcmp(pt,"-dontopenxdevices")==0) ) AddR(argv[0],"Gdraw.DontOpenXDevices", "true"); else if ( strcmp(pt,"-keyboard")==0 && i<argc-1 ) AddR(argv[0],"Gdraw.Keyboard", argv[++i]); else if ( strcmp(pt,"-display")==0 && i<argc-1 ) display = argv[++i]; # if MyMemory else if ( strcmp(pt,"-memory")==0 ) __malloc_debug(5); # endif else if ( strncmp(pt,"-usecairo",strlen("-usecairo"))==0 ) { if ( strcmp(pt,"-usecairo=no")==0 ) GDrawEnableCairo(false); else GDrawEnableCairo(true); } else if ( strcmp(pt,"-nosplash")==0 ) splash = 0; else if ( strcmp(pt,"-unique")==0 ) unique = 1; else if ( strcmp(pt,"-recover")==0 && i<argc-1 ) { ++i; if ( strcmp(argv[i],"none")==0 ) recover=0; else if ( strcmp(argv[i],"clean")==0 ) recover= -1; else if ( strcmp(argv[i],"auto")==0 ) recover= 1; else if ( strcmp(argv[i],"inquire")==0 ) recover= 2; else { fprintf( stderr, "Invalid argument to -recover, must be none, auto, inquire or clean\n" ); dousage(); } } else if ( strcmp(pt,"-recover=none")==0 ) { recover = 0; } else if ( strcmp(pt,"-recover=clean")==0 ) { recover = -1; } else if ( strcmp(pt,"-recover=auto")==0 ) { recover = 1; } else if ( strcmp(pt,"-recover=inquire")==0 ) { recover = 2; } else if ( strcmp(pt,"-docs")==0 ) dohelp(); else if ( strcmp(pt,"-help")==0 ) dousage(); else if ( strcmp(pt,"-version")==0 ) doversion(source_version_str); else if ( strcmp(pt,"-quit")==0 ) quit_request = true; else if ( strcmp(pt,"-home")==0 ) /* already did a chdir earlier, don't need to do it again */; #if defined(__Mac) else if ( strncmp(pt,"-psn_",5)==0 ) { /* OK, I don't know what _-psn_ means, but to GW it means */ /* we've been started on the mac from the FontForge.app */ /* structure, and the current directory was (shudder) "/" */ /* (however, we changed to HOME earlier in main routine). */ unique = 1; listen_to_apple_events = true; } #endif } ensureDotFontForgeIsSetup(); GDrawCreateDisplays(display,argv[0]); default_background = GDrawGetDefaultBackground(screen_display); InitToolIconClut(default_background); InitToolIcons(); InitCursors(); #ifndef _NO_PYTHON PyFF_ProcessInitFiles(); #endif /* Wait until the UI has started, otherwise people who don't have consoles*/ /* open won't get our error messages, and it's an important one */ /* Scripting doesn't care about a mismatch, because scripting interpretation */ /* all lives in the library */ check_library_version(&exe_library_version_configuration,true,false); /* the splash screen used not to have a title bar (wam_nodecor) */ /* but I found I needed to know how much the window manager moved */ /* the window around, which I can determine if I have a positioned */ /* decorated window created at the begining */ /* Actually I don't care any more */ wattrs.mask = wam_events|wam_cursor|wam_bordwidth|wam_backcol|wam_positioned|wam_utf8_wtitle|wam_isdlg; wattrs.event_masks = ~(1<<et_charup); wattrs.positioned = 1; wattrs.cursor = ct_pointer; wattrs.utf8_window_title = "FontForge"; wattrs.border_width = 2; wattrs.background_color = 0xffffff; wattrs.is_dlg = !listen_to_apple_events; pos.x = pos.y = 200; pos.width = splashimage.u.image->width; pos.height = splashimage.u.image->height-56; /* 54 */ GDrawBindSelection(NULL,sn_user1,"FontForge"); if ( unique && GDrawSelectionOwned(NULL,sn_user1)) { /* Different event handler, not a dialog */ wattrs.is_dlg = false; splashw = GDrawCreateTopWindow(NULL,&pos,request_e_h,NULL,&wattrs); PingOtherFontForge(argc,argv); } else { if ( quit_request ) exit( 0 ); splashw = GDrawCreateTopWindow(NULL,&pos,splash_e_h,NULL,&wattrs); } memset(&rq,0,sizeof(rq)); rq.utf8_family_name = SERIF_UI_FAMILIES; rq.point_size = 12; rq.weight = 400; splash_font = GDrawInstanciateFont(NULL,&rq); splash_font = GResourceFindFont("Splash.Font",splash_font); GDrawDecomposeFont(splash_font, &rq); rq.style = fs_italic; splash_italic = GDrawInstanciateFont(NULL,&rq); splash_italic = GResourceFindFont("Splash.ItalicFont",splash_italic); GDrawSetFont(splashw,splash_font); GDrawWindowFontMetrics(splashw,splash_font,&as,&ds,&ld); fh = as+ds+ld; SplashLayout(); localsplash = splash; if ( localsplash && !listen_to_apple_events ) start_splash_screen(); if ( AutoSaveFrequency>0 ) autosave_timer=GDrawRequestTimer(splashw,2*AutoSaveFrequency*1000,AutoSaveFrequency*1000,NULL); GDrawProcessPendingEvents(NULL); GDrawSetBuildCharHooks(BuildCharHook,InsCharHook); any = 0; if ( recover==-1 ) CleanAutoRecovery(); else if ( recover ) any = DoAutoRecovery(recover-1); openflags = 0; for ( i=1; i<argc; ++i ) { char buffer[1025]; char *pt = argv[i]; GDrawProcessPendingEvents(NULL); if ( pt[0]=='-' && pt[1]=='-' ) ++pt; if ( strcmp(pt,"-new")==0 ) { FontNew(); any = 1; # if HANYANG } else if ( strcmp(pt,"-newkorean")==0 ) { MenuNewComposition(NULL,NULL,NULL); any = 1; # endif } else if ( strcmp(pt,"-last")==0 ) { if ( next_recent<RECENT_MAX && RecentFiles[next_recent]!=NULL ) if ( ViewPostScriptFont(RecentFiles[next_recent++],openflags)) any = 1; } else if ( strcmp(pt,"-sync")==0 || strcmp(pt,"-memory")==0 || strcmp(pt,"-nosplash")==0 || strcmp(pt,"-recover=none")==0 || strcmp(pt,"-recover=clean")==0 || strcmp(pt,"-recover=auto")==0 || strcmp(pt,"-dontopenxdevices")==0 || strcmp(pt,"-unique")==0 || strncmp(pt,"-usecairo",strlen("-usecairo"))==0 || strcmp(pt,"-home")==0 ) /* Already done, needed to be before display opened */; else if ( strncmp(pt,"-psn_",5)==0 ) /* Already done */; else if ( (strcmp(pt,"-depth")==0 || strcmp(pt,"-vc")==0 || strcmp(pt,"-cmap")==0 || strcmp(pt,"-colormap")==0 || strcmp(pt,"-keyboard")==0 || strcmp(pt,"-display")==0 || strcmp(pt,"-recover")==0 ) && i<argc-1 ) ++i; /* Already done, needed to be before display opened */ else if ( strcmp(pt,"-allglyphs")==0 ) openflags |= of_all_glyphs_in_ttc; else if ( strcmp(pt,"-open")==0 ) doopen = true; else { if ( strstr(argv[i],"://")!=NULL ) { /* Assume an absolute URL */ strncpy(buffer,argv[i],sizeof(buffer)); buffer[sizeof(buffer)-1]= '\0'; } else GFileGetAbsoluteName(argv[i],buffer,sizeof(buffer)); if ( GFileIsDir(buffer) || (strstr(buffer,"://")!=NULL && buffer[strlen(buffer)-1]=='/')) { char *fname; fname = galloc(strlen(buffer)+strlen("/glyphs/contents.plist")+1); strcpy(fname,buffer); strcat(fname,"/glyphs/contents.plist"); if ( GFileExists(fname)) { /* It's probably a Unified Font Object directory */ free(fname); if ( ViewPostScriptFont(buffer,openflags) ) any = 1; } else { strcpy(fname,buffer); strcat(fname,"/font.props"); if ( GFileExists(fname)) { /* It's probably a sf dir collection */ free(fname); if ( ViewPostScriptFont(buffer,openflags) ) any = 1; } else { free(fname); if ( buffer[strlen(buffer)-1]!='/' ) { /* If dirname doesn't end in "/" we'll be looking in parent dir */ buffer[strlen(buffer)+1]='\0'; buffer[strlen(buffer)] = '/'; } fname = GetPostScriptFontName(buffer,false); if ( fname!=NULL ) ViewPostScriptFont(fname,openflags); any = 1; /* Even if we didn't get a font, don't bring up dlg again */ free(fname); } } } else if ( ViewPostScriptFont(buffer,openflags)!=0 ) any = 1; } } if ( !any && !doopen ) any = ReopenLastFonts(); #if defined(__Mac) if ( listen_to_apple_events ) { install_apple_event_handlers(); install_mac_timer(); RunApplicationEventLoop(); } else #endif if ( doopen || !any ) MenuOpen(NULL,NULL,NULL); GDrawEventLoop(NULL); hotkeysSave(); uninm_names_db_close(names_db); lt_dlexit(); return( 0 ); }
int main(int argc, char *argv[]) { #ifdef HW_DOL ipl_set_config(6); // disable Qoob modchip #endif #ifdef WII_DVD DI_Init(); // first #endif int selectedMenu = -1; InitDeviceThread(); InitGCVideo (); ResetVideo_Menu (); // change to menu video mode // Controllers PAD_Init(); #ifdef HW_RVL WPAD_Init(); // read wiimote accelerometer and IR data WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL,640,480); // Wii Power/Reset buttons WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB); SYS_SetPowerCallback(ShutdownCB); SYS_SetResetCallback(ResetCB); #endif // Initialise FreeType if (FT_Init ()) { printf ("Cannot initialise font subsystem!\n"); while (1); } InitialiseAudio(); // Initialize libFAT for SD and USB MountAllFAT(); // Initialize DVD subsystem (GameCube only) #ifdef HW_DOL DVD_Init (); #endif // allocate memory to store rom nesrom = (unsigned char *)malloc(1024*1024*3); // 3 MB should be plenty /*** Minimal Emulation Loop ***/ if ( !FCEUI_Initialize() ) { WaitPrompt("Unable to initialize FCE Ultra\n"); ExitToLoader(); } FCEUI_SetGameGenie(0); // 0 - OFF, 1 - ON memset(FDSBIOS, 0, sizeof(FDSBIOS)); // clear FDS BIOS memory cleanSFMDATA(); // clear state data // Set defaults DefaultSettings(); // store path app was loaded from sprintf(appPath, "fceugx"); if(argc > 0 && argv[0] != NULL) CreateAppPath(argv[0]); // Load preferences if(!LoadPrefs()) { WaitPrompt("Preferences reset - check settings!"); selectedMenu = 1; // change to preferences menu } FCEUI_SetSoundQuality(1); // 0 - low, 1 - high, 2 - high (alt.) FCEUI_SetVidSystem(GCSettings.timing); // causes a small 'pop' in the audio while (1) // main loop { #ifdef HW_RVL if(ShutdownRequested) ShutdownWii(); #endif // go back to checking if devices were inserted/removed // since we're entering the menu LWP_ResumeThread (devicethread); MainMenu(selectedMenu); selectedMenu = 2; // return to game menu from now on // stop checking if devices were removed/inserted // since we're starting emulation again LWP_SuspendThread (devicethread); ResetVideo_Emu(); setFrameTimer(); // set frametimer method before emulation SetPalette(); static int fskipc=0; while(1) // emulation loop { uint8 *gfx; int32 *sound; int32 ssize; #ifdef FRAMESKIP fskipc=(fskipc+1)%(frameskip+1); #endif FCEUI_Emulate(&gfx, &sound, &ssize, fskipc); if(!fskipc) { xbsave = gfx; FCEUD_Update(gfx, sound, ssize); } if(ResetRequested) { PowerNES(); // reset game ResetRequested = 0; } if(ConfigRequested) { ResetVideo_Menu(); if (GCSettings.AutoSave == 1) { SaveRAM(GCSettings.SaveMethod, SILENT); } else if (GCSettings.AutoSave == 2) { SaveState(GCSettings.SaveMethod, SILENT); } else if(GCSettings.AutoSave == 3) { SaveRAM(GCSettings.SaveMethod, SILENT); SaveState(GCSettings.SaveMethod, SILENT); } // save zoom level SavePrefs(SILENT); ConfigRequested = 0; break; // leave emulation loop } } } }
int hexchat_plugin_init(hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { ph = plugin_handle; *plugin_name = "HexTray"; *plugin_desc = "Minimize HexChat to the Windows system tray"; *plugin_version = "1.3.0"; char buffer[256]; /***************************************************************************************************************************/ /************************* Initialize our preferences if they don't exist yet **********************************************/ /***************************************************************************************************************************/ if (hexchat_pluginpref_get_int (ph, "settings") == -1) { hexchat_pluginpref_set_int (ph, "settings", HT_DEF_SET); } if (hexchat_pluginpref_get_int (ph, "aot") == -1) { hexchat_pluginpref_set_int (ph, "aot", HT_DEF_AOT); } if (hexchat_pluginpref_get_int (ph, "key") == -1) { hexchat_pluginpref_set_int (ph, "key", HT_DEF_KEY); } if (hexchat_pluginpref_get_int (ph, "mod") == -1) { hexchat_pluginpref_set_int (ph, "mod", HT_DEF_MOD); } if (hexchat_pluginpref_get_str (ph, "away", buffer) == 0) { hexchat_pluginpref_set_str (ph, "away", ""); } /***************************************************************************************************************************/ /************************* Load our preferences ****************************************************************************/ /***************************************************************************************************************************/ LoadPrefs(); /***************************************************************************************************************************/ /************************* Finds the HexChat window and saves it for later use *********************************************/ /***************************************************************************************************************************/ g_hXchatWnd = (HWND)hexchat_get_info(ph, "win_ptr"); if(g_hXchatWnd == NULL) { EnumThreadWindows(GetCurrentThreadId(), EnumWindowsProc, 0); } g_hOldProc = (WNDPROC)GetWindowLongPtr(g_hXchatWnd, GWLP_WNDPROC); SetWindowLongPtr(g_hXchatWnd, GWLP_WNDPROC, (LONG_PTR)WindowProc); /***************************************************************************************************************************/ /************************* Grab the HexChat Icon, Load our menu, create the window to receive the hotkey messages *********/ /************************* and register the windows message so we know if explorer crashes ***********/ /***************************************************************************************************************************/ g_hTrayMenu = GetSubMenu(LoadMenu((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDR_TRAY_MENU)), 0); g_hHotkeyWnd = CreateDialog((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDD_ALERT), NULL, (DLGPROC)HotKeyProc); g_hPrefDlg = CreateDialog((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDD_PREF), g_hXchatWnd, (DLGPROC)PrefProc); g_hIcons[0] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_XCHAT), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIcons[2] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_HIGHLIGHT), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIcons[5] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_BANNED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIcons[6] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_KICKED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIcons[8] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_PMSG), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIcons[10]= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_SNOTICE), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIcons[11]= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_DISCONNECTED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIcons[22] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_CHANMSG), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); /***************************************************************************************************************************/ /************************* Add our icon to the tray ************************************************************************/ /***************************************************************************************************************************/ char szVersion[64]; _snprintf(szVersion, 64, "HexChat %s", hexchat_get_info(ph, "version")); AddIcon(g_hXchatWnd, 1, g_hIcons[0], szVersion, (NIF_ICON | NIF_MESSAGE | NIF_TIP), WM_TRAYMSG); /***************************************************************************************************************************/ /***************************************************************************************************************************/ /***************************************************************************************************************************/ if(g_dwPrefs & (1<<PREF_DNSIT)) { DWORD dwStyle; dwStyle = GetWindowLong(g_hXchatWnd, GWL_STYLE); dwStyle |= (1<<WS_CHILD); SetWindowLongPtr(g_hXchatWnd, GWL_STYLE, (LONG_PTR)dwStyle); SetWindowLongPtr(g_hXchatWnd, GWL_HWNDPARENT, (LONG_PTR)g_hHotkeyWnd); } /***************************************************************************************************************************/ /************************* Set our hooks and save them for later so we can unhook them *************************************/ /***************************************************************************************************************************/ g_vHooks.push_back(hexchat_hook_print(ph, "Channel Msg Hilight", HEXCHAT_PRI_NORM, event_cb, (void *)CHAN_HILIGHT)); g_vHooks.push_back(hexchat_hook_print(ph, "Channel Message", HEXCHAT_PRI_NORM, event_cb, (void *)CHAN_MESSAGE)); g_vHooks.push_back(hexchat_hook_print(ph, "Topic Change", HEXCHAT_PRI_NORM, event_cb, (void *)CHAN_TOPIC_CHANGE)); g_vHooks.push_back(hexchat_hook_print(ph, "Channel Action Hilight", HEXCHAT_PRI_NORM, event_cb, (void *)CHAN_HILIGHT)); g_vHooks.push_back(hexchat_hook_print(ph, "Channel INVITE", HEXCHAT_PRI_NORM, event_cb, (void *)CHAN_INVITE)); g_vHooks.push_back(hexchat_hook_print(ph, "You Kicked", HEXCHAT_PRI_NORM, event_cb, (void *)CHAN_KICKED)); g_vHooks.push_back(hexchat_hook_print(ph, "Banned", HEXCHAT_PRI_NORM, event_cb, (void *)CHAN_BANNED)); g_vHooks.push_back(hexchat_hook_print(ph, "CTCP Generic", HEXCHAT_PRI_NORM, event_cb, (void *)CTCP_GENERIC)); g_vHooks.push_back(hexchat_hook_print(ph, "Private Message", HEXCHAT_PRI_NORM, event_cb, (void *)PMSG_RECEIVE)); g_vHooks.push_back(hexchat_hook_print(ph, "Private Message to Dialog", HEXCHAT_PRI_NORM, event_cb, (void *)PMSG_RECEIVE)); g_vHooks.push_back(hexchat_hook_print(ph, "Disconnected", HEXCHAT_PRI_NORM, event_cb, (void *)SERV_DISCONNECT)); g_vHooks.push_back(hexchat_hook_print(ph, "Killed", HEXCHAT_PRI_NORM, event_cb, (void *)SERV_KILLED)); g_vHooks.push_back(hexchat_hook_print(ph, "Notice", HEXCHAT_PRI_NORM, event_cb, (void *)SERV_NOTICE)); g_vHooks.push_back(hexchat_hook_command(ph, "tray_alert", HEXCHAT_PRI_NORM, command_cb, "Create an Alert", NULL)); return 1; }
LONG HandleSignal( LONG Signal ) { BlankMsg *CurMsg; LONG RetVal = OK; if( Signal & SIG_TIMER ) { MessageServer( BM_FAILED ); RetVal = UNBLANK; } if( Signal & SIG_PORT ) { while( CurMsg = ( BlankMsg * )GetMsg( ClientPort )) { LONG Type = CurMsg->bm_Type; LONG Flags = CurMsg->bm_Flags; if( Type != BM_PING ) ServerBlanking = ( LONG * )CurMsg->bm_Mess.mn_Node.ln_Name; if( Flags & BF_REPLY ) FreeVec( CurMsg ); else { CurMsg->bm_Flags |= BF_REPLY; ReplyMsg(( struct Message * )CurMsg ); } switch( Type ) { case BM_DOBLANK: case BM_DOTESTBLANK: if( !Blanking ) { PrefObject *TmpPrefs; Blanking = TRUE; CurrentTime( &InitSecs, &InitMicros ); if( Type == BM_DOTESTBLANK ) TmpPrefs = LoadPrefs( "T:GBlankerTmpPrefs" ); switch( Blank( Type == BM_DOBLANK ? CurPrefs : TmpPrefs )) { case FAILED: /* In this case the Blank() function failed to init */ /* (ie. no memory or something). So we yell. */ MessageServer( BM_FAILED ); break; case DELAYEDQUIT: case QUIT: RetVal = QUIT; break; } Blanking = FALSE; if( Type == BM_DOTESTBLANK ) FreeVec( TmpPrefs ); } break; case BM_RELOADPREFS: if( CurPrefs ) FreeVec( CurPrefs ); CurPrefs = LoadPrefs( PrefsPath ); break; case BM_DELAYEDQUIT: RemPort( ClientPort ); PortRemoved = TRUE; RetVal = DELAYEDQUIT; break; case BM_DOQUIT: RetVal = QUIT; break; case BM_UNBLANK: break; } } } if( Signal & SIGBREAKF_CTRL_C ) RetVal = QUIT; return RetVal; }
SpectrogramSettings::Globals::Globals() { LoadPrefs(); }
SpectrogramSettings::SpectrogramSettings() { LoadPrefs(); }
int main( void ) { struct Process *Proc = ( struct Process * )FindTask( 0L ); BlankMsg *FreeMsg; LONG ReturnVal = 0; if( Proc->pr_CLI ) { STRPTR Str = BADDR((( struct CommandLineInterface * ) BADDR( Proc->pr_CLI ))->cli_CommandName ); CopyMem( Str + 1, PrefsPath, *Str ); PrefsPath[*Str] = '\0'; strcat( PrefsPath, ".prefs" ); } IntuitionBase = OpenLibrary( "intuition.library", 37L ); GfxBase = OpenLibrary( GRAPHICSNAME, 37L ); GarshnelibBase = OpenLibrary( "Garshnelib.library", 37L ); if( IntuitionBase && GfxBase && GarshnelibBase ) { ClientPort = CreateMsgPort(); TimerPort = CreateMsgPort(); if( ClientPort && TimerPort ) { TimeOutIO = ( struct timerequest * ) CreateExtIO( TimerPort, sizeof( struct timerequest )); if( TimeOutIO && !OpenDevice( "timer.device", UNIT_VBLANK, ( struct IORequest * )TimeOutIO, 0L )) { ClientPort->mp_Node.ln_Name = PortName; ClientPort->mp_Node.ln_Pri = 0L; AddPort( ClientPort ); CurPrefs = LoadPrefs( PrefsPath ); CurrentTime( &InitSecs, &InitMicros ); RangeSeed = InitSecs + InitMicros; Blank( CurPrefs ); while( FreeMsg = ( BlankMsg * )GetMsg( ClientPort )) { if( FreeMsg->bm_Type & BF_REPLY ) FreeVec( FreeMsg ); else { FreeMsg->bm_Type |= BF_REPLY; ReplyMsg(( struct Message * )FreeMsg ); } } if( CurPrefs ) FreeVec( CurPrefs ); if( !PortRemoved ) RemPort( ClientPort ); } if( TimeOutIO ) { if( TimeOutIO->tr_node.io_Device ) CloseDevice(( struct IORequest * )TimeOutIO ); DeleteExtIO(( struct IORequest * )TimeOutIO ); } } else { Complain( "ClientPort or TimerPort failed to open." ); ReturnVal = 2; } if( ClientPort ) { BlankMsg *TmpMsg; while( TmpMsg = ( BlankMsg * )GetMsg( ClientPort )) { TmpMsg->bm_Flags |= BF_REPLY; ReplyMsg(( struct Message * )TmpMsg ); } DeleteMsgPort( ClientPort ); } if( TimerPort ) DeleteMsgPort( TimerPort ); } else { Complain( "A library failed to open." ); ReturnVal = 1; } if( GarshnelibBase ) CloseLibrary( GarshnelibBase ); if( GfxBase ) CloseLibrary( GfxBase ); if( IntuitionBase ) CloseLibrary( IntuitionBase ); return ReturnVal; }
SpectrogramSettings::SpectrogramSettings() : hFFT(0) , window(0) { LoadPrefs(); }