You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

80 lines
1.6 KiB

  1. /*
  2. Copyright 2017 Virgil Dupras
  3. This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
  4. which should be included with this package. The terms are also available at
  5. http://www.gnu.org/licenses/gpl-3.0.html
  6. */
  7. #import "DetailsPanel.h"
  8. #import "HSPyUtil.h"
  9. @implementation DetailsPanel
  10. @synthesize detailsTable;
  11. - (id)initWithPyRef:(PyObject *)aPyRef
  12. {
  13. self = [super initWithWindowNibName:[self getWindowNibName]];
  14. model = [[PyDetailsPanel alloc] initWithModel:aPyRef];
  15. [model bindCallback:createCallback(@"DetailsPanelView", self)];
  16. return self;
  17. }
  18. - (void)dealloc
  19. {
  20. [model release];
  21. [super dealloc];
  22. }
  23. - (PyDetailsPanel *)model
  24. {
  25. return (PyDetailsPanel *)model;
  26. }
  27. - (NSString *)getWindowNibName
  28. {
  29. return @"DetailsPanel";
  30. }
  31. - (void)refreshDetails
  32. {
  33. [detailsTable reloadData];
  34. }
  35. - (BOOL)isVisible
  36. {
  37. return [[self window] isVisible];
  38. }
  39. - (void)toggleVisibility
  40. {
  41. if ([self isVisible]) {
  42. [[self window] close];
  43. }
  44. else {
  45. [self refreshDetails]; // selection might have changed since last time
  46. [[self window] orderFront:nil];
  47. }
  48. }
  49. /* NSTableView Delegate */
  50. - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
  51. {
  52. return [[self model] numberOfRows];
  53. }
  54. - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)column row:(NSInteger)row
  55. {
  56. return [[self model] valueForColumn:[column identifier] row:row];
  57. }
  58. /* Python --> Cocoa */
  59. - (void)refresh
  60. {
  61. if ([[self window] isVisible]) {
  62. [self refreshDetails];
  63. }
  64. }
  65. @end