embedPrivate->Destroy();
if(embedPrivate->mMozWindowWidget != 0) { embedPrivate->Destroy(); }
gtk_moz_embed_realize(GtkWidget *widget);static voidgtk_moz_embed_unrealize(GtkWidget *widget);static voidgtk_moz_embed_size_allocate(GtkWidget *widget, GtkAllocation *allocation);static voidgtk_moz_embed_map(GtkWidget *widget);static voidgtk_moz_embed_unmap(GtkWidget *widget);#ifdef MOZ_ACCESSIBILITY_ATKstatic AtkObject* gtk_moz_embed_get_accessible (GtkWidget *widget);#endifstatic ginthandle_child_focus_in(GtkWidget     *aWidget,		      GdkEventFocus *aGdkFocusEvent,		      GtkMozEmbed   *aEmbed);static ginthandle_child_focus_out(GtkWidget     *aWidget,		       GdkEventFocus *aGdkFocusEvent,		       GtkMozEmbed   *aEmbed);#ifdef MOZ_WIDGET_GTK// signal handlers for tracking the focus in and and focus out events// on the toplevel window.static voidhandle_toplevel_focus_in (GtkMozArea    *aArea,			  GtkMozEmbed   *aEmbed);static voidhandle_toplevel_focus_out(GtkMozArea    *aArea,			  GtkMozEmbed   *aEmbed);#endif /* MOZ_WIDGET_GTK */#ifdef MOZ_WIDGET_GTK2// signal handlers for tracking the focus in and focus out events on// the toplevel window.static ginthandle_toplevel_focus_in(GtkWidget     *aWidget,			 GdkEventFocus *aEvent,			 EmbedPrivate  *aPrivate);static ginthandle_toplevel_focus_out(GtkWidget     *aWidget,			  GdkEventFocus *aEvent,			  EmbedPrivate  *aPrivate);#endif /* MOZ_WIDGET_GTK2 */// globals for this type of widgetstatic GtkBinClass *embed_parent_class;guint moz_embed_signals[EMBED_LAST_SIGNAL] = { 0 };// GtkObject + class-related functionsGtkTypegtk_moz_embed_get_type(void){  static GtkType moz_embed_type = 0;  if (!moz_embed_type)  {    static const GtkTypeInfo moz_embed_info =    {      "GtkMozEmbed",      sizeof(GtkMozEmbed),      sizeof(GtkMozEmbedClass),      (GtkClassInitFunc)gtk_moz_embed_class_init,      (GtkObjectInitFunc)gtk_moz_embed_init,      0,      0,      0    };    moz_embed_type = gtk_type_unique(GTK_TYPE_BIN, &moz_embed_info);  }  return moz_embed_type;}static voidgtk_moz_embed_class_init(GtkMozEmbedClass *klass){  GtkContainerClass  *container_class;  GtkBinClass        *bin_class;  GtkWidgetClass     *widget_class;  GtkObjectClass     *object_class;    container_class = GTK_CONTAINER_CLASS(klass);  bin_class       = GTK_BIN_CLASS(klass);  widget_class    = GTK_WIDGET_CLASS(klass);  object_class    = GTK_OBJECT_CLASS(klass);  embed_parent_class = (GtkBinClass *)gtk_type_class(gtk_bin_get_type());  widget_class->realize = gtk_moz_embed_realize;  widget_class->unrealize = gtk_moz_embed_unrealize;  widget_class->size_allocate = gtk_moz_embed_size_allocate;  widget_class->map = gtk_moz_embed_map;  widget_class->unmap = gtk_moz_embed_unmap;#ifdef MOZ_ACCESSIBILITY_ATK  widget_class->get_accessible = gtk_moz_embed_get_accessible;#endif  object_class->destroy = gtk_moz_embed_destroy;    // set up our signals  moz_embed_signals[LINK_MESSAGE] =     gtk_signal_new ("link_message",		    GTK_RUN_FIRST,		    GET_OBJECT_CLASS_TYPE(klass),		    GTK_SIGNAL_OFFSET(GtkMozEmbedClass, link_message),		    gtk_marshal_NONE__NONE,		    GTK_TYPE_NONE, 0);  moz_embed_signals[JS_STATUS] =    gtk_signal_new ("js_status",		    GTK_RUN_FIRST,		    GET_OBJECT_CLASS_TYPE(klass),		    GTK_SIGNAL_OFFSET(GtkMozEmbedClass, js_status),		    gtk_marshal_NONE__NONE,		    GTK_TYPE_NONE, 0);  moz_embed_signals[LOCATION] =    gtk_signal_new ("location",		    GTK_RUN_FIRST,		    GET_OBJECT_CLASS_TYPE(klass),		    GTK_SIGNAL_OFFSET(GtkMozEmbedClass, location),		    gtk_marshal_NONE__NONE,		    GTK_TYPE_NONE, 0);  moz_embed_signals[TITLE] =     gtk_signal_new("title",		   GTK_RUN_FIRST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, title),		   gtk_marshal_NONE__NONE,		   GTK_TYPE_NONE, 0);  moz_embed_signals[PROGRESS] =    gtk_signal_new("progress",		   GTK_RUN_FIRST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, progress),		   gtk_marshal_NONE__INT_INT,		   GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);  moz_embed_signals[PROGRESS_ALL] =     gtk_signal_new("progress_all",		   GTK_RUN_FIRST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, progress_all),		   gtkmozembed_VOID__POINTER_INT_INT,		   GTK_TYPE_NONE, 3, GTK_TYPE_POINTER,		   GTK_TYPE_INT, GTK_TYPE_INT);  moz_embed_signals[NET_STATE] =    gtk_signal_new("net_state",		   GTK_RUN_FIRST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, net_state),		   gtkmozembed_VOID__INT_UINT,		   GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_UINT);  moz_embed_signals[NET_STATE_ALL] =    gtk_signal_new("net_state_all",		   GTK_RUN_FIRST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, net_state_all),		   gtkmozembed_VOID__POINTER_INT_UINT,		   GTK_TYPE_NONE, 3, GTK_TYPE_POINTER,		   GTK_TYPE_INT, GTK_TYPE_UINT);  moz_embed_signals[NET_START] =    gtk_signal_new("net_start",		   GTK_RUN_FIRST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, net_start),		   gtk_marshal_NONE__NONE,		   GTK_TYPE_NONE, 0);  moz_embed_signals[NET_STOP] =    gtk_signal_new("net_stop",		   GTK_RUN_FIRST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, net_stop),		   gtk_marshal_NONE__NONE,		   GTK_TYPE_NONE, 0);  moz_embed_signals[NEW_WINDOW] =    gtk_signal_new("new_window",		   GTK_RUN_FIRST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, new_window),		   gtk_marshal_NONE__POINTER_UINT,		   GTK_TYPE_NONE, 2, GTK_TYPE_POINTER, GTK_TYPE_UINT);  moz_embed_signals[VISIBILITY] =    gtk_signal_new("visibility",		   GTK_RUN_FIRST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, visibility),		   gtk_marshal_NONE__BOOL,		   GTK_TYPE_NONE, 1, GTK_TYPE_BOOL);  moz_embed_signals[DESTROY_BROWSER] =    gtk_signal_new("destroy_browser",		   GTK_RUN_FIRST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, destroy_brsr),		   gtk_marshal_NONE__NONE,		   GTK_TYPE_NONE, 0);  moz_embed_signals[OPEN_URI] =     gtk_signal_new("open_uri",		   GTK_RUN_LAST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, open_uri),		   gtk_marshal_BOOL__POINTER,		   GTK_TYPE_BOOL, 1, GTK_TYPE_POINTER);  moz_embed_signals[SIZE_TO] =    gtk_signal_new("size_to",		   GTK_RUN_LAST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, size_to),		   gtk_marshal_NONE__INT_INT,		   GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);  moz_embed_signals[DOM_KEY_DOWN] =    gtk_signal_new("dom_key_down",		   GTK_RUN_LAST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, dom_key_down),		   gtk_marshal_BOOL__POINTER,		   GTK_TYPE_BOOL, 1, GTK_TYPE_POINTER);  moz_embed_signals[DOM_KEY_PRESS] =    gtk_signal_new("dom_key_press",		   GTK_RUN_LAST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, dom_key_press),		   gtk_marshal_BOOL__POINTER,		   GTK_TYPE_BOOL, 1, GTK_TYPE_POINTER);  moz_embed_signals[DOM_KEY_UP] =    gtk_signal_new("dom_key_up",		   GTK_RUN_LAST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, dom_key_up),		   gtk_marshal_BOOL__POINTER,		   GTK_TYPE_BOOL, 1, GTK_TYPE_POINTER);  moz_embed_signals[DOM_MOUSE_DOWN] =    gtk_signal_new("dom_mouse_down",		   GTK_RUN_LAST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, dom_mouse_down),		   gtk_marshal_BOOL__POINTER,		   GTK_TYPE_BOOL, 1, GTK_TYPE_POINTER);  moz_embed_signals[DOM_MOUSE_UP] =    gtk_signal_new("dom_mouse_up",		   GTK_RUN_LAST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, dom_mouse_up),		   gtk_marshal_BOOL__POINTER,		   GTK_TYPE_BOOL, 1, GTK_TYPE_POINTER);  moz_embed_signals[DOM_MOUSE_CLICK] =    gtk_signal_new("dom_mouse_click",		   GTK_RUN_LAST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, dom_mouse_click),		   gtk_marshal_BOOL__POINTER,		   GTK_TYPE_BOOL, 1, GTK_TYPE_POINTER);  moz_embed_signals[DOM_MOUSE_DBL_CLICK] =    gtk_signal_new("dom_mouse_dbl_click",		   GTK_RUN_LAST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, dom_mouse_dbl_click),		   gtk_marshal_BOOL__POINTER,		   GTK_TYPE_BOOL, 1, GTK_TYPE_POINTER);  moz_embed_signals[DOM_MOUSE_OVER] =    gtk_signal_new("dom_mouse_over",		   GTK_RUN_LAST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, dom_mouse_over),		   gtk_marshal_BOOL__POINTER,		   GTK_TYPE_BOOL, 1, GTK_TYPE_POINTER);  moz_embed_signals[DOM_MOUSE_OUT] =    gtk_signal_new("dom_mouse_out",		   GTK_RUN_LAST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, dom_mouse_out),		   gtk_marshal_BOOL__POINTER,		   GTK_TYPE_BOOL, 1, GTK_TYPE_POINTER);  moz_embed_signals[SECURITY_CHANGE] =    gtk_signal_new("security_change",		   GTK_RUN_LAST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, security_change),		   gtk_marshal_NONE__POINTER_UINT,		   GTK_TYPE_NONE, 2, GTK_TYPE_POINTER, GTK_TYPE_UINT);  moz_embed_signals[STATUS_CHANGE] =    gtk_signal_new("status_change",		   GTK_RUN_LAST,		   GET_OBJECT_CLASS_TYPE(klass),		   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, status_change),		   gtkmozembed_VOID__POINTER_INT_POINTER,		   GTK_TYPE_NONE, 3,		   GTK_TYPE_POINTER, GTK_TYPE_INT, GTK_TYPE_POINTER);  moz_embed_signals[DOM_ACTIVATE] =    gtk_signal_new("dom_activate",                   GTK_RUN_LAST,                   GET_OBJECT_CLASS_TYPE(klass),                   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, dom_activate),                   gtk_marshal_BOOL__POINTER,                   GTK_TYPE_BOOL, 1, GTK_TYPE_POINTER);  moz_embed_signals[DOM_FOCUS_IN] =    gtk_signal_new("dom_focus_in",                   GTK_RUN_LAST,                   GET_OBJECT_CLASS_TYPE(klass),                   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, dom_activate),                   gtk_marshal_BOOL__POINTER,                   GTK_TYPE_BOOL, 1, GTK_TYPE_POINTER);  moz_embed_signals[DOM_FOCUS_OUT] =    gtk_signal_new("dom_focus_out",                   GTK_RUN_LAST,                   GET_OBJECT_CLASS_TYPE(klass),                   GTK_SIGNAL_OFFSET(GtkMozEmbedClass, dom_activate),                   gtk_marshal_BOOL__POINTER,                   GTK_TYPE_BOOL, 1, GTK_TYPE_POINTER);#ifdef MOZ_WIDGET_GTK  gtk_object_class_add_signals(object_class, moz_embed_signals,			       EMBED_LAST_SIGNAL);#endif /* MOZ_WIDGET_GTK */}static voidgtk_moz_embed_init(GtkMozEmbed *embed){  EmbedPrivate *priv = new EmbedPrivate();  embed->data = priv;  gtk_widget_set_name(GTK_WIDGET(embed), "gtkmozembed");#ifdef MOZ_WIDGET_GTK2  GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(embed), GTK_NO_WINDOW);#endif}GtkWidget *gtk_moz_embed_new(void){  return GTK_WIDGET(gtk_type_new(gtk_moz_embed_get_type()));}// GtkObject methodsstatic voidgtk_moz_embed_destroy(GtkObject *object){  GtkMozEmbed  *embed;  EmbedPrivate *embedPrivate;    g_return_if_fail(object != NULL);  g_return_if_fail(GTK_IS_MOZ_EMBED(object));  embed = GTK_MOZ_EMBED(object);  embedPrivate = (EmbedPrivate *)embed->data;  if (embedPrivate) {    embedPrivate->Destroy();    delete embedPrivate;    embed->data = NULL;  }}// GtkWidget methodsstatic voidgtk_moz_embed_realize(GtkWidget *widget){  GtkMozEmbed    *embed;  EmbedPrivate   *embedPrivate;  GdkWindowAttr   attributes;  gint            attributes_mask;    g_return_if_fail(widget != NULL);  g_return_if_fail(GTK_IS_MOZ_EMBED(widget));  embed = GTK_MOZ_EMBED(widget);  embedPrivate = (EmbedPrivate *)embed->data;  GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);  attributes.window_type = GDK_WINDOW_CHILD;  attributes.x = widget->allocation.x;  attributes.y = widget->allocation.y;  attributes.width = widget->allocation.width;  attributes.height = widget->allocation.height;  attributes.wclass = GDK_INPUT_OUTPUT;  attributes.visual = gtk_widget_get_visual (widget);  attributes.colormap = gtk_widget_get_colormap (widget);  attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;  widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),				   &attributes, attributes_mask);  gdk_window_set_user_data (widget->window, embed);  widget->style = gtk_style_attach (widget->style, widget->window);  gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);  // initialize the window  nsresult rv;  rv = embedPrivate->Init(embed);  g_return_if_fail(NS_SUCCEEDED(rv));    PRBool alreadyRealized = PR_FALSE;  rv = embedPrivate->Realize(&alreadyRealized);  g_return_if_fail(NS_SUCCEEDED(rv));  GtkWidget *child_widget = GTK_BIN(widget)->child;#ifdef MOZ_WIDGET_GTK2  GtkWidget *toplevel = gtk_widget_get_toplevel(widget);  gtk_signal_connect_while_alive(GTK_OBJECT(toplevel),				 "focus_in_event",				 GTK_SIGNAL_FUNC(handle_toplevel_focus_in),				 embedPrivate,				 GTK_OBJECT(child_widget));  gtk_signal_connect_while_alive(GTK_OBJECT(toplevel),				 "focus_out_event",				 GTK_SIGNAL_FUNC(handle_toplevel_focus_out),				 embedPrivate,				 GTK_OBJECT(child_widget));#endif /* MOZ_WIDGET_GTK2 */  // if we're already realized we don't need to hook up to anything below  if (alreadyRealized)    return;  if (embedPrivate->mURI.Length())    embedPrivate->LoadCurrentURI();  // connect to the focus out event for the child  gtk_signal_connect_while_alive(GTK_OBJECT(child_widget),				 "focus_out_event",				 GTK_SIGNAL_FUNC(handle_child_focus_out),				 embed,				 GTK_OBJECT(child_widget));  gtk_signal_connect_while_alive(GTK_OBJECT(child_widget),				 "focus_in_event",				 GTK_SIGNAL_FUNC(handle_child_focus_in),				 embed,				 GTK_OBJECT(child_widget));#ifdef MOZ_WIDGET_GTK  // connect to the toplevel focus out events for the child  GtkMozArea *mozarea = GTK_MOZAREA(child_widget);  gtk_signal_connect_while_alive(GTK_OBJECT(mozarea),				 "toplevel_focus_in",				 GTK_SIGNAL_FUNC(handle_toplevel_focus_in),				 embed,				 GTK_OBJECT(mozarea));  gtk_signal_connect_while_alive(GTK_OBJECT(mozarea),				 "toplevel_focus_out",				 GTK_SIGNAL_FUNC(handle_toplevel_focus_out),				 embed,				 GTK_OBJECT(mozarea));#endif /* MOZ_WIDGET_GTK */}