Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 238:6af4cc93b137
prev180:e6dcf9b65658
next277:fcc1274776cb
author nkeynes
date Fri Dec 15 10:17:08 2006 +0000 (13 years ago)
permissions -rw-r--r--
last change Add UI for the trace flag
view annotate diff log raw
     1 /**
     2  * $Id: callbacks.c,v 1.17 2006-12-15 10:17:08 nkeynes Exp $
     3  *
     4  * All GTK callbacks go here (stubs are autogenerated by Glade)
     5  *
     6  * Copyright (c) 2005 Nathan Keynes.
     7  *
     8  * This program is free software; you can redistribute it and/or modify
     9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 2 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  * GNU General Public License for more details.
    17  */
    19 #ifdef HAVE_CONFIG_H
    20 #  include <config.h>
    21 #endif
    23 #include <gnome.h>
    25 #include "gui/callbacks.h"
    26 #include "gui/interface.h"
    27 #include "gui/gui.h"
    28 #include "gdrom/gdrom.h"
    29 #include "mem.h"
    30 #include "mmio.h"
    31 #include "dreamcast.h"
    32 #include "loader.h"
    34 int selected_pc = -1;
    35 int selected_row = -1;
    37 void
    38 on_new_file1_activate                  (GtkMenuItem     *menuitem,
    39                                         gpointer         user_data)
    40 {
    42 }
    45 void
    46 on_open1_activate                      (GtkMenuItem     *menuitem,
    47                                         gpointer         user_data)
    48 {
    49     const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
    50     open_file_dialog( "Open...", file_load_magic, NULL, NULL, dir );
    51 }
    54 void
    55 on_save1_activate                      (GtkMenuItem     *menuitem,
    56                                         gpointer         user_data)
    57 {
    59 }
    62 void
    63 on_save_as1_activate                   (GtkMenuItem     *menuitem,
    64                                         gpointer         user_data)
    65 {
    67 }
    70 void
    71 on_exit1_activate                      (GtkMenuItem     *menuitem,
    72                                         gpointer         user_data)
    73 {
    74     gtk_main_quit();
    75 }
    78 void
    79 on_preferences1_activate               (GtkMenuItem     *menuitem,
    80                                         gpointer         user_data)
    81 {
    83 }
    86 void
    87 on_about1_activate                     (GtkMenuItem     *menuitem,
    88                                         gpointer         user_data)
    89 {
    90     GtkWidget *about = create_about_win();
    91     gtk_widget_show(about);
    92 }
    95 void
    96 on_load_btn_clicked                    (GtkButton       *button,
    97                                         gpointer         user_data)
    98 {
    99     const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
   100     open_file_dialog( "Open...", gdrom_mount_image, NULL, NULL, dir );
   101 }
   104 void
   105 on_reset_btn_clicked                   (GtkButton       *button,
   106                                         gpointer         user_data)
   107 {
   108     dreamcast_reset();
   109 }
   112 void
   113 on_stop_btn_clicked                    (GtkButton       *button,
   114                                         gpointer         user_data)
   115 {
   116     dreamcast_stop();
   117 }
   120 void
   121 on_step_btn_clicked                    (GtkButton       *button,
   122                                         gpointer         user_data)
   123 {
   124     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   125     debug_win_single_step(data);
   126 }
   129 void
   130 on_run_btn_clicked                     (GtkButton       *button,
   131                                         gpointer         user_data)
   132 {
   133     dreamcast_run();
   134 }
   137 void
   138 on_runto_btn_clicked                   (GtkButton       *button,
   139                                         gpointer         user_data)
   140 {
   141     if( selected_pc == -1 )
   142         WARN( "No address selected, so can't run to it", NULL );
   143     else {
   144 	debug_info_t data = get_debug_info(GTK_WIDGET(button));
   145 	debug_win_set_oneshot_breakpoint( data, selected_row );
   146 	dreamcast_run();
   147     }
   148 }
   151 void
   152 on_break_btn_clicked                   (GtkButton       *button,
   153                                         gpointer         user_data)
   154 {
   155     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   156     debug_win_toggle_breakpoint( data, selected_row );
   157 }
   159 void on_trace_button_toggled           (GtkToggleButton *button,
   160 					gpointer user_data)
   161 {
   162     struct mmio_region *io_rgn = (struct mmio_region *)user_data;
   163     gboolean isActive = gtk_toggle_button_get_active(button);
   164     if( io_rgn != NULL ) {
   165 	io_rgn->trace_flag = isActive ? 1 : 0;
   166     }
   167 }
   170 gboolean
   171 on_debug_win_delete_event              (GtkWidget       *widget,
   172                                         GdkEvent        *event,
   173                                         gpointer         user_data)
   174 {
   175     gtk_main_quit();
   176     return FALSE;
   177 }
   180 void
   181 on_disasm_list_select_row              (GtkCList        *clist,
   182                                         gint             row,
   183                                         gint             column,
   184                                         GdkEvent        *event,
   185                                         gpointer         user_data)
   186 {
   187     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   188     selected_pc = row_to_address(data, row);
   189     selected_row = row;
   190 }
   193 void
   194 on_disasm_list_unselect_row            (GtkCList        *clist,
   195                                         gint             row,
   196                                         gint             column,
   197                                         GdkEvent        *event,
   198                                         gpointer         user_data)
   199 {
   200     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   201     int pc = row_to_address(data,row);
   202     if( selected_pc == pc ) selected_pc = -1;
   203 }
   206 void
   207 on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
   208                                         gpointer         user_data)
   209 {
   210     mmr_open_win();
   211 }
   214 gboolean
   215 on_mmr_win_delete_event                (GtkWidget       *widget,
   216                                         GdkEvent        *event,
   217                                         gpointer         user_data)
   218 {
   219     mmr_close_win();
   220     return TRUE;
   221 }
   224 void
   225 on_mmr_close_clicked                   (GtkButton       *button,
   226                                         gpointer         user_data)
   227 {
   228     mmr_close_win();
   229 }
   232 void
   233 on_mode_field_changed                  (GtkEditable     *editable,
   234                                         gpointer         user_data)
   235 {
   236     const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
   237     debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
   238     set_disassembly_cpu( data, text );
   239 }
   242 void
   243 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   244                                         gpointer         user_data)
   245 {
   247 }
   250 gboolean
   251 on_page_field_key_press_event          (GtkWidget       *widget,
   252                                         GdkEventKey     *event,
   253                                         gpointer         user_data)
   254 {
   255     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   256 	debug_info_t data = get_debug_info(widget);
   257         const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   258         gchar *endptr;
   259         unsigned int val = strtoul( text, &endptr, 16 );
   260         if( text == endptr ) { /* invalid input */
   261             char buf[10];
   262             sprintf( buf, "%08X", row_to_address(data,0) );
   263             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   264         } else {
   265             set_disassembly_region(data, val);
   266         }
   267     }
   268     return FALSE;
   269 }
   272 void
   273 on_output_list_select_row              (GtkCList        *clist,
   274                                         gint             row,
   275                                         gint             column,
   276                                         GdkEvent        *event,
   277                                         gpointer         user_data)
   278 {
   279     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   280         char *val;
   281         gtk_clist_get_text( clist, row, 2, &val );
   282         if( val[0] != '\0' ) {
   283             int addr = strtoul( val, NULL, 16 );
   284 	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
   285             jump_to_disassembly( data, addr, TRUE );
   286         }
   287     }
   288 }
   291 void
   292 on_jump_pc_btn_clicked                 (GtkButton       *button,
   293                                         gpointer         user_data)
   294 {
   295     debug_info_t data = get_debug_info( GTK_WIDGET(button) );
   296     jump_to_pc( data, TRUE );
   297 }
   300 void
   301 on_button_add_watch_clicked            (GtkButton       *button,
   302                                         gpointer         user_data)
   303 {
   305 }
   308 void
   309 on_button_clear_all_clicked            (GtkButton       *button,
   310                                         gpointer         user_data)
   311 {
   313 }
   316 void
   317 on_button_close_clicked                (GtkButton       *button,
   318                                         gpointer         user_data)
   319 {
   321 }
   324 void
   325 on_view_memory_activate                (GtkMenuItem     *menuitem,
   326                                         gpointer         user_data)
   327 {
   328     dump_window_new();
   329 }
   332 void
   333 on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
   334                                         gpointer         user_data)
   335 {
   336     const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
   337     open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "lxDream Save State (*.dst)", dir );
   338 }
   341 void
   342 on_savestate_button_clicked            (GtkToolButton   *toolbutton,
   343                                         gpointer         user_data)
   344 {
   345     const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
   346     save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "lxDream Save State (*.dst)", dir );
   347 }
.