/* BundleView.m Copyright (C) 2003 Author: Yen-Ju Chen This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "BundleView.h" #include #include #include #include #include #include #include @implementation BundleView - (id) initWithFrame: (NSRect) frame { NSTableColumn *nameColumn, *descColumn; NSScrollView *scrollView; self = [super initWithFrame: frame]; bundles = [[BundleLoader defaultLoader] allNamesOfBundles]; RETAIN(bundles); nameColumn = [[NSTableColumn alloc] initWithIdentifier: @"name"]; [nameColumn setEditable: NO]; [nameColumn setMinWidth: 20]; [[nameColumn headerCell] setStringValue: _(@"Name")]; descColumn = [[NSTableColumn alloc] initWithIdentifier: @"description"]; [descColumn setEditable: NO]; [descColumn setMinWidth: 40]; [[descColumn headerCell] setStringValue: _(@"Description")]; tableView = [[NSTableView alloc] initWithFrame: frame]; [tableView setDrawsGrid: NO]; [tableView addTableColumn: nameColumn]; [tableView addTableColumn: descColumn]; [tableView setAutoresizesAllColumnsToFit: YES]; [tableView setAllowsColumnSelection: NO]; [tableView setAllowsMultipleSelection: NO]; [tableView setAllowsEmptySelection: YES]; [tableView setTarget: self]; [tableView setDataSource: self]; [tableView setDelegate: self]; [tableView setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable]; RELEASE(nameColumn); RELEASE(descColumn); scrollView = [[NSScrollView alloc] initWithFrame: [self bounds]]; [scrollView setHasHorizontalScroller:YES]; [scrollView setHasVerticalScroller:YES]; [scrollView setBorderType: NSBezelBorder]; [scrollView setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)]; [scrollView setDocumentView: tableView]; RELEASE(tableView); [self addSubview: scrollView]; RELEASE(scrollView); return self; } - (void) dealloc { RELEASE(bundles); [super dealloc]; } - (void) reload { RELEASE(bundles); bundles = [[BundleLoader defaultLoader] allNamesOfBundles]; RETAIN(bundles); [tableView reloadData]; } - (int) numberOfRowsInTableView: (NSTableView *) view { return [bundles count]; } - (id) tableView: (NSTableView *) view objectValueForTableColumn: (NSTableColumn *) column row: (int) row { if ([[column identifier] isEqualToString: @"name"]) { // return [[bundles objectAtIndex: row] stringByDeletingPathExtension]; return [bundles objectAtIndex: row]; } else // Description { return [[[BundleLoader defaultLoader] classNameOf: [bundles objectAtIndex: row]] bundleDescription]; } } @end