Index: trunk/Cocoa/Pester/Source/PSAlarmsController.m
===================================================================
--- trunk/Cocoa/Pester/Source/PSAlarmsController.m	(revision 53)
+++ trunk/Cocoa/Pester/Source/PSAlarmsController.m	(revision 102)
@@ -10,4 +10,5 @@
 #import "PSAlarm.h"
 #import "PSAlerts.h"
+#import "NSString-NJRExtensions.h"
 #import "NSTableView-NJRExtensions.h"
 #import "NJRTableView.h"
@@ -18,5 +19,5 @@
 - (void)alarmsChanged;
 {
-    reorderedAlarms = [[tableView delegate] reorderedDataForData: [alarms alarms]];
+    reorderedAlarms = [[alarmList delegate] reorderedDataForData: [alarms alarms]];
 }
 
@@ -34,18 +35,25 @@
            }
         [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(alarmsChanged) name: PSAlarmsDidChangeNotification object: alarms];
-        [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(tableViewSelectionDidChange:) name: NSTableViewSelectionDidChangeNotification object: tableView];
-        [tableView setAutosaveName: @"Alarm list"];
-        [tableView setAutosaveTableColumns: YES];
+        [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(tableViewSelectionDidChange:) name: NSTableViewSelectionDidChangeNotification object: alarmList];
+        messageAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: [[[alarmList tableColumnWithIdentifier: @"message"] dataCell] font], NSFontAttributeName, nil];
+        [alarmList setAutosaveName: @"Alarm list"];
+        [alarmList setAutosaveTableColumns: YES];
         [self alarmsChanged];
-        [[self window] makeFirstResponder: tableView];
-        [[self window] setResizeIncrements: NSMakeSize(1, [tableView cellHeight])];
+        [[self window] makeFirstResponder: alarmList];
+        [[self window] setResizeIncrements: NSMakeSize(1, [alarmList cellHeight])];
     }
     return self;
 }
 
+- (void)dealloc;
+{
+    [reorderedAlarms release];
+    [messageAttributes release];
+    [super dealloc];
+}
 
 - (IBAction)remove:(id)sender;
 {
-    [alarms removeAlarms: [[tableView delegate] selectedItems]];
+    [alarms removeAlarms: [[alarmList delegate] selectedItems]];
 }
 
@@ -63,6 +71,9 @@
     PSAlarm *alarm = [reorderedAlarms objectAtIndex: row];
 
-    if ([[tableColumn identifier] isEqualToString: @"message"]) return [alarm message];
-    else {
+    if ([[tableColumn identifier] isEqualToString: @"message"]) {
+        NSMutableString *message = [[alarm message] mutableCopy];
+        [message truncateToWidth: [tableView frameOfCellAtColumn: 0 row: row].size.width by: NSLineBreakByTruncatingTail withAttributes: messageAttributes];
+        return [message autorelease];
+    } else {
         NSCalendarDate *date = [alarm date];
         if ([[tableColumn identifier] isEqualToString: @"date"]) return [alarm shortDateString];
@@ -96,5 +107,5 @@
 - (void)tableViewSelectionDidChange:(NSNotification *)aNotification;
 {
-    [removeButton setEnabled: ([tableView numberOfSelectedRows] != 0)];
+    [removeButton setEnabled: ([alarmList numberOfSelectedRows] != 0)];
 }
 
@@ -115,7 +126,7 @@
 - (NSRect)windowWillUseStandardFrame:(NSWindow *)sender defaultFrame:(NSRect)defaultFrame;
 {
-    NSWindow *window = [tableView window];
+    NSWindow *window = [alarmList window];
     NSRect frame = [window frame];
-    NSScrollView *scrollView = [tableView enclosingScrollView];
+    NSScrollView *scrollView = [alarmList enclosingScrollView];
     float displayedHeight = [[scrollView contentView] bounds].size.height;
     float heightChange = [[scrollView documentView] bounds].size.height - displayedHeight;
@@ -124,6 +135,6 @@
     if (heightChange >= 0 && heightChange <= 1) {
         // either the window is already optimal size, or it's too big
-        float rowHeight = [tableView cellHeight];
-        heightChange = (rowHeight * [tableView numberOfRows]) - displayedHeight;
+        float rowHeight = [alarmList cellHeight];
+        heightChange = (rowHeight * [alarmList numberOfRows]) - displayedHeight;
     }
 
