mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-02-10 07:30:30 +00:00
Update the GUI with the new ethernet configuration changes. Handle migrations
from the GUI. Also move from a combo to a fixed popdown menu with pretty printed ethernet interfaces.
This commit is contained in:
parent
732109eff2
commit
02c1747d34
@ -61,7 +61,8 @@ SRCS = ../main.cpp main_windows.cpp ../prefs.cpp ../prefs_items.cpp prefs_window
|
|||||||
$(CDENABLESRCS) $(ROUTERSRCS) $(CPUSRCS)
|
$(CDENABLESRCS) $(ROUTERSRCS) $(CPUSRCS)
|
||||||
|
|
||||||
UI_SRCS = ../prefs.cpp prefs_windows.cpp prefs_editor_gtk.cpp xpram_windows.cpp \
|
UI_SRCS = ../prefs.cpp prefs_windows.cpp prefs_editor_gtk.cpp xpram_windows.cpp \
|
||||||
../prefs_items.cpp ../user_strings.cpp user_strings_windows.cpp b2ether/Packet32.cpp BasiliskIIGUI.rc
|
../prefs_items.cpp ../user_strings.cpp user_strings_windows.cpp util_windows.cpp \
|
||||||
|
b2ether/Packet32.cpp BasiliskIIGUI.rc
|
||||||
|
|
||||||
UI_APP = BasiliskIIGUI.exe
|
UI_APP = BasiliskIIGUI.exe
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "xpram.h"
|
#include "xpram.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
#include "prefs_editor.h"
|
#include "prefs_editor.h"
|
||||||
|
#include "util_windows.h"
|
||||||
#include "b2ether/inc/b2ether_hl.h"
|
#include "b2ether/inc/b2ether_hl.h"
|
||||||
|
|
||||||
|
|
||||||
@ -66,6 +67,7 @@ enum {
|
|||||||
STR_SERIALB_CTRL = STR_SERPORTB_CTRL,
|
STR_SERIALB_CTRL = STR_SERPORTB_CTRL,
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
|
#define DISABLE_SCSI 1 /* XXX merge code from original Basilisk II for Windows */
|
||||||
#define PROGRAM_NAME "BasiliskII"
|
#define PROGRAM_NAME "BasiliskII"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -116,12 +118,17 @@ static GtkWidget *make_browse_button(GtkWidget *entry)
|
|||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void add_menu_item(GtkWidget *menu, const char *label, GtkSignalFunc func, gpointer data = NULL)
|
||||||
|
{
|
||||||
|
GtkWidget *item = gtk_menu_item_new_with_label(label);
|
||||||
|
gtk_widget_show(item);
|
||||||
|
gtk_signal_connect(GTK_OBJECT(item), "activate", func, data);
|
||||||
|
gtk_menu_append(GTK_MENU(menu), item);
|
||||||
|
}
|
||||||
|
|
||||||
static void add_menu_item(GtkWidget *menu, int label_id, GtkSignalFunc func)
|
static void add_menu_item(GtkWidget *menu, int label_id, GtkSignalFunc func)
|
||||||
{
|
{
|
||||||
GtkWidget *item = gtk_menu_item_new_with_label(GetString(label_id));
|
add_menu_item(menu, GetString(label_id), func, NULL);
|
||||||
gtk_widget_show(item);
|
|
||||||
gtk_signal_connect(GTK_OBJECT(item), "activate", func, NULL);
|
|
||||||
gtk_menu_append(GTK_MENU(menu), item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *make_pane(GtkWidget *notebook, int title_id)
|
static GtkWidget *make_pane(GtkWidget *notebook, int title_id)
|
||||||
@ -458,6 +465,20 @@ static GtkItemFactoryEntry menu_items[] = {
|
|||||||
{(gchar *)GetString(STR_HELP_ITEM_ABOUT_GTK), "<control>H", GTK_SIGNAL_FUNC(cb_about), 0, NULL}
|
{(gchar *)GetString(STR_HELP_ITEM_ABOUT_GTK), "<control>H", GTK_SIGNAL_FUNC(cb_about), 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void PrefsMigrate(void)
|
||||||
|
{
|
||||||
|
// Ethernet
|
||||||
|
const char *ether = PrefsFindString("ether");
|
||||||
|
if (ether && ether[0] == '{') {
|
||||||
|
PrefsReplaceString("etherguid", ether);
|
||||||
|
PrefsReplaceString("ether", "b2ether");
|
||||||
|
}
|
||||||
|
if (PrefsFindBool("routerenabled")) {
|
||||||
|
PrefsRemoveItem("etherguid");
|
||||||
|
PrefsReplaceString("ether", "router");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool PrefsEditor(void)
|
bool PrefsEditor(void)
|
||||||
{
|
{
|
||||||
// Create window
|
// Create window
|
||||||
@ -490,7 +511,9 @@ bool PrefsEditor(void)
|
|||||||
gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, 0);
|
||||||
|
|
||||||
create_volumes_pane(notebook);
|
create_volumes_pane(notebook);
|
||||||
// create_scsi_pane(notebook); XXX not ready yet (merge scsi_windows.cpp from original B2/Win)
|
#ifndef DISABLE_SCSI
|
||||||
|
create_scsi_pane(notebook);
|
||||||
|
#endif
|
||||||
create_graphics_pane(notebook);
|
create_graphics_pane(notebook);
|
||||||
create_input_pane(notebook);
|
create_input_pane(notebook);
|
||||||
create_serial_pane(notebook);
|
create_serial_pane(notebook);
|
||||||
@ -1319,33 +1342,25 @@ static void create_serial_pane(GtkWidget *top)
|
|||||||
* "Ethernet" pane
|
* "Ethernet" pane
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static GtkWidget *w_ether;
|
|
||||||
static GtkWidget *w_ftp_port_list, *w_tcp_port_list;
|
static GtkWidget *w_ftp_port_list, *w_tcp_port_list;
|
||||||
static const char s_nat_router[] = "NAT/Router module";
|
|
||||||
static const char s_ndis_tag[] = "NDIS ";
|
|
||||||
|
|
||||||
// Set sensitivity of widgets
|
// Set sensitivity of widgets
|
||||||
static void set_ethernet_sensitive(void)
|
static void set_ethernet_sensitive(void)
|
||||||
{
|
{
|
||||||
const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether));
|
const char *str = PrefsFindString("ether");
|
||||||
|
|
||||||
bool is_nat_router = strcmp(str, s_nat_router) == 0;
|
bool is_router = str && strcmp(str, "router") == 0;
|
||||||
gtk_widget_set_sensitive(w_ftp_port_list, is_nat_router);
|
gtk_widget_set_sensitive(w_ftp_port_list, is_router);
|
||||||
gtk_widget_set_sensitive(w_tcp_port_list, is_nat_router);
|
gtk_widget_set_sensitive(w_tcp_port_list, is_router);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read settings from widgets and set preferences
|
// Read settings from widgets and set preferences
|
||||||
static void read_ethernet_settings(void)
|
static void read_ethernet_settings(void)
|
||||||
{
|
{
|
||||||
const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether));
|
const char *str = PrefsFindString("ether");
|
||||||
if (str && strlen(str) > sizeof(s_ndis_tag) && strncmp(str, s_ndis_tag, sizeof(s_ndis_tag) - 1) == 0)
|
|
||||||
PrefsReplaceString("ether", &str[sizeof(s_ndis_tag) - 1]);
|
|
||||||
else
|
|
||||||
PrefsRemoveItem("ether");
|
|
||||||
|
|
||||||
const bool router_enabled = str && strcmp(str, s_nat_router) == 0;
|
bool is_router = str && strcmp(str, "router") == 0;
|
||||||
PrefsReplaceBool("routerenabled", router_enabled);
|
if (is_router) {
|
||||||
if (router_enabled) {
|
|
||||||
str = gtk_entry_get_text(GTK_ENTRY(w_ftp_port_list));
|
str = gtk_entry_get_text(GTK_ENTRY(w_ftp_port_list));
|
||||||
PrefsReplaceString("ftp_port_list", str);
|
PrefsReplaceString("ftp_port_list", str);
|
||||||
str = gtk_entry_get_text(GTK_ENTRY(w_tcp_port_list));
|
str = gtk_entry_get_text(GTK_ENTRY(w_tcp_port_list));
|
||||||
@ -1359,16 +1374,45 @@ static void cb_ether_changed(...)
|
|||||||
set_ethernet_sensitive();
|
set_ethernet_sensitive();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add names of ethernet interfaces
|
// Ethernet option "None" selected
|
||||||
// XXX use radio buttons instead (None/NDIS/NAT)
|
static void mn_ether_none(void)
|
||||||
static GList *add_ether_names(void)
|
|
||||||
{
|
{
|
||||||
GList *glist = NULL;
|
PrefsRemoveItem("ether");
|
||||||
|
PrefsRemoveItem("etherguid");
|
||||||
|
}
|
||||||
|
|
||||||
glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB));
|
// Ethernet option "Basilisk II Router" selected
|
||||||
glist = g_list_append(glist, (void *)s_nat_router);
|
static void mn_ether_router(void)
|
||||||
|
{
|
||||||
|
PrefsReplaceString("ether", "router");
|
||||||
|
PrefsRemoveItem("etherguid");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ethernet option for Basilisk II driver selected
|
||||||
|
static void mn_ether_b2ether(GtkWidget *, const char *guid)
|
||||||
|
{
|
||||||
|
PrefsReplaceString("ether", "b2ether");
|
||||||
|
PrefsReplaceString("etherguid", guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create ethernet interfaces menu
|
||||||
|
static int create_ether_menu(GtkWidget *menu)
|
||||||
|
{
|
||||||
|
int active = -1;
|
||||||
|
int n_items = 0;
|
||||||
|
const char *ether = PrefsFindString("ether");
|
||||||
|
const char *etherguid = PrefsFindString("etherguid");
|
||||||
|
|
||||||
|
add_menu_item(menu, STR_NONE_LAB, (GtkSignalFunc)mn_ether_none);
|
||||||
|
if (ether == NULL)
|
||||||
|
active = n_items;
|
||||||
|
n_items++;
|
||||||
|
|
||||||
|
add_menu_item(menu, "Basilisk II Router", (GtkSignalFunc)mn_ether_router);
|
||||||
|
if (ether && strcmp(ether, "router") == 0)
|
||||||
|
active = n_items;
|
||||||
|
n_items++;
|
||||||
|
|
||||||
{ // Get NDIS ethernet adapters (XXX handle "ethermulticastmode")
|
|
||||||
PacketOpenAdapter("", 0);
|
PacketOpenAdapter("", 0);
|
||||||
{
|
{
|
||||||
ULONG sz;
|
ULONG sz;
|
||||||
@ -1381,9 +1425,16 @@ static GList *add_ether_names(void)
|
|||||||
if (strnicmp(p, DEVICE_HEADER, sizeof(DEVICE_HEADER) - 1) == 0) {
|
if (strnicmp(p, DEVICE_HEADER, sizeof(DEVICE_HEADER) - 1) == 0) {
|
||||||
LPADAPTER fd = PacketOpenAdapter(p + sizeof(DEVICE_HEADER) - 1, 0);
|
LPADAPTER fd = PacketOpenAdapter(p + sizeof(DEVICE_HEADER) - 1, 0);
|
||||||
if (fd) {
|
if (fd) {
|
||||||
char str[256];
|
char guid[256];
|
||||||
sprintf(str, "%s%s", s_ndis_tag, p + sizeof(DEVICE_HEADER) - 1);
|
sprintf(guid, "%s", p + sizeof(DEVICE_HEADER) - 1);
|
||||||
glist = g_list_append(glist, strdup(str));
|
const char *name = ether_guid_to_name(guid);
|
||||||
|
if (name && (name = g_locale_to_utf8(name, -1, NULL, NULL, NULL))) {
|
||||||
|
add_menu_item(menu, name, (GtkSignalFunc)mn_ether_b2ether, strdup(guid));
|
||||||
|
if (etherguid && strcmp(guid, etherguid) == 0 &&
|
||||||
|
ether && strcmp(ether, "b2ether") == 0)
|
||||||
|
active = n_items;
|
||||||
|
n_items++;
|
||||||
|
}
|
||||||
PacketCloseAdapter(fd);
|
PacketCloseAdapter(fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1392,15 +1443,14 @@ static GList *add_ether_names(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PacketCloseAdapter(NULL);
|
PacketCloseAdapter(NULL);
|
||||||
}
|
|
||||||
return glist;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
// Create "Ethernet" pane
|
// Create "Ethernet" pane
|
||||||
static void create_ethernet_pane(GtkWidget *top)
|
static void create_ethernet_pane(GtkWidget *top)
|
||||||
{
|
{
|
||||||
GtkWidget *box, *hbox, *table, *label, *combo, *sep, *entry;
|
GtkWidget *box, *hbox, *table, *label, *sep, *entry, *opt, *menu, *item;
|
||||||
|
|
||||||
box = make_pane(top, STR_NETWORK_PANE_TITLE);
|
box = make_pane(top, STR_NETWORK_PANE_TITLE);
|
||||||
table = make_table(box, 2, 5);
|
table = make_table(box, 2, 5);
|
||||||
@ -1409,26 +1459,15 @@ static void create_ethernet_pane(GtkWidget *top)
|
|||||||
gtk_widget_show(label);
|
gtk_widget_show(label);
|
||||||
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
|
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
|
||||||
|
|
||||||
GList *glist = add_ether_names();
|
opt = gtk_option_menu_new();
|
||||||
combo = gtk_combo_new();
|
gtk_widget_show(opt);
|
||||||
gtk_widget_show(combo);
|
menu = gtk_menu_new();
|
||||||
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
|
int active = create_ether_menu(menu);
|
||||||
const char *str = PrefsFindString("ether");
|
if (active >= 0)
|
||||||
if (str == NULL || str[0] == '\0') {
|
gtk_menu_set_active(GTK_MENU(menu), active);
|
||||||
if (PrefsFindBool("routerenabled"))
|
gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu);
|
||||||
str = s_nat_router;
|
gtk_table_attach(GTK_TABLE(table), opt, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
|
||||||
else
|
gtk_signal_connect(GTK_OBJECT(opt), "changed", GTK_SIGNAL_FUNC(cb_ether_changed), NULL);
|
||||||
str = GetString(STR_NONE_LAB);
|
|
||||||
}
|
|
||||||
else if (str[0] == '{') {
|
|
||||||
static char s_device[256];
|
|
||||||
sprintf(s_device, "%s%s", s_ndis_tag, str);
|
|
||||||
str = s_device;
|
|
||||||
}
|
|
||||||
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str);
|
|
||||||
gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
|
|
||||||
w_ether = GTK_COMBO(combo)->entry;
|
|
||||||
gtk_signal_connect(GTK_OBJECT(w_ether), "changed", GTK_SIGNAL_FUNC(cb_ether_changed), NULL);
|
|
||||||
|
|
||||||
sep = gtk_hseparator_new();
|
sep = gtk_hseparator_new();
|
||||||
gtk_widget_show(sep);
|
gtk_widget_show(sep);
|
||||||
@ -1439,7 +1478,7 @@ static void create_ethernet_pane(GtkWidget *top)
|
|||||||
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
|
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4);
|
||||||
|
|
||||||
entry = gtk_entry_new();
|
entry = gtk_entry_new();
|
||||||
str = PrefsFindString("ftp_port_list");
|
const char *str = PrefsFindString("ftp_port_list");
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
str = "";
|
str = "";
|
||||||
gtk_entry_set_text(GTK_ENTRY(entry), str);
|
gtk_entry_set_text(GTK_ENTRY(entry), str);
|
||||||
@ -1611,7 +1650,6 @@ static void read_settings(void)
|
|||||||
uint8 XPRAM[XPRAM_SIZE];
|
uint8 XPRAM[XPRAM_SIZE];
|
||||||
void MountVolume(void *fh) { }
|
void MountVolume(void *fh) { }
|
||||||
void FileDiskLayout(loff_t size, uint8 *data, loff_t &start_byte, loff_t &real_size) { }
|
void FileDiskLayout(loff_t size, uint8 *data, loff_t &start_byte, loff_t &real_size) { }
|
||||||
void WarningAlert(const char *text) { }
|
|
||||||
void recycle_write_packet(LPPACKET) { }
|
void recycle_write_packet(LPPACKET) { }
|
||||||
VOID CALLBACK packet_read_completion(DWORD, DWORD, LPOVERLAPPED) { }
|
VOID CALLBACK packet_read_completion(DWORD, DWORD, LPOVERLAPPED) { }
|
||||||
|
|
||||||
@ -1636,11 +1674,16 @@ static void display_alert(int title_id, const char *text, int flags)
|
|||||||
MessageBox(NULL, text, GetString(title_id), MB_OK | flags);
|
MessageBox(NULL, text, GetString(title_id), MB_OK | flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ErrorAlert(const char *text)
|
void ErrorAlert(const char *text)
|
||||||
{
|
{
|
||||||
display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP);
|
display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WarningAlert(const char *text)
|
||||||
|
{
|
||||||
|
display_alert(STR_WARNING_ALERT_TITLE, text, MB_ICONSTOP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start standalone GUI
|
* Start standalone GUI
|
||||||
@ -1655,6 +1698,9 @@ int main(int argc, char *argv[])
|
|||||||
// Read preferences
|
// Read preferences
|
||||||
PrefsInit(argc, argv);
|
PrefsInit(argc, argv);
|
||||||
|
|
||||||
|
// Migrate preferences
|
||||||
|
PrefsMigrate();
|
||||||
|
|
||||||
// Show preferences editor
|
// Show preferences editor
|
||||||
bool start = PrefsEditor();
|
bool start = PrefsEditor();
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ prefs_desc platform_prefs_items[] = {
|
|||||||
{"debugextfs", TYPE_BOOLEAN, false, "debug extfs system"},
|
{"debugextfs", TYPE_BOOLEAN, false, "debug extfs system"},
|
||||||
{"extdrives", TYPE_STRING, false, "define allowed extfs drives"},
|
{"extdrives", TYPE_STRING, false, "define allowed extfs drives"},
|
||||||
{"pollmedia", TYPE_BOOLEAN, false, "poll for new media (e.g. cd, floppy)"},
|
{"pollmedia", TYPE_BOOLEAN, false, "poll for new media (e.g. cd, floppy)"},
|
||||||
|
{"etherguid", TYPE_STRING, false, "GUID of the ethernet device to use"},
|
||||||
{"etherpermanentaddress", TYPE_BOOLEAN, false, "use permanent NIC address to identify itself"},
|
{"etherpermanentaddress", TYPE_BOOLEAN, false, "use permanent NIC address to identify itself"},
|
||||||
{"ethermulticastmode", TYPE_INT32, false, "how to multicast packets"},
|
{"ethermulticastmode", TYPE_INT32, false, "how to multicast packets"},
|
||||||
{"etherfakeaddress", TYPE_STRING, false, "optional fake hardware address"},
|
{"etherfakeaddress", TYPE_STRING, false, "optional fake hardware address"},
|
||||||
@ -130,7 +131,6 @@ void AddPlatformPrefsDefaults(void)
|
|||||||
#endif
|
#endif
|
||||||
PrefsReplaceBool("etherpermanentaddress", true);
|
PrefsReplaceBool("etherpermanentaddress", true);
|
||||||
PrefsReplaceInt32("ethermulticastmode", 0);
|
PrefsReplaceInt32("ethermulticastmode", 0);
|
||||||
PrefsReplaceBool("routerenabled", false);
|
|
||||||
PrefsReplaceString("ftp_port_list", "21");
|
PrefsReplaceString("ftp_port_list", "21");
|
||||||
PrefsReplaceString("seriala", "COM1");
|
PrefsReplaceString("seriala", "COM1");
|
||||||
PrefsReplaceString("serialb", "COM2");
|
PrefsReplaceString("serialb", "COM2");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user