2
GNUstep ProjectCenter - http://www.gnustep.org/experience/ProjectCenter.html
4
Copyright (C) 2000-2004 Free Software Foundation
6
Authors: Philippe C.D. Robert
9
This file is part of GNUstep.
11
This application is free software; you can redistribute it and/or
12
modify it under the terms of the GNU General Public
13
License as published by the Free Software Foundation; either
14
version 2 of the License, or (at your option) any later version.
16
This application is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
Library General Public License for more details.
21
You should have received a copy of the GNU General Public
22
License along with this library; if not, write to the Free
23
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
26
#import <ProjectCenter/PCEditorManager.h>
28
#import <ProjectCenter/PCSaveModified.h>
30
BOOL PCRunSaveModifiedFilesPanel(PCEditorManager *manager,
31
NSString *defaultText,
32
NSString *alternateText,
35
PCSaveModified *saveModifiedPanel;
38
if (!(saveModifiedPanel = [[PCSaveModified alloc] init]))
43
result = [saveModifiedPanel saveFilesWithEditorManager:manager
44
defaultButtonText:defaultText
45
alternateButtonText:alternateText
46
otherButtonText:otherText];
47
RELEASE(saveModifiedPanel);
53
@implementation PCSaveModified
55
- (BOOL)saveFilesWithEditorManager:(PCEditorManager *)manager
56
defaultButtonText:(NSString *)defaultText
57
alternateButtonText:(NSString *)alternateText
58
otherButtonText:(NSString *)otherText
60
if ([NSBundle loadNibNamed:@"SaveModified" owner:self] == NO)
62
NSLog(@"Error loading SaveModified NIB file!");
66
editorManager = manager;
69
[filesList setCornerView:nil];
70
[filesList setHeaderView:nil];
71
[filesList setDataSource:self];
72
[filesList setTarget:self];
73
[filesList selectAll:self];
74
[filesList reloadData];
77
[defaultButton setTitle:defaultText];
78
[alternateButton setTitle:alternateText];
79
[otherButton setTitle:otherText];
81
[panel makeKeyAndOrderFront:self];
83
[NSApp runModalForWindow:panel];
85
if (clickedButton == defaultButton)
87
[self saveSelectedFiles];
90
else if (clickedButton == alternateButton)
94
else if (clickedButton == otherButton)
105
NSLog(@"PCSaveModified: dealloc");
112
- (BOOL)saveSelectedFiles
114
NSArray *modifiedFiles = [editorManager modifiedFiles];
115
NSIndexSet *selectedRows = [filesList selectedRowIndexes];
116
NSArray *filesToSave = [modifiedFiles objectsAtIndexes:selectedRows];
117
NSEnumerator *enumerator = [filesToSave objectEnumerator];
118
NSString *filePath = nil;
120
NSLog(@"SaveModified|filesToSave: %@", filesToSave);
122
while ((filePath = [enumerator nextObject]))
124
[[editorManager editorForFile:filePath] saveFileIfNeeded];
130
- (void)buttonClicked:(id)sender
132
clickedButton = sender;
137
// ============================================================================
138
// ==== TableView delegate
139
// ============================================================================
140
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
142
if (aTableView != filesList)
147
return [[editorManager modifiedFiles] count];
150
- (id) tableView:(NSTableView *)aTableView
151
objectValueForTableColumn:(NSTableColumn *)aTableColumn
154
if (aTableView != filesList)
159
return [[[editorManager modifiedFiles] objectAtIndex:rowIndex] lastPathComponent];