From: <ho...@us...> - 2010-10-13 16:53:51
|
Revision: 17240 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=17240&view=rev Author: hofman Date: 2010-10-13 16:53:44 +0000 (Wed, 13 Oct 2010) Log Message: ----------- Get window for sheet for webgroup from the webview. Set status text through a delegate instead of a document. Modified Paths: -------------- trunk/bibdesk/BDSKWebGroupViewController.h trunk/bibdesk/BDSKWebGroupViewController.m trunk/bibdesk/BibDocument_Groups.h trunk/bibdesk/BibDocument_Groups.m Modified: trunk/bibdesk/BDSKWebGroupViewController.h =================================================================== --- trunk/bibdesk/BDSKWebGroupViewController.h 2010-10-13 15:47:14 UTC (rev 17239) +++ trunk/bibdesk/BDSKWebGroupViewController.h 2010-10-13 16:53:44 UTC (rev 17240) @@ -39,8 +39,10 @@ #import <Cocoa/Cocoa.h> -@class BDSKCollapsibleView, BDSKEdgeView, BDSKWebGroup, WebView, WebFrame, BibDocument, BDSKDragTextField, BDSKFieldEditor, BDSKNewWebWindowHandler; +@class BDSKCollapsibleView, BDSKEdgeView, BDSKWebGroup, WebView, WebFrame, BDSKDragTextField, BDSKFieldEditor, BDSKNewWebWindowHandler; +@protocol BDSKWebGroupViewControllerDelegate; + @interface BDSKWebGroupViewController : NSViewController <NSMenuDelegate> { IBOutlet BDSKCollapsibleView *collapsibleView; IBOutlet BDSKDragTextField *urlField; @@ -48,7 +50,7 @@ IBOutlet NSSegmentedControl *backForwardButton; IBOutlet NSButton *stopOrReloadButton; - BibDocument *document; + id <BDSKWebGroupViewControllerDelegate> delegate; WebFrame *loadingWebFrame; NSUndoManager *undoManager; NSMutableArray *downloads; @@ -58,7 +60,7 @@ BDSKNewWebWindowHandler *newWindowHandler; } -- (id)initWithGroup:(BDSKWebGroup *)aGroup document:(BibDocument *)aDocument; +- (id)initWithGroup:(BDSKWebGroup *)aGroup delegate:(id<BDSKWebGroupViewControllerDelegate>)aDelegate; - (NSView *)webView; @@ -77,3 +79,8 @@ - (void)addBookmark:(id)sender; @end + + +@protocol BDSKWebGroupViewControllerDelegate <NSObject> +- (void)webGroupViewController:(BDSKWebGroupViewController *)controller setStatusText:(NSString *)text; +@end Modified: trunk/bibdesk/BDSKWebGroupViewController.m =================================================================== --- trunk/bibdesk/BDSKWebGroupViewController.m 2010-10-13 15:47:14 UTC (rev 17239) +++ trunk/bibdesk/BDSKWebGroupViewController.m 2010-10-13 16:53:44 UTC (rev 17240) @@ -52,7 +52,6 @@ #import "NSFileManager_BDSKExtensions.h" #import "NSWorkspace_BDSKExtensions.h" #import "BibDocument.h" -#import "BibDocument_UI.h" #import "BDSKBookmarkController.h" #import "BDSKBookmark.h" #import "NSMenu_BDSKExtensions.h" @@ -81,10 +80,10 @@ [WebView registerURLSchemeAsLocal:BDSKBibDeskScheme]; } -- (id)initWithGroup:(BDSKWebGroup *)aGroup document:(BibDocument *)aDocument { +- (id)initWithGroup:(BDSKWebGroup *)aGroup delegate:(id<BDSKWebGroupViewControllerDelegate>)aDelegate { if (self = [super initWithNibName:@"BDSKWebGroupView" bundle:nil]) { [self setRepresentedObject:aGroup]; - document = aDocument; + delegate = aDelegate; } return self; } @@ -96,6 +95,7 @@ [webView setUIDelegate:nil]; [webView setPolicyDelegate:nil]; [urlField setDelegate:nil]; + delegate = nil; BDSKDESTROY(undoManager); BDSKDESTROY(downloads); BDSKDESTROY(fieldEditor); @@ -506,22 +506,15 @@ #pragma mark WebUIDelegate protocol -- (void)setStatus:(NSString *)text { - if ([webView window] == nil) - return; - if ([NSString isEmptyString:text]) - [document updateStatus]; - else - [document setStatus:text]; -} - - (void)webView:(WebView *)sender setStatusText:(NSString *)text { - [self setStatus:text]; + if ([webView window]) + [delegate webGroupViewController:self setStatusText:text]; } - (void)webView:(WebView *)sender mouseDidMoveOverElement:(NSDictionary *)elementInformation modifierFlags:(NSUInteger)modifierFlags { NSURL *aLink = [elementInformation objectForKey:WebElementLinkURLKey]; - [self setStatus:[[aLink absoluteString] stringByReplacingPercentEscapes]]; + if ([webView window]) + [delegate webGroupViewController:self setStatusText:[[aLink absoluteString] stringByReplacingPercentEscapes]]; } - (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems; @@ -628,7 +621,7 @@ #pragma mark NSURLDownloadDelegate protocol - (NSWindow *)downloadWindowForAuthenticationSheet:(WebDownload *)download { - return [document windowForSheet]; + return [webView window]; } - (void)download:(NSURLDownload *)download decideDestinationWithSuggestedFilename:(NSString *)filename { @@ -666,10 +659,11 @@ alternateButton:nil otherButton:nil informativeTextWithFormat:errorDescription]; - [alert beginSheetModalForWindow:[document windowForSheet] - modalDelegate:nil - didEndSelector:NULL - contextInfo:NULL]; + NSWindow *window = [webView window]; + if (window) + [alert beginSheetModalForWindow:window modalDelegate:nil didEndSelector:NULL contextInfo:NULL]; + else + [alert runModal]; } @end Modified: trunk/bibdesk/BibDocument_Groups.h =================================================================== --- trunk/bibdesk/BibDocument_Groups.h 2010-10-13 15:47:14 UTC (rev 17239) +++ trunk/bibdesk/BibDocument_Groups.h 2010-10-13 16:53:44 UTC (rev 17240) @@ -37,10 +37,11 @@ #import <Cocoa/Cocoa.h> #import "BibDocument.h" +#import "BDSKWebGroupViewController.h" @class BDSKGroup, BDSKSmartGroup, BDSKStaticGroup, BDSKExternalGroup, BDSKURLGroup, BDSKScriptGroup, BDSKWebGroup, BDSKFilterController, BDSKURLGroupSheetController, BDSKScriptGroupSheetController, BDSKWebGroupViewController; -@interface BibDocument (Groups) +@interface BibDocument (Groups) <BDSKWebGroupViewControllerDelegate> - (BOOL)hasLibraryGroupSelected; - (BOOL)hasLastImportGroupSelected; Modified: trunk/bibdesk/BibDocument_Groups.m =================================================================== --- trunk/bibdesk/BibDocument_Groups.m 2010-10-13 15:47:14 UTC (rev 17239) +++ trunk/bibdesk/BibDocument_Groups.m 2010-10-13 16:53:44 UTC (rev 17240) @@ -73,7 +73,6 @@ #import "BDSKMainTableView.h" #import "BDSKSearchGroupSheetController.h" #import "BDSKSearchGroupViewController.h" -#import "BDSKWebGroupViewController.h" #import "BDSKServerInfo.h" #import "BDSKSearchBookmarkController.h" #import "BDSKSearchBookmark.h" @@ -232,7 +231,7 @@ - (BDSKWebGroupViewController *)webGroupViewController { if (webGroupViewController == nil) - webGroupViewController = [[BDSKWebGroupViewController alloc] initWithGroup:[groups webGroup] document:self]; + webGroupViewController = [[BDSKWebGroupViewController alloc] initWithGroup:[groups webGroup] delegate:self]; return webGroupViewController; } @@ -286,6 +285,12 @@ } } +- (void)webGroupViewController:(BDSKWebGroupViewController *)controller setStatusText:(NSString *)text { + if ([NSString isEmptyString:text]) + [self updateStatus]; + else + [self setStatus:text]; +} #pragma mark Notification handlers This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |