mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-02-19 01:51:09 +00:00
AppIcons are now set/cleaned correctly
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@8478 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
de3d438171
commit
043563d37c
2 changed files with 79 additions and 8 deletions
|
@ -41,6 +41,7 @@
|
|||
NSTextField *appClassField;
|
||||
NSTextField *appImageField;
|
||||
NSButton *setAppIconButton;
|
||||
NSButton *clearAppIconButton;
|
||||
NSImageView *appIconView;
|
||||
NSImage *icon;
|
||||
}
|
||||
|
@ -70,4 +71,11 @@
|
|||
|
||||
- (void)updateValuesFromProjectDict;
|
||||
|
||||
- (void)clearAppIcon:(id)sender;
|
||||
- (void)setAppIcon:(id)sender;
|
||||
|
||||
- (BOOL)setAppIconWithImageAtPath:(NSString *)path;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
|
@ -79,27 +79,37 @@
|
|||
appImageField =[[NSTextField alloc] initWithFrame:NSMakeRect(84,204,176,21)];
|
||||
[appImageField setAlignment: NSLeftTextAlignment];
|
||||
[appImageField setBordered: YES];
|
||||
[appImageField setEditable: YES];
|
||||
[appImageField setEditable: NO];
|
||||
[appImageField setBezeled: YES];
|
||||
[appImageField setDrawsBackground: YES];
|
||||
[appImageField setStringValue:@""];
|
||||
[projectProjectInspectorView addSubview:appImageField];
|
||||
|
||||
setAppIconButton =[[NSButton alloc] initWithFrame:NSMakeRect(180,180,80,21)];
|
||||
[setAppIconButton setTitle:@"Set..."];
|
||||
setAppIconButton =[[NSButton alloc] initWithFrame:NSMakeRect(220,180,40,21)];
|
||||
[setAppIconButton setTitle:@"Set"];
|
||||
[setAppIconButton setTarget:self];
|
||||
[setAppIconButton setAction:@selector(setAppIcon:)];
|
||||
[projectProjectInspectorView addSubview:setAppIconButton];
|
||||
|
||||
clearAppIconButton =[[NSButton alloc] initWithFrame:NSMakeRect(180,180,40,21)];
|
||||
[clearAppIconButton setTitle:@"Clear"];
|
||||
[clearAppIconButton setTarget:self];
|
||||
[clearAppIconButton setAction:@selector(clearAppIcon:)];
|
||||
[projectProjectInspectorView addSubview:clearAppIconButton];
|
||||
|
||||
_box = [[NSBox alloc] init];
|
||||
[_box setFrame:frame];
|
||||
[_box setTitlePosition:NSNoTitle];
|
||||
//[_box setBorderType:NSNoBorder];
|
||||
[_box setBorderType:NSBezelBorder];
|
||||
[projectProjectInspectorView addSubview:_box];
|
||||
AUTORELEASE(_box);
|
||||
|
||||
|
||||
appIconView = [[NSImageView alloc] initWithFrame:frame];
|
||||
[_box addSubview:appIconView];
|
||||
|
||||
RELEASE(_box);
|
||||
RELEASE(setAppIconButton);
|
||||
RELEASE(clearAppIconButton);
|
||||
RELEASE(appIconView);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -135,8 +145,6 @@
|
|||
[rootCategories release];
|
||||
[appClassField release];
|
||||
[appImageField release];
|
||||
[setAppIconButton release];
|
||||
[appIconView release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -163,6 +171,7 @@
|
|||
NSLog([NSString stringWithFormat:@"Couldn't build the GNUmakefile %@!",makefile]);
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![content writeToFile:makefile atomically:YES]) {
|
||||
NSLog([NSString stringWithFormat:@"Couldn't write the GNUmakefile %@!",makefile]);
|
||||
return NO;
|
||||
|
@ -213,4 +222,58 @@
|
|||
[appImageField setStringValue:[projectDict objectForKey:PCAppIcon]];
|
||||
}
|
||||
|
||||
- (void)clearAppIcon:(id)sender
|
||||
{
|
||||
[projectDict setObject:@"" forKey:PCAppIcon];
|
||||
[appImageField setStringValue:@"No Icon!"];
|
||||
[appIconView setImage:nil];
|
||||
[appIconView display];
|
||||
[self writeMakefile];
|
||||
}
|
||||
|
||||
- (void)setAppIcon:(id)sender
|
||||
{
|
||||
int result;
|
||||
NSArray *fileTypes = [NSImage imageFileTypes];
|
||||
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
|
||||
|
||||
[openPanel setAllowsMultipleSelection:NO];
|
||||
result = [openPanel runModalForDirectory:NSHomeDirectory()
|
||||
file:nil
|
||||
types:fileTypes];
|
||||
|
||||
if (result == NSOKButton) {
|
||||
NSArray *files = [openPanel filenames];
|
||||
NSString *imageFilePath = [files objectAtIndex:0];
|
||||
|
||||
if (![self setAppIconWithImageAtPath:imageFilePath]) {
|
||||
NSRunAlertPanel(@"Error while opening file!",
|
||||
@"Couldn't open %@", @"OK", nil, nil,imageFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)setAppIconWithImageAtPath:(NSString *)path
|
||||
{
|
||||
NSRect frame = {{0,0}, {64, 64}};
|
||||
NSImage *image;
|
||||
|
||||
if (!(image = [[NSImage alloc] initWithContentsOfFile:path])) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
[self addFile:path forKey:PCImages copy:YES];
|
||||
[projectDict setObject:[path lastPathComponent] forKey:PCAppIcon];
|
||||
|
||||
[appImageField setStringValue:[path lastPathComponent]];
|
||||
|
||||
frame.size = [image size];
|
||||
[appIconView setFrame:frame];
|
||||
[appIconView setImage:image];
|
||||
[appIconView display];
|
||||
RELEASE(image);
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue