1 /** \file uidatasette.c
2 * \brief Create independent datasette control widgets
3 *
4 * \author Michael C. Martin <mcmartin@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 #include "vice.h"
29 #include "uidatasette.h"
30 #include "datasette.h"
31 #include "uitapeattach.h"
32 #include "uisettings.h"
33
34 #include <stdio.h>
35
36
37 /** \brief Handler for the "activate" event of the "Configure" menu item
38 *
39 * Pop up the settings UI and select "I/O extensions" -> "Tapeport devices"
40 *
41 * \param[in] widget menu item triggering the event
42 * \param[in] data extra event data (unused)
43 */
on_configure_activate(GtkWidget * widget,gpointer data)44 static void on_configure_activate(GtkWidget *widget, gpointer data)
45 {
46 ui_settings_dialog_create_and_activate_node(
47 "io-extensions/tapeport-devices");
48 }
49
50
ui_datasette_tape_action_cb(GtkWidget * widget,gpointer data)51 void ui_datasette_tape_action_cb(GtkWidget *widget, gpointer data)
52 {
53 int val = GPOINTER_TO_INT(data);
54 if (val >= DATASETTE_CONTROL_STOP && val <= DATASETTE_CONTROL_RESET_COUNTER) {
55 datasette_control(val);
56 } else {
57 fprintf(stderr, "Got an impossible Datasette Control action, code %ld (valid range %d-%d)\n", (long)val, DATASETTE_CONTROL_STOP, DATASETTE_CONTROL_RESET_COUNTER);
58 }
59 }
60
ui_create_datasette_control_menu(void)61 GtkWidget *ui_create_datasette_control_menu(void)
62 {
63 GtkWidget *menu, *item, *menu_items[DATASETTE_CONTROL_RESET_COUNTER+1];
64 int i;
65
66 menu = gtk_menu_new();
67 item = gtk_menu_item_new_with_label("Attach tape image...");
68 gtk_container_add(GTK_CONTAINER(menu), item);
69 g_signal_connect(item, "activate", G_CALLBACK(ui_tape_attach_callback), NULL);
70 item = gtk_menu_item_new_with_label("Detach tape image");
71 gtk_container_add(GTK_CONTAINER(menu), item);
72 g_signal_connect(item, "activate", G_CALLBACK(ui_tape_detach_callback), NULL);
73 gtk_container_add(GTK_CONTAINER(menu), gtk_separator_menu_item_new());
74 menu_items[0] = gtk_menu_item_new_with_label("Stop");
75 menu_items[1] = gtk_menu_item_new_with_label("Start");
76 menu_items[2] = gtk_menu_item_new_with_label("Forward");
77 menu_items[3] = gtk_menu_item_new_with_label("Rewind");
78 menu_items[4] = gtk_menu_item_new_with_label("Record");
79 menu_items[5] = gtk_menu_item_new_with_label("Reset");
80 menu_items[6] = gtk_menu_item_new_with_label("Reset Counter");
81 for (i = 0; i <= DATASETTE_CONTROL_RESET_COUNTER; ++i) {
82 gtk_container_add(GTK_CONTAINER(menu), menu_items[i]);
83 g_signal_connect(menu_items[i], "activate", G_CALLBACK(ui_datasette_tape_action_cb), GINT_TO_POINTER(i));
84 }
85
86 /* add "configure tapeport devices" */
87 gtk_container_add(GTK_CONTAINER(menu), gtk_separator_menu_item_new());
88 item = gtk_menu_item_new_with_label("Configure tapeport devices ...");
89 g_signal_connect(item, "activate", G_CALLBACK(on_configure_activate),
90 NULL);
91 gtk_container_add(GTK_CONTAINER(menu), item);
92
93 gtk_widget_show_all(menu);
94 return menu;
95 }
96