1 /**\file cbm2memorysizewidget.c
2 * \brief CBM-II memory size widget
3 *
4 * \author Bas Wassink <b.wassink@ziggo.nl>
5 */
6
7 /*
8 * $VICERES RamSize xcbm5x0 xcbm2
9 */
10
11 /*
12 * This file is part of VICE, the Versatile Commodore Emulator.
13 * See README for copyright notice.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 * 02111-1307 USA.
29 *
30 */
31
32 #include "vice.h"
33
34 #include <gtk/gtk.h>
35
36 #include "basewidgets.h"
37 #include "debug_gtk3.h"
38 #include "machine.h"
39 #include "resources.h"
40 #include "widgethelpers.h"
41
42 #include "cbm2memorysizewidget.h"
43
44
45 /** \brief List of RAM sizes for 5x0 in KiB
46 */
47 static const vice_gtk3_radiogroup_entry_t ram_sizes_cbm5x0[] = {
48 { "64KiB", 64 },
49 { "128KiB", 128 },
50 { "256KiB", 256 },
51 { "512KiB", 512 },
52 { "1024KiB", 1024 },
53 { NULL, -1 }
54 };
55
56
57 /** \brief List of RAM sizes for 6x0/7x0 in KiB
58 */
59 static const vice_gtk3_radiogroup_entry_t ram_sizes_cbm6x0[] = {
60 { "128KiB", 128 },
61 { "256KiB", 256 },
62 { "512KiB", 512 },
63 { "1024KiB", 1024 },
64 { NULL, -1 }
65 };
66
67
68
69 /** \brief Create CBM-II memory size widget
70 *
71 * \return GtkGrid
72 */
cbm2_memory_size_widget_create(void)73 GtkWidget *cbm2_memory_size_widget_create(void)
74 {
75 GtkWidget *grid;
76 GtkWidget *radio_group;
77 const vice_gtk3_radiogroup_entry_t *ram_sizes;
78
79 if (machine_class == VICE_MACHINE_CBM5x0) {
80 ram_sizes = ram_sizes_cbm5x0;
81 } else {
82 ram_sizes = ram_sizes_cbm6x0;
83 }
84
85 grid = uihelpers_create_grid_with_label("RAM size", 1);
86 radio_group = vice_gtk3_resource_radiogroup_new("RamSize", ram_sizes,
87 GTK_ORIENTATION_VERTICAL);
88 g_object_set(radio_group, "margin-left", 16, NULL);
89 gtk_grid_attach(GTK_GRID(grid), radio_group, 0, 1, 1, 1);
90 gtk_widget_show_all(grid);
91 return grid;
92 }
93
94
95 /** \brief Set used-defined callback to trigger when the RAM size changes
96 *
97 * \param[in,out] widget cbm2 memory size widget
98 * \param[in] user-defined callback
99 */
cbm2_memory_size_widget_set_callback(GtkWidget * widget,void (* callback)(GtkWidget *,int))100 void cbm2_memory_size_widget_set_callback(
101 GtkWidget *widget,
102 void (*callback)(GtkWidget *, int))
103 {
104 GtkWidget *group = gtk_grid_get_child_at(GTK_GRID(widget), 0, 1);
105 if (group != NULL) {
106 vice_gtk3_resource_radiogroup_add_callback(group, callback);
107 }
108 }
109
110
111 /** \brief Update/sync widget via its resource
112 *
113 * \param[in] widget cbm2 memory size widget
114 */
cbm2_memory_size_widget_update(GtkWidget * widget)115 void cbm2_memory_size_widget_update(GtkWidget *widget)
116 {
117 GtkWidget *group = gtk_grid_get_child_at(GTK_GRID(widget), 0, 1);
118 if (group != NULL) {
119 vice_gtk3_resource_radiogroup_sync(group);
120 }
121 }
122
123