static void     menu_stream_cb     (GtkMenuItem *menuitem, TestGtkBrowser *browser); static void     menu_close_cb      (GtkMenuItem *menuitem, TestGtkBrowser *browser); static void     menu_quit_cb       (GtkMenuItem *menuitem, TestGtkBrowser *browser); static gboolean delete_cb          (GtkWidget *widget, GdkEventAny *event, TestGtkBrowser *browser); static void     destroy_cb         (GtkWidget *widget, TestGtkBrowser *browser);   static void location_changed_cb  (GtkMozEmbed *embed, TestGtkBrowser *browser); static void title_changed_cb     (GtkMozEmbed *embed, TestGtkBrowser *browser); static void load_started_cb      (GtkMozEmbed *embed, TestGtkBrowser *browser); static void load_finished_cb     (GtkMozEmbed *embed, TestGtkBrowser *browser); static void net_state_change_cb  (GtkMozEmbed *embed, gint flags, guint status, TestGtkBrowser *browser); static void net_state_change_all_cb (GtkMozEmbed *embed, const char *uri, gint flags, guint status, TestGtkBrowser *browser); static void progress_change_cb   (GtkMozEmbed *embed, gint cur, gint max, TestGtkBrowser *browser); static void progress_change_all_cb (GtkMozEmbed *embed, const char *uri, gint cur, gint max, TestGtkBrowser *browser); static void link_message_cb      (GtkMozEmbed *embed, TestGtkBrowser *browser); static void js_status_cb         (GtkMozEmbed *embed, TestGtkBrowser *browser); static void new_window_cb        (GtkMozEmbed *embed, GtkMozEmbed **retval, guint chromemask, TestGtkBrowser *browser); static void visibility_cb        (GtkMozEmbed *embed, gboolean visibility, TestGtkBrowser *browser); static void destroy_brsr_cb      (GtkMozEmbed *embed, TestGtkBrowser *browser); static gint open_uri_cb          (GtkMozEmbed *embed, const char *uri, TestGtkBrowser *browser); static void size_to_cb           (GtkMozEmbed *embed, gint width, gint height, TestGtkBrowser *browser); static gint dom_key_down_cb      (GtkMozEmbed *embed, nsIDOMKeyEvent *event, TestGtkBrowser *browser); static gint dom_key_press_cb     (GtkMozEmbed *embed, nsIDOMKeyEvent *event, TestGtkBrowser *browser); static gint dom_key_up_cb        (GtkMozEmbed *embed, nsIDOMKeyEvent *event, TestGtkBrowser *browser); static gint dom_mouse_down_cb    (GtkMozEmbed *embed, nsIDOMMouseEvent *event, TestGtkBrowser *browser); static gint dom_mouse_up_cb      (GtkMozEmbed *embed, nsIDOMMouseEvent *event, TestGtkBrowser *browser); static gint dom_mouse_click_cb   (GtkMozEmbed *embed, nsIDOMMouseEvent *event, TestGtkBrowser *browser); static gint dom_mouse_dbl_click_cb (GtkMozEmbed *embed, nsIDOMMouseEvent *event, TestGtkBrowser *browser); static gint dom_mouse_over_cb    (GtkMozEmbed *embed, nsIDOMMouseEvent *event, TestGtkBrowser *browser); static gint dom_mouse_out_cb     (GtkMozEmbed *embed, nsIDOMMouseEvent *event, TestGtkBrowser *browser);   static void update_status_bar_text  (TestGtkBrowser *browser); static void update_temp_message     (TestGtkBrowser *browser, const char *message); static void update_nav_buttons      (TestGtkBrowser *browser);  int main(int argc, char **argv) { gtk_set_locale(); gtk_init(&argc, &argv);  TestGtkBrowser *browser = new_gtk_browser(GTK_MOZ_EMBED_FLAG_DEFAULTCHROME);   gtk_widget_set_usize(browser->mozEmbed, 400, 400);  set_browser_visibility(browser, TRUE);  if (argc > 1) gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser->mozEmbed), argv[1]);  gtk_main(); }  static TestGtkBrowser * new_gtk_browser(guint32 chromeMask) { guint32         actualChromeMask = chromeMask; TestGtkBrowser *browser = 0;  num_browsers++;  browser = g_new0(TestGtkBrowser, 1);  browser_list = g_list_prepend(browser_list, browser);  browser->menuBarOn = FALSE; browser->toolBarOn = FALSE; browser->locationBarOn = FALSE; browser->statusBarOn = FALSE;  g_print("new_gtk_browser\n");  if (chromeMask == GTK_MOZ_EMBED_FLAG_DEFAULTCHROME) actualChromeMask = GTK_MOZ_EMBED_FLAG_ALLCHROME;  if (actualChromeMask & GTK_MOZ_EMBED_FLAG_MENUBARON) { browser->menuBarOn = TRUE; g_print("\tmenu bar\n"); } if (actualChromeMask & GTK_MOZ_EMBED_FLAG_TOOLBARON) { browser->toolBarOn = TRUE; g_print("\ttool bar\n"); } if (actualChromeMask & GTK_MOZ_EMBED_FLAG_LOCATIONBARON) { browser->locationBarOn = TRUE; g_print("\tlocation bar\n"); } if (actualChromeMask & GTK_MOZ_EMBED_FLAG_STATUSBARON) { browser->statusBarOn = TRUE; g_print("\tstatus bar\n"); }   browser->topLevelWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);  browser->topLevelVBox = gtk_vbox_new(FALSE, 0);  gtk_container_add(GTK_CONTAINER(browser->topLevelWindow), browser->topLevelVBox);  browser->menuBar = gtk_menu_bar_new();  browser->fileMenuItem = gtk_menu_item_new_with_label("File"); browser->fileMenu = gtk_menu_new(); gtk_menu_item_set_submenu (GTK_MENU_ITEM(browser->fileMenuItem), browser->fileMenu);  browser->fileOpenNewBrowser = gtk_menu_item_new_with_label("Open New Browser"); gtk_menu_append(GTK_MENU(browser->fileMenu), browser->fileOpenNewBrowser);  browser->fileStream = gtk_menu_item_new_with_label("Test Stream"); gtk_menu_append(GTK_MENU(browser->fileMenu), browser->fileStream);  browser->fileClose = gtk_menu_item_new_with_label("Close"); gtk_menu_append(GTK_MENU(browser->fileMenu), browser->fileClose);  browser->fileQuit = gtk_menu_item_new_with_label("Quit"); gtk_menu_append(GTK_MENU(browser->fileMenu), browser->fileQuit);   gtk_menu_bar_append(GTK_MENU_BAR(browser->menuBar), browser->fileMenuItem);   gtk_box_pack_start(GTK_BOX(browser->topLevelVBox), browser->menuBar, FALSE, FALSE, 0);  browser->toolbarHBox = gtk_hbox_new(FALSE, 0);  gtk_box_pack_start(GTK_BOX(browser->topLevelVBox), browser->toolbarHBox, FALSE, FALSE, 0);  browser->toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);  gtk_box_pack_start(GTK_BOX(browser->toolbarHBox), browser->toolbar, FALSE, FALSE, 0);  browser->backButton = gtk_toolbar_append_item(GTK_TOOLBAR(browser->toolbar), "Back", "Go Back", "Go Back", 0, GTK_SIGNAL_FUNC(back_clicked_cb), browser);  browser->stopButton = gtk_toolbar_append_item(GTK_TOOLBAR(browser->toolbar), "Stop", "Stop", "Stop", 0, GTK_SIGNAL_FUNC(stop_clicked_cb), browser);  browser->forwardButton = gtk_toolbar_append_item(GTK_TOOLBAR(browser->toolbar), "Forward", "Forward", "Forward", 0, GTK_SIGNAL_FUNC(forward_clicked_cb), browser);  browser->reloadButton = gtk_toolbar_append_item(GTK_TOOLBAR(browser->toolbar), "Reload", "Reload", "Reload", 0, GTK_SIGNAL_FUNC(reload_clicked_cb), browser);  browser->urlEntry = gtk_entry_new();  gtk_box_pack_start(GTK_BOX(browser->toolbarHBox), browser->urlEntry, TRUE, TRUE, 0);  browser->mozEmbed = gtk_moz_embed_new();  gtk_box_pack_start(GTK_BOX(browser->topLevelVBox), browser->mozEmbed, TRUE, TRUE, 0);  browser->progressAreaHBox = gtk_hbox_new(FALSE, 0);  gtk_box_pack_start(GTK_BOX(browser->topLevelVBox), browser->progressAreaHBox, FALSE, FALSE, 0);  browser->progressBar = gtk_progress_bar_new();  gtk_box_pack_start(GTK_BOX(browser->progressAreaHBox), browser->progressBar, FALSE, FALSE, 0);    browser->statusAlign = gtk_alignment_new(0, 0, 1, 1); gtk_widget_set_usize(browser->statusAlign, 1, -1);  browser->statusBar = gtk_statusbar_new(); gtk_container_add(GTK_CONTAINER(browser->statusAlign), browser->statusBar);  gtk_box_pack_start(GTK_BOX(browser->progressAreaHBox), browser->statusAlign, TRUE, TRUE, 0);  gtk_widget_set_sensitive(browser->backButton, FALSE); gtk_widget_set_sensitive(browser->stopButton, FALSE); gtk_widget_set_sensitive(browser->forwardButton, FALSE); gtk_widget_set_sensitive(browser->reloadButton, FALSE);   gtk_signal_connect(GTK_OBJECT(browser->topLevelWindow), "delete_event", GTK_SIGNAL_FUNC(delete_cb), browser);   gtk_signal_connect(GTK_OBJECT(browser->urlEntry), "activate", GTK_SIGNAL_FUNC(url_activate_cb), browser);   gtk_signal_connect(GTK_OBJECT(browser->fileOpenNewBrowser), "activate", GTK_SIGNAL_FUNC(menu_open_new_cb), browser);  gtk_signal_connect(GTK_OBJECT(browser->fileStream), "activate", GTK_SIGNAL_FUNC(menu_stream_cb), browser);  gtk_signal_connect(GTK_OBJECT(browser->fileClose), "activate", GTK_SIGNAL_FUNC(menu_close_cb), browser);  gtk_signal_connect(GTK_OBJECT(browser->fileQuit), "activate", GTK_SIGNAL_FUNC(menu_quit_cb), browser);   gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "location", GTK_SIGNAL_FUNC(location_changed_cb), browser);  gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "title", GTK_SIGNAL_FUNC(title_changed_cb), browser);  gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "net_start", GTK_SIGNAL_FUNC(load_started_cb), browser); gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "net_stop", GTK_SIGNAL_FUNC(load_finished_cb), browser);  gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "net_state", GTK_SIGNAL_FUNC(net_state_change_cb), browser); gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "net_state_all", GTK_SIGNAL_FUNC(net_state_change_all_cb), browser);  gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "progress", GTK_SIGNAL_FUNC(progress_change_cb), browser); gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "progress_all", GTK_SIGNAL_FUNC(progress_change_all_cb), browser);  gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "link_message", GTK_SIGNAL_FUNC(link_message_cb), browser);  gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "js_status", GTK_SIGNAL_FUNC(js_status_cb), browser);  gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "new_window", GTK_SIGNAL_FUNC(new_window_cb), browser);  gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "visibility", GTK_SIGNAL_FUNC(visibility_cb), browser);   gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "destroy_browser", GTK_SIGNAL_FUNC(destroy_brsr_cb), browser);   gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "open_uri", GTK_SIGNAL_FUNC(open_uri_cb), browser);    gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "size_to", GTK_SIGNAL_FUNC(size_to_cb), browser);  gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_key_down", GTK_SIGNAL_FUNC(dom_key_down_cb), browser); gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_key_press", GTK_SIGNAL_FUNC(dom_key_press_cb), browser); gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_key_up", GTK_SIGNAL_FUNC(dom_key_up_cb), browser); gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_down", GTK_SIGNAL_FUNC(dom_mouse_down_cb), browser); gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_up", GTK_SIGNAL_FUNC(dom_mouse_up_cb), browser); gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_click", GTK_SIGNAL_FUNC(dom_mouse_click_cb), browser); gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_dbl_click", GTK_SIGNAL_FUNC(dom_mouse_dbl_click_cb), browser); gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_over", GTK_SIGNAL_FUNC(dom_mouse_over_cb), browser); gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "dom_mouse_out", GTK_SIGNAL_FUNC(dom_mouse_out_cb), browser);  gtk_signal_connect(GTK_OBJECT(browser->mozEmbed), "destroy", GTK_SIGNAL_FUNC(destroy_cb), browser);   gtk_moz_embed_set_chrome_mask(GTK_MOZ_EMBED(browser->mozEmbed), actualChromeMask);  return browser; }  void set_browser_visibility (TestGtkBrowser *browser, gboolean visibility) { if (!visibility) { gtk_widget_hide(browser->topLevelWindow); return; }  if (browser->menuBarOn) gtk_widget_show_all(browser->menuBar); else gtk_widget_hide_all(browser->menuBar);   if (browser->toolBarOn || browser->locationBarOn) gtk_widget_show_all(browser->toolbarHBox); else gtk_widget_hide_all(browser->toolbarHBox);  if (browser->statusBarOn) gtk_widget_show_all(browser->progressAreaHBox); else gtk_widget_hide_all(browser->progressAreaHBox);  gtk_widget_show(browser->mozEmbed); gtk_widget_show(browser->topLevelVBox); gtk_widget_show(browser->topLevelWindow); }  void back_clicked_cb (GtkButton *button, TestGtkBrowser *browser) { gtk_moz_embed_go_back(GTK_MOZ_EMBED(browser->mozEmbed)); }  void stop_clicked_cb (GtkButton *button, TestGtkBrowser *browser) { g_print("stop_clicked_cb\n"); gtk_moz_embed_stop_load(GTK_MOZ_EMBED(browser->mozEmbed)); }  void forward_clicked_cb (GtkButton *button, TestGtkBrowser *browser) { g_print("forward_clicked_cb\n"); gtk_moz_embed_go_forward(GTK_MOZ_EMBED(browser->mozEmbed)); }  void reload_clicked_cb  (GtkButton *button, TestGtkBrowser *browser) { g_print("reload_clicked_cb\n"); gtk_moz_embed_reload(GTK_MOZ_EMBED(browser->mozEmbed), GTK_MOZ_EMBED_FLAG_RELOADNORMAL); }  void stream_clicked_cb  (GtkButton   *button, TestGtkBrowser *browser) { char *data; char *data2; data = "<html>Hi"; data2 = " there</html>\n"; g_print("stream_clicked_cb\n"); gtk_moz_embed_open_stream(GTK_MOZ_EMBED(browser->mozEmbed), "file: gtk_moz_embed_append_data(GTK_MOZ_EMBED(browser->mozEmbed), data, strlen(data)); gtk_moz_embed_append_data(GTK_MOZ_EMBED(browser->mozEmbed), data2, strlen(data2)); gtk_moz_embed_close_stream(GTK_MOZ_EMBED(browser->mozEmbed)); }  void url_activate_cb    (GtkEditable *widget, TestGtkBrowser *browser) { gchar *text = gtk_editable_get_chars(widget, 0, -1); g_print("loading url %s\n", text); gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser->mozEmbed), text); g_free(text); }  void menu_open_new_cb   (GtkMenuItem *menuitem, TestGtkBrowser *browser) { g_print("opening new browser.\n"); TestGtkBrowser *newBrowser = new_gtk_browser(GTK_MOZ_EMBED_FLAG_DEFAULTCHROME); gtk_widget_set_usize(newBrowser->mozEmbed, 400, 400); set_browser_visibility(newBrowser, TRUE); }  void
menu_stream_cb     (GtkMenuItem *menuitem, TestGtkBrowser *browser){  g_print("menu_stream_cb\n");  char *data;  char *data2;  data = "<html>Hi";  data2 = " there</html>\n";  g_print("stream_clicked_cb\n");  gtk_moz_embed_open_stream(GTK_MOZ_EMBED(browser->mozEmbed),			    "file://", "text/html");  gtk_moz_embed_append_data(GTK_MOZ_EMBED(browser->mozEmbed),			    data, strlen(data));  gtk_moz_embed_append_data(GTK_MOZ_EMBED(browser->mozEmbed),			    data2, strlen(data2));  gtk_moz_embed_close_stream(GTK_MOZ_EMBED(browser->mozEmbed));}