• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /macosx-10.10/pyobjc-45/2.6/pyobjc/pyobjc-framework-Cocoa/Examples/AppKit/CocoaBindings/Bookmarks/
1#
2#  BookmarksDocument.py
3#  Bookmarks
4#
5#  Converted by u.fiedler on 10.02.05.
6#
7#  The original version was written in Objective-C by Malcolm Crawford
8#  at http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
9
10import objc
11from Cocoa import *
12
13# BookmarksDocument defines this as it may be used for copy and paste
14# in addition to just drag and drop
15CopiedRowsType = u"COPIED_ROWS_TYPE"
16
17class BookmarksDocument (NSDocument):
18    bookmarksArray = objc.ivar('bookmarksArray')
19
20    def init(self):
21        self = super(BookmarksDocument, self).init()
22        if self is None:
23            return None
24        self.bookmarksArray = NSMutableArray.array()
25        return self
26
27    def windowNibName(self):
28        return u"BookmarksDocument"
29
30    # Straightforward, standard document class
31    # Allows content array to be saved, and file opened
32    # Provides accessor methods for bookmarksArray
33
34    # open and save -- very simple, just (un)archive bookmarksArray
35    def dataRepresentationOfType_(self, aType):
36        return NSKeyedArchiver.archivedDataWithRootObject_(self.bookmarksArray)
37
38    def loadDataRepresentation_ofType_(self, data, aType):
39        self.bookmarksArray = NSKeyedUnarchiver.unarchiveObjectWithData_(data)
40        return True
41