/*
 * DO NOT EDIT THIS FILE - it is generated by Glade.
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>

#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>

#include "debug-cb.h"
#include "debug-intf.h"
#include "debug-sup.h"

#define GLADE_HOOKUP_OBJECT(component,widget,name) \
  g_object_set_data_full (G_OBJECT (component), name, \
  g_object_ref (G_OBJECT(widget)), (GDestroyNotify) g_object_unref)

// gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)

#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
  g_object_set_data (G_OBJECT (component), name, widget)

GtkWidget*
create_debugmain (void)
{
  GtkWidget *debugmain;
  GtkWidget *vbox1;
  GtkWidget *menu;
  GtkWidget *menuitem4;
  GtkWidget *menuitem4_menu;
  GtkWidget *new_mem;
  GtkWidget *new_disasm;
  GtkWidget *new_errorlog;
  GtkWidget *separator2;
  GtkWidget *run;
  GtkWidget *run_h;
  GtkWidget *run_cpu;
  GtkWidget *run_irq;
  GtkWidget *run_vbl;
  GtkWidget *separator3;
  GtkWidget *step_into;
  GtkWidget *step_over;
  GtkWidget *step_out;
  GtkWidget *separator4;
  GtkWidget *soft_reset;
  GtkWidget *hard_reset;
  GtkWidget *exit;
  GtkWidget *item1;
  GtkWidget *item1_menu;
  GSList *raw_opcodes_group = NULL;
  GtkWidget *raw_opcodes;
  GtkWidget *enc_opcodes;
  GtkWidget *comments;
  GtkWidget *hbox1;
  GtkWidget *registers;
  GtkWidget *vbox2;
  GtkWidget *disasm;
  GtkWidget *console;
  GtkWidget *edit;
  GtkAccelGroup *accel_group;

  accel_group = gtk_accel_group_new ();

  debugmain = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (debugmain, "debugmain");
  gtk_window_set_title (GTK_WINDOW (debugmain), "Debug main window");
  gtk_window_set_default_size (GTK_WINDOW (debugmain), 350, 300);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_set_name (vbox1, "vbox1");
  gtk_widget_show (vbox1);
  gtk_container_add (GTK_CONTAINER (debugmain), vbox1);

  menu = gtk_menu_bar_new ();
  gtk_widget_set_name (menu, "menu");
  gtk_widget_show (menu);
  gtk_box_pack_start (GTK_BOX (vbox1), menu, FALSE, FALSE, 0);

  menuitem4 = gtk_menu_item_new_with_mnemonic ("_Debug");
  gtk_widget_set_name (menuitem4, "menuitem4");
  gtk_widget_show (menuitem4);
  gtk_container_add (GTK_CONTAINER (menu), menuitem4);

  menuitem4_menu = gtk_menu_new ();
  gtk_widget_set_name (menuitem4_menu, "menuitem4_menu");
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu);

  new_mem = gtk_menu_item_new_with_mnemonic ("New Memory Window");
  gtk_widget_set_name (new_mem, "new_mem");
  gtk_widget_show (new_mem);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), new_mem);
  gtk_widget_add_accelerator (new_mem, "activate", accel_group,
                              GDK_m, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  new_disasm = gtk_menu_item_new_with_mnemonic ("New Disassembly Window");
  gtk_widget_set_name (new_disasm, "new_disasm");
  gtk_widget_show (new_disasm);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), new_disasm);
  gtk_widget_add_accelerator (new_disasm, "activate", accel_group,
                              GDK_d, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  new_errorlog = gtk_menu_item_new_with_mnemonic ("New Error Log Window");
  gtk_widget_set_name (new_errorlog, "new_errorlog");
  gtk_widget_show (new_errorlog);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), new_errorlog);
  gtk_widget_add_accelerator (new_errorlog, "activate", accel_group,
                              GDK_l, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  separator2 = gtk_separator_menu_item_new ();
  gtk_widget_set_name (separator2, "separator2");
  gtk_widget_show (separator2);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), separator2);
  gtk_widget_set_sensitive (separator2, FALSE);

  run = gtk_menu_item_new_with_mnemonic ("Run");
  gtk_widget_set_name (run, "run");
  gtk_widget_show (run);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), run);
  gtk_widget_add_accelerator (run, "activate", accel_group,
                              GDK_F5, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  run_h = gtk_menu_item_new_with_mnemonic ("Run and Hide Debugger");
  gtk_widget_set_name (run_h, "run_h");
  gtk_widget_show (run_h);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), run_h);
  gtk_widget_add_accelerator (run_h, "activate", accel_group,
                              GDK_F12, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  run_cpu = gtk_menu_item_new_with_mnemonic ("Run to Next CPU");
  gtk_widget_set_name (run_cpu, "run_cpu");
  gtk_widget_show (run_cpu);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), run_cpu);
  gtk_widget_add_accelerator (run_cpu, "activate", accel_group,
                              GDK_F6, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  run_irq = gtk_menu_item_new_with_mnemonic ("Run until Next Interrupt on This CPU");
  gtk_widget_set_name (run_irq, "run_irq");
  gtk_widget_show (run_irq);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), run_irq);
  gtk_widget_add_accelerator (run_irq, "activate", accel_group,
                              GDK_F7, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  run_vbl = gtk_menu_item_new_with_mnemonic ("Run until Next VBLANK");
  gtk_widget_set_name (run_vbl, "run_vbl");
  gtk_widget_show (run_vbl);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), run_vbl);
  gtk_widget_add_accelerator (run_vbl, "activate", accel_group,
                              GDK_F8, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  separator3 = gtk_separator_menu_item_new ();
  gtk_widget_set_name (separator3, "separator3");
  gtk_widget_show (separator3);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), separator3);
  gtk_widget_set_sensitive (separator3, FALSE);

  step_into = gtk_menu_item_new_with_mnemonic ("Step Into");
  gtk_widget_set_name (step_into, "step_into");
  gtk_widget_show (step_into);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), step_into);
  gtk_widget_add_accelerator (step_into, "activate", accel_group,
                              GDK_F11, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  step_over = gtk_menu_item_new_with_mnemonic ("Step Over");
  gtk_widget_set_name (step_over, "step_over");
  gtk_widget_show (step_over);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), step_over);
  gtk_widget_add_accelerator (step_over, "activate", accel_group,
                              GDK_F9, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  step_out = gtk_menu_item_new_with_mnemonic ("Step Out");
  gtk_widget_set_name (step_out, "step_out");
  gtk_widget_show (step_out);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), step_out);
  gtk_widget_add_accelerator (step_out, "activate", accel_group,
                              GDK_F11, (GdkModifierType) GDK_SHIFT_MASK,
                              GTK_ACCEL_VISIBLE);

  separator4 = gtk_separator_menu_item_new ();
  gtk_widget_set_name (separator4, "separator4");
  gtk_widget_show (separator4);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), separator4);
  gtk_widget_set_sensitive (separator4, FALSE);

  soft_reset = gtk_menu_item_new_with_mnemonic ("Soft Reset");
  gtk_widget_set_name (soft_reset, "soft_reset");
  gtk_widget_show (soft_reset);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), soft_reset);
  gtk_widget_add_accelerator (soft_reset, "activate", accel_group,
                              GDK_F3, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  hard_reset = gtk_menu_item_new_with_mnemonic ("Hard Reset");
  gtk_widget_set_name (hard_reset, "hard_reset");
  gtk_widget_show (hard_reset);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), hard_reset);
  gtk_widget_add_accelerator (hard_reset, "activate", accel_group,
                              GDK_F3, (GdkModifierType) GDK_SHIFT_MASK,
                              GTK_ACCEL_VISIBLE);

  exit = gtk_menu_item_new_with_mnemonic ("Exit");
  gtk_widget_set_name (exit, "exit");
  gtk_widget_show (exit);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), exit);

  item1 = gtk_menu_item_new_with_mnemonic ("_Options");
  gtk_widget_set_name (item1, "item1");
  gtk_widget_show (item1);
  gtk_container_add (GTK_CONTAINER (menu), item1);

  item1_menu = gtk_menu_new ();
  gtk_widget_set_name (item1_menu, "item1_menu");
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (item1), item1_menu);

  raw_opcodes = gtk_radio_menu_item_new_with_mnemonic (raw_opcodes_group, "Raw Opcodes");
  raw_opcodes_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (raw_opcodes));
  gtk_widget_set_name (raw_opcodes, "raw_opcodes");
  gtk_widget_show (raw_opcodes);
  gtk_container_add (GTK_CONTAINER (item1_menu), raw_opcodes);
  gtk_widget_add_accelerator (raw_opcodes, "activate", accel_group,
                              GDK_r, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);
  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (raw_opcodes), TRUE);

  enc_opcodes = gtk_radio_menu_item_new_with_mnemonic (raw_opcodes_group, "Encryped Opcodes");
  raw_opcodes_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (enc_opcodes));
  gtk_widget_set_name (enc_opcodes, "enc_opcodes");
  gtk_widget_show (enc_opcodes);
  gtk_container_add (GTK_CONTAINER (item1_menu), enc_opcodes);
  gtk_widget_add_accelerator (enc_opcodes, "activate", accel_group,
                              GDK_e, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);
  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (enc_opcodes), TRUE);

  comments = gtk_radio_menu_item_new_with_mnemonic (raw_opcodes_group, "Comments");
  raw_opcodes_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (comments));
  gtk_widget_set_name (comments, "comments");
  gtk_widget_show (comments);
  gtk_container_add (GTK_CONTAINER (item1_menu), comments);
  gtk_widget_add_accelerator (comments, "activate", accel_group,
                              GDK_c, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);
  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (comments), TRUE);

  hbox1 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox1, "hbox1");
  gtk_widget_show (hbox1);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 2);

  registers = dview_new ("registers", "", "", 0, 0);
  gtk_widget_set_name (registers, "registers");
  gtk_widget_show (registers);
  gtk_box_pack_start (GTK_BOX (hbox1), registers, FALSE, TRUE, 0);
  GTK_WIDGET_UNSET_FLAGS (registers, GTK_CAN_FOCUS);
  GTK_WIDGET_UNSET_FLAGS (registers, GTK_CAN_DEFAULT);

  vbox2 = gtk_vbox_new (FALSE, 0);
  gtk_widget_set_name (vbox2, "vbox2");
  gtk_widget_show (vbox2);
  gtk_box_pack_start (GTK_BOX (hbox1), vbox2, TRUE, TRUE, 0);

  disasm = dview_new ("disasm", "", "", 0, 0);
  gtk_widget_set_name (disasm, "disasm");
  gtk_widget_show (disasm);
  gtk_box_pack_start (GTK_BOX (vbox2), disasm, TRUE, TRUE, 2);
  GTK_WIDGET_UNSET_FLAGS (disasm, GTK_CAN_FOCUS);
  GTK_WIDGET_UNSET_FLAGS (disasm, GTK_CAN_DEFAULT);

  console = dview_new ("console", "", "", 0, 0);
  gtk_widget_set_name (console, "console");
  gtk_widget_show (console);
  gtk_box_pack_start (GTK_BOX (vbox2), console, TRUE, TRUE, 0);
  GTK_WIDGET_UNSET_FLAGS (console, GTK_CAN_FOCUS);
  GTK_WIDGET_UNSET_FLAGS (console, GTK_CAN_DEFAULT);

  edit = gtk_entry_new ();
  gtk_widget_set_name (edit, "edit");
  gtk_widget_show (edit);
  gtk_box_pack_start (GTK_BOX (vbox2), edit, FALSE, FALSE, 0);
  gtk_entry_set_activates_default (GTK_ENTRY (edit), TRUE);

  g_signal_connect ((gpointer) new_mem, "activate",
                    G_CALLBACK (on_new_mem_activate),
                    NULL);
  g_signal_connect ((gpointer) new_disasm, "activate",
                    G_CALLBACK (on_new_disasm_activate),
                    NULL);
  g_signal_connect ((gpointer) new_errorlog, "activate",
                    G_CALLBACK (on_new_errorlog_activate),
                    NULL);
  g_signal_connect ((gpointer) run, "activate",
                    G_CALLBACK (on_run_activate),
                    NULL);
  g_signal_connect ((gpointer) run_h, "activate",
                    G_CALLBACK (on_run_h_activate),
                    NULL);
  g_signal_connect ((gpointer) run_cpu, "activate",
                    G_CALLBACK (on_run_cpu_activate),
                    NULL);
  g_signal_connect ((gpointer) run_irq, "activate",
                    G_CALLBACK (on_run_irq_activate),
                    NULL);
  g_signal_connect ((gpointer) run_vbl, "activate",
                    G_CALLBACK (on_run_vbl_activate),
                    NULL);
  g_signal_connect ((gpointer) step_into, "activate",
                    G_CALLBACK (on_step_into_activate),
                    NULL);
  g_signal_connect ((gpointer) step_over, "activate",
                    G_CALLBACK (on_step_over_activate),
                    NULL);
  g_signal_connect ((gpointer) step_out, "activate",
                    G_CALLBACK (on_step_out_activate),
                    NULL);
  g_signal_connect ((gpointer) soft_reset, "activate",
                    G_CALLBACK (on_soft_reset_activate),
                    NULL);
  g_signal_connect ((gpointer) hard_reset, "activate",
                    G_CALLBACK (on_hard_reset_activate),
                    NULL);
  g_signal_connect ((gpointer) exit, "activate",
                    G_CALLBACK (on_exit_activate),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (debugmain, debugmain, "debugmain");
  GLADE_HOOKUP_OBJECT (debugmain, vbox1, "vbox1");
  GLADE_HOOKUP_OBJECT (debugmain, menu, "menu");
  GLADE_HOOKUP_OBJECT (debugmain, menuitem4, "menuitem4");
  GLADE_HOOKUP_OBJECT (debugmain, menuitem4_menu, "menuitem4_menu");
  GLADE_HOOKUP_OBJECT (debugmain, new_mem, "new_mem");
  GLADE_HOOKUP_OBJECT (debugmain, new_disasm, "new_disasm");
  GLADE_HOOKUP_OBJECT (debugmain, new_errorlog, "new_errorlog");
  GLADE_HOOKUP_OBJECT (debugmain, separator2, "separator2");
  GLADE_HOOKUP_OBJECT (debugmain, run, "run");
  GLADE_HOOKUP_OBJECT (debugmain, run_h, "run_h");
  GLADE_HOOKUP_OBJECT (debugmain, run_cpu, "run_cpu");
  GLADE_HOOKUP_OBJECT (debugmain, run_irq, "run_irq");
  GLADE_HOOKUP_OBJECT (debugmain, run_vbl, "run_vbl");
  GLADE_HOOKUP_OBJECT (debugmain, separator3, "separator3");
  GLADE_HOOKUP_OBJECT (debugmain, step_into, "step_into");
  GLADE_HOOKUP_OBJECT (debugmain, step_over, "step_over");
  GLADE_HOOKUP_OBJECT (debugmain, step_out, "step_out");
  GLADE_HOOKUP_OBJECT (debugmain, separator4, "separator4");
  GLADE_HOOKUP_OBJECT (debugmain, soft_reset, "soft_reset");
  GLADE_HOOKUP_OBJECT (debugmain, hard_reset, "hard_reset");
  GLADE_HOOKUP_OBJECT (debugmain, exit, "exit");
  GLADE_HOOKUP_OBJECT (debugmain, item1, "item1");
  GLADE_HOOKUP_OBJECT (debugmain, item1_menu, "item1_menu");
  GLADE_HOOKUP_OBJECT (debugmain, raw_opcodes, "raw_opcodes");
  GLADE_HOOKUP_OBJECT (debugmain, enc_opcodes, "enc_opcodes");
  GLADE_HOOKUP_OBJECT (debugmain, comments, "comments");
  GLADE_HOOKUP_OBJECT (debugmain, hbox1, "hbox1");
  GLADE_HOOKUP_OBJECT (debugmain, registers, "registers");
  GLADE_HOOKUP_OBJECT (debugmain, vbox2, "vbox2");
  GLADE_HOOKUP_OBJECT (debugmain, disasm, "disasm");
  GLADE_HOOKUP_OBJECT (debugmain, console, "console");
  GLADE_HOOKUP_OBJECT (debugmain, edit, "edit");

  gtk_widget_grab_focus (edit);
  gtk_window_add_accel_group (GTK_WINDOW (debugmain), accel_group);

  return debugmain;
}

GtkWidget*
create_memorywin (void)
{
  GtkWidget *memorywin;
  GtkWidget *vbox3;
  GtkWidget *menu;
  GtkWidget *debug;
  GtkWidget *debug_menu;
  GtkWidget *new_mem;
  GtkWidget *new_disasm;
  GtkWidget *new_errorlog;
  GtkWidget *separator2;
  GtkWidget *run;
  GtkWidget *run_h;
  GtkWidget *run_cpu;
  GtkWidget *run_irq;
  GtkWidget *run_vbl;
  GtkWidget *separator3;
  GtkWidget *step_into;
  GtkWidget *step_over;
  GtkWidget *step_out;
  GtkWidget *separator4;
  GtkWidget *soft_reset;
  GtkWidget *hard_reset;
  GtkWidget *exit;
  GtkWidget *options;
  GtkWidget *options_menu;
  GSList *chunks_1_group = NULL;
  GtkWidget *chunks_1;
  GtkWidget *chunks_2;
  GtkWidget *chunks_4;
  GtkWidget *separator5;
  GtkWidget *reverse;
  GtkWidget *separator6;
  GtkWidget *ibpl;
  GtkWidget *dbpl;
  GtkWidget *hbox2;
  GtkWidget *edit;
  GtkWidget *zone;
  GtkWidget *memoryview;
  GtkAccelGroup *accel_group;

  accel_group = gtk_accel_group_new ();

  memorywin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (memorywin, "memorywin");
  gtk_window_set_title (GTK_WINDOW (memorywin), "Memory View");

  vbox3 = gtk_vbox_new (FALSE, 0);
  gtk_widget_set_name (vbox3, "vbox3");
  gtk_widget_show (vbox3);
  gtk_container_add (GTK_CONTAINER (memorywin), vbox3);

  menu = gtk_menu_bar_new ();
  gtk_widget_set_name (menu, "menu");
  gtk_widget_show (menu);
  gtk_box_pack_start (GTK_BOX (vbox3), menu, FALSE, FALSE, 0);

  debug = gtk_menu_item_new_with_mnemonic ("_Debug");
  gtk_widget_set_name (debug, "debug");
  gtk_widget_show (debug);
  gtk_container_add (GTK_CONTAINER (menu), debug);

  debug_menu = gtk_menu_new ();
  gtk_widget_set_name (debug_menu, "debug_menu");
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (debug), debug_menu);

  new_mem = gtk_menu_item_new_with_mnemonic ("New Memory Window");
  gtk_widget_set_name (new_mem, "new_mem");
  gtk_widget_show (new_mem);
  gtk_container_add (GTK_CONTAINER (debug_menu), new_mem);
  gtk_widget_add_accelerator (new_mem, "activate", accel_group,
                              GDK_m, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  new_disasm = gtk_menu_item_new_with_mnemonic ("New Disassembly Window");
  gtk_widget_set_name (new_disasm, "new_disasm");
  gtk_widget_show (new_disasm);
  gtk_container_add (GTK_CONTAINER (debug_menu), new_disasm);
  gtk_widget_add_accelerator (new_disasm, "activate", accel_group,
                              GDK_d, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  new_errorlog = gtk_menu_item_new_with_mnemonic ("New Error Log Window");
  gtk_widget_set_name (new_errorlog, "new_errorlog");
  gtk_widget_show (new_errorlog);
  gtk_container_add (GTK_CONTAINER (debug_menu), new_errorlog);
  gtk_widget_add_accelerator (new_errorlog, "activate", accel_group,
                              GDK_l, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  separator2 = gtk_separator_menu_item_new ();
  gtk_widget_set_name (separator2, "separator2");
  gtk_widget_show (separator2);
  gtk_container_add (GTK_CONTAINER (debug_menu), separator2);
  gtk_widget_set_sensitive (separator2, FALSE);

  run = gtk_menu_item_new_with_mnemonic ("Run");
  gtk_widget_set_name (run, "run");
  gtk_widget_show (run);
  gtk_container_add (GTK_CONTAINER (debug_menu), run);
  gtk_widget_add_accelerator (run, "activate", accel_group,
                              GDK_F5, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  run_h = gtk_menu_item_new_with_mnemonic ("Run and Hide Debugger");
  gtk_widget_set_name (run_h, "run_h");
  gtk_widget_show (run_h);
  gtk_container_add (GTK_CONTAINER (debug_menu), run_h);
  gtk_widget_add_accelerator (run_h, "activate", accel_group,
                              GDK_F12, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  run_cpu = gtk_menu_item_new_with_mnemonic ("Run to Next CPU");
  gtk_widget_set_name (run_cpu, "run_cpu");
  gtk_widget_show (run_cpu);
  gtk_container_add (GTK_CONTAINER (debug_menu), run_cpu);
  gtk_widget_add_accelerator (run_cpu, "activate", accel_group,
                              GDK_F6, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  run_irq = gtk_menu_item_new_with_mnemonic ("Run until Next Interrupt on This CPU");
  gtk_widget_set_name (run_irq, "run_irq");
  gtk_widget_show (run_irq);
  gtk_container_add (GTK_CONTAINER (debug_menu), run_irq);
  gtk_widget_add_accelerator (run_irq, "activate", accel_group,
                              GDK_F7, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  run_vbl = gtk_menu_item_new_with_mnemonic ("Run until Next VBLANK");
  gtk_widget_set_name (run_vbl, "run_vbl");
  gtk_widget_show (run_vbl);
  gtk_container_add (GTK_CONTAINER (debug_menu), run_vbl);
  gtk_widget_add_accelerator (run_vbl, "activate", accel_group,
                              GDK_F8, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  separator3 = gtk_separator_menu_item_new ();
  gtk_widget_set_name (separator3, "separator3");
  gtk_widget_show (separator3);
  gtk_container_add (GTK_CONTAINER (debug_menu), separator3);
  gtk_widget_set_sensitive (separator3, FALSE);

  step_into = gtk_menu_item_new_with_mnemonic ("Step Into");
  gtk_widget_set_name (step_into, "step_into");
  gtk_widget_show (step_into);
  gtk_container_add (GTK_CONTAINER (debug_menu), step_into);
  gtk_widget_add_accelerator (step_into, "activate", accel_group,
                              GDK_F11, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  step_over = gtk_menu_item_new_with_mnemonic ("Step Over");
  gtk_widget_set_name (step_over, "step_over");
  gtk_widget_show (step_over);
  gtk_container_add (GTK_CONTAINER (debug_menu), step_over);
  gtk_widget_add_accelerator (step_over, "activate", accel_group,
                              GDK_F10, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  step_out = gtk_menu_item_new_with_mnemonic ("Step Out");
  gtk_widget_set_name (step_out, "step_out");
  gtk_widget_show (step_out);
  gtk_container_add (GTK_CONTAINER (debug_menu), step_out);
  gtk_widget_add_accelerator (step_out, "activate", accel_group,
                              GDK_F11, (GdkModifierType) GDK_SHIFT_MASK,
                              GTK_ACCEL_VISIBLE);

  separator4 = gtk_separator_menu_item_new ();
  gtk_widget_set_name (separator4, "separator4");
  gtk_widget_show (separator4);
  gtk_container_add (GTK_CONTAINER (debug_menu), separator4);
  gtk_widget_set_sensitive (separator4, FALSE);

  soft_reset = gtk_menu_item_new_with_mnemonic ("Soft Reset");
  gtk_widget_set_name (soft_reset, "soft_reset");
  gtk_widget_show (soft_reset);
  gtk_container_add (GTK_CONTAINER (debug_menu), soft_reset);
  gtk_widget_add_accelerator (soft_reset, "activate", accel_group,
                              GDK_F3, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  hard_reset = gtk_menu_item_new_with_mnemonic ("Hard Reset");
  gtk_widget_set_name (hard_reset, "hard_reset");
  gtk_widget_show (hard_reset);
  gtk_container_add (GTK_CONTAINER (debug_menu), hard_reset);
  gtk_widget_add_accelerator (hard_reset, "activate", accel_group,
                              GDK_F3, (GdkModifierType) GDK_SHIFT_MASK,
                              GTK_ACCEL_VISIBLE);

  exit = gtk_menu_item_new_with_mnemonic ("Exit");
  gtk_widget_set_name (exit, "exit");
  gtk_widget_show (exit);
  gtk_container_add (GTK_CONTAINER (debug_menu), exit);

  options = gtk_menu_item_new_with_mnemonic ("_Options");
  gtk_widget_set_name (options, "options");
  gtk_widget_show (options);
  gtk_container_add (GTK_CONTAINER (menu), options);

  options_menu = gtk_menu_new ();
  gtk_widget_set_name (options_menu, "options_menu");
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (options), options_menu);

  chunks_1 = gtk_radio_menu_item_new_with_mnemonic (chunks_1_group, "1-byte chunks");
  chunks_1_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (chunks_1));
  gtk_widget_set_name (chunks_1, "chunks_1");
  gtk_widget_show (chunks_1);
  gtk_container_add (GTK_CONTAINER (options_menu), chunks_1);
  gtk_widget_add_accelerator (chunks_1, "activate", accel_group,
                              GDK_1, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);
  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (chunks_1), TRUE);

  chunks_2 = gtk_radio_menu_item_new_with_mnemonic (chunks_1_group, "2-bytes chunks");
  chunks_1_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (chunks_2));
  gtk_widget_set_name (chunks_2, "chunks_2");
  gtk_widget_show (chunks_2);
  gtk_container_add (GTK_CONTAINER (options_menu), chunks_2);
  gtk_widget_add_accelerator (chunks_2, "activate", accel_group,
                              GDK_2, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);
  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (chunks_2), TRUE);

  chunks_4 = gtk_radio_menu_item_new_with_mnemonic (chunks_1_group, "4-bytes chunks");
  chunks_1_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (chunks_4));
  gtk_widget_set_name (chunks_4, "chunks_4");
  gtk_widget_show (chunks_4);
  gtk_container_add (GTK_CONTAINER (options_menu), chunks_4);
  gtk_widget_add_accelerator (chunks_4, "activate", accel_group,
                              GDK_4, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);
  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (chunks_4), TRUE);

  separator5 = gtk_separator_menu_item_new ();
  gtk_widget_set_name (separator5, "separator5");
  gtk_widget_show (separator5);
  gtk_container_add (GTK_CONTAINER (options_menu), separator5);
  gtk_widget_set_sensitive (separator5, FALSE);

  reverse = gtk_check_menu_item_new_with_mnemonic ("Reverse View");
  gtk_widget_set_name (reverse, "reverse");
  gtk_widget_show (reverse);
  gtk_container_add (GTK_CONTAINER (options_menu), reverse);
  gtk_widget_add_accelerator (reverse, "activate", accel_group,
                              GDK_r, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  separator6 = gtk_separator_menu_item_new ();
  gtk_widget_set_name (separator6, "separator6");
  gtk_widget_show (separator6);
  gtk_container_add (GTK_CONTAINER (options_menu), separator6);
  gtk_widget_set_sensitive (separator6, FALSE);

  ibpl = gtk_menu_item_new_with_mnemonic ("Increase bytes per line");
  gtk_widget_set_name (ibpl, "ibpl");
  gtk_widget_show (ibpl);
  gtk_container_add (GTK_CONTAINER (options_menu), ibpl);
  gtk_widget_add_accelerator (ibpl, "activate", accel_group,
                              GDK_p, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  dbpl = gtk_menu_item_new_with_mnemonic ("Decrease bytes per line");
  gtk_widget_set_name (dbpl, "dbpl");
  gtk_widget_show (dbpl);
  gtk_container_add (GTK_CONTAINER (options_menu), dbpl);
  gtk_widget_add_accelerator (dbpl, "activate", accel_group,
                              GDK_o, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  hbox2 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox2, "hbox2");
  gtk_widget_show (hbox2);
  gtk_box_pack_start (GTK_BOX (vbox3), hbox2, FALSE, TRUE, 0);

  edit = gtk_entry_new ();
  gtk_widget_set_name (edit, "edit");
  gtk_widget_show (edit);
  gtk_box_pack_start (GTK_BOX (hbox2), edit, TRUE, TRUE, 0);

  zone = gtk_combo_box_new_text ();
  gtk_widget_set_name (zone, "zone");
  gtk_widget_show (zone);
  gtk_box_pack_start (GTK_BOX (hbox2), zone, TRUE, TRUE, 0);

  memoryview = dview_new ("memoryview", "", "", 0, 0);
  gtk_widget_set_name (memoryview, "memoryview");
  gtk_widget_show (memoryview);
  gtk_box_pack_start (GTK_BOX (vbox3), memoryview, TRUE, TRUE, 0);
  GTK_WIDGET_UNSET_FLAGS (memoryview, GTK_CAN_FOCUS);
  GTK_WIDGET_UNSET_FLAGS (memoryview, GTK_CAN_DEFAULT);

  g_signal_connect ((gpointer) new_mem, "activate",
                    G_CALLBACK (on_new_mem_activate),
                    NULL);
  g_signal_connect ((gpointer) new_disasm, "activate",
                    G_CALLBACK (on_new_disasm_activate),
                    NULL);
  g_signal_connect ((gpointer) new_errorlog, "activate",
                    G_CALLBACK (on_new_errorlog_activate),
                    NULL);
  g_signal_connect ((gpointer) run, "activate",
                    G_CALLBACK (on_run_activate),
                    NULL);
  g_signal_connect ((gpointer) run_h, "activate",
                    G_CALLBACK (on_run_h_activate),
                    NULL);
  g_signal_connect ((gpointer) run_cpu, "activate",
                    G_CALLBACK (on_run_cpu_activate),
                    NULL);
  g_signal_connect ((gpointer) run_irq, "activate",
                    G_CALLBACK (on_run_irq_activate),
                    NULL);
  g_signal_connect ((gpointer) run_vbl, "activate",
                    G_CALLBACK (on_run_vbl_activate),
                    NULL);
  g_signal_connect ((gpointer) step_into, "activate",
                    G_CALLBACK (on_step_into_activate),
                    NULL);
  g_signal_connect ((gpointer) step_over, "activate",
                    G_CALLBACK (on_step_over_activate),
                    NULL);
  g_signal_connect ((gpointer) step_out, "activate",
                    G_CALLBACK (on_step_out_activate),
                    NULL);
  g_signal_connect ((gpointer) soft_reset, "activate",
                    G_CALLBACK (on_soft_reset_activate),
                    NULL);
  g_signal_connect ((gpointer) hard_reset, "activate",
                    G_CALLBACK (on_hard_reset_activate),
                    NULL);
  g_signal_connect ((gpointer) exit, "activate",
                    G_CALLBACK (on_exit_activate),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (memorywin, memorywin, "memorywin");
  GLADE_HOOKUP_OBJECT (memorywin, vbox3, "vbox3");
  GLADE_HOOKUP_OBJECT (memorywin, menu, "menu");
  GLADE_HOOKUP_OBJECT (memorywin, debug, "debug");
  GLADE_HOOKUP_OBJECT (memorywin, debug_menu, "debug_menu");
  GLADE_HOOKUP_OBJECT (memorywin, new_mem, "new_mem");
  GLADE_HOOKUP_OBJECT (memorywin, new_disasm, "new_disasm");
  GLADE_HOOKUP_OBJECT (memorywin, new_errorlog, "new_errorlog");
  GLADE_HOOKUP_OBJECT (memorywin, separator2, "separator2");
  GLADE_HOOKUP_OBJECT (memorywin, run, "run");
  GLADE_HOOKUP_OBJECT (memorywin, run_h, "run_h");
  GLADE_HOOKUP_OBJECT (memorywin, run_cpu, "run_cpu");
  GLADE_HOOKUP_OBJECT (memorywin, run_irq, "run_irq");
  GLADE_HOOKUP_OBJECT (memorywin, run_vbl, "run_vbl");
  GLADE_HOOKUP_OBJECT (memorywin, separator3, "separator3");
  GLADE_HOOKUP_OBJECT (memorywin, step_into, "step_into");
  GLADE_HOOKUP_OBJECT (memorywin, step_over, "step_over");
  GLADE_HOOKUP_OBJECT (memorywin, step_out, "step_out");
  GLADE_HOOKUP_OBJECT (memorywin, separator4, "separator4");
  GLADE_HOOKUP_OBJECT (memorywin, soft_reset, "soft_reset");
  GLADE_HOOKUP_OBJECT (memorywin, hard_reset, "hard_reset");
  GLADE_HOOKUP_OBJECT (memorywin, exit, "exit");
  GLADE_HOOKUP_OBJECT (memorywin, options, "options");
  GLADE_HOOKUP_OBJECT (memorywin, options_menu, "options_menu");
  GLADE_HOOKUP_OBJECT (memorywin, chunks_1, "chunks_1");
  GLADE_HOOKUP_OBJECT (memorywin, chunks_2, "chunks_2");
  GLADE_HOOKUP_OBJECT (memorywin, chunks_4, "chunks_4");
  GLADE_HOOKUP_OBJECT (memorywin, separator5, "separator5");
  GLADE_HOOKUP_OBJECT (memorywin, reverse, "reverse");
  GLADE_HOOKUP_OBJECT (memorywin, separator6, "separator6");
  GLADE_HOOKUP_OBJECT (memorywin, ibpl, "ibpl");
  GLADE_HOOKUP_OBJECT (memorywin, dbpl, "dbpl");
  GLADE_HOOKUP_OBJECT (memorywin, hbox2, "hbox2");
  GLADE_HOOKUP_OBJECT (memorywin, edit, "edit");
  GLADE_HOOKUP_OBJECT (memorywin, zone, "zone");
  GLADE_HOOKUP_OBJECT (memorywin, memoryview, "memoryview");

  gtk_window_add_accel_group (GTK_WINDOW (memorywin), accel_group);

  return memorywin;
}

GtkWidget*
create_disasmwin (void)
{
  GtkWidget *disasmwin;
  GtkWidget *vbox4;
  GtkWidget *menubar1;
  GtkWidget *menuitem5;
  GtkWidget *menuitem5_menu;
  GtkWidget *menuitem6;
  GtkWidget *menuitem7;
  GtkWidget *menuitem8;
  GtkWidget *separatormenuitem1;
  GtkWidget *menuitem9;
  GtkWidget *menuitem10;
  GtkWidget *menuitem11;
  GtkWidget *menuitem12;
  GtkWidget *menuitem13;
  GtkWidget *separatormenuitem2;
  GtkWidget *menuitem14;
  GtkWidget *menuitem15;
  GtkWidget *menuitem16;
  GtkWidget *separatormenuitem3;
  GtkWidget *menuitem17;
  GtkWidget *menuitem18;
  GtkWidget *menuitem19;
  GtkWidget *menuitem20;
  GtkWidget *menuitem20_menu;
  GSList *raw_opcodes_group = NULL;
  GtkWidget *raw_opcodes;
  GtkWidget *enc_opcodes;
  GtkWidget *comments;
  GtkWidget *hbox3;
  GtkWidget *edit;
  GtkWidget *cpu;
  GtkWidget *disasmview;
  GtkAccelGroup *accel_group;

  accel_group = gtk_accel_group_new ();

  disasmwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (disasmwin, "disasmwin");
  gtk_window_set_title (GTK_WINDOW (disasmwin), "Disassembly");

  vbox4 = gtk_vbox_new (FALSE, 0);
  gtk_widget_set_name (vbox4, "vbox4");
  gtk_widget_show (vbox4);
  gtk_container_add (GTK_CONTAINER (disasmwin), vbox4);

  menubar1 = gtk_menu_bar_new ();
  gtk_widget_set_name (menubar1, "menubar1");
  gtk_widget_show (menubar1);
  gtk_box_pack_start (GTK_BOX (vbox4), menubar1, FALSE, FALSE, 0);

  menuitem5 = gtk_menu_item_new_with_mnemonic ("_Debug");
  gtk_widget_set_name (menuitem5, "menuitem5");
  gtk_widget_show (menuitem5);
  gtk_container_add (GTK_CONTAINER (menubar1), menuitem5);

  menuitem5_menu = gtk_menu_new ();
  gtk_widget_set_name (menuitem5_menu, "menuitem5_menu");
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem5), menuitem5_menu);

  menuitem6 = gtk_menu_item_new_with_mnemonic ("New Memory Window");
  gtk_widget_set_name (menuitem6, "menuitem6");
  gtk_widget_show (menuitem6);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), menuitem6);
  gtk_widget_add_accelerator (menuitem6, "activate", accel_group,
                              GDK_m, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  menuitem7 = gtk_menu_item_new_with_mnemonic ("New Disassembly Window");
  gtk_widget_set_name (menuitem7, "menuitem7");
  gtk_widget_show (menuitem7);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), menuitem7);
  gtk_widget_add_accelerator (menuitem7, "activate", accel_group,
                              GDK_d, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  menuitem8 = gtk_menu_item_new_with_mnemonic ("New Error Log Window");
  gtk_widget_set_name (menuitem8, "menuitem8");
  gtk_widget_show (menuitem8);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), menuitem8);
  gtk_widget_add_accelerator (menuitem8, "activate", accel_group,
                              GDK_l, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  separatormenuitem1 = gtk_separator_menu_item_new ();
  gtk_widget_set_name (separatormenuitem1, "separatormenuitem1");
  gtk_widget_show (separatormenuitem1);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), separatormenuitem1);
  gtk_widget_set_sensitive (separatormenuitem1, FALSE);

  menuitem9 = gtk_menu_item_new_with_mnemonic ("Run");
  gtk_widget_set_name (menuitem9, "menuitem9");
  gtk_widget_show (menuitem9);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), menuitem9);
  gtk_widget_add_accelerator (menuitem9, "activate", accel_group,
                              GDK_F5, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem10 = gtk_menu_item_new_with_mnemonic ("Run and Hide Debugger");
  gtk_widget_set_name (menuitem10, "menuitem10");
  gtk_widget_show (menuitem10);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), menuitem10);
  gtk_widget_add_accelerator (menuitem10, "activate", accel_group,
                              GDK_F12, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem11 = gtk_menu_item_new_with_mnemonic ("Run to Next CPU");
  gtk_widget_set_name (menuitem11, "menuitem11");
  gtk_widget_show (menuitem11);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), menuitem11);
  gtk_widget_add_accelerator (menuitem11, "activate", accel_group,
                              GDK_F6, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem12 = gtk_menu_item_new_with_mnemonic ("Run until Next Interrupt on This CPU");
  gtk_widget_set_name (menuitem12, "menuitem12");
  gtk_widget_show (menuitem12);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), menuitem12);
  gtk_widget_add_accelerator (menuitem12, "activate", accel_group,
                              GDK_F7, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem13 = gtk_menu_item_new_with_mnemonic ("Run until Next VBLANK");
  gtk_widget_set_name (menuitem13, "menuitem13");
  gtk_widget_show (menuitem13);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), menuitem13);
  gtk_widget_add_accelerator (menuitem13, "activate", accel_group,
                              GDK_F8, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  separatormenuitem2 = gtk_separator_menu_item_new ();
  gtk_widget_set_name (separatormenuitem2, "separatormenuitem2");
  gtk_widget_show (separatormenuitem2);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), separatormenuitem2);
  gtk_widget_set_sensitive (separatormenuitem2, FALSE);

  menuitem14 = gtk_menu_item_new_with_mnemonic ("Step Into");
  gtk_widget_set_name (menuitem14, "menuitem14");
  gtk_widget_show (menuitem14);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), menuitem14);
  gtk_widget_add_accelerator (menuitem14, "activate", accel_group,
                              GDK_F11, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem15 = gtk_menu_item_new_with_mnemonic ("Step Over");
  gtk_widget_set_name (menuitem15, "menuitem15");
  gtk_widget_show (menuitem15);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), menuitem15);
  gtk_widget_add_accelerator (menuitem15, "activate", accel_group,
                              GDK_F10, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem16 = gtk_menu_item_new_with_mnemonic ("Step Out");
  gtk_widget_set_name (menuitem16, "menuitem16");
  gtk_widget_show (menuitem16);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), menuitem16);
  gtk_widget_add_accelerator (menuitem16, "activate", accel_group,
                              GDK_F11, (GdkModifierType) GDK_SHIFT_MASK,
                              GTK_ACCEL_VISIBLE);

  separatormenuitem3 = gtk_separator_menu_item_new ();
  gtk_widget_set_name (separatormenuitem3, "separatormenuitem3");
  gtk_widget_show (separatormenuitem3);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), separatormenuitem3);
  gtk_widget_set_sensitive (separatormenuitem3, FALSE);

  menuitem17 = gtk_menu_item_new_with_mnemonic ("Soft Reset");
  gtk_widget_set_name (menuitem17, "menuitem17");
  gtk_widget_show (menuitem17);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), menuitem17);
  gtk_widget_add_accelerator (menuitem17, "activate", accel_group,
                              GDK_F3, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem18 = gtk_menu_item_new_with_mnemonic ("Hard Reset");
  gtk_widget_set_name (menuitem18, "menuitem18");
  gtk_widget_show (menuitem18);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), menuitem18);
  gtk_widget_add_accelerator (menuitem18, "activate", accel_group,
                              GDK_F3, (GdkModifierType) GDK_SHIFT_MASK,
                              GTK_ACCEL_VISIBLE);

  menuitem19 = gtk_menu_item_new_with_mnemonic ("Exit");
  gtk_widget_set_name (menuitem19, "menuitem19");
  gtk_widget_show (menuitem19);
  gtk_container_add (GTK_CONTAINER (menuitem5_menu), menuitem19);

  menuitem20 = gtk_menu_item_new_with_mnemonic ("_Options");
  gtk_widget_set_name (menuitem20, "menuitem20");
  gtk_widget_show (menuitem20);
  gtk_container_add (GTK_CONTAINER (menubar1), menuitem20);

  menuitem20_menu = gtk_menu_new ();
  gtk_widget_set_name (menuitem20_menu, "menuitem20_menu");
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem20), menuitem20_menu);

  raw_opcodes = gtk_radio_menu_item_new_with_mnemonic (raw_opcodes_group, "Raw Opcodes");
  raw_opcodes_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (raw_opcodes));
  gtk_widget_set_name (raw_opcodes, "raw_opcodes");
  gtk_widget_show (raw_opcodes);
  gtk_container_add (GTK_CONTAINER (menuitem20_menu), raw_opcodes);
  gtk_widget_add_accelerator (raw_opcodes, "activate", accel_group,
                              GDK_r, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);
  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (raw_opcodes), TRUE);

  enc_opcodes = gtk_radio_menu_item_new_with_mnemonic (raw_opcodes_group, "Encrypted Opcodes");
  raw_opcodes_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (enc_opcodes));
  gtk_widget_set_name (enc_opcodes, "enc_opcodes");
  gtk_widget_show (enc_opcodes);
  gtk_container_add (GTK_CONTAINER (menuitem20_menu), enc_opcodes);
  gtk_widget_add_accelerator (enc_opcodes, "activate", accel_group,
                              GDK_e, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);
  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (enc_opcodes), TRUE);

  comments = gtk_radio_menu_item_new_with_mnemonic (raw_opcodes_group, "Comments");
  raw_opcodes_group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (comments));
  gtk_widget_set_name (comments, "comments");
  gtk_widget_show (comments);
  gtk_container_add (GTK_CONTAINER (menuitem20_menu), comments);
  gtk_widget_add_accelerator (comments, "activate", accel_group,
                              GDK_c, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);
  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (comments), TRUE);

  hbox3 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox3, "hbox3");
  gtk_widget_show (hbox3);
  gtk_box_pack_start (GTK_BOX (vbox4), hbox3, FALSE, TRUE, 0);

  edit = gtk_entry_new ();
  gtk_widget_set_name (edit, "edit");
  gtk_widget_show (edit);
  gtk_box_pack_start (GTK_BOX (hbox3), edit, TRUE, TRUE, 0);

  cpu = gtk_combo_box_new_text ();
  gtk_widget_set_name (cpu, "cpu");
  gtk_widget_show (cpu);
  gtk_box_pack_start (GTK_BOX (hbox3), cpu, TRUE, TRUE, 0);

  disasmview = dview_new ("disasmview", "", "", 0, 0);
  gtk_widget_set_name (disasmview, "disasmview");
  gtk_widget_show (disasmview);
  gtk_box_pack_start (GTK_BOX (vbox4), disasmview, TRUE, TRUE, 0);
  GTK_WIDGET_UNSET_FLAGS (disasmview, GTK_CAN_FOCUS);
  GTK_WIDGET_UNSET_FLAGS (disasmview, GTK_CAN_DEFAULT);

  g_signal_connect ((gpointer) menuitem6, "activate",
                    G_CALLBACK (on_new_mem_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem7, "activate",
                    G_CALLBACK (on_new_disasm_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem8, "activate",
                    G_CALLBACK (on_new_errorlog_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem9, "activate",
                    G_CALLBACK (on_run_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem10, "activate",
                    G_CALLBACK (on_run_h_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem11, "activate",
                    G_CALLBACK (on_run_cpu_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem12, "activate",
                    G_CALLBACK (on_run_irq_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem13, "activate",
                    G_CALLBACK (on_run_vbl_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem14, "activate",
                    G_CALLBACK (on_step_into_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem15, "activate",
                    G_CALLBACK (on_step_over_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem16, "activate",
                    G_CALLBACK (on_step_out_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem17, "activate",
                    G_CALLBACK (on_soft_reset_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem18, "activate",
                    G_CALLBACK (on_hard_reset_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem19, "activate",
                    G_CALLBACK (on_exit_activate),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (disasmwin, disasmwin, "disasmwin");
  GLADE_HOOKUP_OBJECT (disasmwin, vbox4, "vbox4");
  GLADE_HOOKUP_OBJECT (disasmwin, menubar1, "menubar1");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem5, "menuitem5");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem5_menu, "menuitem5_menu");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem6, "menuitem6");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem7, "menuitem7");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem8, "menuitem8");
  GLADE_HOOKUP_OBJECT (disasmwin, separatormenuitem1, "separatormenuitem1");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem9, "menuitem9");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem10, "menuitem10");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem11, "menuitem11");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem12, "menuitem12");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem13, "menuitem13");
  GLADE_HOOKUP_OBJECT (disasmwin, separatormenuitem2, "separatormenuitem2");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem14, "menuitem14");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem15, "menuitem15");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem16, "menuitem16");
  GLADE_HOOKUP_OBJECT (disasmwin, separatormenuitem3, "separatormenuitem3");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem17, "menuitem17");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem18, "menuitem18");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem19, "menuitem19");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem20, "menuitem20");
  GLADE_HOOKUP_OBJECT (disasmwin, menuitem20_menu, "menuitem20_menu");
  GLADE_HOOKUP_OBJECT (disasmwin, raw_opcodes, "raw_opcodes");
  GLADE_HOOKUP_OBJECT (disasmwin, enc_opcodes, "enc_opcodes");
  GLADE_HOOKUP_OBJECT (disasmwin, comments, "comments");
  GLADE_HOOKUP_OBJECT (disasmwin, hbox3, "hbox3");
  GLADE_HOOKUP_OBJECT (disasmwin, edit, "edit");
  GLADE_HOOKUP_OBJECT (disasmwin, cpu, "cpu");
  GLADE_HOOKUP_OBJECT (disasmwin, disasmview, "disasmview");

  gtk_window_add_accel_group (GTK_WINDOW (disasmwin), accel_group);

  return disasmwin;
}

GtkWidget*
create_logwin (void)
{
  GtkWidget *logwin;
  GtkWidget *vbox5;
  GtkWidget *menubar2;
  GtkWidget *menuitem26;
  GtkWidget *menuitem26_menu;
  GtkWidget *menuitem27;
  GtkWidget *menuitem28;
  GtkWidget *menuitem29;
  GtkWidget *separatormenuitem5;
  GtkWidget *menuitem30;
  GtkWidget *menuitem31;
  GtkWidget *menuitem32;
  GtkWidget *menuitem33;
  GtkWidget *menuitem34;
  GtkWidget *separatormenuitem6;
  GtkWidget *menuitem35;
  GtkWidget *menuitem36;
  GtkWidget *menuitem37;
  GtkWidget *separatormenuitem7;
  GtkWidget *menuitem38;
  GtkWidget *menuitem39;
  GtkWidget *menuitem40;
  GtkWidget *logview;
  GtkAccelGroup *accel_group;

  accel_group = gtk_accel_group_new ();

  logwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (logwin, "logwin");
  gtk_window_set_title (GTK_WINDOW (logwin), "Log Viewer");

  vbox5 = gtk_vbox_new (FALSE, 0);
  gtk_widget_set_name (vbox5, "vbox5");
  gtk_widget_show (vbox5);
  gtk_container_add (GTK_CONTAINER (logwin), vbox5);

  menubar2 = gtk_menu_bar_new ();
  gtk_widget_set_name (menubar2, "menubar2");
  gtk_widget_show (menubar2);
  gtk_box_pack_start (GTK_BOX (vbox5), menubar2, FALSE, FALSE, 0);

  menuitem26 = gtk_menu_item_new_with_mnemonic ("_Debug");
  gtk_widget_set_name (menuitem26, "menuitem26");
  gtk_widget_show (menuitem26);
  gtk_container_add (GTK_CONTAINER (menubar2), menuitem26);

  menuitem26_menu = gtk_menu_new ();
  gtk_widget_set_name (menuitem26_menu, "menuitem26_menu");
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem26), menuitem26_menu);

  menuitem27 = gtk_menu_item_new_with_mnemonic ("New Memory Window");
  gtk_widget_set_name (menuitem27, "menuitem27");
  gtk_widget_show (menuitem27);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), menuitem27);
  gtk_widget_add_accelerator (menuitem27, "activate", accel_group,
                              GDK_m, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  menuitem28 = gtk_menu_item_new_with_mnemonic ("New Disassembly Window");
  gtk_widget_set_name (menuitem28, "menuitem28");
  gtk_widget_show (menuitem28);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), menuitem28);
  gtk_widget_add_accelerator (menuitem28, "activate", accel_group,
                              GDK_d, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  menuitem29 = gtk_menu_item_new_with_mnemonic ("New Error Log Window");
  gtk_widget_set_name (menuitem29, "menuitem29");
  gtk_widget_show (menuitem29);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), menuitem29);
  gtk_widget_add_accelerator (menuitem29, "activate", accel_group,
                              GDK_l, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  separatormenuitem5 = gtk_separator_menu_item_new ();
  gtk_widget_set_name (separatormenuitem5, "separatormenuitem5");
  gtk_widget_show (separatormenuitem5);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), separatormenuitem5);
  gtk_widget_set_sensitive (separatormenuitem5, FALSE);

  menuitem30 = gtk_menu_item_new_with_mnemonic ("Run");
  gtk_widget_set_name (menuitem30, "menuitem30");
  gtk_widget_show (menuitem30);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), menuitem30);
  gtk_widget_add_accelerator (menuitem30, "activate", accel_group,
                              GDK_F5, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem31 = gtk_menu_item_new_with_mnemonic ("Run and Hide Debugger");
  gtk_widget_set_name (menuitem31, "menuitem31");
  gtk_widget_show (menuitem31);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), menuitem31);
  gtk_widget_add_accelerator (menuitem31, "activate", accel_group,
                              GDK_F12, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem32 = gtk_menu_item_new_with_mnemonic ("Run to Next CPU");
  gtk_widget_set_name (menuitem32, "menuitem32");
  gtk_widget_show (menuitem32);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), menuitem32);
  gtk_widget_add_accelerator (menuitem32, "activate", accel_group,
                              GDK_F6, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem33 = gtk_menu_item_new_with_mnemonic ("Run until Next Interrupt on This CPU");
  gtk_widget_set_name (menuitem33, "menuitem33");
  gtk_widget_show (menuitem33);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), menuitem33);
  gtk_widget_add_accelerator (menuitem33, "activate", accel_group,
                              GDK_F7, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem34 = gtk_menu_item_new_with_mnemonic ("Run until Next VBLANK");
  gtk_widget_set_name (menuitem34, "menuitem34");
  gtk_widget_show (menuitem34);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), menuitem34);
  gtk_widget_add_accelerator (menuitem34, "activate", accel_group,
                              GDK_F8, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  separatormenuitem6 = gtk_separator_menu_item_new ();
  gtk_widget_set_name (separatormenuitem6, "separatormenuitem6");
  gtk_widget_show (separatormenuitem6);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), separatormenuitem6);
  gtk_widget_set_sensitive (separatormenuitem6, FALSE);

  menuitem35 = gtk_menu_item_new_with_mnemonic ("Step Into");
  gtk_widget_set_name (menuitem35, "menuitem35");
  gtk_widget_show (menuitem35);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), menuitem35);
  gtk_widget_add_accelerator (menuitem35, "activate", accel_group,
                              GDK_F11, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem36 = gtk_menu_item_new_with_mnemonic ("Step Over");
  gtk_widget_set_name (menuitem36, "menuitem36");
  gtk_widget_show (menuitem36);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), menuitem36);
  gtk_widget_add_accelerator (menuitem36, "activate", accel_group,
                              GDK_F10, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem37 = gtk_menu_item_new_with_mnemonic ("Step Out");
  gtk_widget_set_name (menuitem37, "menuitem37");
  gtk_widget_show (menuitem37);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), menuitem37);
  gtk_widget_add_accelerator (menuitem37, "activate", accel_group,
                              GDK_F11, (GdkModifierType) GDK_SHIFT_MASK,
                              GTK_ACCEL_VISIBLE);

  separatormenuitem7 = gtk_separator_menu_item_new ();
  gtk_widget_set_name (separatormenuitem7, "separatormenuitem7");
  gtk_widget_show (separatormenuitem7);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), separatormenuitem7);
  gtk_widget_set_sensitive (separatormenuitem7, FALSE);

  menuitem38 = gtk_menu_item_new_with_mnemonic ("Soft Reset");
  gtk_widget_set_name (menuitem38, "menuitem38");
  gtk_widget_show (menuitem38);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), menuitem38);
  gtk_widget_add_accelerator (menuitem38, "activate", accel_group,
                              GDK_F3, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  menuitem39 = gtk_menu_item_new_with_mnemonic ("Hard Reset");
  gtk_widget_set_name (menuitem39, "menuitem39");
  gtk_widget_show (menuitem39);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), menuitem39);
  gtk_widget_add_accelerator (menuitem39, "activate", accel_group,
                              GDK_F3, (GdkModifierType) GDK_SHIFT_MASK,
                              GTK_ACCEL_VISIBLE);

  menuitem40 = gtk_menu_item_new_with_mnemonic ("Exit");
  gtk_widget_set_name (menuitem40, "menuitem40");
  gtk_widget_show (menuitem40);
  gtk_container_add (GTK_CONTAINER (menuitem26_menu), menuitem40);

  logview = dview_new ("logview", "", "", 0, 0);
  gtk_widget_set_name (logview, "logview");
  gtk_widget_show (logview);
  gtk_box_pack_start (GTK_BOX (vbox5), logview, TRUE, TRUE, 0);
  GTK_WIDGET_UNSET_FLAGS (logview, GTK_CAN_FOCUS);
  GTK_WIDGET_UNSET_FLAGS (logview, GTK_CAN_DEFAULT);

  g_signal_connect ((gpointer) menuitem27, "activate",
                    G_CALLBACK (on_new_mem_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem28, "activate",
                    G_CALLBACK (on_new_disasm_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem29, "activate",
                    G_CALLBACK (on_new_errorlog_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem30, "activate",
                    G_CALLBACK (on_run_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem31, "activate",
                    G_CALLBACK (on_run_h_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem32, "activate",
                    G_CALLBACK (on_run_cpu_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem33, "activate",
                    G_CALLBACK (on_run_irq_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem34, "activate",
                    G_CALLBACK (on_run_vbl_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem35, "activate",
                    G_CALLBACK (on_step_into_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem36, "activate",
                    G_CALLBACK (on_step_over_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem37, "activate",
                    G_CALLBACK (on_step_out_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem38, "activate",
                    G_CALLBACK (on_soft_reset_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem39, "activate",
                    G_CALLBACK (on_hard_reset_activate),
                    NULL);
  g_signal_connect ((gpointer) menuitem40, "activate",
                    G_CALLBACK (on_exit_activate),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (logwin, logwin, "logwin");
  GLADE_HOOKUP_OBJECT (logwin, vbox5, "vbox5");
  GLADE_HOOKUP_OBJECT (logwin, menubar2, "menubar2");
  GLADE_HOOKUP_OBJECT (logwin, menuitem26, "menuitem26");
  GLADE_HOOKUP_OBJECT (logwin, menuitem26_menu, "menuitem26_menu");
  GLADE_HOOKUP_OBJECT (logwin, menuitem27, "menuitem27");
  GLADE_HOOKUP_OBJECT (logwin, menuitem28, "menuitem28");
  GLADE_HOOKUP_OBJECT (logwin, menuitem29, "menuitem29");
  GLADE_HOOKUP_OBJECT (logwin, separatormenuitem5, "separatormenuitem5");
  GLADE_HOOKUP_OBJECT (logwin, menuitem30, "menuitem30");
  GLADE_HOOKUP_OBJECT (logwin, menuitem31, "menuitem31");
  GLADE_HOOKUP_OBJECT (logwin, menuitem32, "menuitem32");
  GLADE_HOOKUP_OBJECT (logwin, menuitem33, "menuitem33");
  GLADE_HOOKUP_OBJECT (logwin, menuitem34, "menuitem34");
  GLADE_HOOKUP_OBJECT (logwin, separatormenuitem6, "separatormenuitem6");
  GLADE_HOOKUP_OBJECT (logwin, menuitem35, "menuitem35");
  GLADE_HOOKUP_OBJECT (logwin, menuitem36, "menuitem36");
  GLADE_HOOKUP_OBJECT (logwin, menuitem37, "menuitem37");
  GLADE_HOOKUP_OBJECT (logwin, separatormenuitem7, "separatormenuitem7");
  GLADE_HOOKUP_OBJECT (logwin, menuitem38, "menuitem38");
  GLADE_HOOKUP_OBJECT (logwin, menuitem39, "menuitem39");
  GLADE_HOOKUP_OBJECT (logwin, menuitem40, "menuitem40");
  GLADE_HOOKUP_OBJECT (logwin, logview, "logview");

  gtk_window_add_accel_group (GTK_WINDOW (logwin), accel_group);

  return logwin;
}

