1 /** \file uivsidwindow.c
2 * \brief Native GTK3 main vsid window code
3 *
4 * \author Marcus Sutton <loggedoubt@gmail.com>
5 */
6
7 /*
8 * This file is part of VICE, the Versatile Commodore Emulator.
9 * See README for copyright notice.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24 * 02111-1307 USA.
25 *
26 */
27
28 /* XXX: It should be possible to compile, link and run all emulators while this
29 * entire file (amongst others) is contained inside an #if 0 wrapper.
30 */
31 #if 1
32
33 #include "vice.h"
34
35 #include <gtk/gtk.h>
36
37 #include "videoarch.h"
38
39 #include "vice_gtk3.h"
40 #include "hvscstilwidget.h"
41 #include "machine.h"
42 #include "psid.h"
43 #include "ui.h"
44 #include "uiapi.h"
45 #include "uivsidmenu.h"
46 #include "vsidmainwidget.h"
47 #include "vsidtuneinfowidget.h"
48 #include "vsync.h"
49
50 #include "uivsidwindow.h"
51
52
53 /** \brief Main widget of VSID
54 *
55 * This should contain play/stop/rewind etc controls, and data on the currently
56 * loaded SID. A proper playlist and Songlength.[txt|md5] support wouldn't
57 * hurt either.
58 */
59 static GtkWidget *main_widget = NULL;
60
61
62 /** \brief Create VSID window
63 *
64 * \param[in] canvas something
65 */
vsid_window_create(video_canvas_t * canvas)66 static void vsid_window_create(video_canvas_t *canvas)
67 {
68 GtkWidget *menu_bar;
69
70 canvas->renderer_backend = NULL;
71 canvas->drawing_area = NULL;
72
73 main_widget = vsid_main_widget_create();
74 gtk_widget_set_size_request(main_widget, 400, 300);
75 gtk_widget_set_hexpand(main_widget, TRUE);
76 gtk_widget_set_vexpand(main_widget, TRUE);
77 gtk_widget_show(main_widget);
78
79 menu_bar = ui_vsid_menu_bar_create();
80 gtk_container_add(GTK_CONTAINER(canvas->grid), menu_bar);
81 gtk_container_add(GTK_CONTAINER(canvas->grid), main_widget);
82 }
83
84
85 /** \brief Load and play PSID/SID file \a filename
86 *
87 * \param[in] filename file to play
88 */
ui_vsid_window_load_psid(const char * filename)89 int ui_vsid_window_load_psid(const char *filename)
90 {
91 vsync_suspend_speed_eval();
92
93 if (machine_autodetect_psid(filename) < 0) {
94 debug_gtk3("'%s' is not a valid PSID file.", filename);
95 ui_error("'%s' is not a valid PSID file.", filename);
96 return -1;
97 }
98 psid_init_driver();
99 machine_play_psid(0);
100 machine_trigger_reset(MACHINE_RESET_MODE_SOFT);
101 vsid_tune_info_widget_set_song_lengths(filename);
102 hvsc_stil_widget_set_psid(filename);
103
104 return 0;
105 }
106
107
108 /** \brief Initialize VSID window
109 */
ui_vsid_window_init(void)110 void ui_vsid_window_init(void)
111 {
112 ui_set_create_window_func(vsid_window_create);
113
114 ui_set_handle_dropped_files_func(ui_vsid_window_load_psid);
115 }
116
117 #endif
118