nsIThread::SetMainThread();
gtk_mozilla_get_type (void){  static GtkType mozilla_type = 0;  if (!mozilla_type) {    static const GtkTypeInfo mozilla_info = {      "GtkMozilla",      sizeof (GtkMozilla),      sizeof (GtkMozillaClass),      (GtkClassInitFunc) gtk_mozilla_class_init,      (GtkObjectInitFunc) gtk_mozilla_init,      0,      0    };    mozilla_type = gtk_type_unique (GTK_TYPE_FIXED, &mozilla_info);    //printf("Setting up registry.\n");        NS_SetupRegistry();    //printf("Creating event queue.\n");        nsIEventQueueService *aEventQService = nsnull;    // Create the Event Queue for the UI thread...    nsresult rv = nsServiceManager::GetService(kEventQueueServiceCID,                                               NS_GET_IID(nsIEventQueueService),                                               (nsISupports **)&aEventQService);        if (!NS_SUCCEEDED(rv)) {      printf("Could not obtain the event queue service\n");      return rv;    }        // Create the event queue    rv = aEventQService->CreateThreadEventQueue();    if (!NS_SUCCEEDED(rv)) {      printf("Could not create the event queue for the the thread");      return rv;    }    nsIEventQueue * EQueue = nsnull;    rv = aEventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &EQueue);    if (!NS_SUCCEEDED(rv)) {      printf("Could not get the newly created thread event queue.\n");      return rv;    }    NS_RELEASE(aEventQService);    // Prefs    rv = nsComponentManager::CreateInstance(kPrefCID,                                             NULL,                                             NS_GET_IID(nsIPref),                                            (void **) & sPrefs);    if (NS_OK != rv)     {      printf("Could not create the pref thing.\n");      return rv;    }        printf("prefs created ok.\n");        sPrefs->StartUp();    sPrefs->ReadUserPrefs();    gdk_input_add(EQueue->GetEventQueueSelectFD(),                  GDK_INPUT_READ,                  event_processor_callback,                  EQueue);    nsIThread::SetMainThread();  }  return mozilla_type;}