-
Notifications
You must be signed in to change notification settings - Fork 0
/
MacstodonSplash.py
188 lines (145 loc) · 5.37 KB
/
MacstodonSplash.py
1
"""Macstodon - a Mastodon client for classic Mac OSMIT LicenseCopyright (c) 2022-2024 Scott Small and ContributorsPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associateddocumentation files (the "Software"), to deal in the Software without restriction, including without limitation therights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permitpersons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of theSoftware.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THEWARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS ORCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OROTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.""""""A quick note from Scott:This file has been almost copied/pasted verbatim from the MacPython IDE,which is why it looks nothing like the other source files style-wise.Changes I made here include: - updated the resources to use the Macstodon logo and give the dialog a black BG - Bugfix to the TextFont calls which were failing and causing the progress bar to not render (the MacPython IDE is affected by this as well, lol) - Fixed the _real__import__ calls which were only passing the name and not the other params, causing crashes when trying to run this in the IDE - Changed the text color to white and changed the text itself - Removed the easter egg"""import Dlgfrom MacstodonConstants import VERSIONsplash = Dlg.GetNewDialog(468, -1)splash.DrawDialog()import Qd, TE, Fm, sys_real__import__ = Nonedef install_importhook(): global _real__import__ import __builtin__ if _real__import__ is None: _real__import__ = __builtin__.__import__ __builtin__.__import__ = my__import__def uninstall_importhook(): global _real__import__ if _real__import__ is not None: import __builtin__ __builtin__.__import__ = _real__import__ _real__import__ = None_progress = 0def importing(module): global _progress Qd.SetPort(splash) Qd.TextFont(Fm.GetFNum("Geneva")) Qd.TextSize(9) rect = (85, 270, 415, 286) Qd.RGBForeColor((65535,65535,65535)) if module: TE.TETextBox('Importing: ' + module, rect, 0) if not _progress: Qd.FrameRect((85, 286, 415, 294)) pos = min(86 + 330 * _progress / 77, 414) Qd.PaintRect((86, 287, pos, 293)) _progress = _progress + 1 else: Qd.EraseRect(rect) Qd.PaintRect((86, 287, pos, 293)) Qd.RGBForeColor((0,0,0))def my__import__(name, globals=None, locals=None, fromlist=None): try: return sys.modules[name] except KeyError: try: importing(name) except: try: rv = _real__import__(name, globals, locals, fromlist) finally: uninstall_importhook() return rv return _real__import__(name, globals, locals, fromlist)install_importhook()kHighLevelEvent = 23import Winfrom Fonts import *from QuickDraw import *from TextEdit import *import string_keepsplashscreenopen = 0abouttext1 = """Macstodon %sA basic Mastodon client for Classic Mac OSby Scott Small, @[email protected]: https://github.com/smallsco/macstodonApplication icon and logo design by MhzModelsAdditional icon design by CM Harrington, @[email protected] with MacPython %s%sWritten by Guido van Rossum with Jack Jansen (and others)"""def nl2return(text): return string.join(string.split(text, '\n'), '\r')def UpdateSplash(drawdialog = 0): if drawdialog: splash.DrawDialog() drawtext() Win.ValidRect(splash.GetWindowPort().portRect)def drawtext(): Qd.SetPort(splash) Qd.TextFont(Fm.GetFNum("Geneva")) Qd.TextSize(9) Qd.RGBForeColor((65535, 65535, 65535)) rect = (10, 135, 487, 270) import __main__ abouttxt = nl2return(abouttext1 % (VERSION, sys.version, sys.copyright)) TE.TETextBox(abouttxt, rect, teJustCenter) Qd.RGBForeColor((0,0,0))UpdateSplash(1)def wait(): import Evt from Events import * global splash try: splash except NameError: return Qd.InitCursor() time = Evt.TickCount() while _keepsplashscreenopen: ok, event = Evt.EventAvail(highLevelEventMask) if ok: # got apple event, back to mainloop break ok, event = Evt.EventAvail(mDownMask | keyDownMask | updateMask) if ok: ok, event = Evt.WaitNextEvent(mDownMask | keyDownMask | updateMask, 30) if ok: (what, message, when, where, modifiers) = event if what == updateEvt: if Win.WhichWindow(message) == splash: UpdateSplash(1) else: break del splashdef about(): global splash, splashresfile, _keepsplashscreenopen _keepsplashscreenopen = 1 splash = Dlg.GetNewDialog(468, -1) splash.DrawDialog() wait()