Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/yabause/src/gtk/yuiscsp.c
2 views
1
/* Copyright 2006 Guillaume Duhamel
2
Copyright 2005-2006 Fabien Coulon
3
4
This file is part of Yabause.
5
6
Yabause is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
11
Yabause is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with Yabause; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
#include <gtk/gtk.h>
22
23
#include "yuiscsp.h"
24
#include "../scsp.h"
25
#include "../yabause.h"
26
#include "settings.h"
27
28
static void yui_scsp_class_init (YuiScspClass * klass);
29
static void yui_scsp_init (YuiScsp * yfe);
30
static void yui_scsp_spin_cursor_changed(GtkWidget * spin, YuiScsp * scsp);
31
static void yui_scsp_clear(YuiScsp * scsp);
32
33
GType yui_scsp_get_type (void) {
34
static GType yfe_type = 0;
35
36
if (!yfe_type)
37
{
38
static const GTypeInfo yfe_info =
39
{
40
sizeof (YuiScspClass),
41
NULL, /* base_init */
42
NULL, /* base_finalize */
43
(GClassInitFunc) yui_scsp_class_init,
44
NULL, /* class_finalize */
45
NULL, /* class_data */
46
sizeof (YuiScsp),
47
0,
48
(GInstanceInitFunc) yui_scsp_init,
49
NULL,
50
};
51
52
yfe_type = g_type_register_static(GTK_TYPE_WINDOW, "YuiScsp", &yfe_info, 0);
53
}
54
55
return yfe_type;
56
}
57
58
static void yui_scsp_class_init (UNUSED YuiScspClass * klass) {
59
}
60
61
static void yui_scsp_init (YuiScsp * yv) {
62
gtk_window_set_title(GTK_WINDOW(yv), "SCSP");
63
64
yv->vbox = gtk_vbox_new(FALSE, 2);
65
gtk_container_set_border_width(GTK_CONTAINER(yv->vbox), 4);
66
gtk_container_add(GTK_CONTAINER(yv), yv->vbox);
67
68
yv->spin = gtk_spin_button_new_with_range(0, 31, 1);
69
gtk_spin_button_set_range(GTK_SPIN_BUTTON(yv->spin), 0, 31);
70
gtk_box_pack_start(GTK_BOX(yv->vbox), yv->spin, FALSE, FALSE, 4);
71
g_signal_connect(G_OBJECT(yv->spin), "value-changed", GTK_SIGNAL_FUNC(yui_scsp_spin_cursor_changed), yv);
72
73
g_signal_connect(G_OBJECT(yv), "delete-event", GTK_SIGNAL_FUNC(yui_scsp_destroy), NULL);
74
75
{
76
GtkWidget * scroll = gtk_scrolled_window_new(NULL, NULL);
77
GtkWidget * text = gtk_text_view_new();
78
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
79
gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
80
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
81
yv->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
82
gtk_container_add(GTK_CONTAINER(scroll), text);
83
gtk_box_pack_start(GTK_BOX(yv->vbox), scroll, TRUE, TRUE, 4);
84
}
85
86
yv->hbox = gtk_hbutton_box_new();
87
gtk_box_set_spacing(GTK_BOX(yv->hbox), 4);
88
gtk_box_pack_start(GTK_BOX(yv->vbox ), yv->hbox, FALSE, FALSE, 4);
89
90
yv->cursor = 0;
91
}
92
93
static gulong paused_handler;
94
static gulong running_handler;
95
static YuiWindow * yui;
96
97
GtkWidget * yui_scsp_new(YuiWindow * y) {
98
GtkWidget * dialog;
99
YuiScsp * yv;
100
101
yui = y;
102
103
dialog = GTK_WIDGET(g_object_new(yui_scsp_get_type(), NULL));
104
yv = YUI_SCSP(dialog);
105
106
{
107
GtkWidget * but2, * but3, * but4;
108
but2 = gtk_button_new();
109
gtk_action_connect_proxy(gtk_action_group_get_action(yui->action_group, "run"), but2);
110
gtk_box_pack_start(GTK_BOX(yv->hbox), but2, FALSE, FALSE, 2);
111
112
but3 = gtk_button_new();
113
gtk_action_connect_proxy(gtk_action_group_get_action(yui->action_group, "pause"), but3);
114
gtk_box_pack_start(GTK_BOX(yv->hbox), but3, FALSE, FALSE, 2);
115
116
but4 = gtk_button_new_from_stock("gtk-close");
117
g_signal_connect_swapped(but4, "clicked", G_CALLBACK(yui_scsp_destroy), dialog);
118
gtk_box_pack_start(GTK_BOX(yv->hbox), but4, FALSE, FALSE, 2);
119
}
120
paused_handler = g_signal_connect_swapped(yui, "paused", G_CALLBACK(yui_scsp_update), yv);
121
running_handler = g_signal_connect_swapped(yui, "running", G_CALLBACK(yui_scsp_clear), yv);
122
123
if ((yui->state & (YUI_IS_RUNNING | YUI_IS_INIT)) == YUI_IS_INIT)
124
yui_scsp_update(yv);
125
126
gtk_widget_show_all(GTK_WIDGET(yv));
127
128
return dialog;
129
}
130
131
void yui_scsp_fill(YuiScsp * scsp) {
132
gchar nameTemp[1024];
133
134
yui_scsp_clear(scsp);
135
136
ScspSlotDebugStats(scsp->cursor, nameTemp );
137
138
gtk_text_buffer_set_text(scsp->buffer, g_strstrip(nameTemp), -1);
139
}
140
141
static void yui_scsp_spin_cursor_changed(GtkWidget * spin, YuiScsp * scsp) {
142
scsp->cursor = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));
143
yui_scsp_fill(scsp);
144
}
145
146
void yui_scsp_update(YuiScsp * scsp) {
147
yui_scsp_fill(scsp);
148
}
149
150
void yui_scsp_destroy(YuiScsp * scsp) {
151
g_signal_handler_disconnect(yui, running_handler);
152
g_signal_handler_disconnect(yui, paused_handler);
153
154
gtk_widget_destroy(GTK_WIDGET(scsp));
155
}
156
157
static void yui_scsp_clear(YuiScsp * scsp) {
158
gtk_text_buffer_set_text(scsp->buffer, "", -1);
159
}
160
161