Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 277:fcc1274776cb
prev238:6af4cc93b137
next296:1aa1c5ba59fd
author nkeynes
date Fri Jan 12 10:16:02 2007 +0000 (14 years ago)
permissions -rw-r--r--
last change Add ability to save flash
view annotate diff log raw
     1 /**
     2  * $Id: callbacks.c,v 1.18 2007-01-12 10:16:02 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     dreamcast_shutdown();
   176     gtk_main_quit();
   177     return FALSE;
   178 }
   181 void
   182 on_disasm_list_select_row              (GtkCList        *clist,
   183                                         gint             row,
   184                                         gint             column,
   185                                         GdkEvent        *event,
   186                                         gpointer         user_data)
   187 {
   188     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   189     selected_pc = row_to_address(data, row);
   190     selected_row = row;
   191 }
   194 void
   195 on_disasm_list_unselect_row            (GtkCList        *clist,
   196                                         gint             row,
   197                                         gint             column,
   198                                         GdkEvent        *event,
   199                                         gpointer         user_data)
   200 {
   201     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   202     int pc = row_to_address(data,row);
   203     if( selected_pc == pc ) selected_pc = -1;
   204 }
   207 void
   208 on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
   209                                         gpointer         user_data)
   210 {
   211     mmr_open_win();
   212 }
   215 gboolean
   216 on_mmr_win_delete_event                (GtkWidget       *widget,
   217                                         GdkEvent        *event,
   218                                         gpointer         user_data)
   219 {
   220     mmr_close_win();
   221     return TRUE;
   222 }
   225 void
   226 on_mmr_close_clicked                   (GtkButton       *button,
   227                                         gpointer         user_data)
   228 {
   229     mmr_close_win();
   230 }
   233 void
   234 on_mode_field_changed                  (GtkEditable     *editable,
   235                                         gpointer         user_data)
   236 {
   237     const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
   238     debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
   239     set_disassembly_cpu( data, text );
   240 }
   243 void
   244 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   245                                         gpointer         user_data)
   246 {
   248 }
   251 gboolean
   252 on_page_field_key_press_event          (GtkWidget       *widget,
   253                                         GdkEventKey     *event,
   254                                         gpointer         user_data)
   255 {
   256     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   257 	debug_info_t data = get_debug_info(widget);
   258         const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   259         gchar *endptr;
   260         unsigned int val = strtoul( text, &endptr, 16 );
   261         if( text == endptr ) { /* invalid input */
   262             char buf[10];
   263             sprintf( buf, "%08X", row_to_address(data,0) );
   264             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   265         } else {
   266             set_disassembly_region(data, val);
   267         }
   268     }
   269     return FALSE;
   270 }
   273 void
   274 on_output_list_select_row              (GtkCList        *clist,
   275                                         gint             row,
   276                                         gint             column,
   277                                         GdkEvent        *event,
   278                                         gpointer         user_data)
   279 {
   280     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   281         char *val;
   282         gtk_clist_get_text( clist, row, 2, &val );
   283         if( val[0] != '\0' ) {
   284             int addr = strtoul( val, NULL, 16 );
   285 	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
   286             jump_to_disassembly( data, addr, TRUE );
   287         }
   288     }
   289 }
   292 void
   293 on_jump_pc_btn_clicked                 (GtkButton       *button,
   294                                         gpointer         user_data)
   295 {
   296     debug_info_t data = get_debug_info( GTK_WIDGET(button) );
   297     jump_to_pc( data, TRUE );
   298 }
   301 void
   302 on_button_add_watch_clicked            (GtkButton       *button,
   303                                         gpointer         user_data)
   304 {
   306 }
   309 void
   310 on_button_clear_all_clicked            (GtkButton       *button,
   311                                         gpointer         user_data)
   312 {
   314 }
   317 void
   318 on_button_close_clicked                (GtkButton       *button,
   319                                         gpointer         user_data)
   320 {
   322 }
   325 void
   326 on_view_memory_activate                (GtkMenuItem     *menuitem,
   327                                         gpointer         user_data)
   328 {
   329     dump_window_new();
   330 }
   333 void
   334 on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
   335                                         gpointer         user_data)
   336 {
   337     const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
   338     open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "lxDream Save State (*.dst)", dir );
   339 }
   342 void
   343 on_savestate_button_clicked            (GtkToolButton   *toolbutton,
   344                                         gpointer         user_data)
   345 {
   346     const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
   347     save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "lxDream Save State (*.dst)", dir );
   348 }
.