Anonymous avatar Anonymous committed e74ae11

Added -run and -runAsSheetForWindow: methods to the CreateAccountWindowController

Comments (0)

Files changed (3)

Source/AccountList.m

 - (IBAction) createAccount: (id) sender;
 {
     CreateAccountWindowController *wc = [[CreateAccountWindowController alloc] init];
-    [wc showWindow: sender];
+    [wc run];
 }
 
 #pragma mark -

Source/CreateAccountWindowController.h

     
     BOOL triedAuth;
     BOOL canInteract;
+    
+    BOOL isSheet;
 }
 
 @property (assign, readwrite) BOOL savePassword;
 - (IBAction) continueClicked: (id) sender;
 - (IBAction) switchToAdvancedView: (id) sender;
 
+- (void) run;
+- (void) runAsSheetForWindow: (NSWindow *)window;
+
 @end

Source/CreateAccountWindowController.m

 @synthesize port;
 @synthesize canInteract;
 
+- (void) run;
+{
+    isSheet = NO;
+    [self showWindow: self];
+}
+
+- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
+{
+}
+
+- (void) runAsSheetForWindow: (NSWindow *)window;
+{
+    isSheet = YES;
+    [NSApp beginSheet: [self window] modalForWindow: window modalDelegate: self didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) contextInfo: NULL];
+}
+
+- (void) closeSelf;
+{
+    if (isSheet) {
+        [NSApp endSheet: [self window]];
+    }
+    [[self window] orderOut: self];
+    isSheet = NO;
+}
+
 - init;
 {
     self =  [super initWithWindowNibName: @"CreateAccountWindow"];
 
 - (IBAction) cancelClicked: (id) sender;
 {
-    [[self window] close];
+    [self closeSelf];
 }
 
 - (IBAction) continueClicked: (id) sender;
 - (void) savePreset;
 {
     // TODO: save preset/bookmark
-    [[self window] close];
+    [self closeSelf];
 }
 
 #pragma mark -
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.