Split preferences into NSViewControllers

This commit is contained in:
Jerry Jacobs
2016-10-02 14:16:50 +02:00
parent 000174057e
commit e1b0265249
12 changed files with 323 additions and 330 deletions
+29 -3
View File
@@ -16,6 +16,8 @@
C4576BE61D11E79F0031BCFD /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4576BE51D11E79F0031BCFD /* Foundation.framework */; };
C4576BEA1D11E7E10031BCFD /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4576BE91D11E7E10031BCFD /* CoreFoundation.framework */; };
C4576BEB1D11E9280031BCFD /* XGSyncthing.m in Sources */ = {isa = PBXBuildFile; fileRef = C4FFB0641D0D7E4C0015D14A /* XGSyncthing.m */; };
C46500121DA1177F00C250BC /* GeneralViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C46500111DA1177F00C250BC /* GeneralViewController.xib */; };
C46500151DA1180800C250BC /* STPreferencesWindowGeneralViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C46500141DA1180800C250BC /* STPreferencesWindowGeneralViewController.m */; };
C47F6C3A1D0DE68D00F36CF6 /* syncthing.icns in Resources */ = {isa = PBXBuildFile; fileRef = C47F6C391D0DE68D00F36CF6 /* syncthing.icns */; };
C4946B011D5877F2008447A2 /* STAboutWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = C4946B001D5877F2008447A2 /* STAboutWindow.xib */; };
C4946B031D587878008447A2 /* STAboutWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = C4946B021D587878008447A2 /* STAboutWindowController.m */; };
@@ -65,6 +67,9 @@
C4576BE51D11E79F0031BCFD /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
C4576BE71D11E7C00031BCFD /* libobjc.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libobjc.tbd; path = usr/lib/libobjc.tbd; sourceTree = SDKROOT; };
C4576BE91D11E7E10031BCFD /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
C46500111DA1177F00C250BC /* GeneralViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = GeneralViewController.xib; path = UI/STPreferencesWindow/GeneralViewController.xib; sourceTree = "<group>"; };
C46500131DA1180800C250BC /* STPreferencesWindowGeneralViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STPreferencesWindowGeneralViewController.h; path = UI/STPreferencesWindow/STPreferencesWindowGeneralViewController.h; sourceTree = "<group>"; };
C46500141DA1180800C250BC /* STPreferencesWindowGeneralViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = STPreferencesWindowGeneralViewController.m; path = UI/STPreferencesWindow/STPreferencesWindowGeneralViewController.m; sourceTree = "<group>"; };
C47F6C391D0DE68D00F36CF6 /* syncthing.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = syncthing.icns; sourceTree = "<group>"; };
C4946B001D5877F2008447A2 /* STAboutWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = STAboutWindow.xib; path = UI/STAboutWindow.xib; sourceTree = "<group>"; };
C4946B021D587878008447A2 /* STAboutWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = STAboutWindowController.m; path = Controllers/STAboutWindowController.m; sourceTree = "<group>"; };
@@ -140,6 +145,26 @@
name = Frameworks;
sourceTree = "<group>";
};
C465000A1DA114FE00C250BC /* STPreferencesWindow */ = {
isa = PBXGroup;
children = (
C4460A7C1D0DD2D500200C21 /* STPreferencesWindowController.h */,
C4460A7D1D0DD2D500200C21 /* STPreferencesWindowController.m */,
C46500131DA1180800C250BC /* STPreferencesWindowGeneralViewController.h */,
C46500141DA1180800C250BC /* STPreferencesWindowGeneralViewController.m */,
);
name = STPreferencesWindow;
sourceTree = "<group>";
};
C46500101DA116D400C250BC /* STPreferencesWindow */ = {
isa = PBXGroup;
children = (
C46500111DA1177F00C250BC /* GeneralViewController.xib */,
C4460A821D0DD38F00200C21 /* STPreferencesWindow.xib */,
);
name = STPreferencesWindow;
sourceTree = "<group>";
};
C4A415571D0D579D00DC6018 = {
isa = PBXGroup;
children = (
@@ -192,8 +217,7 @@
C4D6DD5F1D0DAF530024D20A /* Controllers */ = {
isa = PBXGroup;
children = (
C4460A7C1D0DD2D500200C21 /* STPreferencesWindowController.h */,
C4460A7D1D0DD2D500200C21 /* STPreferencesWindowController.m */,
C465000A1DA114FE00C250BC /* STPreferencesWindow */,
C4460A7E1D0DD2D500200C21 /* STStatusBarController.h */,
C4460A7F1D0DD2D500200C21 /* STStatusBarController.m */,
C4946B021D587878008447A2 /* STAboutWindowController.m */,
@@ -205,7 +229,7 @@
C4D6DD601D0DB18A0024D20A /* UI */ = {
isa = PBXGroup;
children = (
C4460A821D0DD38F00200C21 /* STPreferencesWindow.xib */,
C46500101DA116D400C250BC /* STPreferencesWindow */,
C4A4156B1D0D579D00DC6018 /* STApplication.xib */,
C4946B001D5877F2008447A2 /* STAboutWindow.xib */,
);
@@ -317,6 +341,7 @@
C4A4156D1D0D579D00DC6018 /* STApplication.xib in Resources */,
C4460A831D0DD38F00200C21 /* STPreferencesWindow.xib in Resources */,
C4946B011D5877F2008447A2 /* STAboutWindow.xib in Resources */,
C46500121DA1177F00C250BC /* GeneralViewController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -356,6 +381,7 @@
C4D567A21D3A8DFE002AD881 /* STLoginItem.m in Sources */,
C4FFB0661D0D7F870015D14A /* XGSyncthing.m in Sources */,
C4A415681D0D579D00DC6018 /* main.m in Sources */,
C46500151DA1180800C250BC /* STPreferencesWindowGeneralViewController.m in Sources */,
C4946B031D587878008447A2 /* STAboutWindowController.m in Sources */,
C4460A811D0DD2D500200C21 /* STStatusBarController.m in Sources */,
C4460A801D0DD2D500200C21 /* STPreferencesWindowController.m in Sources */,
Binary file not shown.
@@ -1,92 +0,0 @@
%PDF-1.5
%µí®û
3 0 obj
<< /Length 4 0 R
/Filter /FlateDecode
>>
stream
xœ¥”»®1 †{?…_àø8÷qKƒ„D±PP
Ø3B,Òž-x}ì\F›hvvü%öo'ñÌ®à6¼ >"qpèId´»ŽAÖkZ¢£<ÝF̆ ö_ç¸Úö;À‚ö™ëþGΧ¦û4M‹¿ÀóWÆ—>ßö„·N òz}x‹}˜Ä‰�¿�ñ�Þ?àódbüßãÝÐ=4]¢,‚[«F×ÚÑyÊyk£Ôè0*&
ì&z˜1�†^”È—ãÍ”þ¨3A£‘ÒL™ý±Î�xnky}Ácþ¶>¦µvÚJÒ8O)ª:S’ˆ?ñÍ?ʸ¨u$ÌzÄò?2�|ö¦Æe–ÓÃMÇQñAWl-p™˜ÉK±m(e±»[$$©ŒXèpÔ-]œA[RË,9+wJ”´4íÃâ»{ÕAB>ÄÑlÀ{1Ë¶ŠŸÁe
![U’�­o0k9b;“äºg�¨lÚ.3®ãªÚVù�G3GÊ¡X�>÷³4ôÄÚ궉[¡;Ö‰‰JŠ#
:<÷Çç»ö°=e=õöaÑ7<o¶-Ö t§:Èr;ß>Ý‚Cg|=¦èù®ƒôíÓØ¡ÐŽù)´¡×ïæ×§ûȘî�6}‚?Ä©ûX
endstream
endobj
4 0 obj
465
endobj
2 0 obj
<<
/ExtGState <<
/a0 << /CA 1 /ca 1 >>
>>
/Shading << /sh5 5 0 R >>
>>
endobj
6 0 obj
<< /Type /Page
/Parent 1 0 R
/MediaBox [ 0 0 18 18 ]
/Contents 3 0 R
/Group <<
/Type /Group
/S /Transparency
/I true
/CS /DeviceRGB
>>
/Resources 2 0 R
>>
endobj
7 0 obj
<< /FunctionType 2
/Domain [ 0 1 ]
/C0 [ 0.14902 0.713725 0.858824 ]
/C1 [ 0.0313725 0.509804 0.784314 ]
/N 1
>>
endobj
5 0 obj
<< /ShadingType 2
/ColorSpace /DeviceRGB
/Coords [ 8 0 8 16 ]
/Domain [ 0 1 ]
/Extend [ false false ]
/Function 7 0 R
>>
endobj
1 0 obj
<< /Type /Pages
/Kids [ 6 0 R ]
/Count 1
>>
endobj
8 0 obj
<< /Creator (cairo 1.14.6 (http://cairographics.org))
/Producer (cairo 1.14.6 (http://cairographics.org))
>>
endobj
9 0 obj
<< /Type /Catalog
/Pages 1 0 R
>>
endobj
xref
0 10
0000000000 65535 f
0000001225 00000 n
0000000579 00000 n
0000000015 00000 n
0000000557 00000 n
0000001032 00000 n
0000000680 00000 n
0000000892 00000 n
0000001290 00000 n
0000001417 00000 n
trailer
<< /Size 10
/Root 9 0 R
/Info 8 0 R
>>
startxref
1469
%%EOF
Binary file not shown.
@@ -1,90 +0,0 @@
%PDF-1.5
%µí®û
3 0 obj
<< /Length 4 0 R
/Filter /FlateDecode
>>
stream
xœ¥TË®Ô0 Ýû+üøæ�xË ‰Å… ÄõŽÐ Ò0 ~;�ª)wêtzNjŸ$nîp[�ñ†òd¼E뉣A½ë4rMÄ2jfØÈ)¬ÿuŽ ÖßN4é2k}ÆŸ`ɺØtßL¨ù7xúfðå�O�KÄÇžAäåúøû0Ä–Ù;ü␍ßËý¾|EC¿CÀxG;twM)1cind®�ZG)•öPÛAÅHÞØI�˜9�␍½:X$—GŽSÈýQg�ÆFiˆ2e.gŸŸðL›Ë¯Ü—áµùòA¼SÉQòÅ ê†"¼âÛ”±A|DL²Åü?2ž\rªfò´ÓÓUÇRv^f¬-p›4‘ã¬Ë�ó‚{XŒ‰c)°°=P–t-°�´¤ØÌLÞY¤(Ö¤³[p�ªƒ19FFÀG1­¶Šo`yŸÔ'«ó܈Ö•‰|"=²Nê)i—™×éªÚfyª#•%ŸÕ K}/•:2ÒVØ®¤ÖI#åF,l�¼œkl‡öÐ55²ëí`‘/<]mˆ…ô :˜Ö¶®Á®3N�)º:Èû"&|$ÝÙßX¾¯Ö’äó¤WÝñÃÆU>ÝÃëâ™:ÕZp7ÑpE¯««m$šŸ–
6ö
G 4xՓ–®JS3º¿;ᱚGÜ«wÒÖr±³É1ûîØ.J
endstream
endobj
4 0 obj
533
endobj
2 0 obj
<<
/ExtGState <<
/a0 << /CA 1 /ca 1 >>
>>
/Shading << /sh5 5 0 R >>
>>
endobj
6 0 obj
<< /Type /Page
/Parent 1 0 R
/MediaBox [ 0 0 18 18 ]
/Contents 3 0 R
/Group <<
/Type /Group
/S /Transparency
/I true
/CS /DeviceRGB
>>
/Resources 2 0 R
>>
endobj
7 0 obj
<< /FunctionType 2
/Domain [ 0 1 ]
/C0 [ 0.14902 0.713725 0.858824 ]
/C1 [ 0.0313725 0.509804 0.784314 ]
/N 1
>>
endobj
5 0 obj
<< /ShadingType 2
/ColorSpace /DeviceRGB
/Coords [ 8 0 8 16 ]
/Domain [ 0 1 ]
/Extend [ false false ]
/Function 7 0 R
>>
endobj
1 0 obj
<< /Type /Pages
/Kids [ 6 0 R ]
/Count 1
>>
endobj
8 0 obj
<< /Creator (cairo 1.14.6 (http://cairographics.org))
/Producer (cairo 1.14.6 (http://cairographics.org))
>>
endobj
9 0 obj
<< /Type /Catalog
/Pages 1 0 R
>>
endobj
xref
0 10
0000000000 65535 f
0000001293 00000 n
0000000647 00000 n
0000000015 00000 n
0000000625 00000 n
0000001100 00000 n
0000000748 00000 n
0000000960 00000 n
0000001358 00000 n
0000001485 00000 n
trailer
<< /Size 10
/Root 9 0 R
/Info 8 0 R
>>
startxref
1537
%%EOF
@@ -10,9 +10,4 @@
@interface STPreferencesWindowController : NSWindowController
@property (weak) IBOutlet NSTextField *Syncthing_URI;
@property (weak) IBOutlet NSTextField *Syncthing_ApiKey;
@property (weak) IBOutlet NSButton *StartAtLogin;
@property (weak) IBOutlet NSButton *Test;
@end
@@ -7,8 +7,6 @@
//
#import "STPreferencesWindowController.h"
#import "STLoginItem.h"
#import "XGSyncthing.h"
@interface STPreferencesWindowController ()
@@ -21,53 +19,65 @@
}
- (void)windowDidLoad {
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
[self.Syncthing_URI setStringValue:[defaults objectForKey:@"URI"]];
[self.Syncthing_ApiKey setStringValue:[defaults objectForKey:@"ApiKey"]];
[self.StartAtLogin setStringValue:[defaults objectForKey:@"StartAtLogin"]];
[self updateTestButton];
}
- (void)updateTestButton {
XGSyncthing *st = [[XGSyncthing alloc] init];
[st setURI:[self.Syncthing_URI stringValue]];
[st setApiKey:[self.Syncthing_ApiKey stringValue]];
if ([st ping]) {
[self.Test setImage:[NSImage imageNamed:NSImageNameStatusAvailable]];
} else {
[self.Test setImage:[NSImage imageNamed:NSImageNameStatusUnavailable]];
- (IBAction)toolbarButtonClicked:(id)sender {
NSToolbarItem *item = sender;
[self loadViewWithIdentifier:item.itemIdentifier withAnimation:YES];
}
-(void)loadViewWithIdentifier:(NSString *)viewTabIdentifier
withAnimation:(BOOL)shouldAnimate{
/*
if ([_currentView isEqualToString:viewTabIdentifier]){
return;
}
}
- (void)updateStartAtLogin:(NSUserDefaults *)defaults {
STLoginItem *li = [STLoginItem alloc];
if ([defaults integerForKey:@"StartAtLogin"]) {
if (![li wasAppAddedAsLoginItem])
[li addAppAsLoginItem];
} else {
[li deleteAppFromLoginItem];
}
}
- (IBAction)clickedDone:(id)sender {
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
else
{
_currentView = viewTabIdentifier;
}
*/
//Loop through the view array and find out the class to load
[defaults setObject:[self.Syncthing_URI stringValue] forKey:@"URI"];
[defaults setObject:[self.Syncthing_ApiKey stringValue] forKey:@"ApiKey"];
[defaults setObject:[self.StartAtLogin stringValue] forKey:@"StartAtLogin"];
[self updateStartAtLogin:defaults];
[self close];
}
- (IBAction)clickedTest:(id)sender {
[self updateTestButton];
/*
NSDictionary *viewInfoDict = nil;
for (NSDictionary *dict in _toolbarTabsArray){
if ([dict[@"identifier"] isEqualToString:viewTabIdentifier]){
viewInfoDict = dict;
break;
}
}
*/
//NSString *class = @"STPreferencesWindowGeneralViewController";//viewInfoDict[@"class"];
//if(NSClassFromString(class))
//{
/*
_currentViewController = [[STPreferencesWindowGeneralViewController alloc] init];
//Old View
//NSView * oldView = self.window.contentView;
//self.window.contentView
//New View
NSView *newView = _currentViewController.view;
NSRect windowRect = self.window.frame;
NSRect currentViewRect = newView.frame;
windowRect.origin.y = windowRect.origin.y + (windowRect.size.height - currentViewRect.size.height);
windowRect.size.height = currentViewRect.size.height;
windowRect.size.width = currentViewRect.size.width;
[self.window setContentView:newView];
[self.window setFrame:windowRect display:YES animate:shouldAnimate];
*/
//} else{
// NSAssert(false, @"Couldn't load %@", class);
//}
}
@end
+12 -10
View File
@@ -16,7 +16,7 @@
self.syncthing = [[XGSyncthing alloc] init];
[self applicationLoadConfiguration];
[self.syncthing runExecutable];
//[self.syncthing runExecutable];
self.updateTimer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(updateStatusFromTimer) userInfo:nil repeats:YES];
}
@@ -41,7 +41,7 @@
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *cfgExecutable = [defaults stringForKey:@"Executable"];
NSString *cfgExecutable = [defaults stringForKey:@"Executable"];
if (cfgExecutable) {
[self.syncthing setExecutable:cfgExecutable];
} else {
@@ -50,7 +50,7 @@
@"syncthing/syncthing"]];
}
NSString *cfgURI = [defaults stringForKey:@"URI"];
NSString *cfgURI = [defaults stringForKey:@"URI"];
if (cfgURI) {
[self.syncthing setURI:cfgURI];
} else {
@@ -58,7 +58,7 @@
[defaults setObject:[self.syncthing URI] forKey:@"URI"];
}
NSString *cfgApiKey = [defaults stringForKey:@"ApiKey"];
NSString *cfgApiKey = [defaults stringForKey:@"ApiKey"];
if (cfgApiKey) {
[self.syncthing setApiKey:cfgApiKey];
} else {
@@ -85,14 +85,10 @@
{
if ([self.syncthing ping]) {
[self updateStatusIcon:@"StatusIconDefault"];
[self.statusItem setToolTip:[
NSString stringWithFormat:@"Syncthing - Connected\n%@\nUptime %@",
[self.syncthing URI],
[self.syncthing getUptime]
]];
[self.statusItem setToolTip:@"Connected"];
} else {
[self updateStatusIcon:@"StatusIconNotify"];
[self.statusItem setToolTip:@"Syncthing - Not connected"];
[self.statusItem setToolTip:@"Not connected"];
}
}
@@ -139,6 +135,9 @@
- (IBAction)clickedPreferences:(NSMenuItem *)sender
{
if (self.preferencesWindow)
return;
self.preferencesWindow = [[STPreferencesWindowController alloc] init];
[self.preferencesWindow.window setLevel:NSFloatingWindowLevel];
[NSApp activateIgnoringOtherApps:YES];
@@ -151,6 +150,9 @@
- (IBAction)clickedAbout:(NSMenuItem *)sender
{
if (self.aboutWindow)
return;
self.aboutWindow = [[STAboutWindowController alloc] init];
[self.aboutWindow.window setLevel:NSFloatingWindowLevel];
[NSApp activateIgnoringOtherApps:YES];
+39 -85
View File
@@ -6,123 +6,77 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="STPreferencesWindowController">
<connections>
<outlet property="StartAtLogin" destination="Ung-sw-8yD" id="Ax2-1f-Ncn"/>
<outlet property="Syncthing_ApiKey" destination="T7A-VT-LGq" id="qWa-9x-iyO"/>
<outlet property="Syncthing_URI" destination="vMa-96-PMd" id="NC0-RJ-zb2"/>
<outlet property="Test" destination="Val-jA-8s2" id="NHd-rR-dF8"/>
<outlet property="window" destination="QvC-M9-y7g" id="9An-Ik-DrX"/>
<outlet property="view" destination="EiT-Mj-1SZ" id="mM2-ma-6KB"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Syncthing Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" showsToolbarButton="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<rect key="contentRect" x="0.0" y="0.0" width="432" height="158"/>
<rect key="contentRect" x="0.0" y="0.0" width="432" height="155"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
<view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="432" height="158"/>
<rect key="frame" x="0.0" y="0.0" width="432" height="155"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Nnt-yo-HRx">
<rect key="frame" x="18" y="79" width="49" height="17"/>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YtK-yO-H48">
<rect key="frame" x="0.0" y="0.0" width="432" height="155"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="API key" id="2pX-Wy-VqM">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jhd-zf-uBz">
<rect key="frame" x="18" y="110" width="26" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="URI" id="0Sk-cU-j4d">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="T7A-VT-LGq">
<rect key="frame" x="76" y="74" width="336" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="aNVUG3mSx4PVyZW8LXWGoybFRSXS9c5a" drawsBackground="YES" id="b3K-46-fSH">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vMa-96-PMd">
<rect key="frame" x="76" y="107" width="336" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="http://localhost:8384" drawsBackground="YES" id="V09-vb-gvu">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ung-sw-8yD">
<rect key="frame" x="18" y="22" width="101" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Start at login" bezelStyle="regularSquare" imagePosition="left" inset="2" id="0J0-Mb-jQT">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="cXd-7N-s05">
<rect key="frame" x="20" y="53" width="392" height="5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</box>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DhK-77-ufW">
<rect key="frame" x="346" y="13" width="72" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Done" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="OL3-mH-nnB">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
DQ
</string>
</buttonCell>
<connections>
<action selector="clickedDone:" target="-2" id="5aH-eE-afw"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Val-jA-8s2">
<rect key="frame" x="262" y="13" width="84" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Test" bezelStyle="rounded" image="NSStatusNone" imagePosition="left" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="iDl-jj-w1K">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="clickedTest:" target="-2" id="J9G-To-Nfi"/>
</connections>
</button>
</customView>
</subviews>
</view>
<toolbar key="toolbar" implicitIdentifier="53B9A345-0CFD-45BD-82F7-670D595DF554" autosavesConfiguration="NO" allowsUserCustomization="NO" displayMode="iconAndLabel" sizeMode="regular" id="jKq-By-NJu">
<allowedToolbarItems>
<toolbarItem implicitItemIdentifier="NSToolbarFlexibleSpaceItem" id="MXy-ID-pFQ"/>
<toolbarItem implicitItemIdentifier="A7852587-2076-47F5-84BF-CFB0595487AF" label="General" paletteLabel="General" tag="-1" image="NSPreferencesGeneral" id="1ij-UG-c1I"/>
<toolbarItem implicitItemIdentifier="D874225D-8E52-4A4B-A937-DEA979F1229B" label="Advanced" paletteLabel="Advanced" tag="-1" image="NSAdvanced" id="S5T-mV-7Wv"/>
<toolbarItem implicitItemIdentifier="724E41E5-958D-40E7-AF30-71771B2155F7" label="Info" paletteLabel="Info" tag="-1" image="NSInfo" id="86s-00-8YI"/>
<toolbarItem implicitItemIdentifier="ECEBC334-B37D-4529-A32F-DE546CF4A60E" label="Folders" paletteLabel="Folders" tag="-1" image="NSFolder" id="X60-Ql-i8O"/>
<toolbarItem implicitItemIdentifier="A7852587-2076-47F5-84BF-CFB0595487AF" label="General" paletteLabel="General" tag="-1" image="NSPreferencesGeneral" id="1ij-UG-c1I">
<connections>
<action selector="toolbarButtonClicked:" target="-2" id="cWV-tS-JnL"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="D874225D-8E52-4A4B-A937-DEA979F1229B" label="Advanced" paletteLabel="Advanced" tag="-1" image="NSAdvanced" id="S5T-mV-7Wv">
<connections>
<action selector="toolbarButtonClicked:" target="-2" id="b7K-cg-PrG"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="724E41E5-958D-40E7-AF30-71771B2155F7" label="Info" paletteLabel="Info" tag="-1" image="NSInfo" id="86s-00-8YI">
<connections>
<action selector="toolbarButtonClicked:" target="-2" id="Vse-Kj-679"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="ECEBC334-B37D-4529-A32F-DE546CF4A60E" label="Folders" paletteLabel="Folders" tag="-1" image="NSFolder" id="X60-Ql-i8O">
<connections>
<action selector="toolbarButtonClicked:" target="-2" id="Xxk-aA-9kh"/>
</connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="1C41BB2C-5379-46AE-ACF0-E549531D4E05" label="Devices" paletteLabel="Devices" tag="-1" image="NSComputer" id="poY-nn-e76">
<connections>
<action selector="toolbarButtonClicked:" target="-2" id="SSL-PS-TzM"/>
</connections>
</toolbarItem>
</allowedToolbarItems>
<defaultToolbarItems>
<toolbarItem reference="1ij-UG-c1I"/>
<toolbarItem reference="X60-Ql-i8O"/>
<toolbarItem reference="poY-nn-e76"/>
<toolbarItem reference="MXy-ID-pFQ"/>
<toolbarItem reference="86s-00-8YI"/>
<toolbarItem reference="S5T-mV-7Wv"/>
</defaultToolbarItems>
</toolbar>
<point key="canvasLocation" x="26" y="262"/>
<connections>
<outlet property="delegate" destination="-2" id="J8u-YX-m7n"/>
</connections>
<point key="canvasLocation" x="26" y="260.5"/>
</window>
<toolbarItem implicitItemIdentifier="97090EAA-0A04-42C8-A0EF-26D0A5600BE8" label="Toolbar Item" paletteLabel="Toolbar Item" tag="-1" id="tHp-Ai-VDo"/>
<viewController id="hP8-Be-GWG"/>
<userDefaultsController representsSharedInstance="YES" id="O7J-o6-nEr"/>
</objects>
<resources>
<image name="NSAdvanced" width="32" height="32"/>
<image name="NSComputer" width="32" height="32"/>
<image name="NSFolder" width="32" height="32"/>
<image name="NSInfo" width="32" height="32"/>
<image name="NSPreferencesGeneral" width="32" height="32"/>
<image name="NSStatusNone" width="16" height="16"/>
</resources>
</document>
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="STPreferencesWindowGeneralViewController">
<connections>
<outlet property="StartAtLogin" destination="pFh-78-Lys" id="cK2-BP-Lwt"/>
<outlet property="Syncthing_ApiKey" destination="cQX-Mb-YdG" id="tB5-cf-q5a"/>
<outlet property="Syncthing_URI" destination="ASJ-RF-VWg" id="GCz-xJ-qfw"/>
<outlet property="buttonTest" destination="nc7-jb-j3R" id="nwW-wC-hjj"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="c22-O7-iKe">
<rect key="frame" x="0.0" y="0.0" width="432" height="145"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cD3-jU-ZmO">
<rect key="frame" x="18" y="75" width="49" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="API key" id="xo4-pr-9fQ">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KyG-3H-hE7">
<rect key="frame" x="18" y="106" width="26" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="URI" id="zSk-0T-Qy3">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cQX-Mb-YdG">
<rect key="frame" x="76" y="70" width="336" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="aNVUG3mSx4PVyZW8LXWGoybFRSXS9c5a" drawsBackground="YES" id="bdm-XW-MSF">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ASJ-RF-VWg">
<rect key="frame" x="76" y="103" width="336" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="http://localhost:8384" drawsBackground="YES" id="K62-Vn-vxN">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pFh-78-Lys">
<rect key="frame" x="18" y="18" width="101" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Start at login" bezelStyle="regularSquare" imagePosition="left" inset="2" id="Qb5-4l-omo">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="PH2-6u-0xB">
<rect key="frame" x="20" y="49" width="392" height="5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</box>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wM0-lQ-NfS">
<rect key="frame" x="346" y="9" width="72" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Done" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="eKf-j5-FJs">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
DQ
</string>
</buttonCell>
<connections>
<action selector="clickedDone:" target="-2" id="Bqh-by-5Sv"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nc7-jb-j3R">
<rect key="frame" x="262" y="9" width="84" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Test" bezelStyle="rounded" image="NSStatusNone" imagePosition="left" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="1LY-6m-up3">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="clickedTest:" target="-2" id="CTl-8K-XlV"/>
</connections>
</button>
</subviews>
<point key="canvasLocation" x="268" y="123"/>
</customView>
</objects>
<resources>
<image name="NSStatusNone" width="16" height="16"/>
</resources>
</document>
@@ -0,0 +1,19 @@
//
// STPreferencesWindowGeneralViewController.h
// syncthing
//
// Created by Jerry Jacobs on 02/10/2016.
// Copyright © 2016 Jerry Jacobs. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface STPreferencesWindowGeneralViewController : NSViewController
/* TODO: move into generalViewController */
@property (weak) IBOutlet NSTextField *Syncthing_URI;
@property (weak) IBOutlet NSTextField *Syncthing_ApiKey;
@property (weak) IBOutlet NSButton *StartAtLogin;
@property (weak) IBOutlet NSButton *buttonTest;
@end
@@ -0,0 +1,68 @@
//
// STPreferencesWindowGeneralViewController.m
// syncthing
//
// Created by Jerry Jacobs on 02/10/2016.
// Copyright © 2016 Jerry Jacobs. All rights reserved.
//
#import "STPreferencesWindowGeneralViewController.h"
#import "STLoginItem.h"
#import "XGSyncthing.h"
@interface STPreferencesWindowGeneralViewController ()
@end
@implementation STPreferencesWindowGeneralViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
[self.Syncthing_URI setStringValue:[defaults objectForKey:@"URI"]];
[self.Syncthing_ApiKey setStringValue:[defaults objectForKey:@"ApiKey"]];
[self.StartAtLogin setStringValue:[defaults objectForKey:@"StartAtLogin"]];
[self updateTestButton];
}
- (void)updateTestButton {
XGSyncthing *st = [[XGSyncthing alloc] init];
[st setURI:[self.Syncthing_URI stringValue]];
[st setApiKey:[self.Syncthing_ApiKey stringValue]];
if ([st ping])
[self.buttonTest setImage:[NSImage imageNamed:NSImageNameStatusAvailable]];
else
[self.buttonTest setImage:[NSImage imageNamed:NSImageNameStatusUnavailable]];
}
- (void)updateStartAtLogin:(NSUserDefaults *)defaults {
STLoginItem *li = [STLoginItem alloc];
if ([defaults integerForKey:@"StartAtLogin"]) {
if (![li wasAppAddedAsLoginItem])
[li addAppAsLoginItem];
} else {
[li deleteAppFromLoginItem];
}
}
- (IBAction)clickedDone:(id)sender {
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[self.Syncthing_URI stringValue] forKey:@"URI"];
[defaults setObject:[self.Syncthing_ApiKey stringValue] forKey:@"ApiKey"];
[defaults setObject:[self.StartAtLogin stringValue] forKey:@"StartAtLogin"];
[self updateStartAtLogin:defaults];
}
- (IBAction)clickedTest:(id)sender {
[self updateTestButton];
}
@end