X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/347bfcd74251d80fbc84ce9446cf87cd74a8ed8b..1d009ae71b849a95c86c3117d1b8f063fda8aae5:/mac/macdlg.c diff --git a/mac/macdlg.c b/mac/macdlg.c index 4f18bdd3..93a2a3fa 100644 --- a/mac/macdlg.c +++ b/mac/macdlg.c @@ -1,4 +1,4 @@ -/* $Id: macdlg.c,v 1.11 2003/02/04 23:39:26 ben Exp $ */ +/* $Id: macdlg.c,v 1.16 2003/03/25 23:18:59 ben Exp $ */ /* * Copyright (c) 2002 Ben Harris * All rights reserved. @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -42,27 +41,62 @@ #include #include "putty.h" +#include "dialog.h" #include "mac.h" #include "macresid.h" #include "storage.h" +static void mac_closedlg(WindowPtr); + void mac_newsession(void) { Session *s; + WinInfo *wi; + static struct sesslist sesslist; - /* This should obviously be initialised by other means */ s = smalloc(sizeof(*s)); memset(s, 0, sizeof(*s)); do_defaults(NULL, &s->cfg); s->hasfile = FALSE; - s->settings_window = - GetDialogWindow(GetNewDialog(wSettings, NULL, (WindowPtr)-1)); - - SetWRefCon(s->settings_window, (long)s); + if (HAVE_COLOR_QD()) + s->settings_window = GetNewCWindow(wSettings, NULL, (WindowPtr)-1); + else + s->settings_window = GetNewWindow(wSettings, NULL, (WindowPtr)-1); + + get_sesslist(&sesslist, TRUE); + s->ctrlbox = ctrl_new_box(); + setup_config_box(s->ctrlbox, &sesslist, FALSE, 0); + + s->settings_ctrls.data = &s->cfg; + macctrl_layoutbox(s->ctrlbox, s->settings_window, &s->settings_ctrls); + + wi = smalloc(sizeof(*wi)); + memset(wi, 0, sizeof(*wi)); + wi->s = s; + wi->mcs = &s->settings_ctrls; + wi->wtype = wSettings; + wi->update = &macctrl_update; + wi->click = &macctrl_click; + wi->key = &macctrl_key; + wi->activate = &macctrl_activate; + wi->adjustmenus = &macctrl_adjustmenus; + wi->close = &mac_closedlg; + SetWRefCon(s->settings_window, (long)wi); ShowWindow(s->settings_window); } +static void mac_closedlg(WindowPtr window) +{ + Session *s = mac_windowsession(window); + + macctrl_close(window); + DisposeWindow(window); + if (s->window == NULL) + sfree(s); +} + + void mac_dupsession(void) { Session *s1 = mac_windowsession(FrontWindow()); @@ -266,36 +300,6 @@ pascal OSErr mac_aevt_pdoc(const AppleEvent *req, AppleEvent *reply, return errAEEventNotHandled; } -void mac_activatedlg(WindowPtr window, EventRecord *event) -{ - DialogItemType itemtype; - Handle itemhandle; - short item; - Rect itemrect; - int active; - DialogRef dialog = GetDialogFromWindow(window); - - active = (event->modifiers & activeFlag) != 0; - GetDialogItem(dialog, wiSettingsOpen, &itemtype, &itemhandle, &itemrect); - HiliteControl((ControlHandle)itemhandle, active ? 0 : 255); - DialogSelect(event, &dialog, &item); -} - -void mac_clickdlg(WindowPtr window, EventRecord *event) -{ - short item; - Session *s = mac_windowsession(window); - DialogRef dialog = GetDialogFromWindow(window); - - if (DialogSelect(event, &dialog, &item)) - switch (item) { - case wiSettingsOpen: - HideWindow(window); - mac_startsession(s); - break; - } -} - /* * Local Variables: * c-file-style: "simon"