Camino only - Bug 400639: Remove Advanced Font prefs sheet. Original patch by Christopher Henderson <trendyhendy2000@gmail.com>. r=alqahira sr=pink

git-svn-id: svn://10.0.0.236/branches/CAMINO_2_0_BRANCH@258385 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
stuart.morgan%alumni.case.edu
2009-09-15 01:34:29 +00:00
parent 1fe8d89bac
commit a5c655a402
6 changed files with 192 additions and 150 deletions

View File

@@ -62,16 +62,12 @@
IBOutlet NSTextField* mFontSampleMonospace;
IBOutlet NSTextField* mProportionalSampleLabel;
IBOutlet NSTextField* mProportionalSubLabel;
IBOutlet NSPopUpButton* mMinFontSizePopup;
IBOutlet NSMatrix* mDefaultFontMatrix;
IBOutlet NSButton* mUseMyFontsCheckbox;
// advanced panel stuff
IBOutlet NSPanel* mAdvancedFontsDialog;
IBOutlet NSPopUpButton* mMinFontSizePopup;
IBOutlet NSTextField* mAdvancedFontsLabel;
IBOutlet NSMatrix* mDefaultFontMatrix;
IBOutlet NSView* mPreviousBottomControl;
NSArray* mRegionMappingTable;
@@ -93,8 +89,8 @@
- (IBAction)monospaceFontChoiceButtonClicked:(id)sender;
- (IBAction)fontRegionPopupClicked:(id)sender;
- (IBAction)showAdvancedFontsDialog:(id)sender;
- (IBAction)advancedFontsDone:(id)sender;
- (IBAction)minFontSizePopupClicked:(id)sender;
- (IBAction)defaultFontTypeClicked:(id)sender;
- (IBAction)resetToDefaults:(id)sender;

View File

@@ -71,6 +71,7 @@
- (void)setFontSampleOfType:(NSString*)fontType withFont:(NSFont*)font andDict:(NSDictionary*)regionDict;
- (void)saveFont:(NSFont*)font toDict:(NSMutableDictionary*)regionDict forType:(NSString*)fontType;
- (void)updateAdvancedFontControls;
- (void)updateFontSampleOfType:(NSString*)fontType;
- (NSTextField*)fontSampleForType:(NSString*)fontType;
- (NSString*)fontSizeType:(NSString*)fontType;
@@ -130,13 +131,6 @@
[super dealloc];
}
- (id)initWithBundle:(NSBundle*)bundle
{
self = [super initWithBundle:bundle];
mFontButtonForEditor = nil;
return self;
}
- (void)mainViewDidLoad
{
// should save and restore this
@@ -162,6 +156,7 @@
[self loadFontPrefs];
[self updateFontPreviews];
[self updateAdvancedFontControls];
}
- (void)didUnselect
@@ -170,8 +165,28 @@
[self saveFontPrefs];
}
// The colors and fonts tab views are different heights. We need to resize
// the window when each is selected so the spacing looks correct.
- (void)tabView:(NSTabView*)tabView didSelectTabViewItem:(NSTabViewItem*)tabViewItem
{
NSControl* bottomControl = nil;
if ([[tabViewItem identifier] isEqualToString:@"colors"])
bottomControl = mUseMyColorsCheckbox;
else if ([[tabViewItem identifier] isEqualToString:@"fonts"])
bottomControl = mUseMyFontsCheckbox;
if (bottomControl && bottomControl != mPreviousBottomControl) {
NSWindow* prefsWindow = [mTabView window];
float heightChange = [mPreviousBottomControl frame].origin.y -
[bottomControl frame].origin.y;
NSRect windowFrame = [prefsWindow frame];
windowFrame.size.height += heightChange;
windowFrame.origin.y -= heightChange;
[prefsWindow setFrame:windowFrame display:YES animate:[prefsWindow isVisible]];
mPreviousBottomControl = bottomControl;
}
}
- (void)setupFontRegionPopup
@@ -248,6 +263,7 @@
{
// save the old values
[self updateFontPreviews];
[self updateAdvancedFontControls];
}
- (void)loadFontPrefs
@@ -656,15 +672,6 @@
NSString* propLabelString = [NSString stringWithFormat:[self localizedStringForKey:@"ProportionalLabelFormat"],
[self localizedStringForKey:defaultFontType]];
[mProportionalSampleLabel setStringValue:propLabelString];
NSString* sublabelValue = [self localizedStringForKey:[defaultFontType stringByAppendingString:@"_note"]];
[mProportionalSubLabel setStringValue:sublabelValue];
NSString* noteFontExample = [defaultFontType isEqualToString:@"serif"] ? @"Times" : @"Helvetica";
[mProportionalSubLabel setFont:[[NSFontManager sharedFontManager] fontWithFamily:noteFontExample
traits:0
weight:5 /* normal weight */
size:[[mProportionalSubLabel font] pointSize]]];
[self setupFontSamplesFromDict:regionDict];
}
@@ -674,15 +681,11 @@
const int kDefaultFontSerifTag = 0;
const int kDefaultFontSansSerifTag = 1;
- (IBAction)showAdvancedFontsDialog:(id)sender
- (void)updateAdvancedFontControls
{
NSDictionary* regionDict = [self settingsForCurrentRegion];
if (!regionDict) return;
NSString* advancedLabel = [NSString stringWithFormat:[self localizedStringForKey:@"AdditionalFontsLabelFormat"],
[regionDict objectForKey:@"region"]];
[mAdvancedFontsLabel setStringValue:advancedLabel];
// set up min size popup
int itemIndex = 0;
NSMutableDictionary* fontSizeDict = [regionDict objectForKey:@"fontsize"];
@@ -693,24 +696,14 @@ const int kDefaultFontSansSerifTag = 1;
itemIndex = 0;
}
[mMinFontSizePopup selectItemAtIndex:itemIndex];
// set up default font radio buttons (default to serif)
NSString* defaultFontType = [self defaultProportionalFontTypeForCurrentRegion];
[mDefaultFontMatrix selectCellWithTag:([defaultFontType isEqualToString:@"sans-serif"] ? kDefaultFontSansSerifTag : kDefaultFontSerifTag)];
mFontPanelWasVisible = [[NSFontPanel sharedFontPanel] isVisible];
[[NSFontPanel sharedFontPanel] orderOut:nil];
[NSApp beginSheet:mAdvancedFontsDialog
modalForWindow:[mTabView window] // any old window accessor
modalDelegate:self
didEndSelector:@selector(advancedFontsSheetDidEnd:returnCode:contextInfo:)
contextInfo:NULL];
}
- (IBAction)advancedFontsDone:(id)sender
- (IBAction)minFontSizePopupClicked:(id)sender
{
// save settings
NSDictionary* regionDict = [self settingsForCurrentRegion];
if (!regionDict) return;
@@ -719,21 +712,21 @@ const int kDefaultFontSansSerifTag = 1;
NSMutableDictionary* fontSizeDict = [regionDict objectForKey:@"fontsize"];
[fontSizeDict setObject:[NSNumber numberWithInt:(int)minSize] forKey:@"minimum"];
// Save the default font type.
[self saveFontSizePrefsForRegion:regionDict];
[self updateFontPreviews];
}
- (IBAction)defaultFontTypeClicked:(id)sender
{
NSDictionary* regionDict = [self settingsForCurrentRegion];
if (!regionDict) return;
NSMutableDictionary* defaultFontTypeDict = [regionDict objectForKey:@"defaultFontType"];
NSString* defaultFontType = ([[mDefaultFontMatrix selectedCell] tag] == kDefaultFontSerifTag) ? @"serif" : @"sans-serif";
[defaultFontTypeDict setObject:defaultFontType forKey:@"type"];
[mAdvancedFontsDialog orderOut:self];
[NSApp endSheet:mAdvancedFontsDialog];
// Apply the changes for the current region.
[self saveAllFontPrefsForRegion:regionDict];
[self saveDefaultFontTypePrefForRegion:regionDict];
[self updateFontPreviews];
if (mFontPanelWasVisible)
[[NSFontPanel sharedFontPanel] makeKeyAndOrderFront:self];
}
- (IBAction)resetToDefaults:(id)sender {
@@ -798,13 +791,10 @@ const int kDefaultFontSansSerifTag = 1;
// Update the UI. Order is important here -- syncing the font panel depends on the
// font previews being correct.
[self updateFontPreviews];
[self updateAdvancedFontControls];
[mUseMyFontsCheckbox setState:[self useMyFontsPref]];
}
- (void)advancedFontsSheetDidEnd:(NSWindow*)sheet returnCode:(int)returnCode contextInfo:(void*)contextInfo
{
}
@end
@implementation OrgMozillaCaminoPreferenceAppearance (FontManagerDelegate)
@@ -839,10 +829,6 @@ const int kDefaultFontSansSerifTag = 1;
- (void)changeFont:(id)sender
{
// Ignore font panel changes if the advanced panel is up.
if ([mAdvancedFontsDialog isVisible])
return;
NSDictionary* regionDict = [self settingsForCurrentRegion];
if (mFontButtonForEditor == mChooseProportionalFontButton) {

View File

@@ -1,83 +1,144 @@
{
IBClasses = (
{
CLASS = FirstResponder;
LANGUAGE = ObjC;
SUPERCLASS = NSObject;
},
{
CLASS = NSMenu;
LANGUAGE = ObjC;
SUPERCLASS = NSObject;
},
{
CLASS = NSMenuItem;
LANGUAGE = ObjC;
SUPERCLASS = NSObject;
},
{
CLASS = NSObject;
LANGUAGE = ObjC;
},
{
CLASS = NSPreferencePane;
LANGUAGE = ObjC;
OUTLETS = {
"_firstKeyView" = id;
"_initialKeyView" = id;
"_lastKeyView" = id;
"_window" = id;
};
SUPERCLASS = NSObject;
},
{
CLASS = NSView;
LANGUAGE = ObjC;
SUPERCLASS = NSResponder;
},
{
ACTIONS = {
advancedFontsDone = id;
buttonClicked = id;
colorChanged = id;
fontRegionPopupClicked = id;
monospaceFontChoiceButtonClicked = id;
proportionalFontChoiceButtonClicked = id;
resetToDefaults = id;
showAdvancedFontsDialog = id;
useMyFontsButtonClicked = id;
};
CLASS = OrgMozillaCaminoPreferenceAppearance;
LANGUAGE = ObjC;
OUTLETS = {
mAdvancedFontsDialog = NSPanel;
mAdvancedFontsLabel = NSTextField;
mBackgroundColorWell = NSColorWell;
mChooseMonospaceFontButton = NSButton;
mChooseProportionalFontButton = NSButton;
mDefaultFontMatrix = NSMatrix;
mFontRegionPopup = NSPopUpButton;
mFontSampleMonospace = NSTextField;
mFontSampleProportional = NSTextField;
mMinFontSizePopup = NSPopUpButton;
mProportionalSampleLabel = NSTextField;
mProportionalSubLabel = NSTextField;
mResetButton = NSButton;
mTabView = NSTabView;
mTextColorWell = NSColorWell;
mUnderlineLinksCheckbox = NSButton;
mUnvisitedLinksColorWell = NSColorWell;
mUseMyColorsCheckbox = NSButton;
mUseMyFontsCheckbox = NSButton;
mVisitedLinksColorWell = NSColorWell;
};
SUPERCLASS = PreferencePaneBase;
},
{
CLASS = PreferencePaneBase;
LANGUAGE = ObjC;
SUPERCLASS = NSPreferencePane;
}
);
IBVersion = 1;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBClasses</key>
<array>
<dict>
<key>CLASS</key>
<string>PreferencePaneBase</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSPreferencePane</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSView</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSResponder</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSMenuItem</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSMenu</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>FirstResponder</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSObject</string>
<key>LANGUAGE</key>
<string>ObjC</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSPreferencePane</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>_firstKeyView</key>
<string>id</string>
<key>_initialKeyView</key>
<string>id</string>
<key>_lastKeyView</key>
<string>id</string>
<key>_window</key>
<string>id</string>
</dict>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>buttonClicked</key>
<string>id</string>
<key>colorChanged</key>
<string>id</string>
<key>defaultFontTypeClicked</key>
<string>id</string>
<key>fontRegionPopupClicked</key>
<string>id</string>
<key>minFontSizePopupClicked</key>
<string>id</string>
<key>monospaceFontChoiceButtonClicked</key>
<string>id</string>
<key>proportionalFontChoiceButtonClicked</key>
<string>id</string>
<key>resetToDefaults</key>
<string>id</string>
<key>useMyFontsButtonClicked</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>OrgMozillaCaminoPreferenceAppearance</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>mBackgroundColorWell</key>
<string>NSColorWell</string>
<key>mChooseMonospaceFontButton</key>
<string>NSButton</string>
<key>mChooseProportionalFontButton</key>
<string>NSButton</string>
<key>mDefaultFontMatrix</key>
<string>NSMatrix</string>
<key>mFontRegionPopup</key>
<string>NSPopUpButton</string>
<key>mFontSampleMonospace</key>
<string>NSTextField</string>
<key>mFontSampleProportional</key>
<string>NSTextField</string>
<key>mMinFontSizePopup</key>
<string>NSPopUpButton</string>
<key>mPreviousBottomControl</key>
<string>NSView</string>
<key>mProportionalSampleLabel</key>
<string>NSTextField</string>
<key>mResetButton</key>
<string>NSButton</string>
<key>mTabView</key>
<string>NSTabView</string>
<key>mTextColorWell</key>
<string>NSColorWell</string>
<key>mUnderlineLinksCheckbox</key>
<string>NSButton</string>
<key>mUnvisitedLinksColorWell</key>
<string>NSColorWell</string>
<key>mUseMyColorsCheckbox</key>
<string>NSButton</string>
<key>mUseMyFontsCheckbox</key>
<string>NSButton</string>
<key>mVisitedLinksColorWell</key>
<string>NSColorWell</string>
</dict>
<key>SUPERCLASS</key>
<string>PreferencePaneBase</string>
</dict>
</array>
<key>IBVersion</key>
<string>1</string>
</dict>
</plist>

View File

@@ -2,16 +2,18 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>69 14 356 240 0 0 1440 878 </string>
<key>IBFramework Version</key>
<string>489.0</string>
<string>677</string>
<key>IBLastKnownRelativeProjectPath</key>
<string>../../../Camino.xcodeproj</string>
<key>IBOldestOS</key>
<integer>4</integer>
<key>IBOpenObjects</key>
<array>
<integer>107</integer>
</array>
<key>IBSystem Version</key>
<string>9J61</string>
<string>9L31a</string>
<key>targetFramework</key>
<string>IBCocoaFramework</string>
</dict>

View File

@@ -5,9 +5,6 @@
"ProportionalLabelFormat" = "Proportional (%@):";
"serif" = "Serif";
"sans-serif" = "Sans-serif";
"AdditionalFontsLabelFormat" = "Additional fonts for %@ pages";
"serif_note" = "(like Times)";
"sans-serif_note" = "(like Helvetica)";
/* Displayed when there is no font specified in prefs for a given language group and type */
"NoFontSelected" = "No font selected";