1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
/*
* $Id: floppy_gen_floppydrive_gui_gtk.c,v 1.21 2009-10-15 13:54:56 vrsieh Exp $
*
* Copyright (C) 2003-2009 FAUmachine Team <info@faumachine.org>.
* This program is free software. You can redistribute it and/or modify it
* under the terms of the GNU General Public License, either version 2 of
* the License, or (at your option) any later version. See COPYING.
*/
#include "config.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include "fixme.h"
#include "glue-gui-gtk.h"
#include "glue-gui-gtk-led.h"
#include "glue-gui-gtk-change.h"
#include "floppy_gen_floppydrive_gui_gtk.h"
#define COMP "floppy_gen_floppydrive"
struct cpssp {
GtkWidget *led;
GtkWidget *change;
struct sig_string *port_change;
};
/*
* Simulator Callbacks
*/
static void
gui_floppy_opt_busy_led_set(void *_cpssp, unsigned int val)
{
struct cpssp *cpssp = (struct cpssp *) _cpssp;
gui_gtk_led_set(GUI_GTK_LED(cpssp->led), val);
gui_gtk_flush();
}
static void
gui_floppy_change(void *_cpssp, const char *path)
{
struct cpssp *cpssp = (struct cpssp *) _cpssp;
gui_gtk_change_set(GUI_GTK_CHANGE(cpssp->change), path);
}
/*
* GUI Callbacks
*/
static void
gui_floppy_insert_event(GtkWidget *w, const char *string, gpointer _cpssp)
{
struct cpssp *cpssp = (struct cpssp *) _cpssp;
sig_string_set(cpssp->port_change, cpssp, string);
}
static void
gui_floppy_remove_event(GtkWidget *w, gpointer _cpssp)
{
struct cpssp *cpssp = (struct cpssp *) _cpssp;
sig_string_set(cpssp->port_change, cpssp, "");
}
void *
floppy_gen_floppydrive_gui_gtk_create(
unsigned int page,
const char *name,
const char *model,
const char *unit,
struct sig_manage *port_manage,
struct sig_power_device *port_power,
struct sig_shugart_bus *port_shugart,
struct sig_boolean *port_opt_busy_led,
struct sig_floppy *port_media,
struct sig_string *port_change
)
{
static const struct sig_boolean_funcs opt_busy_led_funcs = {
.set = gui_floppy_opt_busy_led_set,
};
static const struct sig_string_funcs change_funcs = {
.set = gui_floppy_change,
};
struct cpssp *cpssp;
GtkWidget *vbox;
cpssp = malloc(sizeof(*cpssp));
assert(cpssp);
vbox = gtk_vbox_new(FALSE, 1);
/* Busy LED */
cpssp->led = gui_gtk_led_new("Busy");
gtk_widget_show(cpssp->led);
gtk_box_pack_start(GTK_BOX(vbox), cpssp->led, TRUE, FALSE, 1);
/* Change Buttons */
cpssp->change = gui_gtk_change_new("Floppy");
GTK_WIDGET_UNSET_FLAGS(cpssp->change, GTK_CAN_FOCUS);
g_signal_connect(G_OBJECT(cpssp->change), "change-inserted",
G_CALLBACK(gui_floppy_insert_event), cpssp);
g_signal_connect(G_OBJECT(cpssp->change), "change-removed",
G_CALLBACK(gui_floppy_remove_event), cpssp);
gtk_widget_show(cpssp->change);
gtk_box_pack_end(GTK_BOX(vbox), cpssp->change, TRUE, FALSE, 1);
gtk_widget_show(vbox);
gui_gtk_comp_add(page, COMP, name, vbox, FALSE, FALSE, NULL);
/* Out */
cpssp->port_change = port_change;
/* In */
sig_boolean_connect_in(port_opt_busy_led, cpssp, &opt_busy_led_funcs);
sig_string_connect(port_change, cpssp, &change_funcs);
return cpssp;
}
void
floppy_gen_floppydrive_gui_gtk_destroy(void *_cpssp)
{
struct cpssp *cpssp = _cpssp;
free(cpssp);
}
|