cfg->clear_ram_on_file_load = false;
/* UI settings */
+ cfg->layout = UI_LAYOUT1;
cfg->win_width = 640;
cfg->win_height = 480;
cfg->hpane_pos = 100;
cfg->vpane_pos = 200;
- cfg->vpane_mem_pos = 200;
+ cfg->main_pane_pos = 200;
}
static int
&cfg->clear_ram_on_file_load);
/* ui */
+ app_config_key_file_get_int(kf, "ui", "layout", &cfg->layout);
+
+ if ((cfg->layout != UI_LAYOUT1) && (cfg->layout != UI_LAYOUT2)) {
+ log_fail_no_exit("Invalid layout, defaulting to layout 1");
+ cfg->layout = UI_LAYOUT1;
+ }
+
app_config_key_file_get_int(kf, "ui", "win_width", &cfg->win_width);
app_config_key_file_get_int(kf, "ui", "win_height", &cfg->win_height);
app_config_key_file_get_int(kf, "ui", "hpane_pos", &cfg->hpane_pos);
app_config_key_file_get_int(kf, "ui", "vpane_pos", &cfg->vpane_pos);
- app_config_key_file_get_int(kf, "ui", "vpane_mem_pos",
- &cfg->vpane_mem_pos);
+ app_config_key_file_get_int(kf, "ui", "main_pane_pos",
+ &cfg->main_pane_pos);
}
static char *
g_string_append(buf, "\n[ui]\n");
+ g_string_append_printf(buf, "layout=%d\n", cfg->layout);
g_string_append_printf(buf, "win_width=%d\n", cfg->win_width);
g_string_append_printf(buf, "win_height=%d\n", cfg->win_height);
g_string_append_printf(buf, "hpane_pos=%d\n", cfg->hpane_pos);
g_string_append_printf(buf, "vpane_pos=%d\n", cfg->vpane_pos);
- g_string_append_printf(buf, "vpane_mem_pos=%d\n",
- cfg->vpane_mem_pos);
+ g_string_append_printf(buf, "main_pane_pos=%d\n",
+ cfg->main_pane_pos);
file_path = app_config_get_file_path();
static int running;
static int running_function_tag;
+static int restart_gui = true;
GtkWidget *mainwin;
static void
hpaned_notify_event(GtkWindow *window, GdkEvent *event, gpointer data)
{
- GtkWidget *hpaned = data;
+ GtkWidget *paned = data;
- cfg->hpane_pos = gtk_paned_get_position(GTK_PANED(hpaned));
+ cfg->hpane_pos = gtk_paned_get_position(GTK_PANED(paned));
}
static void
vpaned_notify_event(GtkWindow *window, GdkEvent *event, gpointer data)
{
- GtkWidget *vpaned = data;
+ GtkWidget *paned = data;
- cfg->vpane_pos = gtk_paned_get_position(GTK_PANED(vpaned));
+ cfg->vpane_pos = gtk_paned_get_position(GTK_PANED(paned));
}
static void
-vpaned_mem_notify_event(GtkWindow *window, GdkEvent *event, gpointer data)
+main_paned_notify_event(GtkWindow *window, GdkEvent *event, gpointer data)
{
- GtkWidget *vpaned = data;
+ GtkWidget *paned = data;
- cfg->vpane_mem_pos = gtk_paned_get_position(GTK_PANED(vpaned));
+ cfg->main_pane_pos = gtk_paned_get_position(GTK_PANED(paned));
+}
+
+void
+emugtk_restart_gui(void)
+{
+ emugtk_stop_running();
+
+ gtk_widget_destroy(mainwin);
+
+ restart_gui = true;
+}
+
+void
+emugtk_quit_gui(void)
+{
+ gtk_main_quit();
+
+ restart_gui = false;
}
/*
* | | | |
* | |---------------------------------------------------------------| |
* | | | |
- * | | vpaned | |
+ * | | main_paned | |
* | | +---------------------------------------------------------+ | |
* | | | | | |
* | | | hpaned | | |
* | | | | | |
* | | |--------------------------***----------------------------- | |
* | | | | | |
- * | | | vpaned_mem | | |
+ * | | | vpaned | | |
* | | | +---------------------------------------------------+ | | |
* | | | | | | | |
* | | | | scrollwin | | | |
GtkWidget *scrollwin;
GtkWidget *hpaned;
GtkWidget *vpaned;
- GtkWidget *vpaned_mem;
+ GtkWidget *main_paned;
mainwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(mainwin), PACKAGE);
g_signal_connect(G_OBJECT(mainwin), "configure-event",
G_CALLBACK(mainwin_configure_event), NULL);
- /*
- * vbox contains the menu bar and body_vbox (for all remaining
- * items).
- */
- vbox = gtk_vbox_new(FALSE, 1);
-
/* Creating the menu bar. */
menu_bar = AddMenu();
- /* Adding menu bar to vbox */
- gtk_box_pack_start(GTK_BOX(vbox), menu_bar, FALSE, FALSE, 1);
/* Creating the buttons bar. */
buttons_bar = AddButtons();
- /* Adding buttons bar to vbox */
- gtk_box_pack_start(GTK_BOX(vbox), buttons_bar, FALSE, FALSE, 1);
-
- /*
- * vpaned will contain:
- * Top: registers and disassembly windows.
- * Bottom: memory windows
- */
- vpaned = gtk_vpaned_new();
- gtk_paned_set_position(GTK_PANED(vpaned), cfg->vpane_pos);
- g_signal_connect(G_OBJECT(vpaned), "notify::position",
- G_CALLBACK(vpaned_notify_event), vpaned);
/* hpaned will contain registers and disassembly windows. */
hpaned = gtk_hpaned_new();
scrollwin = pgmwin_init();
gtk_paned_pack2(GTK_PANED(hpaned), scrollwin, TRUE, FALSE);
- gtk_paned_pack1(GTK_PANED(vpaned), hpaned, FALSE, FALSE);
-
- vpaned_mem = gtk_vpaned_new();
- gtk_paned_set_position(GTK_PANED(vpaned_mem), cfg->vpane_mem_pos);
- g_signal_connect(G_OBJECT(vpaned_mem), "notify::position",
- G_CALLBACK(vpaned_mem_notify_event), vpaned_mem);
+ vpaned = gtk_vpaned_new();
+ gtk_paned_set_position(GTK_PANED(vpaned), cfg->vpane_pos);
+ g_signal_connect(G_OBJECT(vpaned), "notify::position",
+ G_CALLBACK(vpaned_notify_event), vpaned);
/* Internal memory dump frame. */
scrollwin = memwin_init("Internal memory (IRAM)", INT_MEM_ID);
- gtk_paned_pack1(GTK_PANED(vpaned_mem), scrollwin, FALSE, FALSE);
+ gtk_paned_pack1(GTK_PANED(vpaned), scrollwin, FALSE, FALSE);
/* External memory dump frame. */
scrollwin = memwin_init("External memory (XRAM)", EXT_MEM_ID);
- gtk_paned_pack2(GTK_PANED(vpaned_mem), scrollwin, TRUE, FALSE);
+ gtk_paned_pack2(GTK_PANED(vpaned), scrollwin, TRUE, FALSE);
+
+ /*
+ * main_paned will contain two groups:
+ * group1: registers and disassembly windows.
+ * group2: memory windows
+ */
+ if (cfg->layout == UI_LAYOUT1)
+ main_paned = gtk_vpaned_new();
+ else
+ main_paned = gtk_hpaned_new();
- gtk_paned_pack2(GTK_PANED(vpaned), vpaned_mem, TRUE, FALSE);
+ gtk_paned_set_position(GTK_PANED(main_paned), cfg->main_pane_pos);
+ g_signal_connect(G_OBJECT(main_paned), "notify::position",
+ G_CALLBACK(main_paned_notify_event), main_paned);
+ gtk_paned_pack1(GTK_PANED(main_paned), hpaned, FALSE, FALSE);
+ gtk_paned_pack2(GTK_PANED(main_paned), vpaned, TRUE, FALSE);
- /* Adding vpaned window to vbox */
- gtk_box_pack_start(GTK_BOX(vbox), vpaned, true, true, 1);
+ /*
+ * vbox contains the menu bar and body_vbox (for all remaining
+ * items).
+ */
+ vbox = gtk_vbox_new(FALSE, 1);
+ gtk_box_pack_start(GTK_BOX(vbox), menu_bar, FALSE, FALSE, 1);
+ gtk_box_pack_start(GTK_BOX(vbox), buttons_bar, FALSE, FALSE, 1);
+ gtk_box_pack_start(GTK_BOX(vbox), main_paned, true, true, 1);
/* Adding the vbox to the main window. */
gtk_container_add(GTK_CONTAINER(mainwin), vbox);
+ g_signal_connect(mainwin, "destroy", G_CALLBACK(emugtk_quit_gui), NULL);
+
gtk_widget_show_all(mainwin);
}
LoadHexFile(file);
- emugtk_Reset();
+ emugtk_Reset(); /* Use app-config->clear_ram_on_file_load */
emugtk_UpdateDisplay();
}
gtk_init(&argc, &argv);
- emugtk_window_init();
-
if (options.filename != NULL)
- emugtk_new_file(options.filename);
+ LoadHexFile(options.filename);
else
- emugtk_Reset();
+ cpu8051_Reset();
- gtk_main();
+ while (restart_gui == true) {
+ log_info("Init GUI");
+
+ emugtk_window_init();
+ emugtk_UpdateDisplay();
+ gtk_main();
+ }
log_info("Terminate");
#include "emugtk.h" /* For AddMenuSeparator() function. */
#include "messagebox.h"
#include "viewmenu.h"
+#include "app-config.h"
-static void
-ViewMenuExternalDump(gchar *string)
+extern struct app_config_t *cfg;
+
+void toggle_layout(GtkWidget *widget, gpointer data)
{
- ShowMessage("External Memory Dump", "Not implemented yet!",
- GTK_JUSTIFY_CENTER, MESSAGE_DIALOG_NORMAL_FONT);
+ int id;
+
+ id = GPOINTER_TO_UINT(data);
+
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
+ log_info(" Switching to layout %d", id);
+ cfg->layout = id;
+ emugtk_restart_gui();
+ }
}
-static void
-ViewMenuInternalDump(gchar *string)
+void
+view_add_layout_submenu(GtkWidget *parent)
{
- ShowMessage("Internal Memory Dump", "Not implemented yet!",
- GTK_JUSTIFY_CENTER, MESSAGE_DIALOG_NORMAL_FONT);
+ GtkWidget *submenu;
+ GtkWidget *layout;
+ GtkWidget *layout1;
+ GtkWidget *layout2;
+ GSList *group = NULL;
+
+ submenu = gtk_menu_new();
+
+ layout = gtk_menu_item_new_with_label("Layout");
+
+ layout1 = gtk_radio_menu_item_new_with_label(group, "Layout1");
+ group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(layout1));
+ layout2 = gtk_radio_menu_item_new_with_label(group, "Layout2");
+
+ if (cfg->layout == UI_LAYOUT1)
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(layout1), TRUE);
+ else
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(layout2), TRUE);
+
+ g_signal_connect(G_OBJECT(layout1), "activate",
+ G_CALLBACK(toggle_layout), (gpointer) UI_LAYOUT1);
+ g_signal_connect(G_OBJECT(layout2), "activate",
+ G_CALLBACK(toggle_layout), (gpointer) UI_LAYOUT2);
+
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(layout), submenu);
+ gtk_menu_shell_append(GTK_MENU_SHELL(submenu), layout1);
+ gtk_menu_shell_append(GTK_MENU_SHELL(submenu), layout2);
+ gtk_menu_shell_append(GTK_MENU_SHELL(parent), layout);
}
void
{
GtkWidget *item;
GtkWidget *menu;
+ GtkWidget *view;
menu = gtk_menu_new();
- /* Create the 'Viewmenu External Memory Dump' item. */
- item = gtk_menu_item_new_with_label("External Memory Dump");
+ view = gtk_menu_item_new_with_label("View");
+
+ item = gtk_menu_item_new_with_label("Internal Memory");
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+
+ item = gtk_menu_item_new_with_label("External Memory");
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
- /* Attach the callback functions to the activate signal. */
- g_signal_connect(item, "activate", G_CALLBACK(ViewMenuExternalDump),
- NULL);
AddMenuSeparator(menu);
- /* Create the 'Viewmenu Internal Memory Dump' item. */
- item = gtk_menu_item_new_with_label("Internal Memory Dump");
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
- /* Attach the callback functions to the activate signal. */
- g_signal_connect(item, "activate", G_CALLBACK(ViewMenuInternalDump),
- NULL);
-
- /* Adding submenu title. */
- item = gtk_menu_item_new_with_label("View");
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
- gtk_menu_shell_append((GtkMenuShell *) menu_bar, item);
+ /* Add layout submenu */
+ view_add_layout_submenu(menu);
+
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), menu);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
}