mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 06:00:44 +00:00
Revamped the preferences a little more.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@18636 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
211333bf98
commit
2e59ae0924
7 changed files with 98 additions and 43 deletions
|
@ -1,3 +1,12 @@
|
|||
2004-02-21 01:41 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormHeaderPref.m: Fixed header pre-loading.
|
||||
* GormHeaderPref.gorm: Added table instead of browser.
|
||||
* Palettes/3Containers/GormTableViewEditor.m: Removed
|
||||
some debugging information.
|
||||
* GormPrefGeneral.gorm: Added section for archive type
|
||||
preferences.
|
||||
|
||||
2004-02-19 00:50 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormDocument.m: -[GormDocument handleNotification:]
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
@interface GormHeadersPref : NSObject
|
||||
{
|
||||
id preloadButton;
|
||||
id browser;
|
||||
id table;
|
||||
id addButton;
|
||||
id removeButton;
|
||||
id window;
|
||||
|
|
|
@ -3,14 +3,41 @@
|
|||
#include <Foundation/NSUserDefaults.h>
|
||||
|
||||
#include <AppKit/NSButton.h>
|
||||
#include <AppKit/NSBrowser.h>
|
||||
#include <AppKit/NSTableView.h>
|
||||
#include <AppKit/NSWindow.h>
|
||||
#include <AppKit/NSNibLoading.h>
|
||||
#include <AppKit/NSOpenPanel.h>
|
||||
#include <AppKit/NSStringDrawing.h>
|
||||
|
||||
// data source...
|
||||
@interface HeaderDataSource : NSObject
|
||||
@end
|
||||
|
||||
@implementation HeaderDataSource
|
||||
- (int) numberOfRowsInTableView: (NSTableView *)tv
|
||||
{
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSArray *list = [defaults objectForKey: @"HeaderList"];
|
||||
return [list count];
|
||||
}
|
||||
|
||||
- (id) tableView: (NSTableView *)tv
|
||||
objectValueForTableColumn: (NSTableColumn *)tc
|
||||
row: (int)rowIndex
|
||||
{
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSArray *list = [defaults objectForKey: @"HeaderList"];
|
||||
id value = nil; // NSFontAttributeName
|
||||
if([list count] > 0)
|
||||
{
|
||||
value = [[list objectAtIndex: rowIndex] lastPathComponent];
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation GormHeadersPref
|
||||
|
||||
|
||||
- (id) init
|
||||
{
|
||||
_view = nil;
|
||||
|
@ -39,7 +66,6 @@
|
|||
return _view;
|
||||
}
|
||||
|
||||
|
||||
- (void) addAction: (id)sender
|
||||
{
|
||||
NSArray *fileTypes = [NSArray arrayWithObjects: @"h", @"H", nil];
|
||||
|
@ -54,48 +80,61 @@
|
|||
types: fileTypes];
|
||||
if (result == NSOKButton)
|
||||
{
|
||||
[headers addObjectsFromArray: [openPanel filenames]];
|
||||
[browser reloadColumn: 0];
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSMutableArray *list = [defaults objectForKey: @"HeaderList"];
|
||||
[list addObjectsFromArray: [openPanel filenames]];
|
||||
[defaults setObject: list forKey: @"HeaderList"];
|
||||
[table reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) removeAction: (id)sender
|
||||
{
|
||||
NSCell *cell = [browser selectedCellInColumn: 0];
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSMutableArray *list = [defaults objectForKey: @"HeaderList"];
|
||||
int row = [table selectedRow];
|
||||
|
||||
if(cell != nil)
|
||||
if(row >= 0)
|
||||
{
|
||||
NSString *stringValue = [NSString stringWithString: [cell stringValue]];
|
||||
[headers removeObject: stringValue];
|
||||
[browser reloadColumn: 0];
|
||||
NSLog(@"Header removed");
|
||||
NSString *stringValue = [list objectAtIndex: row];
|
||||
|
||||
if(stringValue != nil)
|
||||
{
|
||||
[list removeObject: stringValue];
|
||||
[table reloadData];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) preloadAction: (id)sender
|
||||
{
|
||||
if (sender != preloadButton)
|
||||
return;
|
||||
|
||||
{
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
[defaults setInteger:[preloadButton state] forKey:@"BACKUPFILE"];
|
||||
[defaults synchronize];
|
||||
if ( [preloadButton state] == NSOnState )
|
||||
{
|
||||
[addButton setEnabled:YES];
|
||||
[removeButton setEnabled: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[addButton setEnabled:NO];
|
||||
[removeButton setEnabled:NO];
|
||||
}
|
||||
}
|
||||
if (sender != preloadButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
[defaults setBool: ([preloadButton state] == NSOnState?YES:NO) forKey:@"PreloadHeaders"];
|
||||
[defaults synchronize];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) tableView: (NSTableView *)tableView
|
||||
shouldEditTableColumn: (NSTableColumn *)aTableColumn
|
||||
row: (int)rowIndex
|
||||
{
|
||||
BOOL result = NO;
|
||||
return result;
|
||||
}
|
||||
|
||||
- (BOOL) tableView: (NSTableView *)tv
|
||||
shouldSelectRow: (int)rowIndex
|
||||
{
|
||||
BOOL result = YES;
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -136,19 +136,19 @@ static NSText *_textObject;
|
|||
*/
|
||||
- (void) deleteSelection
|
||||
{
|
||||
NSLog(@"deleteSelection");
|
||||
NSDebugLog(@"deleteSelection");
|
||||
if ([selection count] == 0)
|
||||
{
|
||||
NSLog(@"no column to delete");
|
||||
NSDebugLog(@"no column to delete");
|
||||
}
|
||||
else
|
||||
if ([tableView numberOfColumns] <= 1)
|
||||
{
|
||||
NSLog(@"can't delete last column");
|
||||
NSDebugLog(@"can't delete last column");
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"FIXME: remove the tableColumn from toplevel"); // FIXME
|
||||
NSDebugLog(@"FIXME: remove the tableColumn from toplevel"); // FIXME
|
||||
[tableView removeTableColumn: [selection objectAtIndex: 0]];
|
||||
[tableView deselectAll: self];
|
||||
[self selectObjects: [NSArray array]];
|
||||
|
@ -160,7 +160,7 @@ static NSText *_textObject;
|
|||
*/
|
||||
- (void) copySelection
|
||||
{
|
||||
NSLog(@"copySelection");
|
||||
NSDebugLog(@"copySelection");
|
||||
if ([[[self selection] objectAtIndex: 0]
|
||||
isKindOfClass: [NSTableColumn class]])
|
||||
{
|
||||
|
@ -170,7 +170,7 @@ static NSText *_textObject;
|
|||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"no paste");
|
||||
NSDebugLog(@"no paste");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ static NSText *_textObject;
|
|||
- (void) pasteInSelection
|
||||
{
|
||||
NSArray *objects;
|
||||
NSLog(@"pasteInSelection");
|
||||
NSDebugLog(@"pasteInSelection");
|
||||
|
||||
|
||||
objects = [document pasteType: IBTableColumnPboardType
|
||||
|
@ -196,12 +196,12 @@ static NSText *_textObject;
|
|||
|
||||
if ([objects count] > 1)
|
||||
{
|
||||
NSLog(@"warning strange behaviour : GormTableViewEditor pasteInSelection");
|
||||
NSDebugLog(@"warning strange behaviour : GormTableViewEditor pasteInSelection");
|
||||
}
|
||||
else if ([[objects objectAtIndex: 0] isKindOfClass: [NSTableColumn class]]
|
||||
== NO)
|
||||
{
|
||||
NSLog(@"invalid data in IBTableColumnPboardType");
|
||||
NSDebugLog(@"invalid data in IBTableColumnPboardType");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ static NSText *_textObject;
|
|||
|
||||
if (opened == NO)
|
||||
{
|
||||
NSLog(@"not opened");
|
||||
NSDebugLog(@"not opened");
|
||||
[super mouseDown: theEvent];
|
||||
return;
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -150,10 +150,17 @@
|
|||
);
|
||||
Outlets = (
|
||||
preloadButton,
|
||||
browser,
|
||||
addButton,
|
||||
removeButton,
|
||||
window
|
||||
window,
|
||||
table
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
HeaderDataSource = {
|
||||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue