-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFMPasteBoxPrefController.py
More file actions
68 lines (45 loc) · 1.97 KB
/
Copy pathFMPasteBoxPrefController.py
File metadata and controls
68 lines (45 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#
# FMPasteBoxPreferenceController.py
#
# Created by Karsten Wolf on 07.02.18.
# Copyright 2018 Karsten Wolf. All rights reserved.
#
from __future__ import print_function
import objc
import Foundation
NSUserDefaults = Foundation.NSUserDefaults
import AppKit
# NSApplication = AppKit.NSApplication
NSWindowController = AppKit.NSWindowController
import FMPasteBoxTools
class FMPasteBoxPreferenceController (NSWindowController):
butSetFileMakerAppPath = objc.IBOutlet()
butSetExportsPath = objc.IBOutlet()
cbDoExports = objc.IBOutlet()
txtFileMakerAppPath = objc.IBOutlet()
txtExportsPath = objc.IBOutlet()
def init(self):
self = self.initWithWindowNibName_("Preferences")
wnd = self.window()
wnd.setTitle_( u"FMPasteBox Preferences" )
wnd.setDelegate_( self )
defaults = NSUserDefaults.standardUserDefaults()
self.txtFileMakerAppPath.setStringValue_( defaults.objectForKey_( u'txtFileMakerAppPath') )
self.txtExportsPath.setStringValue_( defaults.objectForKey_( u'txtExportsPath') )
self.cbDoExports.setState_( defaults.objectForKey_( u'cbDoExports') )
return self
def windowWillClose_(self, notification):
defaults = NSUserDefaults.standardUserDefaults()
defaults.setObject_forKey_(self.txtFileMakerAppPath.stringValue(), u'txtFileMakerAppPath')
defaults.setObject_forKey_(self.txtExportsPath.stringValue(), u'txtExportsPath')
defaults.setObject_forKey_(self.cbDoExports.state(), u'cbDoExports')
@objc.IBAction
def chooseFolder_(self, sender):
if sender == self.butSetFileMakerAppPath:
folders = FMPasteBoxTools.getApplicationDialog()
if folders:
self.txtFileMakerAppPath.setStringValue_( folders )
elif sender == self.butSetExportsPath:
folders = FMPasteBoxTools.getFolderDialog()
if folders:
self.txtExportsPath.setStringValue_( folders[0] )