Stub the parts of PyObjC I'm using (whee)

This commit is contained in:
Danielle McLean 2023-11-27 16:52:17 +11:00
parent 5a3ddd570d
commit 73972cd17e
Signed by: 00dani
GPG key ID: 52C059C3B22A753E
3 changed files with 106 additions and 0 deletions

33
stubs/AppKit/__init__.pyi Normal file
View file

@ -0,0 +1,33 @@
from typing import Final, Literal
from Foundation import CGSize
# There are many other operations available but we only actually use copy, so we don't need all of them here.
NSCompositingOperationClear: Final = 0
NSCompositingOperationCopy: Final = 1
NSCompositingOperation = Literal[0, 1]
class NSRect:
pass
def NSMakeRect(x: float, y: float, w: float, h: float) -> NSRect: ...
class NSImage:
@staticmethod
def alloc() -> type[NSImage]: ...
@staticmethod
def initByReferencingFile_(file: str) -> NSImage: ...
@staticmethod
def initWithData_(data: bytes) -> NSImage: ...
@staticmethod
def initWithSize_(size: CGSize) -> NSImage: ...
def size(self) -> CGSize: ...
def lockFocus(self) -> None: ...
def unlockFocus(self) -> None: ...
def drawInRect_fromRect_operation_fraction_(self, inRect: NSRect, fromRect: NSRect, operation: NSCompositingOperation, fraction: float) -> None: ...

View file

@ -0,0 +1,9 @@
from typing import Type
class CGSize:
width: float
height: float
class NSMutableDictionary(dict[str, object]):
@classmethod
def dictionary(cls: Type[NSMutableDictionary]) -> NSMutableDictionary: ...

View file

@ -0,0 +1,64 @@
from collections.abc import Callable
from typing import Final, Literal
from AppKit import NSImage
from Foundation import CGSize, NSMutableDictionary
MPMusicPlaybackStateStopped: Final = 0
MPMusicPlaybackStatePlaying: Final = 1
MPMusicPlaybackStatePaused: Final = 2
MPMusicPlaybackState = Literal[0, 1, 2]
MPMediaItemPropertyAlbumTitle: Final = 'albumTitle'
MPMediaItemPropertyArtist: Final = 'artist'
MPMediaItemPropertyArtwork: Final = 'artwork'
MPMediaItemPropertyPlaybackDuration: Final = 'playbackDuration'
MPMediaItemPropertyTitle: Final = 'title'
MPNowPlayingInfoPropertyMediaType: Final = 'MPNowPlayingInfoPropertyMediaType'
MPNowPlayingInfoMediaTypeAudio: Final = 1
MPNowPlayingInfoMediaTypeNone: Final = 0
MPNowPlayingInfoPropertyElapsedPlaybackTime: Final = 'MPNowPlayingInfoPropertyElapsedPlaybackTime'
class MPMediaItemArtwork:
@staticmethod
def alloc() -> type[MPMediaItemArtwork]: ...
@staticmethod
def initWithBoundsSize_requestHandler_(size: CGSize, handler: Callable[[CGSize], NSImage]) -> MPMediaItemArtwork: ...
class MPNowPlayingInfoCenter:
@staticmethod
def defaultCenter() -> MPNowPlayingInfoCenter: ...
def setNowPlayingInfo_(self, info: NSMutableDictionary) -> None: ...
def setPlaybackState_(self, state: MPMusicPlaybackState) -> None: ...
MPRemoteCommandHandlerStatusSuccess: Literal[0] = 0
MPRemoteCommandHandlerStatusCommandFailed: Literal[200] = 200
MPRemoteCommandHandlerStatus = Literal[0, 200]
class MPRemoteCommandEvent:
pass
class MPRemoteCommand:
def setEnabled_(self, enabled: bool) -> None: ...
def removeTarget_(self, target: object) -> None: ...
def addTargetWithHandler_(self, handler: Callable[[MPRemoteCommandEvent], MPRemoteCommandHandlerStatus]) -> None: ...
class MPRemoteCommandCenter:
@staticmethod
def sharedCommandCenter() -> MPRemoteCommandCenter: ...
def togglePlayPauseCommand(self) -> MPRemoteCommand: ...
def playCommand(self) -> MPRemoteCommand: ...
def pauseCommand(self) -> MPRemoteCommand: ...
def stopCommand(self) -> MPRemoteCommand: ...
def nextTrackCommand(self) -> MPRemoteCommand: ...
def previousTrackCommand(self) -> MPRemoteCommand: ...
def changePlaybackRateCommand(self) -> MPRemoteCommand: ...
def seekBackwardCommand(self) -> MPRemoteCommand: ...
def skipBackwardCommand(self) -> MPRemoteCommand: ...
def seekForwardCommand(self) -> MPRemoteCommand: ...
def skipForwardCommand(self) -> MPRemoteCommand: ...
def changePlaybackPositionCommand(self) -> MPRemoteCommand: ...