AmendHub

Download:

jcs

/

wallops

/

amendments

/

9

chatter: Minor tweaks

Also fix about box and use WaitNextEvent since that's not the slow
point in MOTD processing

jcs made amendment 9 over 2 years ago
--- chatter.c Fri Feb 4 22:35:21 2022 +++ chatter.c Sun Feb 6 19:30:43 2022 @@ -89,6 +89,8 @@ chatter_init(const char *server, const unsigned short focusable->menu = chatter_menu; focusable->resume = chatter_resume; add_focusable(focusable); + + chatter->focusable = focusable; } void @@ -188,7 +190,11 @@ chatter_close(struct focusable *focusable, EventRecord { struct chatter *chatter = (struct chatter *)(focusable->cookie); - hide_focusable(focusable); + if (chatter->irc_state < IRC_STATE_CONNECTED) { + irc_abort(chatter); + close_focusable(focusable); + } else + hide_focusable(focusable); } void @@ -557,7 +563,7 @@ chatter_printf(struct chatter *chatter, const char *fo } void -chatter_sync_nick_list(struct chatter *chatter) +chatter_sync_nick_list(struct chatter *chatter, bool initial_sync) { Cell cell = { 0, 0 }; size_t n, i, j, ops, voices; @@ -611,12 +617,13 @@ chatter_sync_nick_list(struct chatter *chatter) cell.v++; } - chatter_printf(chatter, "$B%s$0: Total of $B%ld$0 nick%s $B(" - "%ld$0 op%s, $B%ld$0 voice%s$B)$0", chatter->irc_channel->name, - chatter->irc_channel->nusers, - chatter->irc_channel->nusers == 1 ? "" : "s", - ops, ops == 1 ? "" : "s", - voices, voices == 1 ? "" : "s"); + if (initial_sync) + chatter_printf(chatter, "$B%s$0: Total of $B%ld$0 nick%s $B(" + "%ld$0 op%s, $B%ld$0 voice%s$B)$0", + chatter->irc_channel->name, chatter->irc_channel->nusers, + chatter->irc_channel->nusers == 1 ? "" : "s", + ops, ops == 1 ? "" : "s", + voices, voices == 1 ? "" : "s"); } LDoDraw(true, chatter->nick_list); --- chatter.h Fri Feb 4 21:06:25 2022 +++ chatter.h Sun Feb 6 19:37:55 2022 @@ -28,8 +28,10 @@ #define CHATTER_FONT geneva #define CHATTER_FONT_SIZE 10 -#define MBAR_ID 128 +#define MBAR_ID 128 +#define NOTIFICATION_ICON_ID 128 + #define APPLE_MENU_ID 128 #define APPLE_MENU_ABOUT_ID 1 @@ -81,6 +83,7 @@ extern struct focusable **focusables; extern short nfocusables; struct chatter { + struct focusable *focusable; WindowPtr win; TEHandle messages_te; ControlHandle messages_scroller; @@ -122,6 +125,6 @@ void chatter_init(const char *server, const unsigned s const char *channel); void chatter_update_titlebar(struct chatter *chatter); size_t chatter_printf(struct chatter *chatter, const char *format, ...); -void chatter_sync_nick_list(struct chatter *chatter); +void chatter_sync_nick_list(struct chatter *chatter, bool initial_sync); #endif --- main.c Fri Feb 4 21:31:47 2022 +++ main.c Sun Feb 6 19:39:13 2022 @@ -98,8 +98,7 @@ main(void) show_connect_dialog(); for (;;) { - SystemTask(); - GetNextEvent(everyEvent, &event); + WaitNextEvent(everyEvent, &event, 5L, 0L); if (event.what != nullEvent) { event_in = FindWindow(event.where, &event_win); @@ -334,7 +333,7 @@ handle_menu(long menu_id) char short_vers[255] = { 0 }; short vlen; - if ((vers = (VersRecHndl)GetResource('vers', 1))) { + if ((vers = (VersRecHndl)GetResource('vers', 128))) { /* * vers "long version string" is a pascal string after the * short version pascal string @@ -428,6 +427,8 @@ show_focusable(struct focusable *focusable) focusable->visible = true; ShowWindow(focusable->win); SelectWindow(focusable->win); + + cancel_notification(); } void @@ -479,8 +480,7 @@ notify(void) notification.qType = nmType; notification.nmMark = 1; notification.nmSound = (Handle)-1; - notification.nmIcon = GetResource('SICN', 128); - //notification.nmResp = (NMProcPtr *)&notification_response; + notification.nmIcon = GetResource('SICN', NOTIFICATION_ICON_ID); NMInstall(&notification); }