Search
lxdream.org :: lxdream/src/gui/callbacks.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/callbacks.c
changeset 27:1ef09a52cd1e
prev26:ad258e3daaa5
next30:89b30313d757
author nkeynes
date Sun Dec 25 01:28:39 2005 +0000 (15 years ago)
permissions -rw-r--r--
last change Refactor all the GUI bits out of the main directory (except for a couple
lingering temporarily in loader.c
Fix a few timeslice issues
file annotate diff log raw
nkeynes@26
     1
/**
nkeynes@27
     2
 * $Id: callbacks.c,v 1.9 2005-12-25 01:28:39 nkeynes Exp $
nkeynes@26
     3
 *
nkeynes@26
     4
 * All GTK callbacks go here (stubs are autogenerated by Glade)
nkeynes@26
     5
 *
nkeynes@26
     6
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@26
     7
 *
nkeynes@26
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@26
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@26
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@26
    11
 * (at your option) any later version.
nkeynes@26
    12
 *
nkeynes@26
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@26
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@26
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@26
    16
 * GNU General Public License for more details.
nkeynes@26
    17
 */
nkeynes@26
    18
nkeynes@1
    19
#ifdef HAVE_CONFIG_H
nkeynes@1
    20
#  include <config.h>
nkeynes@1
    21
#endif
nkeynes@1
    22
nkeynes@1
    23
#include <gnome.h>
nkeynes@1
    24
nkeynes@26
    25
#include "gui/callbacks.h"
nkeynes@26
    26
#include "gui/interface.h"
nkeynes@26
    27
#include "gui/gui.h"
nkeynes@1
    28
#include "sh4core.h"
nkeynes@1
    29
#include "asic.h"
nkeynes@18
    30
#include "dreamcast.h"
nkeynes@26
    31
#include "loader.h"
nkeynes@1
    32
nkeynes@1
    33
int selected_pc = -1;
nkeynes@1
    34
nkeynes@1
    35
void
nkeynes@1
    36
on_new_file1_activate                  (GtkMenuItem     *menuitem,
nkeynes@1
    37
                                        gpointer         user_data)
nkeynes@1
    38
{
nkeynes@1
    39
nkeynes@1
    40
}
nkeynes@1
    41
nkeynes@1
    42
nkeynes@1
    43
void
nkeynes@1
    44
on_open1_activate                      (GtkMenuItem     *menuitem,
nkeynes@1
    45
                                        gpointer         user_data)
nkeynes@1
    46
{
nkeynes@26
    47
    open_file_dialog( "Open...", file_load_magic, NULL, NULL );
nkeynes@1
    48
}
nkeynes@1
    49
nkeynes@1
    50
nkeynes@1
    51
void
nkeynes@1
    52
on_save1_activate                      (GtkMenuItem     *menuitem,
nkeynes@1
    53
                                        gpointer         user_data)
nkeynes@1
    54
{
nkeynes@1
    55
nkeynes@1
    56
}
nkeynes@1
    57
nkeynes@1
    58
nkeynes@1
    59
void
nkeynes@1
    60
on_save_as1_activate                   (GtkMenuItem     *menuitem,
nkeynes@1
    61
                                        gpointer         user_data)
nkeynes@1
    62
{
nkeynes@1
    63
nkeynes@1
    64
}
nkeynes@1
    65
nkeynes@1
    66
nkeynes@1
    67
void
nkeynes@1
    68
on_exit1_activate                      (GtkMenuItem     *menuitem,
nkeynes@1
    69
                                        gpointer         user_data)
nkeynes@1
    70
{
nkeynes@1
    71
    gtk_main_quit();
nkeynes@1
    72
}
nkeynes@1
    73
nkeynes@1
    74
nkeynes@1
    75
void
nkeynes@1
    76
on_preferences1_activate               (GtkMenuItem     *menuitem,
nkeynes@1
    77
                                        gpointer         user_data)
nkeynes@1
    78
{
nkeynes@1
    79
nkeynes@1
    80
}
nkeynes@1
    81
nkeynes@1
    82
nkeynes@1
    83
void
nkeynes@1
    84
on_about1_activate                     (GtkMenuItem     *menuitem,
nkeynes@1
    85
                                        gpointer         user_data)
nkeynes@1
    86
{
nkeynes@1
    87
    GtkWidget *about = create_about_win();
nkeynes@1
    88
    gtk_widget_show(about);
nkeynes@1
    89
}
nkeynes@1
    90
nkeynes@1
    91
nkeynes@1
    92
void
nkeynes@1
    93
on_load_btn_clicked                    (GtkButton       *button,
nkeynes@1
    94
                                        gpointer         user_data)
nkeynes@1
    95
{
nkeynes@26
    96
    open_file_dialog( "Open...", file_load_magic, NULL, NULL );
nkeynes@1
    97
}
nkeynes@1
    98
nkeynes@1
    99
nkeynes@1
   100
void
nkeynes@1
   101
on_reset_btn_clicked                   (GtkButton       *button,
nkeynes@1
   102
                                        gpointer         user_data)
nkeynes@1
   103
{
nkeynes@26
   104
    dreamcast_reset();
nkeynes@1
   105
}
nkeynes@1
   106
nkeynes@1
   107
nkeynes@1
   108
void
nkeynes@1
   109
on_stop_btn_clicked                    (GtkButton       *button,
nkeynes@1
   110
                                        gpointer         user_data)
nkeynes@1
   111
{
nkeynes@26
   112
    dreamcast_stop();
nkeynes@1
   113
}
nkeynes@1
   114
nkeynes@1
   115
nkeynes@1
   116
void
nkeynes@1
   117
on_step_btn_clicked                    (GtkButton       *button,
nkeynes@1
   118
                                        gpointer         user_data)
nkeynes@1
   119
{
nkeynes@1
   120
    sh4_execute_instruction();
nkeynes@27
   121
    gtk_gui_update();
nkeynes@1
   122
}
nkeynes@1
   123
nkeynes@1
   124
nkeynes@1
   125
void
nkeynes@1
   126
on_run_btn_clicked                     (GtkButton       *button,
nkeynes@1
   127
                                        gpointer         user_data)
nkeynes@1
   128
{
nkeynes@23
   129
    dreamcast_run();
nkeynes@1
   130
}
nkeynes@1
   131
nkeynes@1
   132
nkeynes@1
   133
void
nkeynes@1
   134
on_runto_btn_clicked                   (GtkButton       *button,
nkeynes@1
   135
                                        gpointer         user_data)
nkeynes@1
   136
{
nkeynes@1
   137
    if( selected_pc == -1 )
nkeynes@1
   138
        WARN( "No address selected, so can't run to it", NULL );
nkeynes@1
   139
    else {
nkeynes@1
   140
        INFO( "Running until %08X...", selected_pc );
nkeynes@23
   141
	sh4_set_breakpoint( selected_pc, BREAK_ONESHOT );
nkeynes@23
   142
	dreamcast_run();
nkeynes@1
   143
    }
nkeynes@1
   144
}
nkeynes@1
   145
nkeynes@1
   146
nkeynes@1
   147
void
nkeynes@1
   148
on_break_btn_clicked                   (GtkButton       *button,
nkeynes@1
   149
                                        gpointer         user_data)
nkeynes@1
   150
{
nkeynes@1
   151
nkeynes@1
   152
}
nkeynes@1
   153
nkeynes@1
   154
nkeynes@1
   155
gboolean
nkeynes@1
   156
on_debug_win_delete_event              (GtkWidget       *widget,
nkeynes@1
   157
                                        GdkEvent        *event,
nkeynes@1
   158
                                        gpointer         user_data)
nkeynes@1
   159
{
nkeynes@1
   160
    gtk_main_quit();
nkeynes@26
   161
    return FALSE;
nkeynes@1
   162
}
nkeynes@1
   163
nkeynes@1
   164
nkeynes@1
   165
void
nkeynes@1
   166
on_disasm_list_select_row              (GtkCList        *clist,
nkeynes@1
   167
                                        gint             row,
nkeynes@1
   168
                                        gint             column,
nkeynes@1
   169
                                        GdkEvent        *event,
nkeynes@1
   170
                                        gpointer         user_data)
nkeynes@1
   171
{
nkeynes@9
   172
    debug_info_t data = get_debug_info(GTK_WIDGET(clist));
nkeynes@9
   173
    selected_pc = row_to_address(data, row);
nkeynes@1
   174
}
nkeynes@1
   175
nkeynes@1
   176
nkeynes@1
   177
void
nkeynes@1
   178
on_disasm_list_unselect_row            (GtkCList        *clist,
nkeynes@1
   179
                                        gint             row,
nkeynes@1
   180
                                        gint             column,
nkeynes@1
   181
                                        GdkEvent        *event,
nkeynes@1
   182
                                        gpointer         user_data)
nkeynes@1
   183
{
nkeynes@9
   184
    debug_info_t data = get_debug_info(GTK_WIDGET(clist));
nkeynes@9
   185
    int pc = row_to_address(data,row);
nkeynes@1
   186
    if( selected_pc == pc ) selected_pc = -1;
nkeynes@1
   187
}
nkeynes@1
   188
nkeynes@1
   189
nkeynes@1
   190
void
nkeynes@1
   191
on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
nkeynes@1
   192
                                        gpointer         user_data)
nkeynes@1
   193
{
nkeynes@1
   194
    mmr_open_win();
nkeynes@1
   195
}
nkeynes@1
   196
nkeynes@1
   197
nkeynes@1
   198
gboolean
nkeynes@1
   199
on_mmr_win_delete_event                (GtkWidget       *widget,
nkeynes@1
   200
                                        GdkEvent        *event,
nkeynes@1
   201
                                        gpointer         user_data)
nkeynes@1
   202
{
nkeynes@1
   203
    mmr_close_win();
nkeynes@1
   204
    return TRUE;
nkeynes@1
   205
}
nkeynes@1
   206
nkeynes@1
   207
nkeynes@1
   208
void
nkeynes@1
   209
on_mmr_close_clicked                   (GtkButton       *button,
nkeynes@1
   210
                                        gpointer         user_data)
nkeynes@1
   211
{
nkeynes@1
   212
    mmr_close_win();
nkeynes@1
   213
}
nkeynes@1
   214
nkeynes@1
   215
nkeynes@1
   216
void
nkeynes@1
   217
on_mode_field_changed                  (GtkEditable     *editable,
nkeynes@1
   218
                                        gpointer         user_data)
nkeynes@1
   219
{
nkeynes@18
   220
    const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
nkeynes@10
   221
    debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
nkeynes@10
   222
    set_disassembly_cpu( data, text );
nkeynes@1
   223
}
nkeynes@1
   224
nkeynes@1
   225
nkeynes@1
   226
void
nkeynes@1
   227
on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
nkeynes@1
   228
                                        gpointer         user_data)
nkeynes@1
   229
{
nkeynes@1
   230
nkeynes@1
   231
}
nkeynes@1
   232
nkeynes@1
   233
nkeynes@1
   234
gboolean
nkeynes@1
   235
on_page_field_key_press_event          (GtkWidget       *widget,
nkeynes@1
   236
                                        GdkEventKey     *event,
nkeynes@1
   237
                                        gpointer         user_data)
nkeynes@1
   238
{
nkeynes@1
   239
    if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
nkeynes@9
   240
	debug_info_t data = get_debug_info(widget);
nkeynes@18
   241
        const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
nkeynes@1
   242
        gchar *endptr;
nkeynes@1
   243
        unsigned int val = strtoul( text, &endptr, 16 );
nkeynes@1
   244
        if( text == endptr ) { /* invalid input */
nkeynes@1
   245
            char buf[10];
nkeynes@9
   246
            sprintf( buf, "%08X", row_to_address(data,0) );
nkeynes@1
   247
            gtk_entry_set_text( GTK_ENTRY(widget), buf );
nkeynes@1
   248
        } else {
nkeynes@9
   249
            set_disassembly_region(data, val);
nkeynes@1
   250
        }
nkeynes@1
   251
    }
nkeynes@1
   252
    return FALSE;
nkeynes@1
   253
}
nkeynes@1
   254
nkeynes@1
   255
nkeynes@1
   256
void
nkeynes@1
   257
on_output_list_select_row              (GtkCList        *clist,
nkeynes@1
   258
                                        gint             row,
nkeynes@1
   259
                                        gint             column,
nkeynes@1
   260
                                        GdkEvent        *event,
nkeynes@1
   261
                                        gpointer         user_data)
nkeynes@1
   262
{
nkeynes@1
   263
    if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
nkeynes@1
   264
        char *val;
nkeynes@1
   265
        gtk_clist_get_text( clist, row, 1, &val );
nkeynes@1
   266
        if( val[0] != '\0' ) {
nkeynes@1
   267
            int addr = strtoul( val, NULL, 16 );
nkeynes@9
   268
	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
nkeynes@9
   269
            jump_to_disassembly( data, addr, TRUE );
nkeynes@1
   270
        }
nkeynes@1
   271
    }
nkeynes@1
   272
}
nkeynes@1
   273
nkeynes@1
   274
nkeynes@1
   275
void
nkeynes@1
   276
on_jump_pc_btn_clicked                 (GtkButton       *button,
nkeynes@1
   277
                                        gpointer         user_data)
nkeynes@1
   278
{
nkeynes@9
   279
    debug_info_t data = get_debug_info( GTK_WIDGET(button) );
nkeynes@9
   280
    jump_to_pc( data, TRUE );
nkeynes@1
   281
}
nkeynes@1
   282
nkeynes@2
   283
nkeynes@2
   284
void
nkeynes@2
   285
on_button_add_watch_clicked            (GtkButton       *button,
nkeynes@2
   286
                                        gpointer         user_data)
nkeynes@2
   287
{
nkeynes@2
   288
nkeynes@2
   289
}
nkeynes@2
   290
nkeynes@2
   291
nkeynes@2
   292
void
nkeynes@2
   293
on_button_clear_all_clicked            (GtkButton       *button,
nkeynes@2
   294
                                        gpointer         user_data)
nkeynes@2
   295
{
nkeynes@2
   296
nkeynes@2
   297
}
nkeynes@2
   298
nkeynes@2
   299
nkeynes@2
   300
void
nkeynes@2
   301
on_button_close_clicked                (GtkButton       *button,
nkeynes@2
   302
                                        gpointer         user_data)
nkeynes@2
   303
{
nkeynes@2
   304
nkeynes@2
   305
}
nkeynes@2
   306
nkeynes@2
   307
nkeynes@2
   308
void
nkeynes@2
   309
on_view_memory_activate                (GtkMenuItem     *menuitem,
nkeynes@2
   310
                                        gpointer         user_data)
nkeynes@2
   311
{
nkeynes@2
   312
    dump_window_new();
nkeynes@2
   313
}
nkeynes@2
   314
nkeynes@18
   315
nkeynes@18
   316
void
nkeynes@18
   317
on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
nkeynes@18
   318
                                        gpointer         user_data)
nkeynes@18
   319
{
nkeynes@18
   320
    open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "DreamOn Save State (*.dst)" );
nkeynes@18
   321
}
nkeynes@18
   322
nkeynes@18
   323
nkeynes@18
   324
void
nkeynes@18
   325
on_savestate_button_clicked            (GtkToolButton   *toolbutton,
nkeynes@18
   326
                                        gpointer         user_data)
nkeynes@18
   327
{
nkeynes@18
   328
    save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "DreamOn Save State (*.dst)" );
nkeynes@18
   329
}
nkeynes@18
   330
.