rv = NS_InitEmbedding(component_path); if (NS_FAILED(rv)) return;  nsIEventQueueService* eventQService; rv = nsServiceManager::GetService(kEventQueueServiceCID, NS_GET_IID(nsIEventQueueService), (nsISupports **)&eventQService); if (NS_OK == rv) {  nsIEventQueue *eventQueue; rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &eventQueue); if (NS_FAILED(rv)) return;
if (num_widgets == 0) { int retval; retval = _mozilla_embed_startup_xpcom(); if (retval != TRUE) printf("moz_embed_startup_xpcom(): FAILED\n"); }  num_widgets++;
static void mozilla_defaults( PtWidget_t *widget ){	PtMozillaWidget_t *moz = (PtMozillaWidget_t *)widget;	PtBasicWidget_t *basic = (PtBasicWidget_t *)widget;	nsCOMPtr<nsIWebBrowserChrome> browserChrome;	nsresult rv;	char *component_path = NULL;	rv = NS_InitEmbedding(component_path);	if (NS_FAILED(rv))	  return;	// set up the thread event queue	nsIEventQueueService* eventQService;	rv = nsServiceManager::GetService(kEventQueueServiceCID, NS_GET_IID(nsIEventQueueService), (nsISupports **)&eventQService);	if (NS_OK == rv)	{	  	// get our hands on the thread event queue	  	nsIEventQueue *eventQueue;	  	rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &eventQueue);	  	if (NS_FAILED(rv))			return;		PtAppAddFd(NULL, eventQueue->GetEventQueueSelectFD(), Pt_FD_READ|Pt_FD_NOPOLL, mozilla_handle_event_queue, eventQueue);	  	NS_RELEASE(eventQService);	  	NS_RELEASE(eventQueue);	}	basic->flags = Pt_ALL_OUTLINES | Pt_ALL_BEVELS | Pt_FLAT_FILL;	widget->resize_flags &= ~Pt_RESIZE_XY_BITS; // fixed size.	widget->anchor_flags = Pt_TOP_ANCHORED_TOP | Pt_LEFT_ANCHORED_LEFT | \			Pt_BOTTOM_ANCHORED_TOP | Pt_RIGHT_ANCHORED_LEFT | Pt_ANCHORS_INVALID;	strcpy(moz->url, "www.mozilla.org");	moz->embed_private = new MozEmbedPrivate();	// create an nsIWebBrowser object	moz->embed_private->webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);	// create our glue widget	moz->chrome = new MozEmbedChrome();	moz->embed_private->embed = do_QueryInterface((nsISupports *)(nsIPhEmbed *) moz->chrome);	// get our hands on the browser chrome	browserChrome = do_QueryInterface(moz->embed_private->embed);	// set the toplevel window	moz->embed_private->webBrowser->SetTopLevelWindow(browserChrome);	// set the widget as the owner of the object	moz->embed_private->embed->Init(widget);	// so the embedding widget can find it's owning nsIWebBrowser object	browserChrome->SetWebBrowser(moz->embed_private->webBrowser);	// track the window changes	moz->embed_private->embed->SetLinkChangeCallback((void (*)(void *))mozilla_embed_handle_link_change, widget);	moz->embed_private->embed->SetTitleChangeCallback((void (*)(void *))mozilla_embed_handle_title_change, widget);	moz->embed_private->embed->SetProgressCallback((void (*)(void *, int, int))mozilla_embed_handle_progress, widget);	moz->embed_private->embed->SetNetCallback((void (*)(void *, int, uint))mozilla_embed_handle_net, widget);	moz->embed_private->embed->SetLocationChangeCallback((void (*)(void *))mozilla_embed_handle_location_change, widget);	// get our hands on a copy of the nsIWebNavigation interface for later	moz->embed_private->navigation = do_QueryInterface(moz->embed_private->webBrowser);	browserChrome->SetChromeMask(1);}