Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 26:ad258e3daaa5
prev23:1ec3acd0594d
next27:1ef09a52cd1e
author nkeynes
date Sat Dec 24 08:02:18 2005 +0000 (15 years ago)
permissions -rw-r--r--
last change More structure reorgs/fixes
view annotate diff log raw
     1 /**
     2  * $Id: callbacks.c,v 1.8 2005-12-24 08:02:18 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 "sh4core.h"
    29 #include "asic.h"
    30 #include "dreamcast.h"
    31 #include "loader.h"
    33 int selected_pc = -1;
    35 void
    36 on_new_file1_activate                  (GtkMenuItem     *menuitem,
    37                                         gpointer         user_data)
    38 {
    40 }
    43 void
    44 on_open1_activate                      (GtkMenuItem     *menuitem,
    45                                         gpointer         user_data)
    46 {
    47     open_file_dialog( "Open...", file_load_magic, NULL, NULL );
    48 }
    51 void
    52 on_save1_activate                      (GtkMenuItem     *menuitem,
    53                                         gpointer         user_data)
    54 {
    56 }
    59 void
    60 on_save_as1_activate                   (GtkMenuItem     *menuitem,
    61                                         gpointer         user_data)
    62 {
    64 }
    67 void
    68 on_exit1_activate                      (GtkMenuItem     *menuitem,
    69                                         gpointer         user_data)
    70 {
    71     gtk_main_quit();
    72 }
    75 void
    76 on_preferences1_activate               (GtkMenuItem     *menuitem,
    77                                         gpointer         user_data)
    78 {
    80 }
    83 void
    84 on_about1_activate                     (GtkMenuItem     *menuitem,
    85                                         gpointer         user_data)
    86 {
    87     GtkWidget *about = create_about_win();
    88     gtk_widget_show(about);
    89 }
    92 void
    93 on_load_btn_clicked                    (GtkButton       *button,
    94                                         gpointer         user_data)
    95 {
    96     open_file_dialog( "Open...", file_load_magic, NULL, NULL );
    97 }
   100 void
   101 on_reset_btn_clicked                   (GtkButton       *button,
   102                                         gpointer         user_data)
   103 {
   104     dreamcast_reset();
   105     update_gui();
   106 }
   109 void
   110 on_stop_btn_clicked                    (GtkButton       *button,
   111                                         gpointer         user_data)
   112 {
   113     dreamcast_stop();
   114 }
   117 void
   118 on_step_btn_clicked                    (GtkButton       *button,
   119                                         gpointer         user_data)
   120 {
   121     sh4_execute_instruction();
   122     update_gui();
   123 }
   126 void
   127 on_run_btn_clicked                     (GtkButton       *button,
   128                                         gpointer         user_data)
   129 {
   130     dreamcast_run();
   131 }
   134 void
   135 on_runto_btn_clicked                   (GtkButton       *button,
   136                                         gpointer         user_data)
   137 {
   138     if( selected_pc == -1 )
   139         WARN( "No address selected, so can't run to it", NULL );
   140     else {
   141         INFO( "Running until %08X...", selected_pc );
   142 	sh4_set_breakpoint( selected_pc, BREAK_ONESHOT );
   143 	dreamcast_run();
   144     }
   145 }
   148 void
   149 on_break_btn_clicked                   (GtkButton       *button,
   150                                         gpointer         user_data)
   151 {
   153 }
   156 gboolean
   157 on_debug_win_delete_event              (GtkWidget       *widget,
   158                                         GdkEvent        *event,
   159                                         gpointer         user_data)
   160 {
   161     gtk_main_quit();
   162     return FALSE;
   163 }
   166 void
   167 on_disasm_list_select_row              (GtkCList        *clist,
   168                                         gint             row,
   169                                         gint             column,
   170                                         GdkEvent        *event,
   171                                         gpointer         user_data)
   172 {
   173     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   174     selected_pc = row_to_address(data, row);
   175 }
   178 void
   179 on_disasm_list_unselect_row            (GtkCList        *clist,
   180                                         gint             row,
   181                                         gint             column,
   182                                         GdkEvent        *event,
   183                                         gpointer         user_data)
   184 {
   185     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   186     int pc = row_to_address(data,row);
   187     if( selected_pc == pc ) selected_pc = -1;
   188 }
   191 void
   192 on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
   193                                         gpointer         user_data)
   194 {
   195     mmr_open_win();
   196 }
   199 gboolean
   200 on_mmr_win_delete_event                (GtkWidget       *widget,
   201                                         GdkEvent        *event,
   202                                         gpointer         user_data)
   203 {
   204     mmr_close_win();
   205     return TRUE;
   206 }
   209 void
   210 on_mmr_close_clicked                   (GtkButton       *button,
   211                                         gpointer         user_data)
   212 {
   213     mmr_close_win();
   214 }
   217 void
   218 on_mode_field_changed                  (GtkEditable     *editable,
   219                                         gpointer         user_data)
   220 {
   221     const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
   222     debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
   223     set_disassembly_cpu( data, text );
   224 }
   227 void
   228 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   229                                         gpointer         user_data)
   230 {
   232 }
   235 gboolean
   236 on_page_field_key_press_event          (GtkWidget       *widget,
   237                                         GdkEventKey     *event,
   238                                         gpointer         user_data)
   239 {
   240     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   241 	debug_info_t data = get_debug_info(widget);
   242         const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   243         gchar *endptr;
   244         unsigned int val = strtoul( text, &endptr, 16 );
   245         if( text == endptr ) { /* invalid input */
   246             char buf[10];
   247             sprintf( buf, "%08X", row_to_address(data,0) );
   248             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   249         } else {
   250             set_disassembly_region(data, val);
   251         }
   252     }
   253     return FALSE;
   254 }
   257 void
   258 on_output_list_select_row              (GtkCList        *clist,
   259                                         gint             row,
   260                                         gint             column,
   261                                         GdkEvent        *event,
   262                                         gpointer         user_data)
   263 {
   264     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   265         char *val;
   266         gtk_clist_get_text( clist, row, 1, &val );
   267         if( val[0] != '\0' ) {
   268             int addr = strtoul( val, NULL, 16 );
   269 	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
   270             jump_to_disassembly( data, addr, TRUE );
   271         }
   272     }
   273 }
   276 void
   277 on_jump_pc_btn_clicked                 (GtkButton       *button,
   278                                         gpointer         user_data)
   279 {
   280     debug_info_t data = get_debug_info( GTK_WIDGET(button) );
   281     jump_to_pc( data, TRUE );
   282 }
   285 void
   286 on_button_add_watch_clicked            (GtkButton       *button,
   287                                         gpointer         user_data)
   288 {
   290 }
   293 void
   294 on_button_clear_all_clicked            (GtkButton       *button,
   295                                         gpointer         user_data)
   296 {
   298 }
   301 void
   302 on_button_close_clicked                (GtkButton       *button,
   303                                         gpointer         user_data)
   304 {
   306 }
   309 void
   310 on_view_memory_activate                (GtkMenuItem     *menuitem,
   311                                         gpointer         user_data)
   312 {
   313     dump_window_new();
   314 }
   317 void
   318 on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
   319                                         gpointer         user_data)
   320 {
   321     open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "DreamOn Save State (*.dst)" );
   322 }
   325 void
   326 on_savestate_button_clicked            (GtkToolButton   *toolbutton,
   327                                         gpointer         user_data)
   328 {
   329     save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "DreamOn Save State (*.dst)" );
   330 }
.