Provide Editor and Fixed font preferences, instead of plain and rich

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@38395 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Riccardo Mottola 2015-03-11 07:21:35 +00:00
parent a180a70e83
commit 35b76bb231
4 changed files with 76 additions and 64 deletions

View file

@ -1,9 +1,10 @@
//
// GNUstep ProjectCenter - http://www.gnustep.org/experience/ProjectCenter.html
//
// Copyright (C) 2001-2009 Free Software Foundation
// Copyright (C) 2001-2015 Free Software Foundation
//
// Authors: Sergii Stoian
// Riccardo Mottola
//
// Description:
//
@ -26,10 +27,10 @@
#import <AppKit/AppKit.h>
#import <Protocols/Preferences.h>
#define EditorPlainTextFont @"EditorPlainTextFont"
#define EditorPlainTextFontSize @"EditorPlainTextFontSize"
#define EditorRichTextFont @"EditorRichTextFont"
#define EditorRichTextFontSize @"EditorRichTextFontSize"
#define EditorTextFont @"EditorTextFont"
#define EditorTextFontSize @"EditorTextFontSize"
#define ConsoleFixedFont @"ConsoleFixedFont"
#define ConsoleFixedFontSize @"ConsoleFixedFontSize"
#define EditorLines @"EditorLines"
#define EditorColumns @"EditorColumns"
@ -45,10 +46,10 @@
IBOutlet NSBox *editorFSCView;
IBOutlet NSButton *plainTextFontButton;
IBOutlet NSTextField *plainTextFontField;
IBOutlet NSButton *richTextFontButton;
IBOutlet NSTextField *richTextFontField;
IBOutlet NSButton *editorFontButton;
IBOutlet NSTextField *editorFontField;
IBOutlet NSButton *consoleFixedFontButton;
IBOutlet NSTextField *consoleFixedFontField;
IBOutlet NSTextField *editorLinesField;
IBOutlet NSTextField *editorColumnsField;
@ -57,15 +58,15 @@
IBOutlet NSColorWell *backgroundColorWell;
IBOutlet NSColorWell *selectionColorWell;
NSFont *currentPlainFont;
NSFont *currentRichFont;
NSFont *currentEditorFont;
NSFont *currentConsoleFixedFont;
NSColor *currentBackgroundColor;
NSColor *currentForegroundColor;
NSColor *currentSelectionColor;
}
- (void)setEditorPlainTextFont:(id)sender;
- (void)setEditorRichTextFont:(id)sender;
- (void)setEditorTextFont:(id)sender;
- (void)setConsoleFixedFont:(id)sender;
- (void)setEditorSize:(id)sender;
- (void)setEditorColor:(id)sender;

View file

@ -1,9 +1,10 @@
//
// GNUstep ProjectCenter - http://www.gnustep.org/experience/ProjectCenter.html
//
// Copyright (C) 2001-2009 Free Software Foundation
// Copyright (C) 2001-2015 Free Software Foundation
//
// Authors: Sergii Stoian
// Riccardo Mottola
//
// Description:
//
@ -67,8 +68,8 @@
}
prefs = aPrefs;
currentPlainFont = nil;
currentRichFont = nil;
currentEditorFont = nil;
currentConsoleFixedFont = nil;
RETAIN(editorFSCView);
@ -90,11 +91,11 @@
- (void)awakeFromNib
{
[plainTextFontButton setTarget:self];
[plainTextFontField setAllowsEditingTextAttributes:YES];
[editorFontButton setTarget:self];
[editorFontField setAllowsEditingTextAttributes:YES];
[richTextFontButton setTarget:self];
[richTextFontField setAllowsEditingTextAttributes:YES];
[consoleFixedFontButton setTarget:self];
[consoleFixedFontField setAllowsEditingTextAttributes:YES];
}
// ----------------------------------------------------------------------------
@ -105,7 +106,7 @@
{
NSFontManager *fontManager = [NSFontManager sharedFontManager];
[fontManager setSelectedFont:currentPlainFont isMultiple:NO];
[fontManager setSelectedFont:currentEditorFont isMultiple:NO];
[fontManager orderFrontFontPanel:self];
}
@ -121,27 +122,27 @@
return;
}
font = [sender convertFont:currentPlainFont];
font = [sender convertFont:currentEditorFont];
fontString = [NSString stringWithFormat:@"%@ %0.1f",
[font fontName], [font pointSize]];
buttonTag = [button tag];
if (buttonTag == 0) // plain text font button
if (buttonTag == 0) // Editor font button
{
[plainTextFontField setStringValue:fontString];
[plainTextFontField setFont:font];
[prefs setString:[font fontName] forKey:EditorPlainTextFont notify:YES];
[editorFontField setStringValue:fontString];
[editorFontField setFont:font];
[prefs setString:[font fontName] forKey:EditorTextFont notify:YES];
[prefs setFloat:[font pointSize]
forKey:EditorPlainTextFontSize
forKey:EditorTextFontSize
notify:YES];
}
else if (buttonTag == 1) // rich text font button
else if (buttonTag == 1) // Console Fixed Font button
{
[richTextFontField setStringValue:fontString];
[richTextFontField setFont:font];
[prefs setString:[font fontName] forKey:EditorRichTextFont notify:YES];
[consoleFixedFontField setStringValue:fontString];
[consoleFixedFontField setFont:font];
[prefs setString:[font fontName] forKey:ConsoleFixedFont notify:YES];
[prefs setFloat:[font pointSize]
forKey:EditorRichTextFontSize
forKey:ConsoleFixedFontSize
notify:YES];
}
}
@ -180,29 +181,29 @@
{
NSString *fontName;
float fontSize;
NSFont *plainFont = [NSFont userFixedPitchFontOfSize:0.0];
NSFont *richFont = [NSFont systemFontOfSize:0.0];
NSFont *editorFont = [NSFont userFixedPitchFontOfSize:0.0];
NSFont *consoleFixedFont = [NSFont userFixedPitchFontOfSize:0.0];
NSString *val;
// Plain text font
fontName = [prefs stringForKey:EditorPlainTextFont
defaultValue:[plainFont fontName]];
fontSize = [prefs floatForKey:EditorPlainTextFontSize
defaultValue:[plainFont pointSize]];
currentPlainFont = [NSFont fontWithName:fontName size:fontSize];
[plainTextFontField setStringValue:[NSString stringWithFormat:@"%@ %0.1f",
[currentPlainFont fontName], [currentPlainFont pointSize]]];
[plainTextFontField setFont:currentPlainFont];
// Editor font
fontName = [prefs stringForKey:EditorTextFont
defaultValue:[editorFont fontName]];
fontSize = [prefs floatForKey:EditorTextFontSize
defaultValue:[editorFont pointSize]];
currentEditorFont = [NSFont fontWithName:fontName size:fontSize];
[editorFontField setStringValue:[NSString stringWithFormat:@"%@ %0.1f",
[currentEditorFont fontName], [currentEditorFont pointSize]]];
[editorFontField setFont:currentEditorFont];
// Rich text font
fontName = [prefs stringForKey:EditorRichTextFont
defaultValue:[richFont fontName]];
fontSize = [prefs floatForKey:EditorRichTextFontSize
defaultValue:[richFont pointSize]];
currentRichFont = [NSFont fontWithName:fontName size:fontSize];
[richTextFontField setStringValue:[NSString stringWithFormat:@"%@ %0.1f",
[currentRichFont fontName], [currentRichFont pointSize]]];
[richTextFontField setFont:currentRichFont];
// Console fixed font
fontName = [prefs stringForKey:ConsoleFixedFont
defaultValue:[consoleFixedFont fontName]];
fontSize = [prefs floatForKey:ConsoleFixedFontSize
defaultValue:[consoleFixedFont pointSize]];
consoleFixedFont = [NSFont fontWithName:fontName size:fontSize];
[consoleFixedFontField setStringValue:[NSString stringWithFormat:@"%@ %0.1f",
[currentConsoleFixedFont fontName], [currentConsoleFixedFont pointSize]]];
[consoleFixedFontField setFont:currentConsoleFixedFont];
// Editor window size
val = [prefs stringForKey:EditorLines defaultValue:@"30"];
@ -233,16 +234,16 @@
// --- Actions
// ----------------------------------------------------------------------------
- (void)setEditorPlainTextFont:(id)sender
- (void)setEditorTextFont:(id)sender
{
[[editorFSCView window] makeFirstResponder:plainTextFontButton];
[self pickFont:currentPlainFont];
[[editorFSCView window] makeFirstResponder:editorFontButton];
[self pickFont:currentEditorFont];
}
- (void)setEditorRichTextFont:(id)sender
- (void)setConsoleFixedFont:(id)sender
{
[[editorFSCView window] makeFirstResponder:richTextFontButton];
[self pickFont:currentRichFont];
[[editorFSCView window] makeFirstResponder:consoleFixedFontButton];
[self pickFont:currentConsoleFixedFont];
}
- (void)setEditorSize:(id)sender

View file

@ -1,18 +1,28 @@
{
"## Comment" = "Do NOT change this file, Gorm maintains it";
FirstResponder = {
Actions = (
"setConsoleFixedFont:",
"setEditorColor:",
"setEditorSize:",
"setEditorTextFont:"
);
Super = NSObject;
};
PCEditorFSCPrefs = {
Actions = (
"setEditorPlainTextFont:",
"setEditorRichTextFont:",
"setEditorTextFont:",
"setConsoleFixedFont:",
"setEditorSize:",
"setEditorColor:"
);
Outlets = (
prefs,
editorFSCView,
plainTextFontButton,
plainTextFontField,
richTextFontButton,
richTextFontField,
editorFontButton,
editorFontField,
consoleFixedFontButton,
consoleFixedFontField,
editorLinesField,
editorColumnsField,
foregroundColorWell,