Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 129 lines (109 sloc) 4.717 kB
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
1 //
2 // MFPreferencesController.m
3 // MacFusion2
4 //
b798dd6 Advanced options enabled. License headers added. Added item to launch…
Michael Gorbach authored
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
16
17 #import "MFPreferencesController.h"
18 #import "MFCore.h"
19 #import "MFClient.h"
670c5b9 Fix Port validation bug.
Michael Gorbach authored
20 #import "MFPreferences.h"
781ab2e Fix warnings, and get rid of the un-needed sshnodelay.so.
Michael Gorbach authored
21 #import "MFLogging.h"
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
22
d1e7344 Ready for Beta 5
Michael Gorbach authored
23 #define kMFPrefsPluginToolbarIdentifier @"Plugin"
24 #define kMFPrefsGeneralToolbarIdentifier @"General"
25
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
26 @implementation MFPreferencesController
eb7dcfd Moar polish.
Michael Gorbach authored
27 - (id)initWithWindowNibName:(NSString *)name {
28 if (self = [super initWithWindowNibName: name]) {
29 _client = [MFClient sharedClient];
30 _sharedPreferences = [MFPreferences sharedPreferences];
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
31 }
32
33 return self;
34 }
35
eb7dcfd Moar polish.
Michael Gorbach authored
36 - (NSArray *)prefsViews {
d1e7344 Ready for Beta 5
Michael Gorbach authored
37 return [NSArray arrayWithObjects: pluginPrefsView, generalPrefsView, nil];
38 }
39
eb7dcfd Moar polish.
Michael Gorbach authored
40 - (void)awakeFromNib {
41 [agentLoginItemButton setState:mfcGetStateForAgentLoginItem()];
42 [menuLoginItemButton setState:[_sharedPreferences getBoolForPreference: kMFPrefsAutoloadMenuling]];
43 NSString *macfuseVersion = mfcGetMacFuseVersion();
44 NSString *versionString = macfuseVersion ? [NSString stringWithFormat: @"MacFuse Version %@ Found", macfuseVersion] : @"MacFuse not Found!";
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
45 [fuseVersionTextField setStringValue: versionString];
eb7dcfd Moar polish.
Michael Gorbach authored
46 NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier: @"Preferences"];
47 [toolbar setDelegate:self];
48 [toolbar setAllowsUserCustomization:NO];
49 [toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel];
50 [[self window] setToolbar:toolbar];
51 _prefsViewSizes = [NSMapTable new];
52 _emptyView = [NSView new];
53 for(NSView *view in [self prefsViews]) {
54 NSValue *sizeValue = [NSValue valueWithSize:[view frame].size];
55 [_prefsViewSizes setObject:sizeValue forKey:view];
d1e7344 Ready for Beta 5
Michael Gorbach authored
56 }
eb7dcfd Moar polish.
Michael Gorbach authored
57
58 [self toolbarItemChanged:[[toolbar items] objectAtIndex:0]];
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
59 }
60
eb7dcfd Moar polish.
Michael Gorbach authored
61 - (IBAction)loginItemCheckboxChanged:(id)sender {
62 if (sender == agentLoginItemButton) {
75d77a4 Some renaming of C functions. Fix path resolution problems that lead …
Michael Gorbach authored
63 mfcSetStateForAgentLoginItem([sender state]);
eb7dcfd Moar polish.
Michael Gorbach authored
64 } else if (sender == menuLoginItemButton) {
65 [[MFPreferences sharedPreferences] setBool:[sender state] forPreference:kMFPrefsAutoloadMenuling];
66 } else {
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
67 MFLogS(self, @"Invalid sender for loginItemCheckboxChanged");
68 }
69 }
70
d1e7344 Ready for Beta 5
Michael Gorbach authored
71 # pragma mark Toolbar
eb7dcfd Moar polish.
Michael Gorbach authored
72 - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag {
73 NSToolbarItem *item = nil;
d1e7344 Ready for Beta 5
Michael Gorbach authored
74
eb7dcfd Moar polish.
Michael Gorbach authored
75 if (itemIdentifier == kMFPrefsPluginToolbarIdentifier) {
d1e7344 Ready for Beta 5
Michael Gorbach authored
76 item = [[NSToolbarItem alloc] initWithItemIdentifier: kMFPrefsPluginToolbarIdentifier];
77
eb7dcfd Moar polish.
Michael Gorbach authored
78 [item setLabel:@"Plugins"];
79 [item setImage:[NSImage imageNamed: @"NSAdvanced"]];
80 } else if (itemIdentifier == kMFPrefsGeneralToolbarIdentifier) {
d1e7344 Ready for Beta 5
Michael Gorbach authored
81 item = [[NSToolbarItem alloc] initWithItemIdentifier: kMFPrefsGeneralToolbarIdentifier];
eb7dcfd Moar polish.
Michael Gorbach authored
82 [item setLabel:@"General"];
83 [item setImage:[NSImage imageNamed: @"NSPreferencesGeneral"]];
d1e7344 Ready for Beta 5
Michael Gorbach authored
84 }
85
eb7dcfd Moar polish.
Michael Gorbach authored
86 [item setTarget:self];
87 [item setAction:@selector(toolbarItemChanged:)];
d1e7344 Ready for Beta 5
Michael Gorbach authored
88 return item;
89 }
90
eb7dcfd Moar polish.
Michael Gorbach authored
91 - (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar {
92 return [NSArray arrayWithObjects:kMFPrefsGeneralToolbarIdentifier, kMFPrefsPluginToolbarIdentifier, nil];
d1e7344 Ready for Beta 5
Michael Gorbach authored
93 }
94
eb7dcfd Moar polish.
Michael Gorbach authored
95 - (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar {
96 return [self toolbarAllowedItemIdentifiers:toolbar];
d1e7344 Ready for Beta 5
Michael Gorbach authored
97 }
98
eb7dcfd Moar polish.
Michael Gorbach authored
99 - (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar {
100 return [self toolbarAllowedItemIdentifiers:toolbar];
d1e7344 Ready for Beta 5
Michael Gorbach authored
101 }
102
eb7dcfd Moar polish.
Michael Gorbach authored
103 - (IBAction)toolbarItemChanged:(id)sender {
104 NSView *newView;
105 if ([sender itemIdentifier] == kMFPrefsPluginToolbarIdentifier) {
d1e7344 Ready for Beta 5
Michael Gorbach authored
106 newView = pluginPrefsView;
eb7dcfd Moar polish.
Michael Gorbach authored
107 } else if ([sender itemIdentifier] == kMFPrefsGeneralToolbarIdentifier) {
d1e7344 Ready for Beta 5
Michael Gorbach authored
108 newView = generalPrefsView;
eb7dcfd Moar polish.
Michael Gorbach authored
109 } else {
d1e7344 Ready for Beta 5
Michael Gorbach authored
110 return;
eb7dcfd Moar polish.
Michael Gorbach authored
111 }
d1e7344 Ready for Beta 5
Michael Gorbach authored
112
eb7dcfd Moar polish.
Michael Gorbach authored
113 NSWindow *window = [self window];
114 NSSize size = [[_prefsViewSizes objectForKey: newView] sizeValue];
115 NSRect windowContentFrame = [window contentRectForFrameRect:[window frame]];
d1e7344 Ready for Beta 5
Michael Gorbach authored
116 windowContentFrame.origin.y += windowContentFrame.size.height;
117 windowContentFrame.origin.y -= size.height;
118 windowContentFrame.size.width = size.width;
119 windowContentFrame.size.height = size.height;
120
eb7dcfd Moar polish.
Michael Gorbach authored
121 NSRect newWindowFrame = [window frameRectForContentRect:windowContentFrame];
122 [[[self window] toolbar] setSelectedItemIdentifier:[sender itemIdentifier]];
123 [window setContentView:_emptyView];
d1e7344 Ready for Beta 5
Michael Gorbach authored
124 [window setFrame:newWindowFrame display:YES animate:[window isVisible]];
eb7dcfd Moar polish.
Michael Gorbach authored
125 [window setContentView:newView];
d1e7344 Ready for Beta 5
Michael Gorbach authored
126 }
127
1cb84dd Security system, UI refinement and other fixes. Ready for beta 1
Michael Gorbach authored
128 @end
Something went wrong with that request. Please try again.