Search
lxdream.org :: lxdream/src/gui/dump_win.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/dump_win.c
changeset 457:af605fd32c0b
prev455:3080881d00d4
next484:e2c1476f4c67
author nkeynes
date Sun Oct 21 11:38:02 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Finish updating debug gui window bits
file annotate diff log raw
1.1 --- a/src/gui/dump_win.c Sun Oct 21 05:21:35 2007 +0000
1.2 +++ b/src/gui/dump_win.c Sun Oct 21 11:38:02 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: dump_win.c,v 1.5 2007-10-21 05:21:35 nkeynes Exp $
1.6 + * $Id: dump_win.c,v 1.6 2007-10-21 11:38:02 nkeynes Exp $
1.7 *
1.8 * Implements the memory dump window.
1.9 *
1.10 @@ -21,67 +21,99 @@
1.11 #include <assert.h>
1.12 #include "mem.h"
1.13 #include "gui/gtkui.h"
1.14 -#include "gui/debugif.h"
1.15
1.16 #define MAX_DUMP_SIZE 4096
1.17
1.18 -#define DUMP_DATA_TAG 0xD4B9DA7A
1.19 +#define DUMP_WINDOW_TAG 0xD4B9DA7A
1.20
1.21 -typedef struct dump_data {
1.22 +struct dump_window_info {
1.23 uint32_t _tag;
1.24 uint32_t start;
1.25 uint32_t end;
1.26 int flags;
1.27 unsigned char *data;
1.28
1.29 - GtkEntry *fromInput, *toInput;
1.30 - GtkTextView *textArea;
1.31 + GtkWidget *window;
1.32 + GtkWidget *fromInput, *toInput;
1.33 + GtkWidget *textArea;
1.34 GtkTextTag *changedTag;
1.35 GtkTextBuffer *textBuffer;
1.36 - struct dump_data *next;
1.37 -} *dump_data_t;
1.38 + struct dump_window_info *next;
1.39 +};
1.40
1.41 -static dump_data_t dump_list_head = NULL;
1.42 +static dump_window_t dump_list_head = NULL;
1.43
1.44 gboolean on_dump_window_delete_event( GtkWidget *widget, GdkEvent *event,
1.45 gpointer user_data );
1.46 void on_dump_window_button_view_clicked( GtkWidget *widget, gpointer user_data );
1.47 -void dump_window_set_text( dump_data_t data, unsigned char *old_data, unsigned char *new_data );
1.48 +void dump_window_set_text( dump_window_t data, unsigned char *old_data, unsigned char *new_data );
1.49
1.50
1.51 -void dump_window_new( const gchar *title ) {
1.52 - GtkWidget *win = create_dump_win();
1.53 - GtkWidget *dump_view_button = (GtkWidget *)g_object_get_data(G_OBJECT(win), "dump_view_button");
1.54 - dump_data_t data = malloc( sizeof(struct dump_data) );
1.55 - data->_tag = DUMP_DATA_TAG;
1.56 - data->fromInput = (GtkEntry *)g_object_get_data(G_OBJECT(win), "dump_from");
1.57 - data->toInput = (GtkEntry *)g_object_get_data(G_OBJECT(win), "dump_to");
1.58 - data->textArea = (GtkTextView *)g_object_get_data(G_OBJECT(win), "dump_text");
1.59 - data->next = dump_list_head;
1.60 - dump_list_head = data;
1.61 - data->data = NULL;
1.62 - data->start = 0;
1.63 - data->end = 0;
1.64 - gtk_entry_set_text( data->fromInput, "" );
1.65 - gtk_entry_set_text( data->toInput, "" );
1.66 - data->textBuffer = gtk_text_buffer_new(NULL);
1.67 - data->changedTag = gtk_text_buffer_create_tag(data->textBuffer, "changed",
1.68 - "foreground", "blue",
1.69 - NULL);
1.70 - gtk_text_view_set_buffer(data->textArea, data->textBuffer);
1.71 - gtk_text_view_set_editable(data->textArea, FALSE);
1.72 - gtk_widget_modify_font(GTK_WIDGET(data->textArea),gui_fixed_font);
1.73 +dump_window_t dump_window_new( const gchar *title )
1.74 +{
1.75 + GtkWidget *vbox3;
1.76 + GtkWidget *hbox2;
1.77 + GtkWidget *dump_view_button;
1.78 + GtkWidget *scrolledwindow9;
1.79 +
1.80 + dump_window_t dump = g_malloc0( sizeof( struct dump_window_info ) );
1.81 +
1.82 + dump->_tag = DUMP_WINDOW_TAG;
1.83 + dump->next = dump_list_head;
1.84 + dump_list_head = dump;
1.85 + dump->data = NULL;
1.86 + dump->start = 0;
1.87 + dump->end = 0;
1.88 + dump->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1.89 + gtk_window_set_title (GTK_WINDOW (dump->window), _("Memory dump"));
1.90 +
1.91 + vbox3 = gtk_vbox_new (FALSE, 0);
1.92 + gtk_container_add (GTK_CONTAINER (dump->window), vbox3);
1.93 +
1.94 + hbox2 = gtk_hbox_new (FALSE, 0);
1.95 + dump->fromInput = gtk_entry_new ();
1.96 + gtk_entry_set_text( GTK_ENTRY(dump->fromInput), "" );
1.97 + dump->toInput = gtk_entry_new ();
1.98 + gtk_entry_set_text( GTK_ENTRY(dump->toInput), "" );
1.99 + dump_view_button = gtk_button_new_with_mnemonic (_("View"));
1.100 +
1.101 + gtk_box_pack_start (GTK_BOX (hbox2), gtk_label_new(_(" From ")), FALSE, FALSE, 0);
1.102 + gtk_box_pack_start (GTK_BOX (hbox2), dump->fromInput, FALSE, TRUE, 0);
1.103 + gtk_box_pack_start (GTK_BOX (hbox2), gtk_label_new(_(" To ")), FALSE, FALSE, 0);
1.104 + gtk_box_pack_start (GTK_BOX (hbox2), dump->toInput, FALSE, TRUE, 0);
1.105 + gtk_box_pack_start (GTK_BOX (hbox2), dump_view_button, FALSE, FALSE, 0);
1.106 + gtk_box_pack_start (GTK_BOX (hbox2), gtk_label_new (_(" ")), TRUE, TRUE, 0);
1.107 + gtk_box_pack_start (GTK_BOX (vbox3), hbox2, FALSE, TRUE, 3);
1.108 +
1.109 + dump->textArea = gtk_text_view_new ();
1.110 + dump->textBuffer = gtk_text_buffer_new(NULL);
1.111 + dump->changedTag = gtk_text_buffer_create_tag(dump->textBuffer, "changed",
1.112 + "foreground", "blue", NULL);
1.113 + gtk_widget_modify_font(GTK_WIDGET(dump->textArea),gui_fixed_font);
1.114 + gtk_text_view_set_editable(GTK_TEXT_VIEW(dump->textArea), FALSE);
1.115 + gtk_text_view_set_buffer(GTK_TEXT_VIEW(dump->textArea), dump->textBuffer);
1.116 + scrolledwindow9 = gtk_scrolled_window_new (NULL, NULL);
1.117 + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow9), GTK_SHADOW_IN);
1.118 + gtk_container_add (GTK_CONTAINER (scrolledwindow9), dump->textArea);
1.119 + gtk_box_pack_start (GTK_BOX (vbox3), scrolledwindow9, TRUE, TRUE, 0);
1.120
1.121 - g_signal_connect ((gpointer) win, "delete_event",
1.122 + g_signal_connect (dump->window, "delete_event",
1.123 G_CALLBACK (on_dump_window_delete_event),
1.124 - data);
1.125 - g_signal_connect ((gpointer) dump_view_button, "clicked",
1.126 + dump);
1.127 + g_signal_connect (dump_view_button, "clicked",
1.128 G_CALLBACK (on_dump_window_button_view_clicked),
1.129 - data);
1.130 - gtk_widget_show( GTK_WIDGET(win) );
1.131 + dump);
1.132 + gtk_widget_show_all( dump->window );
1.133 +
1.134 + return dump;
1.135 }
1.136
1.137 -
1.138 +void gtk_entry_set_hex_value( GtkEntry *entry, uint32_t value )
1.139 +{
1.140 + char buf[10];
1.141 + sprintf( buf, "%08X", value );
1.142 + gtk_entry_set_text( entry, buf );
1.143 +}
1.144
1.145 uint32_t gtk_entry_get_hex_value( GtkEntry *entry, uint32_t defaultValue )
1.146 {
1.147 @@ -97,21 +129,13 @@
1.148 return value;
1.149 }
1.150
1.151 -void gtk_entry_set_hex_value( GtkEntry *entry, uint32_t value )
1.152 -{
1.153 - char buf[10];
1.154 - sprintf( buf, "%08X", value );
1.155 - gtk_entry_set_text( entry, buf );
1.156 -}
1.157 -
1.158 -
1.159 gboolean on_dump_window_delete_event( GtkWidget *widget, GdkEvent *event,
1.160 gpointer user_data )
1.161 {
1.162 - dump_data_t data = (dump_data_t)user_data;
1.163 + dump_window_t data = (dump_window_t)user_data;
1.164 if( data->data != NULL )
1.165 free( data->data );
1.166 - dump_data_t node = dump_list_head;
1.167 + dump_window_t node = dump_list_head;
1.168 if( node == data )
1.169 dump_list_head = data->next;
1.170 else {
1.171 @@ -127,14 +151,14 @@
1.172
1.173 void on_dump_window_button_view_clicked( GtkWidget *widget, gpointer user_data )
1.174 {
1.175 - dump_data_t data = (dump_data_t)user_data;
1.176 + dump_window_t data = (dump_window_t)user_data;
1.177 uint32_t startVal, endVal;
1.178
1.179 assert( data != NULL );
1.180 - assert( data->_tag == DUMP_DATA_TAG );
1.181 + assert( data->_tag == DUMP_WINDOW_TAG );
1.182
1.183 - startVal = gtk_entry_get_hex_value(data->fromInput, data->start);
1.184 - endVal = gtk_entry_get_hex_value(data->toInput, data->end);
1.185 + startVal = gtk_entry_get_hex_value(GTK_ENTRY(data->fromInput), data->start);
1.186 + endVal = gtk_entry_get_hex_value(GTK_ENTRY(data->toInput), data->end);
1.187 if( startVal != data->start || endVal != data->end ) {
1.188 if( startVal > endVal ) {
1.189 int tmp = endVal;
1.190 @@ -144,8 +168,8 @@
1.191 if( endVal > startVal + MAX_DUMP_SIZE )
1.192 endVal = startVal + MAX_DUMP_SIZE;
1.193
1.194 - gtk_entry_set_hex_value(data->fromInput,startVal);
1.195 - gtk_entry_set_hex_value(data->toInput,endVal);
1.196 + gtk_entry_set_hex_value(GTK_ENTRY(data->fromInput),startVal);
1.197 + gtk_entry_set_hex_value(GTK_ENTRY(data->toInput),endVal);
1.198 data->start = startVal;
1.199 data->end = endVal;
1.200
1.201 @@ -161,7 +185,7 @@
1.202 }
1.203 }
1.204
1.205 -void dump_window_update( dump_data_t data )
1.206 +void dump_window_update( dump_window_t data )
1.207 {
1.208 if( data->data == NULL )
1.209 return;
1.210 @@ -174,14 +198,14 @@
1.211
1.212 void dump_window_update_all( )
1.213 {
1.214 - dump_data_t node = dump_list_head;
1.215 + dump_window_t node = dump_list_head;
1.216 while( node != NULL ) {
1.217 dump_window_update(node);
1.218 node = node->next;
1.219 }
1.220 }
1.221
1.222 -void dump_window_set_text( dump_data_t data, unsigned char *old_data, unsigned char *new_data )
1.223 +void dump_window_set_text( dump_window_t data, unsigned char *old_data, unsigned char *new_data )
1.224 {
1.225 GtkTextBuffer *buf = data->textBuffer;
1.226 GtkTextTag *changedTag = data->changedTag;
.