Commits

Dominik Wagner  committed 624ba83

added preference window with mechanism for choosing an editor from a list instead of the hardcoded textmate

  • Participants
  • Parent commits 66feaf6

Comments (0)

Files changed (5)

File English.lproj/MainMenu.nib/designable.nib

 <?xml version="1.0" encoding="UTF-8"?>
 <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
 	<data>
-		<int key="IBDocument.SystemTarget">0</int>
+		<int key="IBDocument.SystemTarget">1050</int>
 		<string key="IBDocument.SystemVersion">9G55</string>
 		<string key="IBDocument.InterfaceBuilderVersion">677</string>
 		<string key="IBDocument.AppKitVersion">949.43</string>
 		<string key="IBDocument.HIToolboxVersion">353.00</string>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
+			<integer value="129"/>
 			<integer value="422"/>
-			<integer value="300"/>
+			<integer value="501"/>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
 			<object class="NSCustomObject" id="870936524">
 				<string key="NSClassName">URLFormatter</string>
 			</object>
+			<object class="NSWindowTemplate" id="231914121">
+				<int key="NSWindowStyleMask">15</int>
+				<int key="NSWindowBacking">2</int>
+				<string key="NSWindowRect">{{196, 439}, {403, 71}}</string>
+				<int key="NSWTFlags">1677721600</int>
+				<string key="NSWindowTitle">Preferences</string>
+				<string key="NSWindowClass">NSWindow</string>
+				<nil key="NSViewClass"/>
+				<object class="NSView" key="NSWindowView" id="907472235">
+					<reference key="NSNextResponder"/>
+					<int key="NSvFlags">256</int>
+					<object class="NSMutableArray" key="NSSubviews">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSPopUpButton" id="954829207">
+							<reference key="NSNextResponder" ref="907472235"/>
+							<int key="NSvFlags">268</int>
+							<string key="NSFrame">{{169, 24}, {228, 26}}</string>
+							<reference key="NSSuperview" ref="907472235"/>
+							<bool key="NSEnabled">YES</bool>
+							<object class="NSPopUpButtonCell" key="NSCell" id="202116144">
+								<int key="NSCellFlags">-2076049856</int>
+								<int key="NSCellFlags2">2048</int>
+								<reference key="NSSupport" ref="43958144"/>
+								<reference key="NSControlView" ref="954829207"/>
+								<int key="NSButtonFlags">109199615</int>
+								<int key="NSButtonFlags2">129</int>
+								<string key="NSAlternateContents"/>
+								<string key="NSKeyEquivalent"/>
+								<int key="NSPeriodicDelay">400</int>
+								<int key="NSPeriodicInterval">75</int>
+								<object class="NSMenuItem" key="NSMenuItem" id="907144242">
+									<reference key="NSMenu" ref="88260614"/>
+									<string key="NSTitle">Item 1</string>
+									<string key="NSKeyEquiv"/>
+									<int key="NSKeyEquivModMask">1048576</int>
+									<int key="NSMnemonicLoc">2147483647</int>
+									<int key="NSState">1</int>
+									<reference key="NSOnImage" ref="160795839"/>
+									<reference key="NSMixedImage" ref="977870995"/>
+									<string key="NSAction">_popUpItemAction:</string>
+									<reference key="NSTarget" ref="202116144"/>
+								</object>
+								<bool key="NSMenuItemRespectAlignment">YES</bool>
+								<object class="NSMenu" key="NSMenu" id="88260614">
+									<string key="NSTitle">OtherViews</string>
+									<object class="NSMutableArray" key="NSMenuItems">
+										<bool key="EncodedWithXMLCoder">YES</bool>
+										<reference ref="907144242"/>
+										<object class="NSMenuItem" id="207370474">
+											<reference key="NSMenu" ref="88260614"/>
+											<string key="NSTitle">Item 2</string>
+											<string key="NSKeyEquiv"/>
+											<int key="NSKeyEquivModMask">1048576</int>
+											<int key="NSMnemonicLoc">2147483647</int>
+											<reference key="NSOnImage" ref="160795839"/>
+											<reference key="NSMixedImage" ref="977870995"/>
+											<string key="NSAction">_popUpItemAction:</string>
+											<reference key="NSTarget" ref="202116144"/>
+										</object>
+										<object class="NSMenuItem" id="581758348">
+											<reference key="NSMenu" ref="88260614"/>
+											<string key="NSTitle">Item 3</string>
+											<string key="NSKeyEquiv"/>
+											<int key="NSKeyEquivModMask">1048576</int>
+											<int key="NSMnemonicLoc">2147483647</int>
+											<reference key="NSOnImage" ref="160795839"/>
+											<reference key="NSMixedImage" ref="977870995"/>
+											<string key="NSAction">_popUpItemAction:</string>
+											<reference key="NSTarget" ref="202116144"/>
+										</object>
+									</object>
+								</object>
+								<int key="NSPreferredEdge">1</int>
+								<bool key="NSUsesItemFromMenu">YES</bool>
+								<bool key="NSAltersState">YES</bool>
+								<int key="NSArrowPosition">2</int>
+							</object>
+						</object>
+						<object class="NSTextField" id="859846633">
+							<reference key="NSNextResponder" ref="907472235"/>
+							<int key="NSvFlags">268</int>
+							<string key="NSFrame">{{17, 30}, {140, 17}}</string>
+							<reference key="NSSuperview" ref="907472235"/>
+							<bool key="NSEnabled">YES</bool>
+							<object class="NSTextFieldCell" key="NSCell" id="118995053">
+								<int key="NSCellFlags">68288064</int>
+								<int key="NSCellFlags2">272630784</int>
+								<string key="NSContents">Preferred Text Editor:</string>
+								<reference key="NSSupport" ref="43958144"/>
+								<reference key="NSControlView" ref="859846633"/>
+								<reference key="NSBackgroundColor" ref="99345828"/>
+								<reference key="NSTextColor" ref="295978017"/>
+							</object>
+						</object>
+					</object>
+					<string key="NSFrameSize">{403, 71}</string>
+					<reference key="NSSuperview"/>
+				</object>
+				<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
+				<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
+			</object>
 		</object>
 		<object class="IBObjectContainer" key="IBDocument.Objects">
 			<object class="NSMutableArray" key="connectionRecords">
 					</object>
 					<int key="connectionID">500</int>
 				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">_textEditorPreferenceButton</string>
+						<reference key="source" ref="152602700"/>
+						<reference key="destination" ref="954829207"/>
+					</object>
+					<int key="connectionID">515</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">selectTextEditor:</string>
+						<reference key="source" ref="152602700"/>
+						<reference key="destination" ref="954829207"/>
+					</object>
+					<int key="connectionID">516</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBActionConnection" key="connection">
+						<string key="label">showPreferences:</string>
+						<reference key="source" ref="152602700"/>
+						<reference key="destination" ref="609285721"/>
+					</object>
+					<int key="connectionID">517</int>
+				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
 						<reference key="object" ref="197082050"/>
 						<reference key="parent" ref="720053764"/>
 					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">501</int>
+						<reference key="object" ref="231914121"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="907472235"/>
+						</object>
+						<reference key="parent" ref="1049"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">502</int>
+						<reference key="object" ref="907472235"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="859846633"/>
+							<reference ref="954829207"/>
+						</object>
+						<reference key="parent" ref="231914121"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">504</int>
+						<reference key="object" ref="954829207"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="202116144"/>
+						</object>
+						<reference key="parent" ref="907472235"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">505</int>
+						<reference key="object" ref="202116144"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="88260614"/>
+						</object>
+						<reference key="parent" ref="954829207"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">506</int>
+						<reference key="object" ref="88260614"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="907144242"/>
+							<reference ref="207370474"/>
+							<reference ref="581758348"/>
+						</object>
+						<reference key="parent" ref="202116144"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">507</int>
+						<reference key="object" ref="907144242"/>
+						<reference key="parent" ref="88260614"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">508</int>
+						<reference key="object" ref="207370474"/>
+						<reference key="parent" ref="88260614"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">509</int>
+						<reference key="object" ref="581758348"/>
+						<reference key="parent" ref="88260614"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">511</int>
+						<reference key="object" ref="859846633"/>
+						<object class="NSMutableArray" key="children">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<reference ref="118995053"/>
+						</object>
+						<reference key="parent" ref="907472235"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">512</int>
+						<reference key="object" ref="118995053"/>
+						<reference key="parent" ref="859846633"/>
+					</object>
 				</object>
 			</object>
 			<object class="NSMutableDictionary" key="flattenedProperties">
 					<string>498.IBPluginDependency</string>
 					<string>5.IBPluginDependency</string>
 					<string>5.ImportedFromIB2</string>
+					<string>501.IBEditorWindowLastContentRect</string>
+					<string>501.IBPluginDependency</string>
+					<string>501.IBWindowTemplateEditedContentRect</string>
+					<string>501.NSWindowTemplate.visibleAtLaunch</string>
+					<string>502.IBPluginDependency</string>
+					<string>504.IBPluginDependency</string>
+					<string>505.IBPluginDependency</string>
+					<string>506.IBEditorWindowLastContentRect</string>
+					<string>506.IBPluginDependency</string>
+					<string>507.IBPluginDependency</string>
+					<string>508.IBPluginDependency</string>
+					<string>509.IBPluginDependency</string>
+					<string>511.IBPluginDependency</string>
+					<string>512.IBPluginDependency</string>
 					<string>56.IBPluginDependency</string>
 					<string>56.ImportedFromIB2</string>
 					<string>57.IBEditorWindowLastContentRect</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
+					<string>{{88, 613}, {403, 71}}</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>{{88, 613}, {403, 71}}</string>
+					<boolean value="NO"/>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>{{246, 600}, {228, 63}}</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<reference ref="9"/>
 					<string>{{89, 631}, {186, 183}}</string>
 				</object>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">500</int>
+			<int key="maxID">517</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
 							<string>dismissClonePanel:</string>
 							<string>runClonePanel:</string>
 							<string>runOpenPanel:</string>
+							<string>selectTextEditor:</string>
+							<string>showPreferences:</string>
 							<string>showProjectsWindow:</string>
 						</object>
 						<object class="NSMutableArray" key="dict.values">
 							<string>id</string>
 							<string>id</string>
 							<string>id</string>
+							<string>id</string>
+							<string>id</string>
 						</object>
 					</object>
 					<object class="NSMutableDictionary" key="outlets">
 							<string>_clonePanel</string>
 							<string>_cloneSrcChooseButton</string>
 							<string>_cloneSrcURLField</string>
+							<string>_textEditorPreferenceButton</string>
 						</object>
 						<object class="NSMutableArray" key="dict.values">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<string>NSPanel</string>
 							<string>NSButton</string>
 							<string>NSTextField</string>
+							<string>NSPopUpButton</string>
 						</object>
 					</object>
 					<object class="IBClassDescriptionSource" key="sourceIdentifier">

File English.lproj/MainMenu.nib/keyedobjects.nib

Binary file modified.

File Source/HgTempDir.m

 //
 
 #import "HgTempDir.h"
-
+#import "MercurialApp.h"
 
 @implementation HgTempDir
 
 
-#define kEditorAppBundleID @"com.macromates.textmate"
+#define kEditorAppBundleID [[NSUserDefaults standardUserDefaults] stringForKey:kPrefPreferedTextEditorID]
 
 
 static NSString *sRootTempDir;

File Source/MercurialApp.h

 
 #import <Cocoa/Cocoa.h>
 
+#define kPrefPreferedTextEditorID @"PreferredTextEditorID"
+
 
 /** The main application delegate class of Murky. */
 @interface MercurialApp : NSObject
     IBOutlet NSPanel *_clonePanel;
     IBOutlet NSTextField *_cloneSrcURLField, *_cloneDstURLField;
     IBOutlet NSButton *_cloneSrcChooseButton;
+    
+    IBOutlet NSPopUpButton *_textEditorPreferenceButton;
 }    
 
 - (BOOL) openRepository: (NSString*)path remember: (BOOL)remember;
 
 - (IBAction) showProjectsWindow: (id)sender;
 
+- (NSArray *)supportedTextEditors;
+- (IBAction) showPreferences:(id)sender;
+- (IBAction) selectTextEditor:(id)sender;
+
 @end
 
 

File Source/MercurialApp.m

 
 @implementation MercurialApp
 
++ (void) initialize
+{
+	if (self == [MercurialApp class]) {
+		[[NSUserDefaults standardUserDefaults] registerDefaults:
+			[NSDictionary dictionaryWithObjectsAndKeys:
+				@"com.macromates.textmate",kPrefPreferedTextEditorID,
+			nil]
+		];
+	}
+}
 
 #pragma mark -
 #pragma mark OPENING REPOSITORIES:
     [[ProjectsController sharedInstance] showWindow: sender];
 }
 
+#pragma mark -
+#pragma mark Preferences:
+- (NSArray *)supportedTextEditors {
+	static NSArray *s_supportedTextEditors = nil;
+	if (!s_supportedTextEditors) {
+		s_supportedTextEditors = [NSArray arrayWithObjects:
+			[NSDictionary dictionaryWithObjectsAndKeys:
+				@"de.codingmonkeys.SubEthaEdit", @"editorID",
+				@"SubEthaEdit", @"editorName", nil],
+			[NSDictionary dictionaryWithObjectsAndKeys:
+				@"com.macromates.textmate", @"editorID",
+				@"Textmate", @"editorName", nil],
+		nil];
+	}
+	return s_supportedTextEditors;
+}
+
+- (IBAction) showPreferences:(id)sender {
+	// update popup
+	[_textEditorPreferenceButton removeAllItems];
+	[_textEditorPreferenceButton addItemsWithTitles:[[self supportedTextEditors] valueForKeyPath:@"@unionOfObjects.editorName"]];
+	NSString *selectedEditorID = [[NSUserDefaults standardUserDefaults] stringForKey:kPrefPreferedTextEditorID];
+	int selectedItemIndex = [[[self supportedTextEditors] valueForKeyPath:@"@unionOfObjects.editorID"] indexOfObject:selectedEditorID];
+	[_textEditorPreferenceButton selectItemAtIndex:selectedItemIndex];
+	[[_textEditorPreferenceButton window] makeKeyAndOrderFront:self];
+}
+
+- (IBAction) selectTextEditor:(id)sender {
+	int selectedIndex = [_textEditorPreferenceButton indexOfSelectedItem];
+	[[NSUserDefaults standardUserDefaults] setObject:[[[self supportedTextEditors] valueForKeyPath:@"@unionOfObjects.editorID"] objectAtIndex:selectedIndex] forKey:kPrefPreferedTextEditorID];
+}
+
 
 @end