> As for the xhtml text converter bundle Nicola suggests for use by the > gui library ... the obvious thing IMO would be to write it to use > SimpleWebKit, and perhaps provide an alternative bundle using WebKit > later.
The wrapper can indeed be made 100% interchangeable since both use the WebKit API. So, users can finally install one or the other. Here is a code snippet (this time from mySTEP AppKit and not really tested): - (id) initWithHTML:(NSData *)data documentAttributes:(NSDictionary **)dict; { return [self initWithHTML:data options:nil documentAttributes:dict]; } - (id) initWithHTML:(NSData *)data baseURL:(NSURL *)url documentAttributes:(NSDictionary **)dict; { return [self initWithHTML:data options:[NSDictionary dictionaryWithObject:url forKey:NSBaseURLDocumentOption] documentAttributes:dict]; } // reuse (this is not at all thread safe!) static BOOL didLoadWebKit; static WebView *webView; static BOOL done; - (void) webView:(WebView *)sender didFinishLoadForFrame:(WebFrame*) frame { NSLog(@"did finish loading main frame"); if(frame == [sender mainFrame]) done=YES; } - (id) initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttributes:(NSDictionary **)dict; { // check for HTML like header before trying if(!didLoadWebKit) [[NSBundle bundleWithPath:@"/System/Library/Frameworks/ WebKit.framework"] load], didLoadWebKit=YES; // dynamically load if(!webView) { webView=[[NSClassFromString(@"WebView") alloc] initWithFrame:NSMakeRect(0.0, 0.0, 100.0, 100.0)]; if(!webView) return nil; // can't initialize } [[webView mainFrame] loadData:data MIMEType:@"text/html" textEncodingName:@"utf-8" baseURL:[options objectForKey:NSBaseURLDocumentOption]]; [self setFrameLoadDelegate:self]; done=NO; while(!done) { // loading is not yet done [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:0.2] inMode:NSDefaultRunLoopMode dequeue:NO]; // process events } if(dict) *dict=[NSDictionary dictionaryWithKeysAndAttributes: NSHTMLTextDocumentType, NSDocumentTypeDocumentAttribute, [[[webView mainFrame] dataSource] textEncodingName], NSCharacterEncodingDocumentAttribute, // may be nil? [[[webView mainFrame] dataSource] pageTitle], NSTitleDocumentAttribute, // title may be nil!!! nil]; return [self initWithAttributedString:[[[[webView mainFrame] frameView] documentView] attributedString]]; } -- hns _______________________________________________ Discuss-gnustep mailing list Discuss-gnustep@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnustep