def init(self, app, controller): self._app = app self._controller = controller self._controller.window = self self._when_done = None self._dropbox_app = controller.dropbox_app self._cancelled = None self.screen_frame = get_main_screen_rect() center = get_origin_of_centered_window(self.screen_frame, NSMakeSize(self.BASE_WIDTH, self.BASE_HEIGHT)) rect = NSMakeRect(center.x, center.y, self.BASE_WIDTH, self.BASE_HEIGHT) mask = NSClosableWindowMask | NSTitledWindowMask self.host = WizkitView.alloc().initWithFrame_controller_(rect, controller) self = super(WizkitWindow, self).initWithContentRect_styleMask_view_(rect, mask, self.host) self.setHasShadow_(objc.YES) self.setDelegate_(self) self.setBackgroundColor_(NSColor.clearColor()) self.setOpaque_(objc.NO) self.host.setDrawsBackground_(objc.NO) self.setMovableByWindowBackground_(objc.NO) self.setMovable_(objc.YES) self.window_frame = self.frame() self.setAcceptsMouseMovedEvents_(objc.YES) self._hasLoaded = False self._visible = False self._firstDrag = True self._firstDragOffset = None self._dragOnInputNode = False self.setLevel_(NSFloatingWindowLevel) NSApp().activateIgnoringOtherApps_(True) NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, self.frameHasLoaded_, WebViewProgressFinishedNotification, self.host) return self
def dealloc(self): try: NSNotificationCenter.defaultCenter().removeObserver_(self) except Exception: unhandled_exc_handler() super(TrayIconView, self).dealloc()
def callback_set(self, info): gx = self.w.x.get() gy = self.w.y.get() grid_type = self.w.grid_type.get() if grid_type == 0: grid_type = "units" else: grid_type = "div" try: gxi = int(gx) gyi = int(gy) gxf = float(gx) gyf = float(gy) except ValueError: print("Please enter a floating point number or an integer number.") return if gxf == gxi: gx = gxi else: gx = gxf if gyf == gyi: gy = gyi else: gy = gyf setGrid(self.master, gx, gy, grid_type) self.w.close() NSNotificationCenter.defaultCenter().postNotificationName_object_( "GSRedrawEditView", None)
def dealloc(self): try: NSNotificationCenter.defaultCenter().removeObserver_(self) except Exception: unhandled_exc_handler() super(SelectiveSyncBrowser, self).dealloc()
def dealloc(self): # make sure we remove ourselves as an observer of the text storage view = self.clientView() if view is not None: NSNotificationCenter.defaultCenter().removeObserver_name_object_( self, NSTextStorageDidProcessEditingNotification, view.textStorage()) super(LineNumberNSRulerView, self).dealloc()
def setup_complete(proto): if config.platform == 'darwin': from AppKit import NSNotificationCenter from apaf.utils.osx_support import TorFinishedLoadNotification NSNotificationCenter.defaultCenter().postNotificationName_object_( TorFinishedLoadNotification, None) for service in apaf.hiddenservices: log.msg('%s service running at %s' % (service, service.hs.hostname))
def setClientView_(self, view): oldClientView = self.clientView() if oldClientView != view and isinstance(oldClientView, NSTextView): NSNotificationCenter.defaultCenter().removeObserver_name_object_(self, NSTextStorageDidProcessEditingNotification, oldClientView.textStorage()) super(LineNumberNSRulerView, self).setClientView_(view) if view is not None and isinstance(view, NSTextView): NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, "textDidChange:", NSTextStorageDidProcessEditingNotification, view.textStorage())
def initWithTrayIcon_usingXUI_(self, tray_icon, using_xui): self = super(TrayIconView, self).init() if self is None: return try: defaults = NSUserDefaults.standardUserDefaults() if defaults.boolForKey_('NSGrayBackground'): defaults.setBool_forKey_(0, 'NSGrayBackground') assert not defaults.boolForKey_('NSGrayBackground'), "User has NSGrayBackground set in their defaults, and changing it didn't work" except Exception: unhandled_exc_handler() try: self.canDisplayBadgeCount = using_xui self.badgeCount = 0 self.shouldDrawAttentionRequest = False self.setupImages() self.setupLayers() self.tray_icon = tray_icon self.tray_icon_has_images = True self.menu_is_visible = False self.flashing_state = None self.flash_timer = None self.busy_timer = None self._menu = None self.updateIcon_(TrayController.CONNECTING) self.updateMenu_(()) try: self.status_item = NSStatusBar.systemStatusBar().statusItemWithLength_(self.desiredWidth()) except Exception: try: defaults = NSUserDefaults.standardUserDefaults() except Exception: unhandled_exc_handler() else: if defaults.boolForKey_('NSGrayBackground'): raise Exception("User has NSGrayBackground set in their defaults (and we couldn't fix it to not affect the NSStatusItem)") else: raise unhandled_exc_handler() else: self.status_item.setView_(self) NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, self.windowDidMove_, NSWindowDidMoveNotification, self.window()) except Exception: self.tray_icon_has_images = False unhandled_exc_handler() return self
def start(self): #Glyphs.addCallback(self.addUnderlineButton_, TABDIDOPEN) #Glyphs.addCallback(self.removeUnderlineButton_, TABWILLCLOSE) NSNotificationCenter.defaultCenter().addObserver_selector_name_object_( self, "addUnderlineButton:", TABDIDOPEN, objc.nil) NSNotificationCenter.defaultCenter().addObserver_selector_name_object_( self, "removeUnderlineButton:", TABWILLCLOSE, objc.nil) Glyphs.addCallback(self.drawUnderline, DRAWBACKGROUND) Glyphs.addCallback(self.drawUnderline, DRAWINACTIVE) # load icon from bundle iconPath = pathForResource("underLineTemplate", "pdf", __file__) self.toolBarIcon = NSImage.alloc().initWithContentsOfFile_(iconPath) self.toolBarIcon.setTemplate_(True)
def setClientView_(self, view): oldClientView = self.clientView() if oldClientView != view and isinstance(oldClientView, NSTextView): NSNotificationCenter.defaultCenter().removeObserver_name_object_( self, NSTextStorageDidProcessEditingNotification, oldClientView.textStorage()) super(LineNumberNSRulerView, self).setClientView_(view) if view is not None and isinstance(view, NSTextView): NSNotificationCenter.defaultCenter( ).addObserver_selector_name_object_( self, "textDidChange:", NSTextStorageDidProcessEditingNotification, view.textStorage())
def start(self): try: #Glyphs.addCallback(self.addUnderlineButton_, TABDIDOPEN) #Glyphs.addCallback(self.removeUnderlineButton_, TABWILLCLOSE) NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, "addUnderlineButton:", TABDIDOPEN, objc.nil) NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, "removeUnderlineButton:", TABWILLCLOSE, objc.nil) Glyphs.addCallback(self.drawUnderline, DRAWBACKGROUND) Glyphs.addCallback(self.drawUnderline, DRAWINACTIVE) # load icon from bundle iconPath = pathForResource("underLineTemplate", "pdf", __file__) self.toolBarIcon = NSImage.alloc().initWithContentsOfFile_(iconPath) self.toolBarIcon.setTemplate_(True) except: print (traceback.format_exc())
def awakeFromNib(self): NSLog("Awake from nib.") self.setPreviewMode(True) self.bodyField.setDelegate_(self) self.urlField.setDelegate_(self) self.titleField.setDelegate_(self) # Style the bodyField. self.bodyField.setFont_(NSFont.fontWithName_size_("Monaco", 13)) self.bodyField.setRichText_(NO) self.bodyField.setUsesFontPanel_(NO) # Authenticate to twitter if we can. if self.twitter.is_authenticated(): self.twitter.login() self.twitterCheckbox.setState_(NSOnState) self.ltp.syndicators.append(self.twitter) # Authenticate to G+ if we can. if self.gplus.is_authenticated(): self.gplus.login() self.gplusCheckbox.setState_(NSOnState) self.ltp.syndicators.append(self.gplus) # Listen to the NSApplicationWillTerminateNotification. center = NSNotificationCenter.defaultCenter() center.addObserver_selector_name_object_(self, "applicationWillTerminateNotification:", NSApplicationWillTerminateNotification, None) self.setupStatusBar() self.didPublish = False self.didPreview = False
def __init__(self, posSize, text, callback=None): # there must be a callback as it triggers the creation of the delegate if callback is None: callback = self._fallbackCallback super(FeatureTextEditor, self).__init__(posSize, "", callback=callback) self._nsObject.setHasHorizontalScroller_(True) font = NSFont.fontWithName_size_("Monaco", 10) self._textView.setFont_(font) self._textView.setUsesFindPanel_(True) ## line numbers #ruler = DefconAppKitLineNumberView.alloc().init() #ruler.setClientView_(self._textView) #self._nsObject.setVerticalRulerView_(ruler) #self._nsObject.setHasHorizontalRuler_(False) #self._nsObject.setHasVerticalRuler_(True) #self._nsObject.setRulersVisible_(True) #notificationCenter = NSNotificationCenter.defaultCenter() #notificationCenter.addObserver_selector_name_object_( # ruler, "clientViewSelectionChanged:", NSTextViewDidChangeSelectionNotification, self._textView #) # colors self._mainColor = NSColor.blackColor() self._commentColor = NSColor.colorWithCalibratedWhite_alpha_(.6, 1) self._keywordColor = NSColor.colorWithCalibratedRed_green_blue_alpha_( .8, 0, 0, 1) self._tokenColor = NSColor.colorWithCalibratedRed_green_blue_alpha_( .8, .4, 0, 1) self._classNameColor = NSColor.colorWithCalibratedRed_green_blue_alpha_( 0, 0, .8, 1) self._includeColor = NSColor.colorWithCalibratedRed_green_blue_alpha_( .8, 0, .8, 1) self._stringColor = NSColor.colorWithCalibratedRed_green_blue_alpha_( 0, .6, 0, 1) # build the placard placardW = 65 placardH = 16 self._placardJumps = [] self._placard = vanilla.Group((0, 0, placardW, placardH)) self._placard.featureJumpButton = PlacardPopUpButton( (0, 0, placardW, placardH), [], callback=self._placardFeatureSelectionCallback, sizeStyle="mini") self._nsObject.setPlacard_(self._placard.getNSView()) # registed for syntax coloring notifications self._programmaticallySettingText = False delegate = self._textViewDelegate delegate.vanillaWrapper = weakref.ref(self) notificationCenter = NSNotificationCenter.defaultCenter() notificationCenter.addObserver_selector_name_object_( self._textViewDelegate, "textStorageDidProcessEditing:", NSTextStorageDidProcessEditingNotification, self._textView.textStorage()) # set the text self.set(text)
def __init__(self): # setup a callback nsobject wrapper self.__callbackWrapper = VanillaCallbackWrapper(self._myAction) # get the default notification center N = NSNotificationCenter.defaultCenter() # add observer for `PyDEUserDefaultChanged` (when a font/color changed in the Preferences) N.addObserver_selector_name_object_(self.__callbackWrapper, "action:", "PyDEUserDefaultChanged", None)
def awakeFromNib(self): self.renderSubscriptions() center = NSNotificationCenter.defaultCenter() center.addObserver_selector_name_object_( self, 'applicationDidBecomeActive:', NSApplicationDidBecomeActiveNotification, None ) center.addObserver_selector_name_object_( self, 'applicationDidResignActive:', NSApplicationDidResignActiveNotification, None )
def start(self): for window in Glyphs.windows(): if window.className() == "GSMacroWindow": self.macroPanel = window if not self.macroPanel: LogError("Floating Macro Panel: could not find macro panel.") return self.macroPanel.setLevel_(NSFloatingWindowLevel) NSNotificationCenter.defaultCenter().addObserverForName_object_queue_usingBlock_( NSApplicationWillResignActiveNotification, None, NSOperationQueue.mainQueue(), lambda x: self.willResignActive(x), ) NSNotificationCenter.defaultCenter().addObserverForName_object_queue_usingBlock_( NSApplicationWillBecomeActiveNotification, None, NSOperationQueue.mainQueue(), lambda x: self.willBecomeActive(x), )
def setColorTheme(colorTheme): notification = "PyDEUserDefaultChanged" # set token colors setDefault("PyDETokenColors", colorTheme['tokens']) # set background color colorBackground = rgbToNSColor(hexToRGB(colorTheme['background'])) setDefaultColor("PyDEbackgroundColor", colorBackground) # set highlight color colorHighlight = rgbToNSColor(hexToRGB(colorTheme['highlight'])) setDefaultColor("PyDEHightLightColor", colorHighlight) # update code editor nc = NSNotificationCenter.defaultCenter() nc.postNotificationName_object_userInfo_(notification, None, None)
def __init__(self, posSize, text, callback=None): # there must be a callback as it triggers the creation of the delegate if callback is None: callback = self._fallbackCallback super(FeatureTextEditor, self).__init__(posSize, "", callback=callback) self._nsObject.setHasHorizontalScroller_(True) font = NSFont.fontWithName_size_("Monaco", 10) self._textView.setFont_(font) self._textView.setUsesFindPanel_(True) ## line numbers #ruler = DefconAppKitLineNumberView.alloc().init() #ruler.setClientView_(self._textView) #self._nsObject.setVerticalRulerView_(ruler) #self._nsObject.setHasHorizontalRuler_(False) #self._nsObject.setHasVerticalRuler_(True) #self._nsObject.setRulersVisible_(True) #notificationCenter = NSNotificationCenter.defaultCenter() #notificationCenter.addObserver_selector_name_object_( # ruler, "clientViewSelectionChanged:", NSTextViewDidChangeSelectionNotification, self._textView #) # colors self._mainColor = NSColor.blackColor() self._commentColor = NSColor.colorWithCalibratedWhite_alpha_(.6, 1) self._keywordColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(.8, 0, 0, 1) self._tokenColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(.8, .4, 0, 1) self._classNameColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(0, 0, .8, 1) self._includeColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(.8, 0, .8, 1) self._stringColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(0, .6, 0, 1) # build the placard placardW = 65 placardH = 16 self._placardJumps = [] self._placard = vanilla.Group((0, 0, placardW, placardH)) self._placard.featureJumpButton = PlacardPopUpButton((0, 0, placardW, placardH), [], callback=self._placardFeatureSelectionCallback, sizeStyle="mini") self._nsObject.setPlacard_(self._placard.getNSView()) # registed for syntax coloring notifications self._programmaticallySettingText = False delegate = self._textViewDelegate delegate.vanillaWrapper = weakref.ref(self) notificationCenter = NSNotificationCenter.defaultCenter() notificationCenter.addObserver_selector_name_object_( self._textViewDelegate, "textStorageDidProcessEditing", NSTextStorageDidProcessEditingNotification, self._textView.textStorage()) # set the text self.set(text)
def applicationDidFinishLaunching_(self, notification): statusbar = NSStatusBar.systemStatusBar() # Create the statusbar item self.statusitem = statusbar.statusItemWithLength_( NSVariableStatusItemLength) # set title self.statusitem.setTitle_("apaf") # Let it highlight upon clicking self.statusitem.setHighlightMode_(1) # Set tooltip self.statusitem.setToolTip_('Anonymous Python Application Framework') # set status image path = NSBundle.mainBundle().pathForResource_ofType_( "status_bar_icon", "png") image = NSImage.alloc().initWithContentsOfFile_(path) self.statusitem.setImage_(image) # Build menu self.menu = NSMenu.alloc().init() self.menu.setAutoenablesItems_(0) self.menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_( 'Loading...', 'openAdmin:', '') self.menu.addItem_(self.menuitem) self.menuitem.setEnabled_(0) print "is it %d" % self.menuitem.isEnabled() # Default event quit = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_( 'Quit', 'terminate:', '') self.menu.addItem_(quit) # Bind it to the status item self.statusitem.setMenu_(self.menu) # listen for completed notification sel = objc.selector(self.torHasLoaded, signature='v@:') ns = NSNotificationCenter.defaultCenter() ns.addObserver_selector_name_object_(self, sel, TorFinishedLoadNotification, None) self.runApaf()
def applicationDidFinishLaunching_(self, notification): statusbar = NSStatusBar.systemStatusBar() # Create the statusbar item self.statusitem = statusbar.statusItemWithLength_(NSVariableStatusItemLength) # set title self.statusitem.setTitle_("apaf") # Let it highlight upon clicking self.statusitem.setHighlightMode_(1) # Set tooltip self.statusitem.setToolTip_('Anonymous Python Application Framework') # set status image path = NSBundle.mainBundle().pathForResource_ofType_("status_bar_icon", "png") image = NSImage.alloc().initWithContentsOfFile_(path) self.statusitem.setImage_(image) # Build menu self.menu = NSMenu.alloc().init() self.menu.setAutoenablesItems_(0) self.menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Loading...', 'openAdmin:', '') self.menu.addItem_(self.menuitem) self.menuitem.setEnabled_(0) print "is it %d" % self.menuitem.isEnabled() # Default event quit = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Quit', 'terminate:', '') self.menu.addItem_(quit) # Bind it to the status item self.statusitem.setMenu_(self.menu) # listen for completed notification sel = objc.selector(self.torHasLoaded, signature='v@:') ns = NSNotificationCenter.defaultCenter() ns.addObserver_selector_name_object_(self, sel, TorFinishedLoadNotification, None) self.runApaf()
def dealloc(self): notificationCenter = NSNotificationCenter.defaultCenter() notificationCenter.removeObserver_(self) super(DefconAppKitLineNumberView, self).dealloc()
from AppKit import NSApp, NSApplication, NSNotificationCenter, NSApplicationDidFinishLaunchingNotification from Foundation import NSAutoreleasePool, NSObject pool = NSAutoreleasePool.alloc().init() class MyApplicationActivator(NSObject): def activateNow_(self, aNotification): NSApp().activateIgnoringOtherApps_(True) try: app_main() except: sys.excepthook(*sys.exc_info()) os._exit(0) activator = MyApplicationActivator.alloc().init() NSNotificationCenter.defaultCenter().addObserver_selector_name_object_( activator, 'activateNow:', NSApplicationDidFinishLaunchingNotification, None, ) NSApplication.sharedApplication() NSApp().run() del pool else: app_main()
def close(self): app.terminate_(None) cb = Callback.alloc().init() accessory = NSView.alloc().initWithFrame_(NSMakeRect(0,0,200,34)) for i, name in enumerate(['Cancel', 'Copy']): button = NSButton.alloc().init() button.setBezelStyle_(NSRoundedBezelStyle) button.setTitle_(name) button.sizeToFit() x = (i + 0.5) / 2 * 200 - button.frame().size.width / 2 frame = NSMakeRect(x, (34 - button.frame().size.height)/2, button.frame().size.width, button.frame().size.height) button.setFrame_(frame) button.setAutoresizingMask_(NSViewMaxXMargin | NSViewMinXMargin | NSViewMaxYMargin | NSViewMinYMargin) button.setTarget_(cb) button.setAction_({"Cancel": "close", "Copy": "copy"}[name]) accessory.addSubview_(button) NSApp.activateIgnoringOtherApps_(True) panel = NSColorPanel.sharedColorPanel() panel.setShowsAlpha_(True) panel.setAccessoryView_(accessory) panel.makeKeyAndOrderFront_(None) NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(cb, "close", NSWindowDidResignKeyNotification, panel) from PyObjCTools import AppHelper AppHelper.runEventLoop() cb.copy()
def stopMouseMoved(self): NSNotificationCenter.defaultCenter().removeObserver_(self)
def dealloc(self): # make sure we remove ourselves as an observer of the text storage view = self.clientView() if view is not None: NSNotificationCenter.defaultCenter().removeObserver_name_object_(self, NSTextStorageDidProcessEditingNotification, view.textStorage()) super(LineNumberNSRulerView, self).dealloc()
accessory = NSView.alloc().initWithFrame_(NSMakeRect(0, 0, 200, 34)) for i, name in enumerate(['Cancel', 'Copy']): button = NSButton.alloc().init() button.setBezelStyle_(NSRoundedBezelStyle) button.setTitle_(name) button.sizeToFit() x = (i + 0.5) / 2 * 200 - button.frame().size.width / 2 frame = NSMakeRect(x, (34 - button.frame().size.height) / 2, button.frame().size.width, button.frame().size.height) button.setFrame_(frame) button.setAutoresizingMask_(NSViewMaxXMargin | NSViewMinXMargin | NSViewMaxYMargin | NSViewMinYMargin) button.setTarget_(cb) button.setAction_({"Cancel": "close", "Copy": "copy"}[name]) accessory.addSubview_(button) NSApp.activateIgnoringOtherApps_(True) panel = NSColorPanel.sharedColorPanel() panel.setShowsAlpha_(True) panel.setAccessoryView_(accessory) panel.makeKeyAndOrderFront_(None) NSNotificationCenter.defaultCenter().addObserver_selector_name_object_( cb, "close", NSWindowDidResignKeyNotification, panel) from PyObjCTools import AppHelper AppHelper.runEventLoop() cb.copy()
def preferencesChanged(self, sender=None): nc = NSNotificationCenter.defaultCenter() nc.postNotificationName_object_userInfo_("drawBotUserDefaultChanged", None, None)
def start(app_main = None): global sdl if sys.platform == "darwin": init_SDL_dll("/Library/Frameworks/SDL.framework/SDL", "/Library/Frameworks/SDL.framework/Headers") init_SDLImage_dll("/Library/Frameworks/SDL_image.framework/SDL_image", "/Library/Frameworks/SDL_image.framework/Headers") using_cocoapy = False try: from AppKit import NSApp, NSApplication, NSNotificationCenter, NSApplicationDidFinishLaunchingNotification from Foundation import NSAutoreleasePool, NSObject except ImportError: using_cocoapy = True if not using_cocoapy: pool = NSAutoreleasePool.alloc().init() class MyApplicationActivator(NSObject): def activateNow_(self, aNotification): try: app_main() except: sys.excepthook(*sys.exc_info()) os._exit(0) activator = MyApplicationActivator.alloc().init() NSNotificationCenter.defaultCenter().addObserver_selector_name_object_( activator, 'activateNow:', NSApplicationDidFinishLaunchingNotification, None, ) NSApplication.sharedApplication() NSApp().activateIgnoringOtherApps_(True) NSApp().finishLaunching() NSApp().updateWindows() if app_main is not None: NSApp().run() del pool else: # use CocoaPy if sys.version_info.major == 2: import cocoapy as cp else: from . import cocoapy cp = cocoapy init_SDL_dll("/Library/Frameworks/SDL.framework/SDL", "/Library/Frameworks/SDL.framework/Headers") init_SDLImage_dll("/Library/Frameworks/SDL_image.framework/SDL_image", "/Library/Frameworks/SDL_image.framework/Headers") print('Done loading SDL') pool = cp.send_message('NSAutoreleasePool', 'alloc') pool = cp.send_message(pool, 'init') class MyApplicationActivator_Impl(object): MyApplicationActivator = cp.ObjCSubclass('NSObject', 'MyApplicationActivator') @MyApplicationActivator.method('@') def init(self): self = cp.ObjCInstance(cp.send_super(self, 'init')) return self @MyApplicationActivator.method('v@') def activateNow(self, aNotification): try: app_main() except: sys.excepthook(*sys.exc_info()) os._exit(0) MyApplicationActivator = cp.ObjCClass('MyApplicationActivator') activator = MyApplicationActivator.alloc().init() center = cp.send_message('NSNotificationCenter', 'defaultCenter') cp.send_message(center, 'addObserver:selector:name:object:', activator, cp.get_selector("activateNow"), cp.get_NSString("NSApplicationDidFinishLaunchingNotification"), None) app = cp.send_message('NSApplication', 'sharedApplication') cp.send_message('NSApp', 'finishLaunching') cp.send_message('NSApp', 'updateWindows') cp.send_message('NSApp', 'activateIgnoringOtherApps', True) if app_main is not None: cp.send_message(app, 'run') else: init_SDL_dll(*get_lib_binheader("SDL")) init_SDLImage_dll(*get_lib_binheader("SDL_image","SDL")) if app_main is not None: app_main()
def viewWillMoveToWindow_(self, window): if not window: return notification_center = NSNotificationCenter.defaultCenter() notification_center.addObserver_selector_name_object_(self, 'windowChangedKeyNotification:', NSWindowDidBecomeKeyNotification, window) notification_center.addObserver_selector_name_object_(self, 'windowChangedKeyNotification:', NSWindowDidResignKeyNotification, window)
sdl = cdll.LoadLibrary("/Library/Frameworks/SDL.framework/SDL") from AppKit import NSApp, NSApplication, NSNotificationCenter, NSApplicationDidFinishLaunchingNotification from Foundation import NSAutoreleasePool, NSObject pool = NSAutoreleasePool.alloc().init() class MyApplicationActivator(NSObject): def activateNow_(self, aNotification): NSApp().activateIgnoringOtherApps_(True) try: app_main() except: sys.excepthook(*sys.exc_info()) os._exit(0) activator = MyApplicationActivator.alloc().init() NSNotificationCenter.defaultCenter().addObserver_selector_name_object_( activator, 'activateNow:', NSApplicationDidFinishLaunchingNotification, None, ) NSApplication.sharedApplication() NSApp().run() del pool else: app_main()
def setup_complete(proto): NSNotificationCenter.defaultCenter().postNotificationName_object_( darwin.TorFinishedLoadNotification, None) darwin.embeed_browser() base.setup_complete(proto)
def _breakCycles(self): notificationCenter = NSNotificationCenter.defaultCenter() notificationCenter.removeObserver_(self._textViewDelegate)
def startMouseMoved(self): NSNotificationCenter.defaultCenter().addObserver_selector_name_object_( self, self.mouseDidMove_, MOUSEMOVED, objc.nil)
] for targetLayer in targetLayers: deleteCornerComponentsOnLayer(targetLayer) for h in [h for h in thisLayer.hints if h.type == CORNER]: # query corner component attributes: pathIndex = indexOfPath(thisLayer, h.originNode.parent) nodeIndex = indexOfNode(thisLayer, pathIndex, h.originNode) # create eqivalent corner component in target layer: newCorner = h.copy() targetLayer.hints.append(newCorner) thisFont = Glyphs.font # frontmost font thisFontMaster = thisFont.selectedFontMaster # active master listOfSelectedLayers = thisFont.selectedLayers # active layers of selected glyphs if thisFont and listOfSelectedLayers: thisFont.disableUpdateInterface() # suppresses UI updates in Font View for thisLayer in listOfSelectedLayers: thisGlyph = thisLayer.parent print("Processing", thisGlyph.name) thisGlyph.beginUndo() # begin undo grouping process(thisLayer) thisGlyph.endUndo() # end undo grouping thisFont.enableUpdateInterface() # re-enables UI updates in Font View NSNotificationCenter.defaultCenter().postNotificationName_object_( "GSUpdateInterface", thisFont)