Skip to content

Commit fed1b54

Browse files
committed
Added menu item to show the preferences window.
1 parent ea5ff71 commit fed1b54

4 files changed

Lines changed: 29 additions & 5 deletions

File tree

XcodeBoost/MFPluginController.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#import "MFPluginController.h"
1010
#import "NSMenu+XcodeBoost.h"
11+
#import "MFPreferencesWindowController.h"
1112
#import "DVTSourceTextView+XcodeBoost.h"
1213
#import "MFHighlightRegexWindowController.h"
1314
#import "IDEKit.h"
@@ -18,6 +19,7 @@ @implementation MFPluginController
1819
NSBundle *_pluginBundle;
1920
NSTextView *_activeTextView;
2021

22+
MFPreferencesWindowController *_preferencesWindowController;
2123
MFHighlightRegexWindowController *_highlightRegexWindowController;
2224
}
2325

@@ -86,6 +88,8 @@ - (NSMenuItem *)createTextToolsMenuItem
8688
[submenu addItem:[self createMenuItemWithTitle:@"Highlight Regex Matches" action:@selector(highlightRegexMatches_clicked:)]];
8789
[submenu addItem:[self createMenuItemWithTitle:@"Remove Most Recently Added Highlight" action:@selector(removeMostRecentlyAddedHighlight_clicked:)]];
8890
[submenu addItem:[self createMenuItemWithTitle:@"Remove All Highlighting" action:@selector(removeAllHighlighting_clicked:)]];
91+
[submenu addItem:[NSMenuItem separatorItem]];
92+
[submenu addItem:[self createMenuItemWithTitle:@"Preferences..." action:@selector(preferences_clicked:)]];
8993

9094
NSMenuItem *textToolsMenuItem = [[NSMenuItem alloc] initWithTitle:@"XcodeBoost" action:NULL keyEquivalent:@""];
9195
[textToolsMenuItem setSubmenu:submenu];
@@ -203,6 +207,16 @@ - (void)removeAllHighlighting_clicked:(id)sender
203207
[[[self currentSourceTextView] xb_manipulator] removeAllHighlighting];
204208
}
205209

210+
#pragma mark Preferences
211+
212+
- (void)preferences_clicked:(id)sender
213+
{
214+
if (!_preferencesWindowController)
215+
_preferencesWindowController = [[MFPreferencesWindowController alloc] initWithBundle:_pluginBundle];
216+
217+
[_preferencesWindowController showWindow:self];
218+
}
219+
206220
#pragma mark Implementation
207221

208222
- (IDEEditor *)currentEditor

XcodeBoost/MFPreferencesWindowController.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
@property (weak) IBOutlet NSColorWell *colorWell3;
1616
@property (weak) IBOutlet NSColorWell *colorWell4;
1717

18+
#pragma mark Lifetime
19+
20+
- (id)initWithBundle:(NSBundle *)bundle;
21+
22+
#pragma mark Action Methods
23+
1824
- (IBAction)colorChanged:(id)sender;
1925

2026
@end

XcodeBoost/MFPreferencesWindowController.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ @implementation MFPreferencesWindowController
1515
NSUserDefaults *_defaults;
1616
}
1717

18-
- (id)initWithWindow:(NSWindow *)window
18+
#pragma mark Lifetime
19+
20+
- (id)initWithBundle:(NSBundle *)bundle
1921
{
20-
self = [super initWithWindow:window];
21-
if (self)
22+
NSString *nibPath = [bundle pathForResource:@"PreferencesWindow" ofType:@"nib"];
23+
self = [super initWithWindowNibPath:nibPath owner:self];
24+
if (self)
2225
{
2326
_defaults = [NSUserDefaults standardUserDefaults];
24-
}
25-
return self;
27+
}
28+
return self;
2629
}
2730

2831
- (void)windowDidLoad

XcodeBoost/PreferencesWindow.xib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<outlet property="colorWell2" destination="TJd-vg-OPF" id="TMG-o4-6ih"/>
1111
<outlet property="colorWell3" destination="5A6-sq-JXe" id="Gxr-QI-5h6"/>
1212
<outlet property="colorWell4" destination="Nb7-V2-BBi" id="azg-RO-Kh7"/>
13+
<outlet property="window" destination="QvC-M9-y7g" id="aYl-ru-0zi"/>
1314
</connections>
1415
</customObject>
1516
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>

0 commit comments

Comments
 (0)