rename navigation pref pane to "General", also remove multiple pane view and default to "General". no bug, sr=pinkerton

git-svn-id: svn://10.0.0.236/trunk@167703 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
joshmoz%gmail.com
2005-01-14 01:40:13 +00:00
parent bbc4adb2b5
commit c9e50f64bc
12 changed files with 43 additions and 1048 deletions

View File

@@ -222,7 +222,7 @@
};
03C5AB1107722DFD00EAF77D = {
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
path = "Info-DownloadsPrefPane.plist";
refType = 4;
sourceTree = "<group>";
@@ -419,7 +419,7 @@
};
03E2D8540771F73F00BD2443 = {
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
path = "Info-TabsPrefPane.plist";
refType = 4;
sourceTree = "<group>";
@@ -1197,7 +1197,7 @@
3003B8AC044514E300B85BF3 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
name = English;
path = resources/localized/English.lproj/SearchURLList.plist;
refType = 4;
@@ -1307,7 +1307,7 @@
};
3F22CC1303DF42A200026DCE = {
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
name = Charset.dict;
path = resources/application/Charset.dict;
refType = 4;
@@ -1712,8 +1712,6 @@
3F44ABDE05BDFB9E00CB4B08,
3F44ABDF05BDFB9E00CB4B08,
3F44ABE005BDFB9E00CB4B08,
3F44ABE105BDFB9E00CB4B08,
3F44ABE205BDFB9E00CB4B08,
3F44ABE305BDFB9E00CB4B08,
3F44ABE405BDFB9E00CB4B08,
3F44ABE505BDFB9E00CB4B08,
@@ -1847,18 +1845,6 @@
settings = {
};
};
3F44ABE105BDFB9E00CB4B08 = {
fileRef = F53F21F1022B7C77010001CA;
isa = PBXBuildFile;
settings = {
};
};
3F44ABE205BDFB9E00CB4B08 = {
fileRef = F53F21F3022B7C77010001CA;
isa = PBXBuildFile;
settings = {
};
};
3F44ABE305BDFB9E00CB4B08 = {
fileRef = F5BF71450231B8BC010001CA;
isa = PBXBuildFile;
@@ -2290,7 +2276,6 @@
3F44AC3405BDFB9E00CB4B08,
3F44AC3505BDFB9E00CB4B08,
3F44AC3605BDFB9E00CB4B08,
3F44AC3705BDFB9E00CB4B08,
3F44AC3805BDFB9E00CB4B08,
3F44AC3905BDFB9E00CB4B08,
3F8C00940681262400658CBC,
@@ -2502,12 +2487,6 @@
settings = {
};
};
3F44AC3705BDFB9E00CB4B08 = {
fileRef = F53F21ED022B7C77010001CA;
isa = PBXBuildFile;
settings = {
};
};
3F44AC3805BDFB9E00CB4B08 = {
fileRef = F507A86103128A3D01026D5D;
isa = PBXBuildFile;
@@ -2875,8 +2854,6 @@
3F44AC8A05BDFB9E00CB4B08,
3F44AC8B05BDFB9E00CB4B08,
3F44AC8C05BDFB9E00CB4B08,
3F44AC8D05BDFB9E00CB4B08,
3F44AC8E05BDFB9E00CB4B08,
3F44AC8F05BDFB9E00CB4B08,
3F44AC9005BDFB9E00CB4B08,
3F44AC9105BDFB9E00CB4B08,
@@ -3013,18 +2990,6 @@
settings = {
};
};
3F44AC8D05BDFB9E00CB4B08 = {
fileRef = F53F21F2022B7C77010001CA;
isa = PBXBuildFile;
settings = {
};
};
3F44AC8E05BDFB9E00CB4B08 = {
fileRef = F53F21F4022B7C77010001CA;
isa = PBXBuildFile;
settings = {
};
};
3F44AC8F05BDFB9E00CB4B08 = {
fileRef = F5BF71460231B8BC010001CA;
isa = PBXBuildFile;
@@ -4683,7 +4648,7 @@
};
3F44AD8705BDFB9F00CB4B08 = {
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
path = "Info-Camino__Upgraded_.plist";
refType = 4;
sourceTree = "<group>";
@@ -4862,7 +4827,7 @@
};
3F44AD9E05BDFB9F00CB4B08 = {
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
path = "Info-AppearancePrefPane__Upgraded_.plist";
refType = 4;
sourceTree = "<group>";
@@ -5033,7 +4998,7 @@
};
3F44ADB205BDFBA000CB4B08 = {
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
path = "Info-NavigationPrefPane__Upgraded_.plist";
refType = 4;
sourceTree = "<group>";
@@ -5048,7 +5013,7 @@
};
3F44ADC105BDFBA000CB4B08 = {
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
path = "Info-PersonalPrefPane__Upgraded_.plist";
refType = 4;
sourceTree = "<group>";
@@ -5234,7 +5199,7 @@
};
3F44ADD905BDFBA000CB4B08 = {
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
path = "Info-PrivacyPrefPane__Upgraded_.plist";
refType = 4;
sourceTree = "<group>";
@@ -5422,7 +5387,7 @@
};
3F44ADF005BDFBA000CB4B08 = {
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
path = "Info-SecurityPrefPane__Upgraded_.plist";
refType = 4;
sourceTree = "<group>";
@@ -5610,7 +5575,7 @@
};
3F44AE0705BDFBA000CB4B08 = {
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
path = "Info-WebFeaturesPrefPane__Upgraded_.plist";
refType = 4;
sourceTree = "<group>";
@@ -5701,8 +5666,6 @@
3F44AE1705BDFBA000CB4B08,
3F44AE1805BDFBA000CB4B08,
3F44AE1905BDFBA000CB4B08,
3F44AE1A05BDFBA000CB4B08,
3F44AE1B05BDFBA000CB4B08,
3F44AE1C05BDFBA000CB4B08,
3F44AE1D05BDFBA000CB4B08,
3F44AE1E05BDFBA000CB4B08,
@@ -5836,18 +5799,6 @@
settings = {
};
};
3F44AE1A05BDFBA000CB4B08 = {
fileRef = F53F21F1022B7C77010001CA;
isa = PBXBuildFile;
settings = {
};
};
3F44AE1B05BDFBA000CB4B08 = {
fileRef = F53F21F3022B7C77010001CA;
isa = PBXBuildFile;
settings = {
};
};
3F44AE1C05BDFBA000CB4B08 = {
fileRef = F5BF71450231B8BC010001CA;
isa = PBXBuildFile;
@@ -6279,7 +6230,6 @@
3F44AE6D05BDFBA000CB4B08,
3F44AE6E05BDFBA000CB4B08,
3F44AE6F05BDFBA000CB4B08,
3F44AE7005BDFBA000CB4B08,
3F44AE7105BDFBA000CB4B08,
3F44AE7205BDFBA000CB4B08,
3F8C00950681262400658CBC,
@@ -6490,12 +6440,6 @@
settings = {
};
};
3F44AE7005BDFBA000CB4B08 = {
fileRef = F53F21ED022B7C77010001CA;
isa = PBXBuildFile;
settings = {
};
};
3F44AE7105BDFBA000CB4B08 = {
fileRef = F507A86103128A3D01026D5D;
isa = PBXBuildFile;
@@ -6863,8 +6807,6 @@
3F44AEC305BDFBA000CB4B08,
3F44AEC405BDFBA000CB4B08,
3F44AEC505BDFBA000CB4B08,
3F44AEC605BDFBA000CB4B08,
3F44AEC705BDFBA000CB4B08,
3F44AEC805BDFBA000CB4B08,
3F44AEC905BDFBA000CB4B08,
3F44AECA05BDFBA000CB4B08,
@@ -7000,18 +6942,6 @@
settings = {
};
};
3F44AEC605BDFBA000CB4B08 = {
fileRef = F53F21F2022B7C77010001CA;
isa = PBXBuildFile;
settings = {
};
};
3F44AEC705BDFBA000CB4B08 = {
fileRef = F53F21F4022B7C77010001CA;
isa = PBXBuildFile;
settings = {
};
};
3F44AEC805BDFBA000CB4B08 = {
fileRef = F5BF71460231B8BC010001CA;
isa = PBXBuildFile;
@@ -8704,7 +8634,7 @@
};
3F44AFC505BDFBA100CB4B08 = {
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
path = "Info-CaminoStatic__Upgraded_.plist";
refType = 4;
sourceTree = "<group>";
@@ -8811,7 +8741,7 @@
};
3F44AFD305BDFBA100CB4B08 = {
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
path = "Info-AddressBookManager__Upgraded_.plist";
refType = 4;
sourceTree = "<group>";
@@ -9180,7 +9110,7 @@
3FAA54C70587778700BBF630 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
name = bookmarks.plist;
path = resources/application/bookmarks.plist;
refType = 2;
@@ -12097,7 +12027,7 @@
};
F51B70B4026EC8A601A80166 = {
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
name = Camino.scriptSuite;
path = resources/application/Camino.scriptSuite;
refType = 2;
@@ -12691,15 +12621,6 @@
refType = 2;
sourceTree = SOURCE_ROOT;
};
F53F21ED022B7C77010001CA = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = text.plist;
name = MVPreferencePaneGroups.plist;
path = src/preferences/MVPreferencePaneGroups.plist;
refType = 2;
sourceTree = SOURCE_ROOT;
};
F53F21EE022B7C77010001CA = {
fileEncoding = 30;
isa = PBXFileReference;
@@ -12727,42 +12648,6 @@
refType = 2;
sourceTree = SOURCE_ROOT;
};
F53F21F1022B7C77010001CA = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.h;
name = MVPreferencesGroupedIconView.h;
path = src/preferences/MVPreferencesGroupedIconView.h;
refType = 2;
sourceTree = SOURCE_ROOT;
};
F53F21F2022B7C77010001CA = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.objc;
name = MVPreferencesGroupedIconView.m;
path = src/preferences/MVPreferencesGroupedIconView.m;
refType = 2;
sourceTree = SOURCE_ROOT;
};
F53F21F3022B7C77010001CA = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.h;
name = MVPreferencesMultipleIconView.h;
path = src/preferences/MVPreferencesMultipleIconView.h;
refType = 2;
sourceTree = SOURCE_ROOT;
};
F53F21F4022B7C77010001CA = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.objc;
name = MVPreferencesMultipleIconView.m;
path = src/preferences/MVPreferencesMultipleIconView.m;
refType = 2;
sourceTree = SOURCE_ROOT;
};
F540BD1A029ED15301026D5D = {
isa = PBXFileReference;
lastKnownFileType = image.tiff;
@@ -13763,7 +13648,7 @@
F5949A47030D58A1014E8430 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
path = xhtml11.dtd;
refType = 4;
sourceTree = "<group>";
@@ -14241,7 +14126,7 @@
};
F5CA1A1A02D3956F01F34900 = {
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
name = English;
path = resources/localized/English.lproj/Camino.scriptTerminology;
refType = 2;
@@ -14251,14 +14136,9 @@
children = (
F507A85303116EA401026D5D,
F53F21EC022B7C77010001CA,
F53F21ED022B7C77010001CA,
F507A86103128A3D01026D5D,
F53F21EF022B7C77010001CA,
F53F21F0022B7C77010001CA,
F53F21F1022B7C77010001CA,
F53F21F2022B7C77010001CA,
F53F21F3022B7C77010001CA,
F53F21F4022B7C77010001CA,
);
isa = PBXGroup;
name = "Prefs window";
@@ -15371,7 +15251,7 @@
F6BD64D501B3172601A962F7 = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = text.plist.xml;
lastKnownFileType = text.xml;
name = platformHTMLBindings.xml;
path = ../dist/Embed/res/builtin/platformHTMLBindings.xml;
refType = 2;

View File

@@ -2,30 +2,11 @@
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
ACTIONS = {showAll = id; showPreferences = id; };
ACTIONS = {showPreferences = id; };
CLASS = MVPreferencesController;
LANGUAGE = ObjC;
OUTLETS = {
groupView = id;
loadingImageView = id;
loadingTextFeld = id;
loadingView = id;
multiView = id;
window = id;
};
OUTLETS = {loadingImageView = id; loadingTextFeld = id; loadingView = id; window = id; };
SUPERCLASS = NSObject;
},
{
CLASS = MVPreferencesGroupedIconView;
LANGUAGE = ObjC;
OUTLETS = {preferencesController = id; };
SUPERCLASS = NSView;
},
{
CLASS = MVPreferencesMultipleIconView;
LANGUAGE = ObjC;
OUTLETS = {preferencesController = id; };
SUPERCLASS = NSView;
}
);
IBVersion = 1;

View File

@@ -3,14 +3,15 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>22 42 356 240 0 0 1280 832 </string>
<string>37 67 356 240 0 0 1920 1178 </string>
<key>IBEditorPositions</key>
<dict>
<key>11</key>
<string>627 639 615 292 0 0 1920 1178 </string>
</dict>
<key>IBFramework Version</key>
<string>364.0</string>
<key>IBOpenObjects</key>
<array>
<integer>7</integer>
</array>
<key>IBSystem Version</key>
<string>7M34</string>
<string>7S215</string>
</dict>
</plist>

View File

@@ -1,19 +0,0 @@
(
{
identifier = general;
panes = (
org.mozilla.chimera.preference.navigation,
org.mozilla.chimera.preference.appearance,
org.mozilla.chimera.preference.webfeatures,
org.mozilla.camino.preference.tabs,
org.mozilla.camino.preference.downloads,
);
},
{
identifier = security;
panes = (
org.mozilla.chimera.preference.privacy,
org.mozilla.chimera.preference.security,
);
}
)

View File

@@ -38,14 +38,9 @@
extern NSString *MVPreferencesWindowNotification;
@class MVPreferencesMultipleIconView;
@class MVPreferencesGroupedIconView;
@interface MVPreferencesController : NSObject {
IBOutlet NSWindow *window;
IBOutlet NSView *loadingView;
IBOutlet MVPreferencesMultipleIconView *multiView;
IBOutlet MVPreferencesGroupedIconView *groupView;
IBOutlet NSImageView *loadingImageView;
IBOutlet NSTextField *loadingTextFeld;
NSView *mainView;
@@ -56,7 +51,6 @@ extern NSString *MVPreferencesWindowNotification;
}
+ (MVPreferencesController *) sharedInstance;
- (NSWindow *) window;
- (void) showAll:(id) sender;
- (void) showPreferences:(id) sender;
- (void) selectPreferencePaneByIdentifier:(NSString *) identifier;
@end

View File

@@ -36,8 +36,6 @@
#import <PreferencePanes/PreferencePanes.h>
#import "MVPreferencesController.h"
#import "MVPreferencesMultipleIconView.h"
#import "MVPreferencesGroupedIconView.h"
#import "ToolbarAdditions.h"
#include "nsCOMPtr.h"
@@ -45,11 +43,8 @@
#include "nsIPref.h"
#include "CHBrowserService.h"
// #import "Defines.h"
static MVPreferencesController *sharedInstance = nil;
NSString *MVToolbarShowAllItemIdentifier = @"MVToolbarShowAllItem";
NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
@interface NSToolbar (NSToolbarPrivate)
@@ -61,7 +56,6 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
- (IBAction) _selectPreferencePane:(id) sender;
- (void) _resizeWindowForContentView:(NSView *) view;
- (NSImage *) _imageForPaneBundle:(NSBundle *) bundle;
- (NSString *) _paletteLabelForPaneBundle:(NSBundle *) bundle;
- (NSString *) _labelForPaneBundle:(NSBundle *) bundle;
@end
@@ -83,8 +77,9 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
for ( i = 0; i < [panes count]; i++ ) {
bundle = [NSBundle bundleWithPath:[NSString stringWithFormat:@"%@/%@", bundlePath, [panes objectAtIndex:i]]];
[bundle load];
if( bundle ) [panes replaceObjectAtIndex:i withObject:bundle];
else {
if (bundle) {
[panes replaceObjectAtIndex:i withObject:bundle];
} else {
[panes removeObjectAtIndex:i];
i--;
}
@@ -114,27 +109,17 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
- (void) awakeFromNib
{
NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier:@"preferences.toolbar"] autorelease];
NSArray *groups = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"MVPreferencePaneGroups" ofType:@"plist"]];
if( groups ) {
[groupView setPreferencePanes:panes];
[groupView setPreferencePaneGroups:groups];
mainView = groupView;
} else {
[multiView setPreferencePanes:panes];
mainView = multiView;
}
[window setDelegate:self];
[window setFrameAutosaveName:@"CaminoPreferenceWindowFrame"];
[toolbar setAllowsUserCustomization:YES];
[toolbar setAutosavesConfiguration:YES];
[toolbar setAllowsUserCustomization:NO];
[toolbar setAutosavesConfiguration:NO];
[toolbar setDelegate:self];
[toolbar setAlwaysCustomizableByDrag:YES];
[toolbar setAlwaysCustomizableByDrag:NO];
[toolbar setShowsContextMenu:NO];
[window setToolbar:toolbar];
[toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel];
[toolbar setIndexOfFirstMovableItem:2];
}
- (NSWindow *) window
@@ -151,40 +136,12 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
// the window visible. Too bad cocoa doesn't give us any notifications of this.
CHBrowserService::InitEmbedding();
}
// If neither a pref pane nor the group pane is showing, then show the group pane
// If a pref pane is not showing, then show the general pane
if (!currentPaneIdentifier && (![[window contentView] isEqual:mainView]))
[self showAll:nil];
[self selectPreferencePaneByIdentifier:@"org.mozilla.chimera.preference.navigation"];
[window makeKeyAndOrderFront:nil];
}
- (IBAction) showAll:(id) sender
{
if ( [[window contentView] isEqual:mainView] ) return;
if ( currentPaneIdentifier && [[loadedPanes objectForKey:currentPaneIdentifier] shouldUnselect] != NSUnselectNow ) {
/* more to handle later */
#if DEBUG
NSLog(@"can't unselect current preferences pane");
#endif
return;
}
[window setContentView:[[[NSView alloc] initWithFrame:[mainView frame]] autorelease]];
[window setTitle:[NSString stringWithFormat:NSLocalizedString( @"PrefsWindowTitleFormat", @"" ), [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]]];
[self _resizeWindowForContentView:mainView];
[[loadedPanes objectForKey:currentPaneIdentifier] willUnselect];
[window setContentView:mainView];
[[loadedPanes objectForKey:currentPaneIdentifier] didUnselect];
[currentPaneIdentifier autorelease];
currentPaneIdentifier = nil;
[window setInitialFirstResponder:mainView];
[window makeFirstResponder:mainView];
if ([NSToolbar instancesRespondToSelector:@selector(setSelectedItemIdentifier:)])
[[window toolbar] setSelectedItemIdentifier:MVToolbarShowAllItemIdentifier];
}
- (void) selectPreferencePaneByIdentifier:(NSString *) identifier
{
NSBundle *bundle = [NSBundle bundleWithIdentifier:identifier];
@@ -284,30 +241,19 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
willBeInsertedIntoToolbar:(BOOL) flag
{
NSToolbarItem *toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier] autorelease];
if ( [itemIdentifier isEqualToString:MVToolbarShowAllItemIdentifier] ) {
[toolbarItem setLabel:NSLocalizedString( @"ShowAllPrefItems", @"" )];
[toolbarItem setImage:[NSImage imageNamed:@"NSApplicationIcon"]];
NSBundle *bundle = [NSBundle bundleWithIdentifier:itemIdentifier];
if (bundle) {
[toolbarItem setLabel:[self _labelForPaneBundle:bundle]];
[toolbarItem setImage:[self _imageForPaneBundle:bundle]];
[toolbarItem setTarget:self];
[toolbarItem setAction:@selector( showAll: )];
} else {
NSBundle *bundle = [NSBundle bundleWithIdentifier:itemIdentifier];
if( bundle ) {
[toolbarItem setLabel:[self _labelForPaneBundle:bundle]];
[toolbarItem setPaletteLabel:[self _paletteLabelForPaneBundle:bundle]];
[toolbarItem setImage:[self _imageForPaneBundle:bundle]];
[toolbarItem setTarget:self];
[toolbarItem setAction:@selector( _selectPreferencePane: )];
} else toolbarItem = nil;
}
[toolbarItem setAction:@selector( _selectPreferencePane: )];
} else toolbarItem = nil;
return toolbarItem;
}
- (NSArray *) toolbarDefaultItemIdentifiers:(NSToolbar *) toolbar
{
NSMutableArray *fixed = [NSMutableArray arrayWithObjects:MVToolbarShowAllItemIdentifier, NSToolbarSeparatorItemIdentifier, nil];
NSArray *defaults = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"MVPreferencePaneDefaults" ofType:@"plist"]];
[fixed addObjectsFromArray:defaults];
return fixed;
return [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"MVPreferencePaneDefaults" ofType:@"plist"]];
}
- (NSArray *) toolbarAllowedItemIdentifiers:(NSToolbar *) toolbar
@@ -317,8 +263,6 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
id item = nil;
while ( ( item = [enumerator nextObject] ) )
[items addObject:[item bundleIdentifier]];
//[items addObject:MVToolbarShowAllItemIdentifier];
[items addObject:NSToolbarSeparatorItemIdentifier];
return items;
}
@@ -330,7 +274,6 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
id item = nil;
while ( ( item = [enumerator nextObject] ) )
[items addObject:[item bundleIdentifier]];
[items addObject:MVToolbarShowAllItemIdentifier];
return items;
}
@@ -377,26 +320,6 @@ NSString *MVPreferencesWindowNotification = @"MVPreferencesWindowNotification";
return image;
}
- (NSString *) _paletteLabelForPaneBundle:(NSBundle *) bundle
{
NSString *label = nil;
NSMutableDictionary *cache = [paneInfo objectForKey:[bundle bundleIdentifier]];
label = [[[cache objectForKey:@"MVPreferencePanePaletteLabel"] retain] autorelease];
if ( ! label ) {
NSDictionary *info = [bundle infoDictionary];
label = NSLocalizedStringFromTableInBundle(@"PreferencePanelLabel", nil, bundle, nil);
if ( [label isEqualToString:@"PreferencePanelLabel"] ) label = NSLocalizedStringFromTableInBundle( @"NSPrefPaneIconLabel", @"InfoPlist", bundle, nil );
if ( [label isEqualToString:@"NSPrefPaneIconLabel"] ) label = [info objectForKey:@"NSPrefPaneIconLabel"];
if ( ! label ) label = NSLocalizedStringFromTableInBundle( @"CFBundleName", @"InfoPlist", bundle, nil );
if ( [label isEqualToString:@"CFBundleName"] ) label = [info objectForKey:@"CFBundleName"];
if ( ! label ) label = [bundle bundleIdentifier];
if ( ! cache ) [paneInfo setObject:[NSMutableDictionary dictionary] forKey:[bundle bundleIdentifier]];
cache = [paneInfo objectForKey:[bundle bundleIdentifier]];
if ( label ) [cache setObject:label forKey:@"MVPreferencePanePaletteLabel"];
}
return label;
}
- (NSString *) _labelForPaneBundle:(NSBundle *) bundle
{
NSString *label = nil;

View File

@@ -1,59 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Chimera code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import <Cocoa/Cocoa.h>
@class MVPreferencesController;
extern const unsigned int groupViewHeight, multiIconViewYOffset;
@interface MVPreferencesGroupedIconView : NSView
{
IBOutlet MVPreferencesController *preferencesController;
NSBundle *selectedPane;
NSArray *preferencePanes, *preferencePaneGroups;
NSMutableArray *groupMultiIconViews;
}
- (void) setPreferencesController:(MVPreferencesController *) newPreferencesController;
- (void) setPreferencePanes:(NSArray *) newPreferencePanes;
- (NSArray *) preferencePanes;
- (void) setPreferencePaneGroups:(NSArray *) newPreferencePaneGroups;
- (NSArray *) preferencePaneGroups;
@end

View File

@@ -1,208 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Chimera code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import "MVPreferencesGroupedIconView.h"
#import "MVPreferencesMultipleIconView.h"
#import "MVPreferencesController.h"
@interface MVPreferencesMultipleIconView (MVPreferencesMultipleIconViewPrivate)
- (unsigned int) _numberOfRows;
@end
@interface MVPreferencesGroupedIconView (MVPreferencesGroupedIconViewPrivate)
- (unsigned int) _numberOfGroups;
- (void) _sizeToFit;
- (NSRect) _rectForGroupAtIndex:(unsigned int) index;
- (NSRect) _rectForGroupSeparatorAtIndex:(unsigned int) index;
- (void) _generateGroupViews;
- (void) _generateGroupViewAtIndex:(unsigned int) index;
@end
@implementation MVPreferencesGroupedIconView
const unsigned int groupViewHeight = 95;
const unsigned int multiIconViewYOffset = 18;
const unsigned int sideGutterWidths = 15;
const unsigned int extraRowHeight = 69;
- (id) initWithFrame:(NSRect) frame
{
if( ( self = [super initWithFrame:frame] ) ) {
groupMultiIconViews = [[NSMutableArray array] retain];
}
return self;
}
- (void) drawRect:(NSRect) rect
{
[self _generateGroupViews];
}
- (void) setPreferencesController:(MVPreferencesController *) newPreferencesController
{
[preferencesController autorelease];
preferencesController = [newPreferencesController retain];
[self _sizeToFit];
[self setNeedsDisplay:YES];
}
- (void) setPreferencePanes:(NSArray *) newPreferencePanes
{
[preferencePanes autorelease];
preferencePanes = [newPreferencePanes retain];
[self _sizeToFit];
[self setNeedsDisplay:YES];
}
- (NSArray *) preferencePanes
{
return preferencePanes;
}
- (void) setPreferencePaneGroups:(NSArray *) newPreferencePaneGroups
{
[preferencePaneGroups autorelease];
preferencePaneGroups = [newPreferencePaneGroups retain];
[self _sizeToFit];
[self setNeedsDisplay:YES];
}
- (NSArray *) preferencePaneGroups
{
return preferencePaneGroups;
}
- (BOOL) acceptsFirstResponder
{
return YES;
}
- (BOOL) becomeFirstResponder
{
[[self window] makeFirstResponder:[self viewWithTag:0]];
return YES;
}
- (BOOL) resignFirstResponder
{
return YES;
}
- (BOOL) isFlipped
{
return YES;
}
- (BOOL) isOpaque
{
return NO;
}
@end
@implementation MVPreferencesGroupedIconView (MVPreferencesGroupedIconViewPrivate)
- (unsigned int) _numberOfGroups {
return [[self preferencePaneGroups] count];
}
- (void) _sizeToFit {
if( ! [self _numberOfGroups] ) return;
[self _generateGroupViews];
[self setFrameSize:NSMakeSize( NSWidth( _bounds ), NSMaxY( [self _rectForGroupAtIndex:[self _numberOfGroups] - 1] ) ) ];
}
- (NSRect) _rectForGroupAtIndex:(unsigned int) index {
unsigned int extra = 0, groupIndex;
for( groupIndex = 0; groupIndex < index; groupIndex++ )
extra += [[self viewWithTag:groupIndex] _numberOfRows] * extraRowHeight;
return NSMakeRect( 0., (index * groupViewHeight ) + multiIconViewYOffset + index + extra, NSWidth( [self frame] ), groupViewHeight );
}
- (NSRect) _rectForGroupSeparatorAtIndex:(unsigned int) index {
unsigned int extra = 0, groupIndex;
if( ! index ) return NSZeroRect;
for( groupIndex = 0; groupIndex < index; groupIndex++ )
extra += [[self viewWithTag:groupIndex] _numberOfRows] * extraRowHeight;
return NSMakeRect( sideGutterWidths, ((index + 1) * groupViewHeight) - groupViewHeight + index + extra, NSWidth( [self frame] ) - (sideGutterWidths * 2), 1 );
}
- (void) _generateGroupViews {
unsigned int groupIndex, groupCount;
groupCount = [self _numberOfGroups];
for( groupIndex = 0; groupIndex < groupCount; groupIndex++ )
[self _generateGroupViewAtIndex:groupIndex];
}
- (void) _generateGroupViewAtIndex:(unsigned int) index {
MVPreferencesMultipleIconView *multiIconView = nil;
NSString *identifier = [[preferencePaneGroups objectAtIndex:index] objectForKey:@"identifier"];
NSString *name = NSLocalizedStringFromTable( identifier, @"MVPreferencePaneGroups", nil );
NSDictionary *attributesDictionary;
unsigned nameHeight = 0;
if( ! ( multiIconView = [self viewWithTag:index] ) ) {
NSMutableArray *panes = [NSMutableArray array];
NSBox *sep = [[[NSBox alloc] initWithFrame:[self _rectForGroupSeparatorAtIndex:index]] autorelease];
NSEnumerator *enumerator = [[[preferencePaneGroups objectAtIndex:index] objectForKey:@"panes"] objectEnumerator];
id pane = nil, bundle = 0;
multiIconView = [[[MVPreferencesMultipleIconView alloc] initWithFrame:[self _rectForGroupAtIndex:index]] autorelease];
while( ( pane = [enumerator nextObject] ) ) {
bundle = [NSBundle bundleWithIdentifier:pane];
if( bundle ) [panes addObject:bundle];
}
[multiIconView setPreferencesController:preferencesController];
[multiIconView setPreferencePanes:panes];
[multiIconView setTag:index];
[sep setBoxType:NSBoxSeparator];
[sep setBorderType:NSBezelBorder];
[self addSubview:multiIconView];
[self addSubview:sep];
// if( ! index ) [[self window] makeFirstResponder:multiIconView];
if( index - 1 >= 0 ) [[self viewWithTag:index - 1] setNextKeyView:multiIconView];
if( index == [self _numberOfGroups] - 1 ) [multiIconView setNextKeyView:[self viewWithTag:0]];
}
attributesDictionary = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont boldSystemFontOfSize:13.], NSFontAttributeName, nil];
nameHeight = [[NSFont boldSystemFontOfSize:13.] ascender];
[name drawAtPoint:NSMakePoint( sideGutterWidths - 1, NSMinY( [multiIconView frame] ) - nameHeight - 1 ) withAttributes:attributesDictionary];
}
@end

View File

@@ -1,64 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Chimera code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* David Hyatt <hyatt@mozilla.org>
* Simon Fraser <sfraser@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import <Cocoa/Cocoa.h>
@class MVPreferencesController;
extern const NSSize buttonSize, iconSize;
extern const unsigned int titleBaseline, iconBaseline, bottomBorder;
@interface MVPreferencesMultipleIconView : NSView
{
IBOutlet MVPreferencesController *preferencesController;
unsigned int pressedIconIndex, focusedIndex;
int tag;
NSBundle *selectedPane;
NSArray *preferencePanes;
}
- (void) setPreferencesController:(MVPreferencesController *) newPreferencesController;
- (void) setPreferencePanes:(NSArray *) newPreferencePanes;
- (NSArray *) preferencePanes;
- (void) setSelectedPane:(NSBundle *) newSelectedClientRecord;
- (int) tag;
- (void) setTag:(int) newTag;
@end

View File

@@ -1,434 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Chimera code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import "MVPreferencesMultipleIconView.h"
#import "MVPreferencesController.h"
#import "ImageAdditions.h"
@interface MVPreferencesMultipleIconView (MVPreferencesMultipleIconViewPrivate)
- (void) _focusFirst;
- (void) _focusLast;
- (unsigned int) _iconsWide;
- (unsigned int) _numberOfIcons;
- (unsigned int) _numberOfRows;
- (BOOL) _isIconSelectedAtIndex:(unsigned int) index;
- (BOOL) _column:(unsigned int *) column andRow:(unsigned int *) row forIndex:(unsigned int) index;
- (NSRect) _boundsForIndex:(unsigned int) index;
- (BOOL) _iconImage:(NSImage **) image andName:(NSString **) name forIndex:(unsigned int) index;
- (BOOL) _iconImage:(NSImage **) image andName:(NSString **) name andIdentifier:(NSString **) identifier forIndex:(unsigned int) index;
- (void) _drawIconAtIndex:(unsigned int) index drawRect:(NSRect) drawRect;
- (void) _sizeToFit;
- (BOOL) _dragIconIndex:(unsigned int) index event:(NSEvent *) event;
- (BOOL) _dragIconImage:(NSImage *) iconImage andName:(NSString *) name event:(NSEvent *) event;
- (BOOL) _dragIconImage:(NSImage *) iconImage andName:(NSString *) name andIdentifier:(NSString *) identifier event:(NSEvent *) event;
@end
@interface MVPreferencesController (MVPreferencesControllerPrivate)
- (IBAction) _selectPreferencePane:(id) sender;
- (void) _resizeWindowForContentView:(NSView *) view;
- (NSImage *) _imageForPaneBundle:(NSBundle *) bundle;
- (NSString *) _paletteLabelForPaneBundle:(NSBundle *) bundle;
- (NSString *) _labelForPaneBundle:(NSBundle *) bundle;
@end
@implementation MVPreferencesMultipleIconView
const NSSize buttonSize = { 81.0, 75.0 };
const NSSize iconSize = { 32.0, 32.0 };
const unsigned int titleBaseline = 15;
const unsigned int iconBaseline = 30;
const unsigned int bottomBorder = 15;
- (id) initWithFrame:(NSRect) rect {
if( ( self = [super initWithFrame:rect] ) ) {
pressedIconIndex = NSNotFound;
focusedIndex = NSNotFound;
selectedPane = nil;
}
return self;
}
- (void) setPreferencesController:(MVPreferencesController *) newPreferencesController {
[preferencesController autorelease];
preferencesController = [newPreferencesController retain];
[self setNeedsDisplay:YES];
}
- (void) setPreferencePanes:(NSArray *) newPreferencePanes {
[preferencePanes autorelease];
preferencePanes = [newPreferencePanes retain];
[self _sizeToFit];
[self setNeedsDisplay:YES];
}
- (NSArray *) preferencePanes {
return preferencePanes;
}
- (void) setSelectedPane:(NSBundle *) newSelectedPane {
selectedPane = newSelectedPane;
[self setNeedsDisplay:YES];
}
- (void) mouseDown:(NSEvent *) event {
NSPoint eventLocation;
NSRect slopRect;
const float dragSlop = 4.;
unsigned int index;
NSRect buttonRect;
BOOL mouseInBounds = NO;
eventLocation = [self convertPoint:[event locationInWindow] fromView:nil];
slopRect = NSInsetRect( NSMakeRect( eventLocation.x, eventLocation.y, 1., 1. ), -dragSlop, -dragSlop );
index = floor( eventLocation.x / buttonSize.width ) + ( floor( eventLocation.y / buttonSize.height ) * [self _iconsWide] );
buttonRect = [self _boundsForIndex:index];
if( index >= ( [self _iconsWide] * ( floor( eventLocation.y / buttonSize.height ) + 1 ) ) ) return;
if( ! NSWidth( buttonRect ) ) return;
pressedIconIndex = index;
[self setNeedsDisplayInRect:[self _boundsForIndex:index]];
while( 1 ) {
NSEvent *nextEvent;
NSPoint nextEventLocation;
unsigned int newPressedIconIndex;
nextEvent = [NSApp nextEventMatchingMask:NSLeftMouseDraggedMask|NSLeftMouseUpMask untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:YES];
nextEventLocation = [self convertPoint:[nextEvent locationInWindow] fromView:nil];
mouseInBounds = NSMouseInRect(nextEventLocation, buttonRect, [self isFlipped]);
newPressedIconIndex = ( mouseInBounds ? index : NSNotFound );
if( newPressedIconIndex != pressedIconIndex ) {
pressedIconIndex = newPressedIconIndex;
[self setNeedsDisplayInRect:[self _boundsForIndex:pressedIconIndex]];
}
if( [nextEvent type] == NSLeftMouseUp ) break;
else if( ! NSMouseInRect( nextEventLocation, slopRect, NO ) ) {
if( [self _dragIconIndex:index event:event] ) {
mouseInBounds = NO;
break;
}
}
}
pressedIconIndex = NSNotFound;
[self setNeedsDisplayInRect:[self _boundsForIndex:index]];
if( mouseInBounds )
[preferencesController selectPreferencePaneByIdentifier:[[preferencePanes objectAtIndex:index] bundleIdentifier]];
}
#define kTabCharCode 9
#define kShiftTabCharCode 25
#define kSpaceCharCode 32
- (void) keyDown:(NSEvent *) theEvent {
NSView *nextView = nil;
if( [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == kTabCharCode ) {
[self setKeyboardFocusRingNeedsDisplayInRect:[self _boundsForIndex:focusedIndex]];
if( focusedIndex == NSNotFound && [self _numberOfIcons] ) focusedIndex = 0;
else if( ! ( [theEvent modifierFlags] & NSShiftKeyMask ) ) focusedIndex++;
if( focusedIndex >= [self _numberOfIcons] ) {
if( ( nextView = [self nextValidKeyView] ) ) {
[[self window] makeFirstResponder:nextView];
focusedIndex = NSNotFound;
if( [nextView isKindOfClass:[MVPreferencesMultipleIconView class]] )
[(MVPreferencesMultipleIconView *)nextView _focusFirst];
} else focusedIndex = 0;
}
if( ! [self _numberOfIcons] ) focusedIndex = NSNotFound;
[self setNeedsDisplayInRect:[self _boundsForIndex:focusedIndex]];
} else if( [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == kShiftTabCharCode ) {
[self setKeyboardFocusRingNeedsDisplayInRect:[self _boundsForIndex:focusedIndex]];
if( focusedIndex == NSNotFound && [self _numberOfIcons] ) focusedIndex = [self _numberOfIcons] - 1;
else if( [theEvent modifierFlags] & NSShiftKeyMask ) focusedIndex--;
if( (signed) focusedIndex < 0 && [self _numberOfIcons] ) {
if( ( nextView = [self previousValidKeyView] ) ) {
[[self window] makeFirstResponder:nextView];
focusedIndex = NSNotFound;
if( [nextView isKindOfClass:[MVPreferencesMultipleIconView class]] )
[(MVPreferencesMultipleIconView *)nextView _focusLast];
} else focusedIndex = [self _numberOfIcons] - 1;
}
if( ! [self _numberOfIcons] ) focusedIndex = NSNotFound;
[self setNeedsDisplayInRect:[self _boundsForIndex:focusedIndex]];
} else if( [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == kSpaceCharCode ) {
if( focusedIndex != NSNotFound && focusedIndex < [self _numberOfIcons] && focusedIndex >= 0 ) {
[preferencesController selectPreferencePaneByIdentifier:[[preferencePanes objectAtIndex:focusedIndex] bundleIdentifier]];
focusedIndex = NSNotFound;
}
}
}
- (BOOL) acceptsFirstResponder {
return YES;
}
- (BOOL) becomeFirstResponder {
focusedIndex = NSNotFound;
return YES;
}
- (BOOL) resignFirstResponder {
[self setKeyboardFocusRingNeedsDisplayInRect:[self _boundsForIndex:focusedIndex]];
focusedIndex = NSNotFound;
return YES;
}
- (void) drawRect:(NSRect) rect {
unsigned int paneIndex, paneCount;
paneCount = [self _numberOfIcons];
for( paneIndex = 0; paneIndex < paneCount; paneIndex++ )
[self _drawIconAtIndex:paneIndex drawRect:rect];
}
- (BOOL) isFlipped {
return YES;
}
- (BOOL) isOpaque {
return NO;
}
- (int) tag {
return tag;
}
- (void) setTag:(int) newTag {
tag = newTag;
}
- (NSDragOperation) draggingSourceOperationMaskForLocal:(BOOL) flag {
return NSDragOperationMove;
}
- (void) draggedImage:(NSImage *)image endedAt:(NSPoint) screenPoint operation:(NSDragOperation) operation {
}
- (BOOL) ignoreModifierKeysWhileDragging {
return YES;
}
@end
@implementation MVPreferencesMultipleIconView (MVPreferencesMultipleIconViewPrivate)
- (void) _focusFirst {
focusedIndex = 0;
[self setNeedsDisplayInRect:[self _boundsForIndex:focusedIndex]];
}
- (void) _focusLast {
focusedIndex = [self _numberOfIcons] - 1;
[self setNeedsDisplayInRect:[self _boundsForIndex:focusedIndex]];
}
- (unsigned int) _iconsWide {
return NSWidth( [self bounds] ) / buttonSize.width;
}
- (unsigned int) _numberOfIcons {
return [[self preferencePanes] count];
}
- (unsigned int) _numberOfRows {
unsigned int row = 0, column = 0;
if( ! [self _column:&column andRow:&row forIndex:[self _numberOfIcons] - 1] ) return 0;
return row;
}
- (BOOL) _isIconSelectedAtIndex:(unsigned int) index {
return [[self preferencePanes] objectAtIndex:index] == selectedPane;
}
- (BOOL) _column:(unsigned int *) column andRow:(unsigned int *) row forIndex:(unsigned int) index {
if( index >= [self _numberOfIcons] ) return NO;
*row = index / [self _iconsWide];
*column = index % [self _iconsWide];
return YES;
}
- (NSRect) _boundsForIndex:(unsigned int) index {
unsigned int row = 0, column = 0, leftEdge = 0;
if( ! [self _column:&column andRow:&row forIndex:index] ) return NSZeroRect;
leftEdge = ( NSWidth( _bounds ) - ( [self _iconsWide] * buttonSize.width ) ) / 2. ;
return NSMakeRect( ( column * buttonSize.width ) + leftEdge, row * buttonSize.height - (row * 6), buttonSize.width, buttonSize.height );
}
- (BOOL) _iconImage:(NSImage **) image andName:(NSString **) name forIndex:(unsigned int) index {
NSString *unused;
return [self _iconImage:image andName:name andIdentifier:&unused forIndex:index];
}
- (BOOL) _iconImage:(NSImage **) image andName:(NSString **) name andIdentifier:(NSString **) identifier forIndex:(unsigned int) index {
NSDictionary *info = nil;
NSBundle *pane = nil;
if( index >= [self _numberOfIcons] ) return NO;
pane = [[self preferencePanes] objectAtIndex:index];
info = [pane infoDictionary];
*image = [preferencesController _imageForPaneBundle:pane];
*name = [preferencesController _paletteLabelForPaneBundle:pane];
*identifier = [pane bundleIdentifier];
return YES;
}
- (void) _drawIconAtIndex:(unsigned int) index drawRect:(NSRect) drawRect {
NSImage *image;
NSString *name;
unsigned int row, column;
NSPoint drawPoint;
float nameHeight;
NSRect buttonRect, destinationRect;
NSDictionary *attributesDictionary;
NSMutableParagraphStyle *paraStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
buttonRect = [self _boundsForIndex:index];
if( ! NSIntersectsRect( buttonRect, drawRect ) ) return;
if( ! [self _iconImage:&image andName:&name forIndex:index] ) return;
if( ! [self _column:&column andRow:&row forIndex:index] ) return;
// Draw dark gray rectangle around currently selected icon (for MultipleIconView)
if( [self _isIconSelectedAtIndex:index] ) {
[[NSColor colorWithCalibratedWhite:0.8 alpha:0.75] set];
NSRectFillUsingOperation(buttonRect, NSCompositeSourceOver);
}
if( focusedIndex == index ) {
CGContextSaveGState( context );
NSSetFocusRingStyle( NSFocusRingAbove );
}
// Draw icon, dark if it is currently being pressed
destinationRect = NSIntegralRect( NSMakeRect( NSMidX( buttonRect) - iconSize.width / 2., NSMaxY( buttonRect ) - iconBaseline - iconSize.height, iconSize.width, iconSize.height ) );
destinationRect.size = iconSize;
if( index != pressedIconIndex && image )
[image drawFlippedInRect:destinationRect operation:NSCompositeSourceOver fraction:1.];
else if( image )
{
NSImage *darkImage;
NSSize darkImageSize;
darkImage = [image copy];
darkImageSize = [darkImage size];
[darkImage lockFocus];
{
[[NSColor blackColor] set];
NSRectFillUsingOperation( NSMakeRect( 0., 0., darkImageSize.width, darkImageSize.height ), NSCompositeSourceIn );
[darkImage unlockFocus];
}
[darkImage drawFlippedInRect:destinationRect operation:NSCompositeSourceOver fraction:1.];
[image drawFlippedInRect:destinationRect operation:NSCompositeSourceOver fraction:.6666667];
[darkImage release];
}
if( focusedIndex == index )
CGContextRestoreGState( context );
// Draw text
[paraStyle setAlignment:NSCenterTextAlignment];
attributesDictionary = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont toolTipsFontOfSize:11.], NSFontAttributeName, paraStyle, NSParagraphStyleAttributeName, nil];
nameHeight = [[NSFont toolTipsFontOfSize:11.] defaultLineHeightForFont];
drawPoint = NSMakePoint( rint( buttonSize.width + 2 * NSMinX( buttonRect ) - NSWidth( _bounds ) - 1 ), rint( NSMaxY( buttonRect ) - titleBaseline - nameHeight ) );
[name drawAtPoint:drawPoint withAttributes:attributesDictionary];
}
- (void) _sizeToFit {
if( ! [self preferencePanes] ) return;
[self setFrameSize:NSMakeSize( NSWidth( _bounds ), NSMaxY( [self _boundsForIndex:[self _numberOfIcons] - 1] ) + bottomBorder ) ];
}
- (BOOL) _dragIconIndex:(unsigned int) index event:(NSEvent *) event {
NSImage *iconImage;
NSString *name;
NSString *identifier;
if( ! [self _iconImage:&iconImage andName:&name andIdentifier:&identifier forIndex:index] )
return YES;
return [self _dragIconImage:iconImage andName:name andIdentifier:identifier event:event];
}
- (BOOL) _dragIconImage:(NSImage *) iconImage andName:(NSString *) name event:(NSEvent *) event {
return [self _dragIconImage:iconImage andName:name andIdentifier:name event:event];
}
- (BOOL) _dragIconImage:(NSImage *) iconImage andName:(NSString *) name andIdentifier:(NSString *) identifier event:(NSEvent *) event {
NSImage *dragImage;
NSPasteboard *pasteboard;
NSPoint dragPoint, startPoint;
NSMutableParagraphStyle *paraStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
dragImage = [[NSImage alloc] initWithSize:buttonSize];
[dragImage lockFocus];
{
float nameHeight;
NSSize nameSize;
NSDictionary *attributesDictionary;
[iconImage drawInRect:NSMakeRect( buttonSize.width / 2. - iconSize.width / 2., iconBaseline, iconSize.width, iconSize.height ) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:.5];
[paraStyle setAlignment:NSCenterTextAlignment];
attributesDictionary = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont toolTipsFontOfSize:11.], NSFontAttributeName, [[NSColor blackColor] colorWithAlphaComponent:.5], NSForegroundColorAttributeName, paraStyle, NSParagraphStyleAttributeName, nil];
nameSize = [name sizeWithAttributes:attributesDictionary];
nameHeight = [[NSFont toolTipsFontOfSize:11.] defaultLineHeightForFont];
[name drawAtPoint:NSMakePoint( 0., nameHeight + titleBaseline - nameSize.height ) withAttributes:attributesDictionary];
[dragImage unlockFocus];
}
pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pasteboard declareTypes:[NSArray arrayWithObject:@"NSToolbarIndividualItemDragType"] owner:nil];
[pasteboard setString:identifier forType:@"NSToolbarItemIdentiferPboardType"];
dragPoint = [self convertPoint:[event locationInWindow] fromView:nil];
startPoint = [self _boundsForIndex:[preferencePanes indexOfObject:[NSBundle bundleWithIdentifier:identifier]]].origin;
startPoint.y += buttonSize.height;
[self setNeedsDisplayInRect:[self _boundsForIndex:pressedIconIndex]];
pressedIconIndex = NSNotFound;
[self dragImage:dragImage at:startPoint offset:NSZeroSize event:event pasteboard:pasteboard source:self slideBack:YES];
return YES;
}
@end