1 /** \brief  petui.c
2  * \brief   Native GTK3 PET UI
3  *
4  * \author  Marco van den Heuvel <blackystardust68@yahoo.com>
5  * \author  Bas Wassink <b.wassink@ziggo.nl>
6  */
7 
8 /*
9  * This file is part of VICE, the Versatile Commodore Emulator.
10  * See README for copyright notice.
11  *
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.
16  *
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.
21  *
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., 59 Temple Place, Suite 330, Boston, MA
25  *  02111-1307  USA.
26  *
27  */
28 
29 #include "vice.h"
30 
31 #include <stdio.h>
32 
33 #include "debug_gtk3.h"
34 #include "crtc.h"
35 #include "crtcontrolwidget.h"
36 #include "machine.h"
37 #include "machinemodelwidget.h"
38 #include "petkeyboardtypewidget.h"
39 #include "petmodel.h"
40 #include "sampler.h"
41 #include "ui.h"
42 #include "uimachinewindow.h"
43 #include "settings_sampler.h"
44 #include "settings_model.h"
45 
46 #include "petui.h"
47 
48 
49 /** \brief  List of PET models
50  *
51  * Used in the machine-model widget
52  */
53 static const char *pet_model_list[] = {
54     "PET 2001-8N",
55     "PET 3008",
56     "PET 3016",
57     "PET 3032",
58     "PET 3032B",
59     "PET 4016",
60     "PET 4032",
61     "PET 4032B",
62     "PET 8032",
63     "PET 8096",
64     "PET 8296",
65     "SuperPET",
66     NULL
67 };
68 
69 
70 /** \brief  Identify the canvas used to create a window
71  *
72  * \return  window index on success, -1 on failure
73  */
identify_canvas(video_canvas_t * canvas)74 static int identify_canvas(video_canvas_t *canvas)
75 {
76     if (canvas != crtc_get_canvas()) {
77         return -1;
78     }
79 
80     return PRIMARY_WINDOW;
81 }
82 
83 /** \brief  Create CRT controls widget for \a target window
84  *
85  * \return  GtkGrid
86  */
create_crt_widget(int target_window)87 static GtkWidget *create_crt_widget(int target_window)
88 {
89     return crt_control_widget_create(NULL, "CRTC", TRUE);
90 }
91 
92 /** \brief  Pre-initialize the UI before the canvas window gets created
93  *
94  * \return  0 on success, -1 on failure
95  */
petui_init_early(void)96 int petui_init_early(void)
97 {
98     ui_machine_window_init();
99     ui_set_identify_canvas_func(identify_canvas);
100     ui_set_create_controls_widget_func(create_crt_widget);
101     return 0;
102 }
103 
104 
105 /** \brief  Initialize the UI
106  *
107  * \return  0 on success, -1 on failure
108  */
petui_init(void)109 int petui_init(void)
110 {
111     machine_model_widget_getter(petmodel_get);
112     machine_model_widget_setter(petmodel_set);
113     machine_model_widget_set_models(pet_model_list);
114 
115     pet_keyboard_type_widget_set_keyboard_num_get(machine_get_num_keyboard_types);
116     pet_keyboard_type_widget_set_keyboard_list_get(machine_get_keyboard_info_list);
117 
118     settings_sampler_set_devices_getter(sampler_get_devices);
119 
120     settings_model_widget_set_model_func(petmodel_get);
121     return 0;
122 }
123 
124 
125 /** \brief  Shut down the UI
126  */
petui_shutdown(void)127 void petui_shutdown(void)
128 {
129     /* NOP */
130 }
131