X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/d082ac49971a1c1a9e84c5b201c30aab675f154f..a86a2725f697fec44ea1527b8c11ff43798c9dfe:/mac/mac.c diff --git a/mac/mac.c b/mac/mac.c index add219b7..72b33011 100644 --- a/mac/mac.c +++ b/mac/mac.c @@ -1,4 +1,4 @@ -/* $Id: mac.c,v 1.1 2002/11/19 02:13:46 ben Exp $ */ +/* $Id: mac.c,v 1.4 2002/11/24 15:08:52 ben Exp $ */ /* * Copyright (c) 1999 Ben Harris * All rights reserved. @@ -41,7 +41,6 @@ #include #include #include -#include #include #include @@ -70,10 +69,12 @@ static void mac_growwindow(WindowPtr, EventRecord *); static void mac_activatewindow(WindowPtr, EventRecord *); static void mac_activateabout(WindowPtr, EventRecord *); static void mac_updatewindow(WindowPtr); +static void mac_updatelicence(WindowPtr); static void mac_keypress(EventRecord *); static int mac_windowtype(WindowPtr); static void mac_menucommand(long); static void mac_openabout(void); +static void mac_openlicence(void); static void mac_adjustcursor(RgnHandle); static void mac_adjustmenus(void); static void mac_closewindow(WindowPtr); @@ -115,13 +116,6 @@ static void mac_startup(void) { InitDialogs(nil); cold = 0; - /* Check for the Thread Manager. Bail out if it's not there. */ - if (Gestalt(gestaltThreadMgrAttr, &mac_gestalts.thdsattr) != noErr || - !(mac_gestalts.thdsattr & (1 << gestaltThreadMgrPresent)) || - &NewThread == kUnresolvedCFragSymbolAddress) - fatalbox("PuTTY requires the Thread Manager in order to operate. " - "The Thread Manager can be obtained from Apple Software " - "Updates."); /* Find out if we've got Color Quickdraw */ if (Gestalt(gestaltQuickdrawVersion, &mac_gestalts.qdvers) != noErr) mac_gestalts.qdvers = gestaltOriginalQD; @@ -173,7 +167,6 @@ static void mac_eventloop(void) { mac_adjustcursor(cursrgn); if (gotevent) mac_event(&event); - YieldToAnyThread(); } DisposeRgn(cursrgn); } @@ -249,7 +242,7 @@ static void mac_contentclick(WindowPtr window, EventRecord *event) { if (DialogSelect(event, &(DialogPtr)window, &item)) switch (item) { case wiAboutLicence: - /* XXX: Do something */ + mac_openlicence(); break; } break; @@ -304,9 +297,28 @@ static void mac_updatewindow(WindowPtr window) { EndUpdate(window); break; case wLicence: - /* Do something */ - break; + mac_updatelicence(window); + break; + } +} + +static void mac_updatelicence(WindowPtr window) +{ + Handle h; + int len; + + SetPort(window); + BeginUpdate(window); + TextFont(applFont); + TextSize(9); + h = Get1Resource('TEXT', wLicence); + len = GetResourceSizeOnDisk(h); + if (h != NULL) { + HLock(h); + TETextBox(*h, len, &window->portRect, teFlushDefault); + HUnlock(h); } + EndUpdate(window); } /* @@ -407,17 +419,33 @@ static void mac_openabout(void) { SelectWindow(windows.about); else { windows.about = GetNewDialog(wAbout, NULL, (WindowPtr)-1); - /* XXX check we're using the right resource file? */ - vers = (VersRecHndl)GetResource('vers', 1); - assert(vers != NULL && *vers != NULL); - longvers = (*vers)->shortVersion + (*vers)->shortVersion[0] + 1; - GetDialogItem(windows.about, wiAboutVersion, &itemtype, &item, &box); - assert(itemtype & kStaticTextDialogItem); - SetDialogItemText(item, longvers); + vers = (VersRecHndl)Get1Resource('vers', 1); + if (vers != NULL && *vers != NULL) { + longvers = (*vers)->shortVersion + (*vers)->shortVersion[0] + 1; + GetDialogItem(windows.about, wiAboutVersion, + &itemtype, &item, &box); + assert(itemtype & kStaticTextDialogItem); + SetDialogItemText(item, longvers); + } ShowWindow(windows.about); } } +static void mac_openlicence(void) { + DialogItemType itemtype; + Handle item; + VersRecHndl vers; + Rect box; + StringPtr longvers; + + if (windows.licence) + SelectWindow(windows.licence); + else { + windows.licence = GetNewWindow(wLicence, NULL, (WindowPtr)-1); + ShowWindow(windows.licence); + } +} + static void mac_closewindow(WindowPtr window) { switch (mac_windowtype(window)) { @@ -431,6 +459,10 @@ static void mac_closewindow(WindowPtr window) { windows.about = NULL; CloseWindow(window); break; + case wLicence: + windows.licence = NULL; + CloseWindow(window); + break; default: CloseWindow(window); break;