Skip to content

Commit

Permalink
newer versions of pyobjc try to map methods to delegate functions
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@14613 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Dec 26, 2016
1 parent eea2e6b commit d33a2d9
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/xpra/platform/darwin/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,16 @@ def handleEvent_withReplyEvent_(self, event, reply_event):
from AppKit import NSApplication, NSWorkspace, NSWorkspaceWillSleepNotification, NSWorkspaceDidWakeNotification #@UnresolvedImport
import objc #@UnresolvedImport

def delegate_cb(delegate, name):
#find the named callback and call it
callback = getattr(delegate, name, None)
log("delegate_cb(%s)=%s", name, callback)
if callback:
try:
callback()
except:
log.error("Error in %s callback %s", name, callback, exc_info=True)

class Delegate(NSObject):
def applicationDidFinishLaunching_(self, notification):
log("applicationDidFinishLaunching_(%s)", notification)
Expand All @@ -566,26 +576,16 @@ def register_sleep_handlers(self):
@objc.signature('B@:#B')
def applicationShouldHandleReopen_hasVisibleWindows_(self, ns_app, flag):
log("applicationShouldHandleReopen_hasVisibleWindows%s", (ns_app, flag))
self.cb("deiconify_callback")
delegate_cb(self, "deiconify_callback")
return True

def receiveSleepNotification_(self, aNotification):
log("receiveSleepNotification_(%s) sleep_callback=%s", aNotification, self.sleep_callback)
self.cb("sleep_callback")
delegate_cb(self, "sleep_callback")

def receiveWakeNotification_(self, aNotification):
log("receiveWakeNotification_(%s)", aNotification)
self.cb("wake_callback")

def cb(self, name):
#find the named callback and call it
callback = getattr(self, name, None)
log("cb(%s)=%s", name, callback)
if callback:
try:
callback()
except:
log.error("Error in %s callback %s", name, callback, exc_info=True)
delegate_cb(self, "wake_callback")


class ClientExtras(object):
Expand Down

0 comments on commit d33a2d9

Please sign in to comment.