Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 296:1aa1c5ba59fd
prev277:fcc1274776cb
author nkeynes
date Tue Jan 16 10:36:19 2007 +0000 (15 years ago)
permissions -rw-r--r--
last change Bug 24: Add basic gui for save scene function
view annotate diff log raw
     1 /**
     2  * $Id: callbacks.c,v 1.19 2007-01-16 10:36:19 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"
    33 #include "pvr2/pvr2.h"
    35 int selected_pc = -1;
    36 int selected_row = -1;
    38 void
    39 on_new_file1_activate                  (GtkMenuItem     *menuitem,
    40                                         gpointer         user_data)
    41 {
    43 }
    46 void
    47 on_open1_activate                      (GtkMenuItem     *menuitem,
    48                                         gpointer         user_data)
    49 {
    50     const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
    51     open_file_dialog( "Open...", file_load_magic, NULL, NULL, dir );
    52 }
    55 void
    56 on_save1_activate                      (GtkMenuItem     *menuitem,
    57                                         gpointer         user_data)
    58 {
    60 }
    63 void
    64 on_save_as1_activate                   (GtkMenuItem     *menuitem,
    65                                         gpointer         user_data)
    66 {
    68 }
    70 void 
    71 on_save_next_scene_activate( GtkMenuItem *menuitem,
    72 			     gpointer user_data) 
    73 {
    74     const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
    75     save_file_dialog( "Save next scene...", pvr2_save_next_scene, "*.dsc", "lxdream scene file (*.dsc)", dir );
    76 }
    78 void
    79 on_exit1_activate                      (GtkMenuItem     *menuitem,
    80                                         gpointer         user_data)
    81 {
    82     gtk_main_quit();
    83 }
    86 void
    87 on_preferences1_activate               (GtkMenuItem     *menuitem,
    88                                         gpointer         user_data)
    89 {
    91 }
    94 void
    95 on_about1_activate                     (GtkMenuItem     *menuitem,
    96                                         gpointer         user_data)
    97 {
    98     GtkWidget *about = create_about_win();
    99     gtk_widget_show(about);
   100 }
   103 void
   104 on_load_btn_clicked                    (GtkButton       *button,
   105                                         gpointer         user_data)
   106 {
   107     const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
   108     open_file_dialog( "Open...", gdrom_mount_image, NULL, NULL, dir );
   109 }
   112 void
   113 on_reset_btn_clicked                   (GtkButton       *button,
   114                                         gpointer         user_data)
   115 {
   116     dreamcast_reset();
   117 }
   120 void
   121 on_stop_btn_clicked                    (GtkButton       *button,
   122                                         gpointer         user_data)
   123 {
   124     dreamcast_stop();
   125 }
   128 void
   129 on_step_btn_clicked                    (GtkButton       *button,
   130                                         gpointer         user_data)
   131 {
   132     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   133     debug_win_single_step(data);
   134 }
   137 void
   138 on_run_btn_clicked                     (GtkButton       *button,
   139                                         gpointer         user_data)
   140 {
   141     dreamcast_run();
   142 }
   145 void
   146 on_runto_btn_clicked                   (GtkButton       *button,
   147                                         gpointer         user_data)
   148 {
   149     if( selected_pc == -1 )
   150         WARN( "No address selected, so can't run to it", NULL );
   151     else {
   152 	debug_info_t data = get_debug_info(GTK_WIDGET(button));
   153 	debug_win_set_oneshot_breakpoint( data, selected_row );
   154 	dreamcast_run();
   155     }
   156 }
   159 void
   160 on_break_btn_clicked                   (GtkButton       *button,
   161                                         gpointer         user_data)
   162 {
   163     debug_info_t data = get_debug_info(GTK_WIDGET(button));
   164     debug_win_toggle_breakpoint( data, selected_row );
   165 }
   167 void on_trace_button_toggled           (GtkToggleButton *button,
   168 					gpointer user_data)
   169 {
   170     struct mmio_region *io_rgn = (struct mmio_region *)user_data;
   171     gboolean isActive = gtk_toggle_button_get_active(button);
   172     if( io_rgn != NULL ) {
   173 	io_rgn->trace_flag = isActive ? 1 : 0;
   174     }
   175 }
   178 gboolean
   179 on_debug_win_delete_event              (GtkWidget       *widget,
   180                                         GdkEvent        *event,
   181                                         gpointer         user_data)
   182 {
   183     dreamcast_shutdown();
   184     gtk_main_quit();
   185     return FALSE;
   186 }
   189 void
   190 on_disasm_list_select_row              (GtkCList        *clist,
   191                                         gint             row,
   192                                         gint             column,
   193                                         GdkEvent        *event,
   194                                         gpointer         user_data)
   195 {
   196     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   197     selected_pc = row_to_address(data, row);
   198     selected_row = row;
   199 }
   202 void
   203 on_disasm_list_unselect_row            (GtkCList        *clist,
   204                                         gint             row,
   205                                         gint             column,
   206                                         GdkEvent        *event,
   207                                         gpointer         user_data)
   208 {
   209     debug_info_t data = get_debug_info(GTK_WIDGET(clist));
   210     int pc = row_to_address(data,row);
   211     if( selected_pc == pc ) selected_pc = -1;
   212 }
   215 void
   216 on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
   217                                         gpointer         user_data)
   218 {
   219     mmr_open_win();
   220 }
   223 gboolean
   224 on_mmr_win_delete_event                (GtkWidget       *widget,
   225                                         GdkEvent        *event,
   226                                         gpointer         user_data)
   227 {
   228     mmr_close_win();
   229     return TRUE;
   230 }
   233 void
   234 on_mmr_close_clicked                   (GtkButton       *button,
   235                                         gpointer         user_data)
   236 {
   237     mmr_close_win();
   238 }
   241 void
   242 on_mode_field_changed                  (GtkEditable     *editable,
   243                                         gpointer         user_data)
   244 {
   245     const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
   246     debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
   247     set_disassembly_cpu( data, text );
   248 }
   251 void
   252 on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
   253                                         gpointer         user_data)
   254 {
   256 }
   259 gboolean
   260 on_page_field_key_press_event          (GtkWidget       *widget,
   261                                         GdkEventKey     *event,
   262                                         gpointer         user_data)
   263 {
   264     if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
   265 	debug_info_t data = get_debug_info(widget);
   266         const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
   267         gchar *endptr;
   268         unsigned int val = strtoul( text, &endptr, 16 );
   269         if( text == endptr ) { /* invalid input */
   270             char buf[10];
   271             sprintf( buf, "%08X", row_to_address(data,0) );
   272             gtk_entry_set_text( GTK_ENTRY(widget), buf );
   273         } else {
   274             set_disassembly_region(data, val);
   275         }
   276     }
   277     return FALSE;
   278 }
   281 void
   282 on_output_list_select_row              (GtkCList        *clist,
   283                                         gint             row,
   284                                         gint             column,
   285                                         GdkEvent        *event,
   286                                         gpointer         user_data)
   287 {
   288     if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
   289         char *val;
   290         gtk_clist_get_text( clist, row, 2, &val );
   291         if( val[0] != '\0' ) {
   292             int addr = strtoul( val, NULL, 16 );
   293 	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
   294             jump_to_disassembly( data, addr, TRUE );
   295         }
   296     }
   297 }
   300 void
   301 on_jump_pc_btn_clicked                 (GtkButton       *button,
   302                                         gpointer         user_data)
   303 {
   304     debug_info_t data = get_debug_info( GTK_WIDGET(button) );
   305     jump_to_pc( data, TRUE );
   306 }
   309 void
   310 on_button_add_watch_clicked            (GtkButton       *button,
   311                                         gpointer         user_data)
   312 {
   314 }
   317 void
   318 on_button_clear_all_clicked            (GtkButton       *button,
   319                                         gpointer         user_data)
   320 {
   322 }
   325 void
   326 on_button_close_clicked                (GtkButton       *button,
   327                                         gpointer         user_data)
   328 {
   330 }
   333 void
   334 on_view_memory_activate                (GtkMenuItem     *menuitem,
   335                                         gpointer         user_data)
   336 {
   337     dump_window_new();
   338 }
   341 void
   342 on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
   343                                         gpointer         user_data)
   344 {
   345     const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
   346     open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "lxDream Save State (*.dst)", dir );
   347 }
   350 void
   351 on_savestate_button_clicked            (GtkToolButton   *toolbutton,
   352                                         gpointer         user_data)
   353 {
   354     const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
   355     save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "lxDream Save State (*.dst)", dir );
   356 }
.