mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-02-15 16:11:25 +00:00
* Framework/PCProjectWindow.m:
(-preferencesDidChange:): Show Builder and Launcher panels only they are visible in project window (fixes bug #20858). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@25423 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8a4661e36b
commit
d90884488d
4 changed files with 176 additions and 168 deletions
|
@ -15,6 +15,9 @@
|
|||
* Headers/ProjectCenter/PCFileManager.h: Added new variable 'operation'
|
||||
and declaraion of new mathods.
|
||||
* Framework/PCProjectManager.m: Use new methods of PCFileManager.
|
||||
* Framework/PCProjectWindow.m:
|
||||
(-preferencesDidChange:): Show Builder and Launcher panels only
|
||||
they are visible in project window (fixes bug #20858).
|
||||
|
||||
2007-08-23 Sergii Stoian <stoyan255@gmail.com>
|
||||
|
||||
|
|
|
@ -83,6 +83,9 @@ static PCFileManager *_mgr = nil;
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// ==== NSFileManager delegate methods
|
||||
// ===========================================================================
|
||||
- (BOOL) fileManager:(NSFileManager *)manager
|
||||
shouldProceedAfterError:(NSDictionary *)errorDict
|
||||
{
|
||||
|
@ -91,164 +94,6 @@ static PCFileManager *_mgr = nil;
|
|||
return YES;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// ==== Dialogs
|
||||
// ===========================================================================
|
||||
|
||||
- (id)_panelForOperation:(int)op
|
||||
title:(NSString *)title
|
||||
accView:(NSView *)accessoryView
|
||||
{
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
NSString *lastOpenDir;
|
||||
id panel;
|
||||
|
||||
operation = op;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case PCOpenFileOperation:
|
||||
panel = [NSOpenPanel openPanel];
|
||||
[panel setCanChooseFiles:YES];
|
||||
[panel setCanChooseDirectories:NO];
|
||||
lastOpenDir = [ud objectForKey:@"FileOpenLastDirectory"];
|
||||
break;
|
||||
case PCSaveFileOperation:
|
||||
panel = [NSSavePanel savePanel];
|
||||
lastOpenDir = [ud objectForKey:@"FileSaveLastDirectory"];
|
||||
break;
|
||||
case PCOpenProjectOperation:
|
||||
panel = [NSOpenPanel openPanel];
|
||||
[panel setAllowsMultipleSelection:NO];
|
||||
[panel setCanChooseFiles:YES];
|
||||
[panel setCanChooseDirectories:YES];
|
||||
lastOpenDir = [ud objectForKey:@"ProjectOpenLastDirectory"];
|
||||
break;
|
||||
case PCAddFileOperation:
|
||||
if (addFilesPanel == nil)
|
||||
{
|
||||
addFilesPanel = [PCAddFilesPanel addFilesPanel];
|
||||
}
|
||||
panel = addFilesPanel;
|
||||
lastOpenDir = [ud objectForKey:@"FileAddLastDirectory"];
|
||||
break;
|
||||
default:
|
||||
return nil;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!lastOpenDir)
|
||||
{
|
||||
lastOpenDir = NSHomeDirectory();
|
||||
}
|
||||
[panel setDirectory:lastOpenDir];
|
||||
[panel setDelegate:self];
|
||||
|
||||
if (title != nil)
|
||||
{
|
||||
[panel setTitle:title];
|
||||
}
|
||||
if (accessoryView != nil)
|
||||
{
|
||||
[panel setAccessoryView:accessoryView];
|
||||
}
|
||||
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
- (void)_saveLastDirectoryForPanel:(id)panel
|
||||
{
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
NSString *key = nil;
|
||||
|
||||
switch (operation)
|
||||
{
|
||||
case PCOpenFileOperation:
|
||||
key = @"FileOpenLastDirectory";
|
||||
break;
|
||||
case PCSaveFileOperation:
|
||||
key = @"FileSaveLastDirectory";
|
||||
break;
|
||||
case PCOpenProjectOperation:
|
||||
key = @"ProjectOpenLastDirectory";
|
||||
break;
|
||||
case PCAddFileOperation:
|
||||
key = @"FileAddLastDirectory";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (key != nil)
|
||||
{
|
||||
[ud setObject:[panel directory] forKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSMutableArray *)filesOfTypes:(NSArray *)types
|
||||
operation:(int)op
|
||||
multiple:(BOOL)yn
|
||||
title:(NSString *)title
|
||||
accView:(NSView *)accessoryView
|
||||
{
|
||||
id panel;
|
||||
NSMutableArray *fileList = [[NSMutableArray alloc] init];
|
||||
NSString *file;
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
BOOL isDir;
|
||||
int result;
|
||||
|
||||
panel = [self _panelForOperation:op title:title accView:accessoryView];
|
||||
|
||||
if ((op == PCOpenFileOperation) || (op == PCOpenProjectOperation))
|
||||
{
|
||||
[panel setAllowsMultipleSelection:yn];
|
||||
|
||||
if ((result = [panel runModalForTypes:types]) == NSOKButton)
|
||||
{
|
||||
[fileList addObjectsFromArray:[panel filenames]];
|
||||
|
||||
file = [fileList objectAtIndex:0];
|
||||
if (op == PCOpenProjectOperation &&
|
||||
[fm fileExistsAtPath:file isDirectory:&isDir] && isDir)
|
||||
{
|
||||
file = [file stringByAppendingPathComponent:@"PC.project"];
|
||||
[fileList insertObject:file atIndex:0];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (op == PCSaveFileOperation)
|
||||
{
|
||||
if ((result = [panel runModal]) == NSOKButton)
|
||||
{
|
||||
[fileList addObject:[panel filename]];
|
||||
}
|
||||
}
|
||||
else if (op == PCAddFileOperation)
|
||||
{
|
||||
PCProject *project = [projectManager activeProject];
|
||||
NSString *selectedCategory = nil;
|
||||
|
||||
[panel setCategories:[project rootCategories]];
|
||||
selectedCategory = [[project projectBrowser] nameOfSelectedCategory];
|
||||
[panel selectCategory:selectedCategory];
|
||||
|
||||
if ((result = [panel runModalForTypes:types]) == NSOKButton)
|
||||
{
|
||||
[fileList addObjectsFromArray:[panel filenames]];
|
||||
}
|
||||
}
|
||||
|
||||
if (result == NSOKButton)
|
||||
{
|
||||
[self _saveLastDirectoryForPanel:panel];
|
||||
return [fileList autorelease];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// ==== File handling
|
||||
// ===========================================================================
|
||||
|
@ -530,7 +375,167 @@ static PCFileManager *_mgr = nil;
|
|||
|
||||
@implementation PCFileManager (UInterface)
|
||||
|
||||
// -- "New File in Project" Panel
|
||||
// ===========================================================================
|
||||
// ==== Panels
|
||||
// ===========================================================================
|
||||
|
||||
- (id)_panelForOperation:(int)op
|
||||
title:(NSString *)title
|
||||
accView:(NSView *)accessoryView
|
||||
{
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
NSString *lastOpenDir;
|
||||
id panel;
|
||||
|
||||
operation = op;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case PCOpenFileOperation:
|
||||
panel = [NSOpenPanel openPanel];
|
||||
[panel setCanChooseFiles:YES];
|
||||
[panel setCanChooseDirectories:NO];
|
||||
lastOpenDir = [ud objectForKey:@"FileOpenLastDirectory"];
|
||||
break;
|
||||
case PCSaveFileOperation:
|
||||
panel = [NSSavePanel savePanel];
|
||||
lastOpenDir = [ud objectForKey:@"FileSaveLastDirectory"];
|
||||
break;
|
||||
case PCOpenProjectOperation:
|
||||
panel = [NSOpenPanel openPanel];
|
||||
[panel setAllowsMultipleSelection:NO];
|
||||
[panel setCanChooseFiles:YES];
|
||||
[panel setCanChooseDirectories:YES];
|
||||
lastOpenDir = [ud objectForKey:@"ProjectOpenLastDirectory"];
|
||||
break;
|
||||
case PCAddFileOperation:
|
||||
if (addFilesPanel == nil)
|
||||
{
|
||||
addFilesPanel = [PCAddFilesPanel addFilesPanel];
|
||||
}
|
||||
panel = addFilesPanel;
|
||||
lastOpenDir = [ud objectForKey:@"FileAddLastDirectory"];
|
||||
break;
|
||||
default:
|
||||
return nil;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!lastOpenDir)
|
||||
{
|
||||
lastOpenDir = NSHomeDirectory();
|
||||
}
|
||||
[panel setDirectory:lastOpenDir];
|
||||
[panel setDelegate:self];
|
||||
|
||||
if (title != nil)
|
||||
{
|
||||
[panel setTitle:title];
|
||||
}
|
||||
if (accessoryView != nil)
|
||||
{
|
||||
[panel setAccessoryView:accessoryView];
|
||||
}
|
||||
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
- (void)_saveLastDirectoryForPanel:(id)panel
|
||||
{
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
NSString *key = nil;
|
||||
|
||||
switch (operation)
|
||||
{
|
||||
case PCOpenFileOperation:
|
||||
key = @"FileOpenLastDirectory";
|
||||
break;
|
||||
case PCSaveFileOperation:
|
||||
key = @"FileSaveLastDirectory";
|
||||
break;
|
||||
case PCOpenProjectOperation:
|
||||
key = @"ProjectOpenLastDirectory";
|
||||
break;
|
||||
case PCAddFileOperation:
|
||||
key = @"FileAddLastDirectory";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (key != nil)
|
||||
{
|
||||
[ud setObject:[panel directory] forKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSMutableArray *)filesOfTypes:(NSArray *)types
|
||||
operation:(int)op
|
||||
multiple:(BOOL)yn
|
||||
title:(NSString *)title
|
||||
accView:(NSView *)accessoryView
|
||||
{
|
||||
id panel;
|
||||
NSMutableArray *fileList = [[NSMutableArray alloc] init];
|
||||
NSString *file;
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
BOOL isDir;
|
||||
int result;
|
||||
|
||||
panel = [self _panelForOperation:op title:title accView:accessoryView];
|
||||
|
||||
if ((op == PCOpenFileOperation) || (op == PCOpenProjectOperation))
|
||||
{
|
||||
[panel setAllowsMultipleSelection:yn];
|
||||
|
||||
if ((result = [panel runModalForTypes:types]) == NSOKButton)
|
||||
{
|
||||
[fileList addObjectsFromArray:[panel filenames]];
|
||||
|
||||
file = [fileList objectAtIndex:0];
|
||||
if (op == PCOpenProjectOperation &&
|
||||
[fm fileExistsAtPath:file isDirectory:&isDir] && isDir)
|
||||
{
|
||||
file = [file stringByAppendingPathComponent:@"PC.project"];
|
||||
[fileList insertObject:file atIndex:0];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (op == PCSaveFileOperation)
|
||||
{
|
||||
if ((result = [panel runModal]) == NSOKButton)
|
||||
{
|
||||
[fileList addObject:[panel filename]];
|
||||
}
|
||||
}
|
||||
else if (op == PCAddFileOperation)
|
||||
{
|
||||
PCProject *project = [projectManager activeProject];
|
||||
NSString *selectedCategory = nil;
|
||||
|
||||
[panel setCategories:[project rootCategories]];
|
||||
selectedCategory = [[project projectBrowser] nameOfSelectedCategory];
|
||||
[panel selectCategory:selectedCategory];
|
||||
|
||||
if ((result = [panel runModalForTypes:types]) == NSOKButton)
|
||||
{
|
||||
[fileList addObjectsFromArray:[panel filenames]];
|
||||
}
|
||||
}
|
||||
|
||||
if (result == NSOKButton)
|
||||
{
|
||||
[self _saveLastDirectoryForPanel:panel];
|
||||
return [fileList autorelease];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// ==== "New File in Project" Panel
|
||||
// ============================================================================
|
||||
- (void)showNewFilePanel
|
||||
{
|
||||
if (!newFilePanel)
|
||||
|
|
|
@ -571,7 +571,8 @@
|
|||
// Project Builder
|
||||
if ([[prefsDict objectForKey:@"SeparateBuilder"] isEqualToString:@"YES"])
|
||||
{
|
||||
if ([[[project projectBuilder] componentView] superview])
|
||||
// Project Build is sepearate and visible in project window
|
||||
if ([[[project projectBuilder] componentView] window] == projectWindow)
|
||||
{
|
||||
[self showProjectBuild:self];
|
||||
}
|
||||
|
@ -589,7 +590,7 @@
|
|||
// Project Launcher
|
||||
if ([[prefsDict objectForKey:@"SeparateLauncher"] isEqualToString:@"YES"])
|
||||
{
|
||||
if ([[[project projectLauncher] componentView] superview])
|
||||
if ([[[project projectLauncher] componentView] window] == projectWindow)
|
||||
{
|
||||
[self showProjectLaunch:self];
|
||||
}
|
||||
|
|
|
@ -78,13 +78,6 @@ enum {
|
|||
// ==== File stuff
|
||||
// ===========================================================================
|
||||
|
||||
// Shows NSOpenPanel and return selected files if any
|
||||
- (NSMutableArray *)filesOfTypes:(NSArray *)types
|
||||
operation:(int)op
|
||||
multiple:(BOOL)yn
|
||||
title:(NSString *)title
|
||||
accView:(NSView *)accessoryView;
|
||||
|
||||
// Checks if directories in path exists and creates if not.
|
||||
- (BOOL)createDirectoriesIfNeededAtPath:(NSString *)path;
|
||||
|
||||
|
@ -126,6 +119,12 @@ enum {
|
|||
|
||||
@interface PCFileManager (UInterface)
|
||||
|
||||
// Shows panel and return selected files if any
|
||||
- (NSMutableArray *)filesOfTypes:(NSArray *)types
|
||||
operation:(int)op
|
||||
multiple:(BOOL)yn
|
||||
title:(NSString *)title
|
||||
accView:(NSView *)accessoryView;
|
||||
- (void)showNewFilePanel;
|
||||
- (void)closeNewFilePanel:(id)sender;
|
||||
- (void)createFile:(id)sender;
|
||||
|
|
Loading…
Reference in a new issue