Skip to content

Commit 88a7a84

Browse files
committed
consolidated the foundation/appkit/cg imports
- meaning the app no longer takes 10 seconds to launch on yosemite
1 parent 95ca9fb commit 88a7a84

18 files changed

Lines changed: 148 additions & 119 deletions

plotdevice/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# encoding: utf-8
22
import os, re, types
3-
from AppKit import *
43
from contextlib import contextmanager, nested
54
from collections import namedtuple
65

6+
from .lib.cocoa import *
77
from .util import _copy_attr, _copy_attrs, _flatten, trim_zeroes
88
from .lib import geometry, pathmatics
99
from .gfx.transform import Dimension

plotdevice/gfx/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# encoding: utf-8
22
from contextlib import contextmanager
3-
from AppKit import *
4-
from Foundation import *
5-
from Quartz import *
3+
from ..lib.cocoa import *
64

75
### graphics context mgmt ###
86

plotdevice/gfx/bezier.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# encoding: utf-8
22
import warnings
3-
from AppKit import *
4-
from Foundation import *
5-
from Quartz import *
3+
from ..lib.cocoa import *
64
from math import pi, sin, cos, sqrt
75

86
from plotdevice import DeviceError

plotdevice/gfx/colors.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
import re
44
import json
55
import warnings
6-
from AppKit import *
7-
from Foundation import *
8-
from Quartz import *
6+
from ..lib.cocoa import *
97

108
from plotdevice import DeviceError
119
from ..util import _copy_attr, _copy_attrs, _flatten, trim_zeroes, rsrc_path

plotdevice/gfx/effects.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
import os
33
import re
44
from contextlib import contextmanager
5-
from AppKit import *
6-
from Foundation import *
7-
from Quartz import *
5+
from ..lib.cocoa import *
86

97
from plotdevice import DeviceError
108
from ..util import _copy_attr, _copy_attrs

plotdevice/gfx/image.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
import warnings
66
import math
77
from contextlib import contextmanager
8-
from AppKit import *
9-
from Foundation import *
10-
from Quartz import *
11-
from Quartz.PDFKit import *
8+
from ..lib.cocoa import *
129

1310
from plotdevice import DeviceError
1411
from ..util import _copy_attrs

plotdevice/gfx/transform.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
import json
55
import warnings
66
import math
7-
from AppKit import *
8-
from Foundation import *
9-
from Quartz import *
7+
from ..lib.cocoa import *
108

119
from plotdevice import DeviceError
1210
from ..util import trim_zeroes

plotdevice/gfx/typography.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from xml.parsers import expat
44
from operator import itemgetter, attrgetter
55
from plotdevice.util import odict, ddict
6-
from AppKit import *
7-
from Foundation import *
6+
from ..lib.cocoa import *
87

98
from plotdevice import DeviceError, INTERNAL as DEFAULT
109
from .atoms import TransformMixin, ColorMixin, EffectsMixin, StyleMixin, BoundsMixin, Grob

plotdevice/gui/app.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import os
44
import objc
55
from glob import glob
6-
from Foundation import *
7-
from AppKit import *
6+
from ..lib.cocoa import *
87
from PyObjCTools import AppHelper
98
from .preferences import PlotDevicePreferencesController, get_default
109
from . import bundle_path, set_timeout
@@ -13,8 +12,8 @@
1312
"""
1413

1514
class PlotDeviceAppDelegate(NSObject):
16-
examplesMenu = objc.IBOutlet()
17-
updatesMenu = objc.IBOutlet()
15+
examplesMenu = IBOutlet()
16+
updatesMenu = IBOutlet()
1817

1918
def awakeFromNib(self):
2019
self._prefsController = None
@@ -77,14 +76,14 @@ def updateExamples(self):
7776
folders[cat].addItem_(item)
7877
self.examplesMenu.setHidden_(not pyfiles)
7978

80-
@objc.IBAction
79+
@IBAction
8180
def newSketch_(self, sender):
8281
kind = ['sketch','anim','ottobot'][sender.tag()]
8382
doc = self.docFromTemplate_('TMPL:'+kind)
8483
if kind=='ottobot':
8584
AppHelper.callLater(0.1, doc.script.runScript)
8685

87-
@objc.IBAction
86+
@IBAction
8887
def openExample_(self, sender):
8988
tmpl = sender.representedObject()
9089
self.docFromTemplate_(tmpl)
@@ -98,18 +97,18 @@ def docFromTemplate_(self, tmpl):
9897
doc.showWindows()
9998
return doc
10099

101-
@objc.IBAction
100+
@IBAction
102101
def showPreferencesPanel_(self, sender):
103102
if self._prefsController is None:
104103
self._prefsController = PlotDevicePreferencesController.alloc().init()
105104
self._prefsController.showWindow_(sender)
106105

107-
@objc.IBAction
106+
@IBAction
108107
def showHelp_(self, sender):
109108
url = NSURL.URLWithString_("http://plotdevice.io/doc")
110109
NSWorkspace.sharedWorkspace().openURL_(url)
111110

112-
@objc.IBAction
111+
@IBAction
113112
def showSite_(self, sender):
114113
url = NSURL.URLWithString_("http://plotdevice.io/")
115114
NSWorkspace.sharedWorkspace().openURL_(url)

plotdevice/gui/document.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
import time
88
import objc
99

10-
from Foundation import *
11-
from AppKit import *
10+
from ..lib.cocoa import *
1211

1312
from .editor import OutputTextView, EditorView
1413
from .widgets import DashboardController, ExportSheet
@@ -114,14 +113,14 @@ def _refresh(self):
114113
# `file's owner' in PlotDeviceDocument.xib
115114
class ScriptController(NSWindowController):
116115
# main document window
117-
graphicsView = objc.IBOutlet()
118-
outputView = objc.IBOutlet()
119-
editorView = objc.IBOutlet()
120-
statusView = objc.IBOutlet()
116+
graphicsView = IBOutlet()
117+
outputView = IBOutlet()
118+
editorView = IBOutlet()
119+
statusView = IBOutlet()
121120

122121
# auxiliary windows
123-
dashboardController = objc.IBOutlet()
124-
exportSheet = objc.IBOutlet()
122+
dashboardController = IBOutlet()
123+
exportSheet = IBOutlet()
125124

126125
## Properties
127126

@@ -301,14 +300,14 @@ def shouldCloseDocument(self):
301300
# Running the script in the main window
302301
#
303302

304-
@objc.IBAction
303+
@IBAction
305304
def runScript_(self, sender):
306305
# listens for cmd-r
307306
if self.vm.session:
308307
return NSBeep()
309308
self.runScript()
310309

311-
@objc.IBAction
310+
@IBAction
312311
def runFullscreen_(self, sender):
313312
# listens for cmd-shift-r
314313
if not self.fullScreen:
@@ -456,13 +455,13 @@ def _ui_state(self):
456455
#
457456
# Exporting to file(s)
458457
#
459-
@objc.IBAction
458+
@IBAction
460459
def exportAsImage_(self, sender):
461460
if self.vm.session:
462461
return NSBeep()
463462
self.exportSheet.beginExport('image')
464463

465-
@objc.IBAction
464+
@IBAction
466465
def exportAsMovie_(self, sender):
467466
if self.vm.session:
468467
return NSBeep()
@@ -514,7 +513,7 @@ def exportStatus(self, event):
514513
#
515514
# Interrupting the run
516515
#
517-
@objc.IBAction
516+
@IBAction
518517
def stopScript_(self, sender=None):
519518
# catch command-period
520519
if self.vm.session:
@@ -583,14 +582,14 @@ def crash(self):
583582
#
584583
# Pasteboards
585584
#
586-
@objc.IBAction
585+
@IBAction
587586
def copyImageAsPDF_(self, sender):
588587
pboard = NSPasteboard.generalPasteboard()
589588
# graphicsView implements the pboard delegate method to provide the data
590589
pboard.declareTypes_owner_([NSPDFPboardType,NSPostScriptPboardType,NSTIFFPboardType], self.graphicsView)
591590

592591

593-
@objc.IBAction
592+
@IBAction
594593
def printDocument_(self, sender):
595594
op = NSPrintOperation.printOperationWithView_printInfo_(self.graphicsView, self.printInfo())
596595
op.runOperationModalForWindow_delegate_didRunSelector_contextInfo_(
@@ -607,22 +606,22 @@ def printOperationDidRun_success_contextInfo_(self, op, success, info):
607606
#
608607
# Zoom commands, forwarding to the graphics view.
609608
#
610-
@objc.IBAction
609+
@IBAction
611610
def zoomIn_(self, sender):
612611
if self.fullScreen is not None: return
613612
self.graphicsView.zoomIn_(sender)
614613

615-
@objc.IBAction
614+
@IBAction
616615
def zoomOut_(self, sender):
617616
if self.fullScreen is not None: return
618617
self.graphicsView.zoomOut_(sender)
619618

620-
@objc.IBAction
619+
@IBAction
621620
def zoomToTag_(self, sender):
622621
if self.fullScreen is not None: return
623622
self.graphicsView.zoomTo_(sender.tag() / 100.0)
624623

625-
@objc.IBAction
624+
@IBAction
626625
def zoomToFit_(self, sender):
627626
if self.fullScreen is not None: return
628627
self.graphicsView.zoomToFit_(sender)

0 commit comments

Comments
 (0)