1
/* Hey EMACS -*- linux-c -*- */
2
/* $Id: dbg_pclog.c 1455 2005-05-31 18:38:03Z roms $ */
4
/* TiEmu - an TI emulator
6
* Copyright (c) 2000-2001, Thomas Corvazier, Romain Lievin
7
* Copyright (c) 2001-2003, Romain Lievin
8
* Copyright (c) 2003, Julien Blache
9
* Copyright (c) 2004, Romain Li�vin
10
* Copyright (c) 2005, Romain Li�vin
12
* This program is free software; you can redistribute it and/or modify
13
* it under the terms of the GNU General Public License as published by
14
* the Free Software Foundation; either version 2 of the License, or
15
* (at your option) any later version.
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* You should have received a copy of the GNU General Public License
23
* along with this program; if not, write to the Free Software
24
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
32
#include <glade/glade.h>
37
#include "ti68k_int.h"
41
static GladeXML *xml = NULL;
42
static GtkWidget *wnd = NULL;
43
static gint already_open = 0;
48
#define CLIST_NVCOLS (1) // 1 visible columns
49
#define CLIST_NCOLS (1) // 1 real columns
51
#define FONT_NAME "courier"
53
static GtkListStore* clist_create(GtkWidget *widget)
55
GtkTreeView *view = GTK_TREE_VIEW(widget);
58
GtkCellRenderer *renderer;
59
GtkTreeSelection *selection;
60
const gchar *text[CLIST_NVCOLS] = { _("Address") };
63
store = gtk_list_store_new(CLIST_NCOLS,
67
model = GTK_TREE_MODEL(store);
69
gtk_tree_view_set_model(view, model);
70
gtk_tree_view_set_headers_visible(view, TRUE);
71
gtk_tree_view_set_rules_hint(view, FALSE);
73
for(i = COL_ADDR; i <= COL_ADDR; i++)
75
renderer = gtk_cell_renderer_text_new();
76
gtk_tree_view_insert_column_with_attributes(view, -1,
82
for (i = 0; i < CLIST_NVCOLS; i++)
84
GtkTreeViewColumn *col;
86
col = gtk_tree_view_get_column(view, i);
87
gtk_tree_view_column_set_resizable(col, TRUE);
90
selection = gtk_tree_view_get_selection(view);
91
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
96
static void clist_populate(GtkListStore *store)
100
for(i = 0; i < bkpts.pclog_size; i++)
106
addr = bkpts.pclog_buf[(bkpts.pclog_ptr + i) % bkpts.pclog_size];
107
str = g_strdup_printf("0x%06x", addr);
109
gtk_list_store_append(store, &iter);
110
gtk_list_store_set(store, &iter,
118
static void clist_refresh(GtkListStore *store)
120
gtk_list_store_clear(store);
121
clist_populate(store);
124
static GtkListStore *store = NULL;
127
Display registers window
129
GtkWidget* dbgpclog_create_window(void)
135
(tilp_paths_build_glade("dbg_pclog-2.glade"), "dbgpclog_window",
138
g_error(_("%s: GUI loading failed !\n"), __FILE__);
139
glade_xml_signal_autoconnect(xml);
141
dbox = glade_xml_get_widget(xml, "dbgpclog_window");
143
gtk_window_set_transient_for(GTK_WINDOW(dbox), GTK_WINDOW(main_wnd));
146
data = glade_xml_get_widget(xml, "treeview1");
147
store = clist_create(data);
148
clist_populate(store);
150
gtk_tree_view_expand_all(GTK_TREE_VIEW(data));
157
GtkWidget* dbgpclog_display_window(void)
160
wnd = dbgpclog_create_window();
163
if(!options3.pclog.minimized)
165
gtk_window_resize(GTK_WINDOW(wnd), options3.pclog.rect.w, options3.pclog.rect.h);
166
gtk_window_move(GTK_WINDOW(wnd), options3.pclog.rect.x, options3.pclog.rect.y);
169
gtk_window_iconify(GTK_WINDOW(wnd));
172
clist_refresh(store);
173
gtk_widget_show(wnd);
178
void dbgpclog_refresh_window(void)
180
if(options3.pclog.visible)
182
clist_refresh(store);
187
on_pclog_button_press_event (GtkWidget *widget,
188
GdkEventButton *event,
191
GtkWidget *list = GTK_WIDGET(widget);
192
GtkTreeView *view = GTK_TREE_VIEW(list);
193
GtkTreeSelection *selection;
198
if(event->type != GDK_2BUTTON_PRESS)
202
selection = gtk_tree_view_get_selection(view);
203
l = gtk_tree_selection_get_selected_rows(selection, &model);
207
GtkTreePath *path = l->data;
208
gchar** row_text = g_malloc0((CLIST_NVCOLS + 1) * sizeof(gchar *));
212
gtk_tree_model_get_iter(model, &iter, path);
213
gtk_tree_model_get(model, &iter, COL_ADDR, &row_text[COL_ADDR], -1);
216
sscanf(row_text[COL_ADDR], "%x", &addr);
217
dbgcode_disasm_at(addr);
219
g_strfreev(row_text);
223
g_list_foreach (l, (GFunc)gtk_tree_path_free, NULL);