X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=src%2Femugtk.c;h=7cd5a2a3995afb228049ba8d67252e89b77971a2;hb=6c53f8ff0267ae104d1b60efb3b8285df338e473;hp=91efb28cb44a31605dd94c567fd72398fc41936d;hpb=536beb0f1eae0cdc86bc82ef945cf01d04e846ca;p=emu8051.git diff --git a/src/emugtk.c b/src/emugtk.c index 91efb28..7cd5a2a 100644 --- a/src/emugtk.c +++ b/src/emugtk.c @@ -49,20 +49,10 @@ static int running; static int running_function_tag; -static GtkWidget *mainwin; -extern struct app_config_t *cfg; - -/* Signal DestroyEvent */ -static void -WindowDestroyEvent(GtkWidget *widget, gpointer data) -{ -#ifdef EMU8051_DEBUG - g_print("emugtk_DestroyEvent(...)\n"); -#endif +GtkWidget *mainwin; - gtk_main_quit(); -} +extern struct app_config_t *cfg; /* Step out of running state */ static void @@ -245,18 +235,21 @@ AddMenu(void) /* Adding the 'Help' submenu */ HelpAddMenu(menu_bar); - gtk_widget_show_all(GTK_WIDGET(menu_bar)); - return menu_bar; } -static void +static int mainwin_configure_event(GtkWindow *window, GdkEvent *event, gpointer data) { - //event->configure.x; - //event->configure.y; cfg->win_width = event->configure.width; cfg->win_height = event->configure.height; + + /* + * Important: + * Returning false allows event to propagate to children. If not, they + * will not be resized when we resize the main window. + */ + return FALSE; } static void @@ -275,10 +268,59 @@ vpaned_notify_event(GtkWindow *window, GdkEvent *event, gpointer data) cfg->vpane_pos = gtk_paned_get_position(GTK_PANED(vpaned)); } +/* + * mainwin + * +---------------------------------------------------------------------+ + * | | + * | vbox | + * | +---------------------------------------------------------------+ | + * | | | | + * | | menu_bar | | + * | | +----------------------+ | | + * | | | File View Help | | | + * | | +----------------------+ | | + * | | | | + * | |---------------------------------------------------------------| | + * | | | | + * | | buttons_bar | | + * | | +-----------------------+ | | + * | | | RST RUN STOP STEP | | | + * | | +-----------------------+ | | + * | | | | + * | |---------------------------------------------------------------| | + * | | | | + * | | vpaned | | + * | | +---------------------------------------------------------+ | | + * | | | | | | + * | | | hpaned | | | + * | | | +---------------------------------------------------+ | | | + * | | | | | | | | | + * | | | | scrollwin | scrollwin | | | | + * | | | | +------------------+ * +--------------------+ | | | | + * | | | | | REGISTERS window | * | Disassembly window | | | | | + * | | | | +------------------+ | +--------------------+ | | | | + * | | | | | | | | | + * | | | +---------------------------------------------------+ | | | + * | | | | | | + * | | |--------------------------***----------------------------- | | + * | | | | | | + * | | | scrollwin | | | + * | | | +---------------------------------------------------+ | | | + * | | | | Memory window | | | | + * | | | +---------------------------------------------------+ | | | + * | | | | | | + * | | +---------------------------------------------------------+ | | + * | | | | + * | | | | + * | +---------------------------------------------------------------+ | + * | | + * | | + * +---------------------------------------------------------------------+ + */ static void emugtk_window_init(void) { - GtkWidget *main_vbox; + GtkWidget *vbox; GtkWidget *menu_bar; GtkWidget *buttons_bar; GtkWidget *scrollwin; @@ -293,26 +335,26 @@ emugtk_window_init(void) /* Window DESTROY event. */ g_signal_connect(mainwin, "destroy", - G_CALLBACK(WindowDestroyEvent), NULL); + G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(G_OBJECT(mainwin), "configure-event", G_CALLBACK(mainwin_configure_event), NULL); /* - * main_vbox contains the menu bar and body_vbox (for all remaining + * vbox contains the menu bar and body_vbox (for all remaining * items). */ - main_vbox = gtk_vbox_new(FALSE, 1); + vbox = gtk_vbox_new(FALSE, 1); /* Creating the menu bar. */ menu_bar = AddMenu(); - /* Adding menu bar to main_vbox */ - gtk_box_pack_start(GTK_BOX(main_vbox), menu_bar, FALSE, FALSE, 1); + /* 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 main_vbox */ - gtk_box_pack_start(GTK_BOX(main_vbox), buttons_bar, FALSE, FALSE, 1); + /* Adding buttons bar to vbox */ + gtk_box_pack_start(GTK_BOX(vbox), buttons_bar, FALSE, FALSE, 1); /* * vpaned will contain: @@ -344,11 +386,11 @@ emugtk_window_init(void) scrollwin = memwin_init(); gtk_paned_pack2(GTK_PANED(vpaned), scrollwin, TRUE, FALSE); - /* Adding vpaned window to main_vbox */ - gtk_box_pack_start(GTK_BOX(main_vbox), vpaned, true, true, 1); + /* Adding vpaned window to vbox */ + gtk_box_pack_start(GTK_BOX(vbox), vpaned, true, true, 1); - /* Adding the main_vbox to the main window. */ - gtk_container_add(GTK_CONTAINER(mainwin), main_vbox); + /* Adding the vbox to the main window. */ + gtk_container_add(GTK_CONTAINER(mainwin), vbox); gtk_widget_show_all(mainwin); }