Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 180:e6dcf9b65658
prev167:71c0cc416a64
next238:6af4cc93b137
author nkeynes
date Sun Jul 02 04:59:00 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change Merge changes made on the MILESTONE1 branch back into head (mostly
release touchups)
view annotate diff log raw
     1 /**
     2  * $Id: callbacks.c,v 1.16 2006-07-02 04:59:00 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 "dreamcast.h"
    31 #include "loader.h"
    33 int selected_pc = -1;
    34 int selected_row = -1;
    36 void
    37 on_new_file1_activate                  (GtkMenuItem     *menuitem,
    38                                         gpointer         user_data)
    39 {
    41 }
    44 void
    45 on_open1_activate                      (GtkMenuItem     *menuitem,
    46                                         gpointer         user_data)
    47 {
    48     const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
    49     open_file_dialog( "Open...", file_load_magic, NULL, NULL, dir );
    50 }
    53 void
    54 on_save1_activate                      (GtkMenuItem     *menuitem,
    55                                         gpointer         user_data)
    56 {
    58 }
    61 void
    62 on_save_as1_activate                   (GtkMenuItem     *menuitem,
    63                                         gpointer         user_data)
    64 {
    66 }
    69 void
    70 on_exit1_activate                      (GtkMenuItem     *menuitem,
    71                                         gpointer         user_data)
    72 {
    73     gtk_main_quit();
    74 }
    77 void
    78 on_preferences1_activate               (GtkMenuItem     *menuitem,
    79                                         gpointer         user_data)
    80 {
    82 }
    85 void
    86 on_about1_activate                     (GtkMenuItem     *menuitem,
    87                                         gpointer         user_data)
    88 {
    89     GtkWidget *about = create_about_win();
    90     gtk_widget_show(about);
    91 }
    94 void
    95 on_load_btn_clicked                    (GtkButton       *button,
    96                                         gpointer         user_data)
    97 {
    98     const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
    99     open_file_dialog( "Open...", gdrom_mount_image, NULL, NULL, dir );
   100 }
   103 void
   104 on_reset_btn_clicked                   (GtkButton       *button,
   105                                         gpointer         user_data)
   106 {
   107     dreamcast_reset();
   108 }
   111 void
   112 on_stop_btn_clicked                    (GtkButton       *button,
   113                                         gpointer         user_data)
   114 {
   115     dreamcast_stop();
   116 }
   119 void
   120 on_step_btn_clicked                    (GtkButton       *button,
   121                                         gpointer         user_data)
   122 {
   123     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   124     debug_win_single_step(data);
   125 }
   128 void
   129 on_run_btn_clicked                     (GtkButton       *button,
   130                                         gpointer         user_data)
   131 {
   132     dreamcast_run();
   133 }
   136 void
   137 on_runto_btn_clicked                   (GtkButton       *button,
   138                                         gpointer         user_data)
   139 {
   140     if( selected_pc == -1 )
   141         WARN( "No address selected, so can't run to it", NULL );
   142     else {
   143 	debug_info_t data = get_debug_info(GTK_WIDGET(button));
   144 	debug_win_set_oneshot_breakpoint( data, selected_row );
   145 	dreamcast_run();
   146     }
   147 }
   150 void
   151 on_break_btn_clicked                   (GtkButton       *button,
   152                                         gpointer         user_data)
   153 {
   154     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   155     debug_win_toggle_breakpoint( data, selected_row );
   156 }
   159 gboolean
   160 on_debug_win_delete_event              (GtkWidget       *widget,
   161                                         GdkEvent        *event,
   162                                         gpointer         user_data)
   163 {
   164     gtk_main_quit();
   165     return FALSE;
   166 }
   169 void
   170 on_disasm_list_select_row              (GtkCList        *clist,
   171                                         gint             row,
   172                                         gint             column,
   173                                         GdkEvent        *event,
   174                                         gpointer         user_data)
   175 {
   176     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   177     selected_pc = row_to_address(data, row);
   178     selected_row = row;
   179 }
   182 void
   183 on_disasm_list_unselect_row            (GtkCList        *clist,
   184                                         gint             row,
   185                                         gint             column,
   186                                         GdkEvent        *event,
   187                                         gpointer         user_data)
   188 {
   189     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   190     int pc = row_to_address(data,row);
   191     if( selected_pc == pc ) selected_pc = -1;
   192 }
   195 void
   196 on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
   197                                         gpointer         user_data)
   198 {
   199     mmr_open_win();
   200 }
   203 gboolean
   204 on_mmr_win_delete_event                (GtkWidget       *widget,
   205                                         GdkEvent        *event,
   206                                         gpointer         user_data)
   207 {
   208     mmr_close_win();
   209     return TRUE;
   210 }
   213 void
   214 on_mmr_close_clicked                   (GtkButton       *button,
   215                                         gpointer         user_data)
   216 {
   217     mmr_close_win();
   218 }
   221 void
   222 on_mode_field_changed                  (GtkEditable     *editable,
   223                                         gpointer         user_data)
   224 {
   225     const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
   226     debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
   227     set_disassembly_cpu( data, text );
   228 }
   231 void
   232 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   233                                         gpointer         user_data)
   234 {
   236 }
   239 gboolean
   240 on_page_field_key_press_event          (GtkWidget       *widget,
   241                                         GdkEventKey     *event,
   242                                         gpointer         user_data)
   243 {
   244     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   245 	debug_info_t data = get_debug_info(widget);
   246         const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   247         gchar *endptr;
   248         unsigned int val = strtoul( text, &endptr, 16 );
   249         if( text == endptr ) { /* invalid input */
   250             char buf[10];
   251             sprintf( buf, "%08X", row_to_address(data,0) );
   252             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   253         } else {
   254             set_disassembly_region(data, val);
   255         }
   256     }
   257     return FALSE;
   258 }
   261 void
   262 on_output_list_select_row              (GtkCList        *clist,
   263                                         gint             row,
   264                                         gint             column,
   265                                         GdkEvent        *event,
   266                                         gpointer         user_data)
   267 {
   268     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   269         char *val;
   270         gtk_clist_get_text( clist, row, 2, &val );
   271         if( val[0] != '\0' ) {
   272             int addr = strtoul( val, NULL, 16 );
   273 	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
   274             jump_to_disassembly( data, addr, TRUE );
   275         }
   276     }
   277 }
   280 void
   281 on_jump_pc_btn_clicked                 (GtkButton       *button,
   282                                         gpointer         user_data)
   283 {
   284     debug_info_t data = get_debug_info( GTK_WIDGET(button) );
   285     jump_to_pc( data, TRUE );
   286 }
   289 void
   290 on_button_add_watch_clicked            (GtkButton       *button,
   291                                         gpointer         user_data)
   292 {
   294 }
   297 void
   298 on_button_clear_all_clicked            (GtkButton       *button,
   299                                         gpointer         user_data)
   300 {
   302 }
   305 void
   306 on_button_close_clicked                (GtkButton       *button,
   307                                         gpointer         user_data)
   308 {
   310 }
   313 void
   314 on_view_memory_activate                (GtkMenuItem     *menuitem,
   315                                         gpointer         user_data)
   316 {
   317     dump_window_new();
   318 }
   321 void
   322 on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
   323                                         gpointer         user_data)
   324 {
   325     const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
   326     open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "lxDream Save State (*.dst)", dir );
   327 }
   330 void
   331 on_savestate_button_clicked            (GtkToolButton   *toolbutton,
   332                                         gpointer         user_data)
   333 {
   334     const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
   335     save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "lxDream Save State (*.dst)", dir );
   336 }
.