зеркало из https://github.com/mozilla/pjs.git
Fix bug 287339: correctly enable/disable bookmark items when tabs close, and windows change layers.
Make the NSOpenPanel into a sheet when a window is up. Allow opening multiple items in the open panel, opening them in tabs. Remove [MainController pumpGeckoEventQueue] which is obsolete and unused. Add NSResponder+Utils.h/m to the project. Remove #ifdefs in AppComponents.mm now that we will be using nsSimpleGlobalHistory.
This commit is contained in:
Родитель
5265c7fe6e
Коммит
c6d8a395b5
|
@ -1017,6 +1017,48 @@
|
|||
settings = {
|
||||
};
|
||||
};
|
||||
0F5FD71B07F48CDC00E8EDBD = {
|
||||
fileEncoding = 30;
|
||||
isa = PBXFileReference;
|
||||
lastKnownFileType = sourcecode.c.h;
|
||||
name = "NSResponder+Utils.h";
|
||||
path = "src/extensions/NSResponder+Utils.h";
|
||||
refType = 4;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0F5FD71C07F48CDC00E8EDBD = {
|
||||
fileRef = 0F5FD71B07F48CDC00E8EDBD;
|
||||
isa = PBXBuildFile;
|
||||
settings = {
|
||||
};
|
||||
};
|
||||
0F5FD71D07F48CDC00E8EDBD = {
|
||||
fileRef = 0F5FD71B07F48CDC00E8EDBD;
|
||||
isa = PBXBuildFile;
|
||||
settings = {
|
||||
};
|
||||
};
|
||||
0F5FD71E07F48CE500E8EDBD = {
|
||||
fileEncoding = 30;
|
||||
isa = PBXFileReference;
|
||||
lastKnownFileType = sourcecode.c.objc;
|
||||
name = "NSResponder+Utils.m";
|
||||
path = "src/extensions/NSResponder+Utils.m";
|
||||
refType = 4;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
0F5FD71F07F48CE500E8EDBD = {
|
||||
fileRef = 0F5FD71E07F48CE500E8EDBD;
|
||||
isa = PBXBuildFile;
|
||||
settings = {
|
||||
};
|
||||
};
|
||||
0F5FD72007F48CE500E8EDBD = {
|
||||
fileRef = 0F5FD71E07F48CE500E8EDBD;
|
||||
isa = PBXBuildFile;
|
||||
settings = {
|
||||
};
|
||||
};
|
||||
0F66E4A807D6D8D500444E2A = {
|
||||
fileRef = 0FCCE56707D6D7DA006DD3D1;
|
||||
isa = PBXBuildFile;
|
||||
|
@ -2446,6 +2488,7 @@
|
|||
0FBC0EE30798FA2700E8E0E2,
|
||||
0F13A30F07D7F3930034B176,
|
||||
0F4752D407DC0F4D002AEE9F,
|
||||
0F5FD71C07F48CDC00E8EDBD,
|
||||
);
|
||||
isa = PBXHeadersBuildPhase;
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -3559,6 +3602,7 @@
|
|||
0FBC0EE00798FA1900E8E0E2,
|
||||
0F13A31007D7F3930034B176,
|
||||
0F4752D507DC0F4D002AEE9F,
|
||||
0F5FD71F07F48CE500E8EDBD,
|
||||
);
|
||||
isa = PBXSourcesBuildPhase;
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -6309,6 +6353,7 @@
|
|||
0FBC0EE40798FA2700E8E0E2,
|
||||
0F13A31107D7F3930034B176,
|
||||
0F4752D607DC0F4D002AEE9F,
|
||||
0F5FD71D07F48CDC00E8EDBD,
|
||||
);
|
||||
isa = PBXHeadersBuildPhase;
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -7423,6 +7468,7 @@
|
|||
0FBC0EE10798FA1900E8E0E2,
|
||||
0F13A31207D7F3930034B176,
|
||||
0F4752D707DC0F4D002AEE9F,
|
||||
0F5FD72007F48CE500E8EDBD,
|
||||
);
|
||||
isa = PBXSourcesBuildPhase;
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -14402,6 +14448,7 @@
|
|||
F527C90203BCD43601A80166,
|
||||
F549ACE40302DEBB01026D5D,
|
||||
F5B34B04034A50C901A80166,
|
||||
0F5FD71B07F48CDC00E8EDBD,
|
||||
F5648739023C3857010001CA,
|
||||
F5C3AB810270072A01A80166,
|
||||
F583E3C203B8228F01A80166,
|
||||
|
@ -14431,6 +14478,7 @@
|
|||
F549ACDF0302DE6001026D5D,
|
||||
F527C90303BCD43601A80166,
|
||||
F5B34B01034A505F01A80166,
|
||||
0F5FD71E07F48CE500E8EDBD,
|
||||
F564873A023C3857010001CA,
|
||||
F583E3BF03B8228701A80166,
|
||||
F541495B02711A8301A80166,
|
||||
|
|
Двоичные данные
camino/resources/localized/English.lproj/MainMenu.nib/keyedobjects.nib
сгенерированный
Двоичные данные
camino/resources/localized/English.lproj/MainMenu.nib/keyedobjects.nib
сгенерированный
Двоичный файл не отображается.
|
@ -36,8 +36,6 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#define SIMPLE_GLOBAL_HISTORY 1
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "SecurityDialogs.h"
|
||||
|
@ -49,14 +47,12 @@
|
|||
|
||||
#include "nsIGenericFactory.h"
|
||||
|
||||
#ifdef SIMPLE_GLOBAL_HISTORY
|
||||
#include "nsSimpleGlobalHistory.h"
|
||||
|
||||
// for some bizarre reason this is in nsDocShellCID.h
|
||||
#define NS_GLOBALHISTORY2_CONTRACTID \
|
||||
"@mozilla.org/browser/global-history;2"
|
||||
|
||||
#endif
|
||||
|
||||
// {0ffd3880-7a1a-11d6-a384-975d1d5f86fc}
|
||||
#define NS_SECURITYDIALOGS_CID \
|
||||
|
@ -76,7 +72,6 @@
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(SecurityDialogs)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(CocoaPromptService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(KeychainPrompt)
|
||||
//NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloadListener)
|
||||
|
||||
static nsresult
|
||||
nsDownloadListenerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
|
@ -97,7 +92,6 @@ nsDownloadListenerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult
|
|||
return rv;
|
||||
}
|
||||
|
||||
#ifdef SIMPLE_GLOBAL_HISTORY
|
||||
// we have to provide a custom constructor to work around a component manager
|
||||
// bug (see bug 276956) that can cause more than one instance of nsSimpleGlobalHistory
|
||||
// to be created (for each of the 2 services it implements). So we enforce its
|
||||
|
@ -134,7 +128,6 @@ nsSimpleGlobalHistoryConstructor(nsISupports *aOuter, REFNSIID aIID, void **aRes
|
|||
// the QI does the AddRef
|
||||
return sGlobalHistorySingleton->QueryInterface(aIID, aResult);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// used by MainController to register the components in which we want to override
|
||||
|
@ -176,10 +169,7 @@ static const nsModuleComponentInfo gAppComponents[] = {
|
|||
NS_COOKIEPROMPTSERVICE_CID,
|
||||
NS_COOKIEPROMPTSERVICE_CONTRACTID,
|
||||
CocoaPromptServiceConstructor
|
||||
}
|
||||
|
||||
#ifdef SIMPLE_GLOBAL_HISTORY
|
||||
,
|
||||
},
|
||||
{
|
||||
"Global History",
|
||||
NS_SIMPLEGLOBALHISTORY_CID,
|
||||
|
@ -191,9 +181,7 @@ static const nsModuleComponentInfo gAppComponents[] = {
|
|||
NS_SIMPLEGLOBALHISTORY_CID,
|
||||
NS_GLOBALHISTORY_AUTOCOMPLETE_CONTRACTID,
|
||||
nsSimpleGlobalHistoryConstructor
|
||||
}
|
||||
#endif
|
||||
,
|
||||
},
|
||||
{
|
||||
"About Bookmarks Module",
|
||||
NS_ABOUT_BOOKMARKS_MODULE_CID,
|
||||
|
|
|
@ -72,7 +72,6 @@ typedef enum EBookmarkOpenBehavior
|
|||
// IBOutlet NSMenuItem* mOfflineMenuItem;
|
||||
IBOutlet NSMenuItem* mCloseWindowMenuItem;
|
||||
IBOutlet NSMenuItem* mCloseTabMenuItem;
|
||||
IBOutlet NSMenuItem* mShowAllBookmarksMenuItem;
|
||||
|
||||
IBOutlet NSMenu* mGoMenu;
|
||||
IBOutlet NSMenu* mBookmarksMenu;
|
||||
|
@ -82,7 +81,8 @@ typedef enum EBookmarkOpenBehavior
|
|||
IBOutlet NSMenuItem* mBookmarksToolbarMenuItem;
|
||||
IBOutlet NSMenuItem* mAddBookmarkMenuItem;
|
||||
IBOutlet NSMenuItem* mCreateBookmarksFolderMenuItem;
|
||||
IBOutlet NSMenuItem* mCreateBookmarksSeparatorMenuItem;
|
||||
IBOutlet NSMenuItem* mCreateBookmarksSeparatorMenuItem; // unused
|
||||
IBOutlet NSMenuItem* mShowAllBookmarksMenuItem;
|
||||
|
||||
BOOL mOffline;
|
||||
|
||||
|
@ -169,7 +169,7 @@ typedef enum EBookmarkOpenBehavior
|
|||
- (void)adjustCloseTabMenuItemKeyEquivalent:(BOOL)inHaveTabs;
|
||||
- (void)fixCloseMenuItemKeyEquivalents;
|
||||
|
||||
- (void)adjustBookmarksMenuItemsEnabling:(BOOL)inBrowserWindowFrontmost;
|
||||
- (void)adjustBookmarksMenuItemsEnabling;
|
||||
|
||||
- (NSView*)getSavePanelView;
|
||||
- (NSWindow*)getFrontmostBrowserWindow;
|
||||
|
@ -185,8 +185,6 @@ typedef enum EBookmarkOpenBehavior
|
|||
|
||||
+ (NSImage*)createImageForDragging:(NSImage*)aIcon title:(NSString*)aTitle;
|
||||
|
||||
- (void)pumpGeckoEventQueue;
|
||||
|
||||
// used by export bookmarks popup to say what file extension should be used on the resulting
|
||||
// bookmarks file.
|
||||
-(IBAction) setFileExtension:(id)aSender;
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#import <Carbon/Carbon.h>
|
||||
|
||||
#import "NSString+Utils.h"
|
||||
#import "NSResponder+Utils.h"
|
||||
#import "NSMenu+Utils.h"
|
||||
|
||||
#import "ChimeraUIConstants.h"
|
||||
#import "MainController.h"
|
||||
|
@ -105,9 +107,16 @@ const int kReuseWindowOnAE = 2;
|
|||
@interface MainController(Private)<NetworkServicesClient>
|
||||
|
||||
- (void)setupStartpage;
|
||||
- (void)installBookmarksMenuEnableHandler;
|
||||
- (NSMenu*)bookmarksMenu;
|
||||
- (BOOL)bookmarksItemsEnabled;
|
||||
- (void)adjustBookmarkMenuItems;
|
||||
- (void)windowLayeringDidChange:(NSNotification*)inNotifiction;
|
||||
- (void)openPanelDidEnd:(NSOpenPanel*)inOpenPanel returnCode:(int)inReturnCode contextInfo:(void*)inContextInfo;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation MainController
|
||||
|
||||
|
@ -181,9 +190,18 @@ const int kReuseWindowOnAE = 2;
|
|||
|
||||
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
[self installBookmarksMenuEnableHandler];
|
||||
|
||||
// initialize prefs if we haven't already.
|
||||
PreferenceManager *pm = [PreferenceManager sharedInstance];
|
||||
|
||||
// register for window layering changes, so that we can update the bookmarks menu
|
||||
NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter];
|
||||
[notificationCenter addObserver:self selector:@selector(windowLayeringDidChange:) name:NSWindowDidBecomeKeyNotification object:nil];
|
||||
[notificationCenter addObserver:self selector:@selector(windowLayeringDidChange:) name:NSWindowDidResignKeyNotification object:nil];
|
||||
[notificationCenter addObserver:self selector:@selector(windowLayeringDidChange:) name:NSWindowDidBecomeMainNotification object:nil];
|
||||
[notificationCenter addObserver:self selector:@selector(windowLayeringDidChange:) name:NSWindowDidResignMainNotification object:nil];
|
||||
|
||||
// start bookmarks
|
||||
RunLoopMessenger *mainThreadRunLoopMessenger = [[RunLoopMessenger alloc] init];
|
||||
[NSThread detachNewThreadSelector:@selector(startBookmarksManager:) toTarget:[BookmarkManager class] withObject:mainThreadRunLoopMessenger];
|
||||
|
@ -226,10 +244,9 @@ const int kReuseWindowOnAE = 2;
|
|||
long systemVersion;
|
||||
OSErr err = ::Gestalt(gestaltSystemVersion, &systemVersion);
|
||||
if ((err == noErr) && (systemVersion >= 0x00001023)) {
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
[nc addObserver:self selector:@selector(availableServicesChanged:) name:NetworkServicesAvailableServicesChanged object:nil];
|
||||
[nc addObserver:self selector:@selector(serviceResolved:) name:NetworkServicesResolutionSuccess object:nil];
|
||||
[nc addObserver:self selector:@selector(serviceResolutionFailed:) name:NetworkServicesResolutionFailure object:nil];
|
||||
[notificationCenter addObserver:self selector:@selector(availableServicesChanged:) name:NetworkServicesAvailableServicesChanged object:nil];
|
||||
[notificationCenter addObserver:self selector:@selector(serviceResolved:) name:NetworkServicesResolutionSuccess object:nil];
|
||||
[notificationCenter addObserver:self selector:@selector(serviceResolutionFailed:) name:NetworkServicesResolutionFailure object:nil];
|
||||
doingRendezvous = YES;
|
||||
}
|
||||
}
|
||||
|
@ -279,6 +296,13 @@ const int kReuseWindowOnAE = 2;
|
|||
[self autorelease];
|
||||
}
|
||||
|
||||
- (void)windowLayeringDidChange:(NSNotification*)inNotifiction
|
||||
{
|
||||
// The key window isn't set until after this notification is processed, so we have to delay the actual
|
||||
// menu update.
|
||||
[self performSelectorOnMainThread:@selector(adjustBookmarksMenuItemsEnabling) withObject:nil waitUntilDone:NO];
|
||||
}
|
||||
|
||||
- (NSMenu *)applicationDockMenu:(NSApplication *)sender
|
||||
{
|
||||
return mDockMenu;
|
||||
|
@ -497,29 +521,65 @@ Otherwise, we return the URL we originally got. Right now this supports .url and
|
|||
|
||||
-(IBAction) openFile:(id)aSender
|
||||
{
|
||||
NSOpenPanel* openPanel = [[[NSOpenPanel alloc] init] autorelease];
|
||||
[openPanel setCanChooseFiles: YES];
|
||||
[openPanel setCanChooseDirectories: NO];
|
||||
[openPanel setAllowsMultipleSelection: NO];
|
||||
NSArray* array = [NSArray arrayWithObjects: @"htm",@"html",@"shtml",@"xhtml",@"xml",
|
||||
@"txt",@"text",
|
||||
@"gif",@"jpg",@"jpeg",@"png",@"bmp",
|
||||
@"webloc",@"url",
|
||||
nil];
|
||||
int result = [openPanel runModalForTypes: array];
|
||||
if (result == NSOKButton) {
|
||||
NSArray* urlArray = [openPanel URLs];
|
||||
if ([urlArray count] == 0)
|
||||
return;
|
||||
NSURL* url = [urlArray objectAtIndex: 0];
|
||||
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url];
|
||||
url = [MainController decodeLocalFileURL:url];
|
||||
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||
if (browserController)
|
||||
[browserController loadURL:[url absoluteString] referrer:nil activate:YES allowPopups:NO];
|
||||
else
|
||||
[self openBrowserWindowWithURL:[url absoluteString] andReferrer:nil behind:nil allowPopups:NO];
|
||||
}
|
||||
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
|
||||
[openPanel setCanChooseFiles:YES];
|
||||
[openPanel setCanChooseDirectories:NO];
|
||||
[openPanel setAllowsMultipleSelection:YES];
|
||||
NSArray* fileTypes = [NSArray arrayWithObjects: @"htm",@"html",@"shtml",@"xhtml",@"xml",
|
||||
@"txt",@"text",
|
||||
@"gif",@"jpg",@"jpeg",@"png",@"bmp",
|
||||
@"webloc",@"url",
|
||||
nil];
|
||||
|
||||
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||
if (browserController)
|
||||
{
|
||||
[openPanel beginSheetForDirectory:nil
|
||||
file:nil
|
||||
types:fileTypes
|
||||
modalForWindow:[browserController window]
|
||||
modalDelegate:self
|
||||
didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:)
|
||||
contextInfo:browserController];
|
||||
}
|
||||
else
|
||||
{
|
||||
int result = [openPanel runModalForTypes:fileTypes];
|
||||
[self openPanelDidEnd:openPanel returnCode:result contextInfo:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)openPanelDidEnd:(NSOpenPanel*)inOpenPanel returnCode:(int)inReturnCode contextInfo:(void*)inContextInfo
|
||||
{
|
||||
if (inReturnCode != NSOKButton)
|
||||
return;
|
||||
|
||||
BrowserWindowController* browserController = (BrowserWindowController*)inContextInfo;
|
||||
|
||||
NSArray* urlArray = [inOpenPanel URLs];
|
||||
if ([urlArray count] == 0)
|
||||
return;
|
||||
|
||||
NSMutableArray* urlStringsArray = [NSMutableArray arrayWithCapacity:[urlArray count]];
|
||||
|
||||
// fix them up
|
||||
NSEnumerator* urlsEnum = [urlArray objectEnumerator];
|
||||
NSURL* curURL;
|
||||
while ((curURL = [urlsEnum nextObject]))
|
||||
{
|
||||
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:curURL];
|
||||
curURL = [MainController decodeLocalFileURL:curURL];
|
||||
[urlStringsArray addObject:[curURL path]];
|
||||
}
|
||||
|
||||
if (!browserController)
|
||||
{
|
||||
[self openBrowserWindowWithURLs:urlStringsArray behind:nil allowPopups:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[browserController openURLArray:urlStringsArray replaceExistingTabs:YES allowPopups:YES];
|
||||
}
|
||||
}
|
||||
|
||||
-(IBAction) openLocation:(id)aSender
|
||||
|
@ -713,34 +773,63 @@ Otherwise, we return the URL we originally got. Right now this supports .url and
|
|||
[[ProgressDlgController sharedDownloadController] showWindow:aSender];
|
||||
}
|
||||
|
||||
|
||||
// super sekrit private API
|
||||
extern "C" MenuRef _NSGetCarbonMenu(NSMenu* aMenu);
|
||||
|
||||
static OSStatus MenuEventHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData)
|
||||
{
|
||||
UInt32 eventKind = ::GetEventKind(inEvent);
|
||||
switch (eventKind)
|
||||
{
|
||||
case kEventMenuOpening:
|
||||
{
|
||||
MainController* mainController = (MainController*)inUserData;
|
||||
MenuRef theMenu;
|
||||
OSStatus err = ::GetEventParameter(inEvent, kEventParamDirectObject, typeMenuRef, NULL, sizeof(MenuRef), NULL, &theMenu);
|
||||
if ((err == noErr) && (theMenu == _NSGetCarbonMenu([mainController bookmarksMenu])))
|
||||
{
|
||||
[mainController adjustBookmarkMenuItems];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// always let the event propagate
|
||||
return eventNotHandledErr;
|
||||
}
|
||||
|
||||
// install a carbon event handler so that we can tell when a menu is being opened
|
||||
// on 10.3, we could use NSMenu delegate methods
|
||||
- (void)installBookmarksMenuEnableHandler
|
||||
{
|
||||
const EventTypeSpec menuEventList[] = { { kEventClassMenu, kEventMenuOpening } };
|
||||
|
||||
InstallApplicationEventHandler(NewEventHandlerUPP(MenuEventHandler),
|
||||
GetEventTypeCount(menuEventList),
|
||||
menuEventList, (void*)self, NULL);
|
||||
}
|
||||
|
||||
//
|
||||
// -adjustBookmarksMenuItemsEnabling:
|
||||
// -adjustBookmarksMenuItemsEnabling
|
||||
//
|
||||
// We've turned off auto-enabling for the bookmarks menu because of the unknown
|
||||
// number of bookmarks in the list so we have to manage it manually. This routine
|
||||
// should be called whenever a window goes away, becomes main, or is no longer main.
|
||||
//
|
||||
- (void)adjustBookmarksMenuItemsEnabling:(BOOL)inBrowserWindowFrontmost
|
||||
- (void)adjustBookmarksMenuItemsEnabling
|
||||
{
|
||||
[mAddBookmarkMenuItem setEnabled:inBrowserWindowFrontmost];
|
||||
[mCreateBookmarksFolderMenuItem setEnabled:inBrowserWindowFrontmost];
|
||||
[mCreateBookmarksSeparatorMenuItem setEnabled:YES];
|
||||
NSResponder* firstResponder = [[NSApp keyWindow] firstResponder];
|
||||
[mAddBookmarkMenuItem setEnabled:([firstResponder responderForAction:[mAddBookmarkMenuItem action]] != nil)];
|
||||
[mCreateBookmarksFolderMenuItem setEnabled:([firstResponder responderForAction:[mCreateBookmarksFolderMenuItem action]] != nil)];
|
||||
[mCreateBookmarksSeparatorMenuItem setEnabled:([firstResponder responderForAction:[mCreateBookmarksSeparatorMenuItem action]] != nil)];
|
||||
|
||||
|
||||
// We need the frontmost browser for the case of the dl/about window
|
||||
// is the main so we can ensure the "show/hide all bookmarks" has the correct
|
||||
// state for that window. Unfortunately, we can't rely on |-getFrontmostBrowserWindow| in all
|
||||
// cases, such as when a window has just been opened. As a result, first
|
||||
// try |-getMainWindowBrowserController| and if that fails use fFBW as a fallback.
|
||||
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||
if (!browserController)
|
||||
browserController = (BrowserWindowController*)[[self getFrontmostBrowserWindow] windowController];
|
||||
|
||||
BOOL showBookmarksEnabled = YES;
|
||||
BOOL browserWindowIsMain = [[[NSApp mainWindow] delegate] isMemberOfClass:[BrowserWindowController class]];
|
||||
BOOL showBookmarksEnabled = [self bookmarksItemsEnabled];
|
||||
BOOL useShowLabel = YES;
|
||||
|
||||
if (browserController)
|
||||
if (browserWindowIsMain)
|
||||
{
|
||||
BrowserWindowController* browserController = (BrowserWindowController*)[[NSApp mainWindow] delegate];
|
||||
if ([browserController bookmarkManagerIsVisible])
|
||||
{
|
||||
useShowLabel = NO;
|
||||
|
@ -759,6 +848,51 @@ Otherwise, we return the URL we originally got. Right now this supports .url and
|
|||
[mShowAllBookmarksMenuItem setEnabled:showBookmarksEnabled];
|
||||
}
|
||||
|
||||
- (NSMenu*)bookmarksMenu
|
||||
{
|
||||
return mBookmarksMenu;
|
||||
}
|
||||
|
||||
- (BOOL)bookmarksItemsEnabled
|
||||
{
|
||||
BOOL enableItems = YES;
|
||||
|
||||
// NSLog(@"Main window %@, key window %@", [NSApp mainWindow], [NSApp keyWindow]);
|
||||
|
||||
// I can't help thinking that there's an easier way, via NSResponder-type logic
|
||||
// XXX this isn't quite right yet. It disables stuff when the toolbar customization
|
||||
// sheet is up, which is unnecessary.
|
||||
NSEnumerator* windowEnum = [[NSApp windows] objectEnumerator];
|
||||
NSWindow* curWindow;
|
||||
while ((curWindow = [windowEnum nextObject]))
|
||||
{
|
||||
if (![curWindow isVisible])
|
||||
continue;
|
||||
|
||||
if ([curWindow level] == NSModalPanelWindowLevel)
|
||||
{
|
||||
enableItems = NO;
|
||||
break;
|
||||
}
|
||||
|
||||
if ([curWindow isSheet])
|
||||
{
|
||||
enableItems = NO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return enableItems;
|
||||
}
|
||||
|
||||
- (void)adjustBookmarkMenuItems
|
||||
{
|
||||
BOOL enableItems = [self bookmarksItemsEnabled];
|
||||
|
||||
int firstBookmarkItem = [mBookmarksMenu indexOfItemWithTag:kBookmarksDividerTag] + 1;
|
||||
[mBookmarksMenu setAllItemsEnabled:enableItems startingWithItemAtIndex:firstBookmarkItem includingSubmenus:YES];
|
||||
}
|
||||
|
||||
- (NSView*)getSavePanelView
|
||||
{
|
||||
if (!mFilterView)
|
||||
|
@ -784,8 +918,8 @@ Otherwise, we return the URL we originally got. Right now this supports .url and
|
|||
unsigned int chromeMask = [[thisWindow windowController] chromeMask];
|
||||
if (chromeMask == 0 ||
|
||||
(chromeMask & nsIWebBrowserChrome::CHROME_TOOLBAR &&
|
||||
chromeMask & nsIWebBrowserChrome::CHROME_STATUSBAR &&
|
||||
chromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE)) {
|
||||
chromeMask & nsIWebBrowserChrome::CHROME_STATUSBAR &&
|
||||
chromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE)) {
|
||||
foundWindow = thisWindow;
|
||||
break;
|
||||
}
|
||||
|
@ -1501,18 +1635,6 @@ static int SortByProtocolAndName(NSDictionary* item1, NSDictionary* item2, void
|
|||
[self openNewWindowOrTabWithURL:pageToLoad andReferrer:nil];
|
||||
}
|
||||
|
||||
// currently unused
|
||||
- (void)pumpGeckoEventQueue
|
||||
{
|
||||
nsCOMPtr<nsIEventQueueService> service = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID);
|
||||
if (!service) return;
|
||||
|
||||
nsCOMPtr<nsIEventQueue> queue;
|
||||
service->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(queue));
|
||||
if (queue)
|
||||
queue->ProcessPendingEvents();
|
||||
}
|
||||
|
||||
// Reads the URL from a .webloc . Returns nil on failure.
|
||||
+(NSString*)urlStringFromWebloc:(NSString*)inFile
|
||||
{
|
||||
|
|
|
@ -443,16 +443,14 @@ enum BWCOpenDest {
|
|||
|
||||
- (void)windowDidBecomeMain:(NSNotification *)notification
|
||||
{
|
||||
// we have to manually enable/disable the bookmarks menu items, because we
|
||||
// turn autoenabling off for that menu
|
||||
[[NSApp delegate] adjustBookmarksMenuItemsEnabling:YES];
|
||||
// MainController listens for window layering notifications and updates bookmarks,
|
||||
// so we don't need to do anything here
|
||||
}
|
||||
|
||||
- (void)windowDidResignMain:(NSNotification *)notification
|
||||
{
|
||||
// we have to manually enable/disable the bookmarks menu items, because we
|
||||
// turn autoenabling off for that menu
|
||||
[[NSApp delegate] adjustBookmarksMenuItemsEnabling:NO];
|
||||
// MainController listens for window layering notifications and updates bookmarks,
|
||||
// so we don't need to do anything here
|
||||
}
|
||||
|
||||
-(void)mouseMoved:(NSEvent*)aEvent
|
||||
|
@ -487,9 +485,6 @@ enum BWCOpenDest {
|
|||
{
|
||||
mClosingWindow = YES;
|
||||
|
||||
#if DEBUG
|
||||
NSLog(@"Window will close notification.");
|
||||
#endif
|
||||
[self autosaveWindowFrame];
|
||||
|
||||
// ensure that the URL auto-complete popup is closed before the mork
|
||||
|
@ -507,10 +502,6 @@ enum BWCOpenDest {
|
|||
// Tell the BrowserTabView the window is closed
|
||||
[mTabBrowser windowClosed];
|
||||
|
||||
// we have to manually enable/disable the bookmarks menu items, because we
|
||||
// turn autoenabling off for that menu
|
||||
[[NSApp delegate] adjustBookmarksMenuItemsEnabling:NO];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
// autorelease just in case we're here because of a window closing
|
||||
|
@ -1319,7 +1310,7 @@ enum BWCOpenDest {
|
|||
- (void)contentViewChangedTo:(NSView*)inView forURL:(NSString*)inURL
|
||||
{
|
||||
// update bookmarks menu
|
||||
[[NSApp delegate] adjustBookmarksMenuItemsEnabling:[[self window] isMainWindow]];
|
||||
[[NSApp delegate] adjustBookmarksMenuItemsEnabling];
|
||||
}
|
||||
|
||||
- (void)updateFromFrontmostTab
|
||||
|
@ -1510,7 +1501,7 @@ enum BWCOpenDest {
|
|||
else
|
||||
[self loadURL:@"about:bookmarks" referrer:nil activate:YES allowPopups:NO];
|
||||
|
||||
[[NSApp delegate] adjustBookmarksMenuItemsEnabling:[[self window] isMainWindow]];
|
||||
[[NSApp delegate] adjustBookmarksMenuItemsEnabling];
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -2322,9 +2313,12 @@ enum BWCOpenDest {
|
|||
|
||||
-(IBAction)closeCurrentTab:(id)sender
|
||||
{
|
||||
if ( [mTabBrowser numberOfTabViewItems] > 1 ) {
|
||||
if ( [mTabBrowser numberOfTabViewItems] > 1 )
|
||||
{
|
||||
[[[mTabBrowser selectedTabViewItem] view] windowClosed];
|
||||
[mTabBrowser removeTabViewItem:[mTabBrowser selectedTabViewItem]];
|
||||
|
||||
[[NSApp delegate] adjustBookmarksMenuItemsEnabling];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче