Skip to content

Commit

Permalink
use NSApplicationActivationPolicyAccessory
Browse files Browse the repository at this point in the history
  • Loading branch information
samschott committed Mar 19, 2024
1 parent 2338874 commit 07d87c2
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions src/maestral_cocoa/private/implementation/cocoa/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

# external imports
import toga_cocoa.factory
import toga_cocoa.app

# monkey patch around toga backend behaviour that is hard to change by subclassing
toga_cocoa.app.NSApplicationActivationPolicyRegular = 1
toga_cocoa.factory.__path__ = ""

from travertino.size import at_least
Expand Down Expand Up @@ -34,7 +37,6 @@
NSViewMaxYMargin,
NSMenuItem,
NSMenu,
NSApplication,
NSObject,
NSImage,
NSImageInterpolationHigh,
Expand All @@ -47,20 +49,17 @@
NSOpenPanel,
NSModalResponseOK,
NSCompositingOperationCopy,
NSApplicationActivationPolicyRegular,
NSURL,
NSButton,
NSSwitchButton,
NSRadioButton,
NSBundle,
)
from toga_cocoa.colors import native_color
from toga_cocoa.keys import cocoa_key
from toga_cocoa.app import App as TogaApp
from toga_cocoa.widgets.base import Widget
from toga_cocoa.widgets.button import Button as TogaButton
from toga_cocoa.window import Window as TogaWindow
from toga_cocoa.factory import ImageView
from toga_cocoa.factory import * # noqa: F401,F406


Expand Down Expand Up @@ -647,23 +646,6 @@ def set_menu(self, menu_impl):

# ==== Application =====================================================================


class SystemTrayAppDelegate(NSObject):
interface = objc_property(object, weak=True)
impl = objc_property(object, weak=True)

@objc_method
def applicationWillTerminate_(self, sender: objc_id) -> None:
if self.interface.app.on_exit:
self.interface.app.on_exit(self.interface.app)

@objc_method
def selectMenuItem_(self, sender: objc_id) -> None:
cmd = self.impl._menu_items[sender]
if cmd.action:
cmd.action(None)


class SystemTrayApp(TogaApp):
_MAIN_WINDOW_CLASS = None

Expand Down

0 comments on commit 07d87c2

Please sign in to comment.