Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 55:96323c198da3
prev45:f99236f0632e
next139:128f569e004e
author nkeynes
date Sun Jan 01 08:09:17 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change Remove sh4core.h reference
view annotate diff log raw
     1 /**
     2  * $Id: callbacks.c,v 1.13 2006-01-01 08:08:55 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 "mem.h"
    29 #include "dreamcast.h"
    30 #include "loader.h"
    32 int selected_pc = -1;
    33 int selected_row = -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 }
   108 void
   109 on_stop_btn_clicked                    (GtkButton       *button,
   110                                         gpointer         user_data)
   111 {
   112     dreamcast_stop();
   113 }
   116 void
   117 on_step_btn_clicked                    (GtkButton       *button,
   118                                         gpointer         user_data)
   119 {
   120     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   121     debug_win_single_step(data);
   122 }
   125 void
   126 on_run_btn_clicked                     (GtkButton       *button,
   127                                         gpointer         user_data)
   128 {
   129     dreamcast_run();
   130 }
   133 void
   134 on_runto_btn_clicked                   (GtkButton       *button,
   135                                         gpointer         user_data)
   136 {
   137     if( selected_pc == -1 )
   138         WARN( "No address selected, so can't run to it", NULL );
   139     else {
   140 	debug_info_t data = get_debug_info(GTK_WIDGET(button));
   141 	debug_win_set_oneshot_breakpoint( data, selected_row );
   142 	dreamcast_run();
   143     }
   144 }
   147 void
   148 on_break_btn_clicked                   (GtkButton       *button,
   149                                         gpointer         user_data)
   150 {
   151     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   152     debug_win_toggle_breakpoint( data, selected_row );
   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     selected_row = row;
   176 }
   179 void
   180 on_disasm_list_unselect_row            (GtkCList        *clist,
   181                                         gint             row,
   182                                         gint             column,
   183                                         GdkEvent        *event,
   184                                         gpointer         user_data)
   185 {
   186     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   187     int pc = row_to_address(data,row);
   188     if( selected_pc == pc ) selected_pc = -1;
   189 }
   192 void
   193 on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
   194                                         gpointer         user_data)
   195 {
   196     mmr_open_win();
   197 }
   200 gboolean
   201 on_mmr_win_delete_event                (GtkWidget       *widget,
   202                                         GdkEvent        *event,
   203                                         gpointer         user_data)
   204 {
   205     mmr_close_win();
   206     return TRUE;
   207 }
   210 void
   211 on_mmr_close_clicked                   (GtkButton       *button,
   212                                         gpointer         user_data)
   213 {
   214     mmr_close_win();
   215 }
   218 void
   219 on_mode_field_changed                  (GtkEditable     *editable,
   220                                         gpointer         user_data)
   221 {
   222     const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
   223     debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
   224     set_disassembly_cpu( data, text );
   225 }
   228 void
   229 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   230                                         gpointer         user_data)
   231 {
   233 }
   236 gboolean
   237 on_page_field_key_press_event          (GtkWidget       *widget,
   238                                         GdkEventKey     *event,
   239                                         gpointer         user_data)
   240 {
   241     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   242 	debug_info_t data = get_debug_info(widget);
   243         const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   244         gchar *endptr;
   245         unsigned int val = strtoul( text, &endptr, 16 );
   246         if( text == endptr ) { /* invalid input */
   247             char buf[10];
   248             sprintf( buf, "%08X", row_to_address(data,0) );
   249             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   250         } else {
   251             set_disassembly_region(data, val);
   252         }
   253     }
   254     return FALSE;
   255 }
   258 void
   259 on_output_list_select_row              (GtkCList        *clist,
   260                                         gint             row,
   261                                         gint             column,
   262                                         GdkEvent        *event,
   263                                         gpointer         user_data)
   264 {
   265     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   266         char *val;
   267         gtk_clist_get_text( clist, row, 2, &val );
   268         if( val[0] != '\0' ) {
   269             int addr = strtoul( val, NULL, 16 );
   270 	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
   271             jump_to_disassembly( data, addr, TRUE );
   272         }
   273     }
   274 }
   277 void
   278 on_jump_pc_btn_clicked                 (GtkButton       *button,
   279                                         gpointer         user_data)
   280 {
   281     debug_info_t data = get_debug_info( GTK_WIDGET(button) );
   282     jump_to_pc( data, TRUE );
   283 }
   286 void
   287 on_button_add_watch_clicked            (GtkButton       *button,
   288                                         gpointer         user_data)
   289 {
   291 }
   294 void
   295 on_button_clear_all_clicked            (GtkButton       *button,
   296                                         gpointer         user_data)
   297 {
   299 }
   302 void
   303 on_button_close_clicked                (GtkButton       *button,
   304                                         gpointer         user_data)
   305 {
   307 }
   310 void
   311 on_view_memory_activate                (GtkMenuItem     *menuitem,
   312                                         gpointer         user_data)
   313 {
   314     dump_window_new();
   315 }
   318 void
   319 on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
   320                                         gpointer         user_data)
   321 {
   322     open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "DreamOn Save State (*.dst)" );
   323 }
   326 void
   327 on_savestate_button_clicked            (GtkToolButton   *toolbutton,
   328                                         gpointer         user_data)
   329 {
   330     save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "DreamOn Save State (*.dst)" );
   331 }
.