dev.stuconnolly.com / svn / safaritabs

  1. /*
  2.  *  $Id: STTableViewDelegate.m 224 2011-08-13 20:39:45Z stuart $
  3.  *
  4.  *  SafariTabs
  5.  *  http://stuconnolly.com/projects/safaritabs/
  6.  *
  7.  *  Copyright (c) 2010 Stuart Connolly. All rights reserved.
  8.  *
  9.  *  This program is free software: you can redistribute it and/or modify
  10.  *  it under the terms of the GNU General Public License as published by
  11.  *  the Free Software Foundation, either version 3 of the License, or
  12.  *  (at your option) any later version.
  13.  *
  14.  *  This program is distributed in the hope that it will be useful,
  15.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17.  *  GNU General Public License for more details.
  18.  *
  19.  *  You should have received a copy of the GNU General Public License
  20.  *  along with this program. If not, see <http://www.gnu.org/licenses/>.
  21.  */
  22.  
  23. #import "STTableViewDelegate.h"
  24. #import "STSessionRestoreTextFieldCell.h"
  25. #import "STSessionRestoreTab.h"
  26.  
  27. #import "STConstants.h"
  28. #import "STUtilities.h"
  29.  
  30. @implementation STSessionRestoreController (STTableViewDelegate)
  31.  
  32. - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
  33. {
  34.     return [_sessionRestoreTabs count];
  35. }
  36.  
  37. - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)i
  38. {          
  39.     return [[_sessionRestoreTabs objectAtIndex:i] valueForKey:[tableColumn identifier]];    
  40. }
  41.  
  42. - (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)i
  43. {
  44.     STSessionRestoreTab *tab = [_sessionRestoreTabs objectAtIndex:i];
  45.    
  46.     if ([[tableColumn identifier] isEqualToString:STTableViewTabTitleColumnIdentifier]) {
  47.         NSImage *image = [[NSImage alloc] initByReferencingFile:[STPluginBundle() pathForResource:@"Tab" ofType:@"tiff"]];
  48.        
  49.         [cell setImage:image];
  50.         [cell setElementName:[tab tabTitle]];
  51.         [cell setElementAddress:[[tab tabURL] absoluteString]];
  52.        
  53.         [image release];
  54.     }
  55. }
  56.  
  57. - (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)i
  58. {  
  59.     [[_sessionRestoreTabs objectAtIndex:i] setValue:object forKey:[tableColumn identifier]];
  60.    
  61.     [self updateUserInterface];
  62. }
  63.  
  64. @end
  65.