printf("event_processor_callback()\n");
static void gtk_mozilla_finalize (GtkObject *object);typedef gboolean (*GtkSignal_BOOL__POINTER_INT) (GtkObject * object,                                                 gpointer arg1,                                                 gint arg2,                                                 gpointer user_data);extern "C" void gtk_mozilla_marshal_BOOL__POINTER_INT (GtkObject * object,                                       GtkSignalFunc func,                                       gpointer func_data,                                       GtkArg * args){  GtkSignal_BOOL__POINTER_INT rfunc;  gboolean *return_val;  return_val = GTK_RETLOC_BOOL (args[2]);  rfunc = (GtkSignal_BOOL__POINTER_INT) func;  *return_val = (*rfunc) (object,                          GTK_VALUE_POINTER (args[0]),                          GTK_VALUE_INT (args[1]),                          func_data);}enum {  WILL_LOAD_URL,  BEGIN_LOAD_URL,  END_LOAD_URL,  LAST_SIGNAL};static guint mozilla_signals[LAST_SIGNAL] = { 0 };static GtkFixedClass *parent_class = NULL;static voidgtk_mozilla_class_init (GtkMozillaClass *klass){  GtkObjectClass *object_class;  GtkWidgetClass *widget_class;  object_class = (GtkObjectClass*) klass;  widget_class = (GtkWidgetClass*) klass;  parent_class = (GtkFixedClass *)gtk_type_class (GTK_TYPE_FIXED);  mozilla_signals[WILL_LOAD_URL] =    gtk_signal_new ("will_load_url",                    GTK_RUN_LAST,                    object_class->type,                    GTK_SIGNAL_OFFSET (GtkMozillaClass, will_load_url),                    gtk_mozilla_marshal_BOOL__POINTER_INT,                    GTK_TYPE_BOOL, 2,                    GTK_TYPE_STRING,                    GTK_TYPE_INT);    mozilla_signals[BEGIN_LOAD_URL] =    gtk_signal_new ("begin_load_url",                    GTK_RUN_FIRST,                    object_class->type,                    GTK_SIGNAL_OFFSET (GtkMozillaClass, begin_load_url),                    gtk_marshal_NONE__POINTER,                    GTK_TYPE_NONE, 1,                    GTK_TYPE_STRING);  mozilla_signals[END_LOAD_URL] =    gtk_signal_new ("end_load_url",                    GTK_RUN_FIRST,                    object_class->type,                    GTK_SIGNAL_OFFSET (GtkMozillaClass, end_load_url),                    gtk_marshal_NONE__POINTER_INT,                    GTK_TYPE_NONE, 2,                    GTK_TYPE_STRING,                    GTK_TYPE_INT);  gtk_object_class_add_signals (object_class, mozilla_signals, LAST_SIGNAL);  object_class->finalize = gtk_mozilla_finalize;  widget_class->realize = gtk_mozilla_realize;  klass->will_load_url = NULL;  klass->begin_load_url = NULL;  klass->end_load_url = NULL;}static voidgtk_mozilla_realize (GtkWidget *widget){  //printf("gtk_mozilla_realize()\n");  GtkMozilla *moz = GTK_MOZILLA(widget);  class GtkMozillaContainer *moz_container;  if (GTK_WIDGET_CLASS (parent_class)->realize)    (* GTK_WIDGET_CLASS (parent_class)->realize) (widget);  moz_container = (class GtkMozillaContainer *)moz->mozilla_container;    moz_container->Show();}// THIS is a total hack.  Needed cause mozilla wont work without prefs// no more.  Having the prefs be static over here is bad and a better// fix is to make them members of some kind of structure which gets// cleaned up at shutdown time.static nsIPref * sPrefs = nsnull;static voidgtk_mozilla_init (GtkMozilla *moz){  //printf("gtk_mozilla_init()\n");    moz->mozilla_container = NULL;    GTK_WIDGET_SET_FLAGS (GTK_WIDGET(moz), GTK_CAN_FOCUS);    moz->mozilla_container = new GtkMozillaContainer(moz,sPrefs);}static void event_processor_callback(gpointer data,                                     gint source,                                     GdkInputCondition condition){  printf("event_processor_callback()\n");  nsIEventQueue *eventQueue = (nsIEventQueue*)data;  eventQueue->ProcessPendingEvents();}GtkTypegtk_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;}GtkWidget*gtk_mozilla_new (void){  GtkMozilla *moz;  moz = GTK_MOZILLA(gtk_type_new(GTK_TYPE_MOZILLA));    return GTK_WIDGET (moz);}static voidgtk_mozilla_finalize (GtkObject *object){  GtkMozilla *moz;  class GtkMozillaContainer *moz_container;  //printf("gtk_mozilla_finalize()\n");  g_return_if_fail(object != NULL);  g_return_if_fail(GTK_IS_MOZILLA(object));  moz = GTK_MOZILLA(object);  moz_container = (class GtkMozillaContainer *)moz->mozilla_container;  moz->mozilla_container = NULL;  if (moz_container) {    delete moz_container;  }    GTK_OBJECT_CLASS(parent_class)->finalize (object);}