forked from macvim-dev/macvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMMPreferenceController.m
More file actions
105 lines (85 loc) · 3.46 KB
/
Copy pathMMPreferenceController.m
File metadata and controls
105 lines (85 loc) · 3.46 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* vi:set ts=8 sts=4 sw=4 ft=objc:
*
* VIM - Vi IMproved by Bram Moolenaar
* MacVim GUI port by Bjorn Winckler
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
#import "MMPreferenceController.h"
#import "Miscellaneous.h"
// On Leopard, we want to use the images provided by the OS for some of the
// toolbar images (NSImageNamePreferencesGeneral and friends). We need to jump
// through some hoops to do that in a way that MacVim still _compiles_ on Tiger
// (life would be easier if we'd require Leopard for building). See
// http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html
// and http://developer.apple.com/technotes/tn2002/tn2064.html
// for how you'd do it with a Leopard build system, and see
// http://lists.cairographics.org/archives/cairo-bugs/2007-December/001818.html
// for why this doesn't work here.
// Using the system images gives us resolution independence and consistency
// with other apps.
#import <dlfcn.h>
NSString* nsImageNamePreferencesGeneral = nil;
NSString* nsImageNamePreferencesAdvanced = nil;
static void loadSymbols()
{
// use dlfcn() instead of the deprecated NSModule api.
void *ptr;
if ((ptr = dlsym(RTLD_DEFAULT, "NSImageNamePreferencesGeneral")) != NULL)
nsImageNamePreferencesGeneral = *(NSString**)ptr;
if ((ptr = dlsym(RTLD_DEFAULT, "NSImageNameAdvanced")) != NULL)
nsImageNamePreferencesAdvanced = *(NSString**)ptr;
}
@implementation MMPreferenceController
- (void)setupToolbar
{
loadSymbols();
if (nsImageNamePreferencesGeneral != NULL) {
[self addView:generalPreferences
label:@"General"
image:[NSImage imageNamed:nsImageNamePreferencesGeneral]];
} else {
[self addView:generalPreferences label:@"General"];
}
if (nsImageNamePreferencesAdvanced != NULL) {
[self addView:advancedPreferences
label:@"Advanced"
image:[NSImage imageNamed:nsImageNamePreferencesAdvanced]];
} else {
[self addView:advancedPreferences label:@"Advanced"];
}
}
- (NSString *)currentPaneIdentifier
{
// We override this to persist the current pane.
return [[NSUserDefaults standardUserDefaults]
stringForKey:MMCurrentPreferencePaneKey];
}
- (void)setCurrentPaneIdentifier:(NSString *)identifier
{
// We override this to persist the current pane.
[[NSUserDefaults standardUserDefaults]
setObject:identifier forKey:MMCurrentPreferencePaneKey];
}
- (IBAction)openInCurrentWindowSelectionChanged:(id)sender
{
BOOL openInCurrentWindowSelected = ([[sender selectedCell] tag] != 0);
BOOL useWindowsLayout =
([[layoutPopUpButton selectedItem] tag] == MMLayoutWindows);
if (openInCurrentWindowSelected && useWindowsLayout) {
[[NSUserDefaults standardUserDefaults] setInteger:MMLayoutTabs forKey:MMOpenLayoutKey];
}
}
- (IBAction)checkForUpdatesChanged:(id)sender
{
// Sparkle's auto-install update preference trumps "check for update", so
// need to make sure to unset that if the user unchecks "check for update".
NSButton *button = (NSButton *)sender;
BOOL checkForUpdates = ([button state] != 0);
if (!checkForUpdates) {
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"SUAutomaticallyUpdate"];
}
}
@end