2009-08-05 08:59:46 +00:00
|
|
|
/*
|
2011-04-12 08:04:01 +00:00
|
|
|
Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
|
2009-08-05 08:59:46 +00:00
|
|
|
|
2010-09-30 10:17:41 +00:00
|
|
|
This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
2009-08-05 08:59:46 +00:00
|
|
|
which should be included with this package. The terms are also available at
|
2010-09-30 10:17:41 +00:00
|
|
|
http://www.hardcoded.net/licenses/bsd_license
|
2009-08-05 08:59:46 +00:00
|
|
|
*/
|
|
|
|
|
2009-06-15 12:33:58 +00:00
|
|
|
#import "DetailsPanel.h"
|
2012-01-12 15:23:31 +00:00
|
|
|
#import "Utils.h"
|
2009-06-15 12:33:58 +00:00
|
|
|
|
2010-02-05 16:15:45 +00:00
|
|
|
@implementation DetailsPanel
|
2012-01-12 14:41:03 +00:00
|
|
|
- (id)init
|
2009-06-15 12:33:58 +00:00
|
|
|
{
|
2012-01-12 14:41:03 +00:00
|
|
|
self = [super initWithWindowNibName:@"DetailsPanel"];
|
2009-06-15 12:33:58 +00:00
|
|
|
[self window]; //So the detailsTable is initialized.
|
2012-01-12 19:23:10 +00:00
|
|
|
py = [[PyDetailsPanel alloc] initWithModel:findHackishModel(@"details_panel")];
|
|
|
|
[py bindCallback:createCallback(@"DetailsPanelView", self)];
|
2012-01-12 14:41:03 +00:00
|
|
|
[py connect];
|
2009-06-15 12:33:58 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-02-12 14:39:29 +00:00
|
|
|
- (void)dealloc
|
|
|
|
{
|
2012-01-12 14:41:03 +00:00
|
|
|
[py disconnect];
|
|
|
|
[py release];
|
2010-02-12 14:39:29 +00:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2010-02-07 15:19:14 +00:00
|
|
|
- (PyDetailsPanel *)py
|
2010-02-05 19:10:54 +00:00
|
|
|
{
|
2010-02-07 15:19:14 +00:00
|
|
|
return (PyDetailsPanel *)py;
|
2010-02-05 19:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)refreshDetails
|
2009-06-15 12:33:58 +00:00
|
|
|
{
|
|
|
|
[detailsTable reloadData];
|
|
|
|
}
|
2009-06-15 12:53:47 +00:00
|
|
|
|
2011-01-13 12:51:00 +00:00
|
|
|
- (BOOL)isVisible
|
|
|
|
{
|
|
|
|
return [[self window] isVisible];
|
|
|
|
}
|
|
|
|
|
2009-11-02 15:16:34 +00:00
|
|
|
- (void)toggleVisibility
|
|
|
|
{
|
2011-01-13 12:51:00 +00:00
|
|
|
if ([self isVisible]) {
|
2009-11-02 15:16:34 +00:00
|
|
|
[[self window] close];
|
2010-02-05 19:10:54 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
[self refreshDetails]; // selection might have changed since last time
|
2009-11-02 15:16:34 +00:00
|
|
|
[[self window] orderFront:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-05 19:10:54 +00:00
|
|
|
/* NSTableView Delegate */
|
|
|
|
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
|
2009-06-15 12:53:47 +00:00
|
|
|
{
|
2010-02-07 15:19:14 +00:00
|
|
|
return [[self py] numberOfRows];
|
2010-02-05 19:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)column row:(NSInteger)row
|
|
|
|
{
|
2010-02-07 15:19:14 +00:00
|
|
|
return [[self py] valueForColumn:[column identifier] row:row];
|
2010-02-05 19:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Python --> Cocoa */
|
|
|
|
- (void)refresh
|
|
|
|
{
|
|
|
|
if ([[self window] isVisible]) {
|
|
|
|
[self refreshDetails];
|
|
|
|
}
|
2009-06-15 12:53:47 +00:00
|
|
|
}
|
2009-06-15 12:33:58 +00:00
|
|
|
@end
|