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)
file annotate diff log raw
nkeynes@26
     1
/**
nkeynes@180
     2
 * $Id: callbacks.c,v 1.16 2006-07-02 04:59:00 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@139
    28
#include "gdrom/gdrom.h"
nkeynes@43
    29
#include "mem.h"
nkeynes@18
    30
#include "dreamcast.h"
nkeynes@26
    31
#include "loader.h"
nkeynes@1
    32
nkeynes@1
    33
int selected_pc = -1;
nkeynes@43
    34
int selected_row = -1;
nkeynes@1
    35
nkeynes@1
    36
void
nkeynes@1
    37
on_new_file1_activate                  (GtkMenuItem     *menuitem,
nkeynes@1
    38
                                        gpointer         user_data)
nkeynes@1
    39
{
nkeynes@1
    40
nkeynes@1
    41
}
nkeynes@1
    42
nkeynes@1
    43
nkeynes@1
    44
void
nkeynes@1
    45
on_open1_activate                      (GtkMenuItem     *menuitem,
nkeynes@1
    46
                                        gpointer         user_data)
nkeynes@1
    47
{
nkeynes@167
    48
    const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
nkeynes@167
    49
    open_file_dialog( "Open...", file_load_magic, NULL, NULL, dir );
nkeynes@1
    50
}
nkeynes@1
    51
nkeynes@1
    52
nkeynes@1
    53
void
nkeynes@1
    54
on_save1_activate                      (GtkMenuItem     *menuitem,
nkeynes@1
    55
                                        gpointer         user_data)
nkeynes@1
    56
{
nkeynes@1
    57
nkeynes@1
    58
}
nkeynes@1
    59
nkeynes@1
    60
nkeynes@1
    61
void
nkeynes@1
    62
on_save_as1_activate                   (GtkMenuItem     *menuitem,
nkeynes@1
    63
                                        gpointer         user_data)
nkeynes@1
    64
{
nkeynes@1
    65
nkeynes@1
    66
}
nkeynes@1
    67
nkeynes@1
    68
nkeynes@1
    69
void
nkeynes@1
    70
on_exit1_activate                      (GtkMenuItem     *menuitem,
nkeynes@1
    71
                                        gpointer         user_data)
nkeynes@1
    72
{
nkeynes@1
    73
    gtk_main_quit();
nkeynes@1
    74
}
nkeynes@1
    75
nkeynes@1
    76
nkeynes@1
    77
void
nkeynes@1
    78
on_preferences1_activate               (GtkMenuItem     *menuitem,
nkeynes@1
    79
                                        gpointer         user_data)
nkeynes@1
    80
{
nkeynes@1
    81
nkeynes@1
    82
}
nkeynes@1
    83
nkeynes@1
    84
nkeynes@1
    85
void
nkeynes@1
    86
on_about1_activate                     (GtkMenuItem     *menuitem,
nkeynes@1
    87
                                        gpointer         user_data)
nkeynes@1
    88
{
nkeynes@1
    89
    GtkWidget *about = create_about_win();
nkeynes@1
    90
    gtk_widget_show(about);
nkeynes@1
    91
}
nkeynes@1
    92
nkeynes@1
    93
nkeynes@1
    94
void
nkeynes@1
    95
on_load_btn_clicked                    (GtkButton       *button,
nkeynes@1
    96
                                        gpointer         user_data)
nkeynes@1
    97
{
nkeynes@167
    98
    const gchar *dir = dreamcast_get_config_value(CONFIG_DEFAULT_PATH);
nkeynes@167
    99
    open_file_dialog( "Open...", gdrom_mount_image, NULL, NULL, dir );
nkeynes@1
   100
}
nkeynes@1
   101
nkeynes@1
   102
nkeynes@1
   103
void
nkeynes@1
   104
on_reset_btn_clicked                   (GtkButton       *button,
nkeynes@1
   105
                                        gpointer         user_data)
nkeynes@1
   106
{
nkeynes@26
   107
    dreamcast_reset();
nkeynes@1
   108
}
nkeynes@1
   109
nkeynes@1
   110
nkeynes@1
   111
void
nkeynes@1
   112
on_stop_btn_clicked                    (GtkButton       *button,
nkeynes@1
   113
                                        gpointer         user_data)
nkeynes@1
   114
{
nkeynes@26
   115
    dreamcast_stop();
nkeynes@1
   116
}
nkeynes@1
   117
nkeynes@1
   118
nkeynes@1
   119
void
nkeynes@1
   120
on_step_btn_clicked                    (GtkButton       *button,
nkeynes@1
   121
                                        gpointer         user_data)
nkeynes@1
   122
{
nkeynes@30
   123
    debug_info_t data = get_debug_info(GTK_WIDGET(button));
nkeynes@30
   124
    debug_win_single_step(data);
nkeynes@1
   125
}
nkeynes@1
   126
nkeynes@1
   127
nkeynes@1
   128
void
nkeynes@1
   129
on_run_btn_clicked                     (GtkButton       *button,
nkeynes@1
   130
                                        gpointer         user_data)
nkeynes@1
   131
{
nkeynes@23
   132
    dreamcast_run();
nkeynes@1
   133
}
nkeynes@1
   134
nkeynes@1
   135
nkeynes@1
   136
void
nkeynes@1
   137
on_runto_btn_clicked                   (GtkButton       *button,
nkeynes@1
   138
                                        gpointer         user_data)
nkeynes@1
   139
{
nkeynes@1
   140
    if( selected_pc == -1 )
nkeynes@1
   141
        WARN( "No address selected, so can't run to it", NULL );
nkeynes@1
   142
    else {
nkeynes@45
   143
	debug_info_t data = get_debug_info(GTK_WIDGET(button));
nkeynes@45
   144
	debug_win_set_oneshot_breakpoint( data, selected_row );
nkeynes@23
   145
	dreamcast_run();
nkeynes@1
   146
    }
nkeynes@1
   147
}
nkeynes@1
   148
nkeynes@1
   149
nkeynes@1
   150
void
nkeynes@1
   151
on_break_btn_clicked                   (GtkButton       *button,
nkeynes@1
   152
                                        gpointer         user_data)
nkeynes@1
   153
{
nkeynes@43
   154
    debug_info_t data = get_debug_info(GTK_WIDGET(button));
nkeynes@45
   155
    debug_win_toggle_breakpoint( data, selected_row );
nkeynes@1
   156
}
nkeynes@1
   157
nkeynes@1
   158
nkeynes@1
   159
gboolean
nkeynes@1
   160
on_debug_win_delete_event              (GtkWidget       *widget,
nkeynes@1
   161
                                        GdkEvent        *event,
nkeynes@1
   162
                                        gpointer         user_data)
nkeynes@1
   163
{
nkeynes@1
   164
    gtk_main_quit();
nkeynes@26
   165
    return FALSE;
nkeynes@1
   166
}
nkeynes@1
   167
nkeynes@1
   168
nkeynes@1
   169
void
nkeynes@1
   170
on_disasm_list_select_row              (GtkCList        *clist,
nkeynes@1
   171
                                        gint             row,
nkeynes@1
   172
                                        gint             column,
nkeynes@1
   173
                                        GdkEvent        *event,
nkeynes@1
   174
                                        gpointer         user_data)
nkeynes@1
   175
{
nkeynes@9
   176
    debug_info_t data = get_debug_info(GTK_WIDGET(clist));
nkeynes@9
   177
    selected_pc = row_to_address(data, row);
nkeynes@43
   178
    selected_row = row;
nkeynes@1
   179
}
nkeynes@1
   180
nkeynes@1
   181
nkeynes@1
   182
void
nkeynes@1
   183
on_disasm_list_unselect_row            (GtkCList        *clist,
nkeynes@1
   184
                                        gint             row,
nkeynes@1
   185
                                        gint             column,
nkeynes@1
   186
                                        GdkEvent        *event,
nkeynes@1
   187
                                        gpointer         user_data)
nkeynes@1
   188
{
nkeynes@9
   189
    debug_info_t data = get_debug_info(GTK_WIDGET(clist));
nkeynes@9
   190
    int pc = row_to_address(data,row);
nkeynes@1
   191
    if( selected_pc == pc ) selected_pc = -1;
nkeynes@1
   192
}
nkeynes@1
   193
nkeynes@1
   194
nkeynes@1
   195
void
nkeynes@1
   196
on_mem_mapped_regs1_activate           (GtkMenuItem     *menuitem,
nkeynes@1
   197
                                        gpointer         user_data)
nkeynes@1
   198
{
nkeynes@1
   199
    mmr_open_win();
nkeynes@1
   200
}
nkeynes@1
   201
nkeynes@1
   202
nkeynes@1
   203
gboolean
nkeynes@1
   204
on_mmr_win_delete_event                (GtkWidget       *widget,
nkeynes@1
   205
                                        GdkEvent        *event,
nkeynes@1
   206
                                        gpointer         user_data)
nkeynes@1
   207
{
nkeynes@1
   208
    mmr_close_win();
nkeynes@1
   209
    return TRUE;
nkeynes@1
   210
}
nkeynes@1
   211
nkeynes@1
   212
nkeynes@1
   213
void
nkeynes@1
   214
on_mmr_close_clicked                   (GtkButton       *button,
nkeynes@1
   215
                                        gpointer         user_data)
nkeynes@1
   216
{
nkeynes@1
   217
    mmr_close_win();
nkeynes@1
   218
}
nkeynes@1
   219
nkeynes@1
   220
nkeynes@1
   221
void
nkeynes@1
   222
on_mode_field_changed                  (GtkEditable     *editable,
nkeynes@1
   223
                                        gpointer         user_data)
nkeynes@1
   224
{
nkeynes@18
   225
    const gchar *text = gtk_entry_get_text( GTK_ENTRY(editable) );
nkeynes@10
   226
    debug_info_t data = get_debug_info( GTK_WIDGET(editable) );
nkeynes@10
   227
    set_disassembly_cpu( data, text );
nkeynes@1
   228
}
nkeynes@1
   229
nkeynes@1
   230
nkeynes@1
   231
void
nkeynes@1
   232
on_page_locked_btn_toggled             (GtkToggleButton *togglebutton,
nkeynes@1
   233
                                        gpointer         user_data)
nkeynes@1
   234
{
nkeynes@1
   235
nkeynes@1
   236
}
nkeynes@1
   237
nkeynes@1
   238
nkeynes@1
   239
gboolean
nkeynes@1
   240
on_page_field_key_press_event          (GtkWidget       *widget,
nkeynes@1
   241
                                        GdkEventKey     *event,
nkeynes@1
   242
                                        gpointer         user_data)
nkeynes@1
   243
{
nkeynes@1
   244
    if( event->keyval == GDK_Return || event->keyval == GDK_Linefeed ) {
nkeynes@9
   245
	debug_info_t data = get_debug_info(widget);
nkeynes@18
   246
        const gchar *text = gtk_entry_get_text( GTK_ENTRY(widget) );
nkeynes@1
   247
        gchar *endptr;
nkeynes@1
   248
        unsigned int val = strtoul( text, &endptr, 16 );
nkeynes@1
   249
        if( text == endptr ) { /* invalid input */
nkeynes@1
   250
            char buf[10];
nkeynes@9
   251
            sprintf( buf, "%08X", row_to_address(data,0) );
nkeynes@1
   252
            gtk_entry_set_text( GTK_ENTRY(widget), buf );
nkeynes@1
   253
        } else {
nkeynes@9
   254
            set_disassembly_region(data, val);
nkeynes@1
   255
        }
nkeynes@1
   256
    }
nkeynes@1
   257
    return FALSE;
nkeynes@1
   258
}
nkeynes@1
   259
nkeynes@1
   260
nkeynes@1
   261
void
nkeynes@1
   262
on_output_list_select_row              (GtkCList        *clist,
nkeynes@1
   263
                                        gint             row,
nkeynes@1
   264
                                        gint             column,
nkeynes@1
   265
                                        GdkEvent        *event,
nkeynes@1
   266
                                        gpointer         user_data)
nkeynes@1
   267
{
nkeynes@1
   268
    if( event->type == GDK_2BUTTON_PRESS && event->button.button == 1 ) {
nkeynes@1
   269
        char *val;
nkeynes@45
   270
        gtk_clist_get_text( clist, row, 2, &val );
nkeynes@1
   271
        if( val[0] != '\0' ) {
nkeynes@1
   272
            int addr = strtoul( val, NULL, 16 );
nkeynes@9
   273
	    debug_info_t data = get_debug_info( GTK_WIDGET(clist) );
nkeynes@9
   274
            jump_to_disassembly( data, addr, TRUE );
nkeynes@1
   275
        }
nkeynes@1
   276
    }
nkeynes@1
   277
}
nkeynes@1
   278
nkeynes@1
   279
nkeynes@1
   280
void
nkeynes@1
   281
on_jump_pc_btn_clicked                 (GtkButton       *button,
nkeynes@1
   282
                                        gpointer         user_data)
nkeynes@1
   283
{
nkeynes@9
   284
    debug_info_t data = get_debug_info( GTK_WIDGET(button) );
nkeynes@9
   285
    jump_to_pc( data, TRUE );
nkeynes@1
   286
}
nkeynes@1
   287
nkeynes@2
   288
nkeynes@2
   289
void
nkeynes@2
   290
on_button_add_watch_clicked            (GtkButton       *button,
nkeynes@2
   291
                                        gpointer         user_data)
nkeynes@2
   292
{
nkeynes@2
   293
nkeynes@2
   294
}
nkeynes@2
   295
nkeynes@2
   296
nkeynes@2
   297
void
nkeynes@2
   298
on_button_clear_all_clicked            (GtkButton       *button,
nkeynes@2
   299
                                        gpointer         user_data)
nkeynes@2
   300
{
nkeynes@2
   301
nkeynes@2
   302
}
nkeynes@2
   303
nkeynes@2
   304
nkeynes@2
   305
void
nkeynes@2
   306
on_button_close_clicked                (GtkButton       *button,
nkeynes@2
   307
                                        gpointer         user_data)
nkeynes@2
   308
{
nkeynes@2
   309
nkeynes@2
   310
}
nkeynes@2
   311
nkeynes@2
   312
nkeynes@2
   313
void
nkeynes@2
   314
on_view_memory_activate                (GtkMenuItem     *menuitem,
nkeynes@2
   315
                                        gpointer         user_data)
nkeynes@2
   316
{
nkeynes@2
   317
    dump_window_new();
nkeynes@2
   318
}
nkeynes@2
   319
nkeynes@18
   320
nkeynes@18
   321
void
nkeynes@18
   322
on_loadstate_button_clicked            (GtkToolButton   *toolbutton,
nkeynes@18
   323
                                        gpointer         user_data)
nkeynes@18
   324
{
nkeynes@167
   325
    const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
nkeynes@180
   326
    open_file_dialog( "Load state...", dreamcast_load_state, "*.dst", "lxDream Save State (*.dst)", dir );
nkeynes@18
   327
}
nkeynes@18
   328
nkeynes@18
   329
nkeynes@18
   330
void
nkeynes@18
   331
on_savestate_button_clicked            (GtkToolButton   *toolbutton,
nkeynes@18
   332
                                        gpointer         user_data)
nkeynes@18
   333
{
nkeynes@167
   334
    const gchar *dir = dreamcast_get_config_value(CONFIG_SAVE_PATH);
nkeynes@180
   335
    save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", "lxDream Save State (*.dst)", dir );
nkeynes@18
   336
}
nkeynes@18
   337
.