--- np2/x11/gtk2/gtk_menu.c 2008/03/18 15:03:48 1.13
+++ np2/x11/gtk2/gtk_menu.c 2012/01/23 04:57:24 1.28
@@ -1,7 +1,5 @@
-/* $Id: gtk_menu.c,v 1.13 2008/03/18 15:03:48 monaka Exp $ */
-
/*
- * Copyright (c) 2004 NONAKA Kimihiro (aw9k-nnk@asahi-net.or.jp)
+ * Copyright (c) 2004-2011 NONAKA Kimihiro
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -243,6 +241,7 @@ static GtkRadioActionEntry f12key_entrie
{ "f12mouse", NULL, "F12 = _Mouse", NULL, NULL, 0 },
{ "f12copy", NULL, "F12 = Co_py", NULL, NULL, 1 },
{ "f12stop", NULL, "F12 = S_top", NULL, NULL, 2 },
+{ "f12help", NULL, "F12 = _Help", NULL, NULL, 7 },
{ "f12equal", NULL, "F12 = tenkey [=]", NULL, NULL, 4 },
{ "f12comma", NULL, "F12 = tenkey [,]", NULL, NULL, 3 },
};
@@ -418,6 +417,7 @@ static const gchar *ui_info =
" \n"
" \n"
" \n"
+" \n"
" \n"
" \n"
" \n"
@@ -564,9 +564,6 @@ cb_bmpsave(GtkAction *action, gpointer u
SCRNBMP bmp = NULL;
FILEH fh;
- UNUSED(action);
- UNUSED(user_data);
-
uninstall_idle_process();
bmp = scrnbmp();
@@ -581,8 +578,11 @@ cb_bmpsave(GtkAction *action, gpointer u
if (dialog == NULL)
goto end;
- g_object_set(G_OBJECT(dialog), "show-hidden", TRUE, NULL);
- gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);
+ gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog), TRUE);
+#if GTK_MAJOR_VERSION >= 2 && GTK_MINOR_VERSION >= 8
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog),
+ TRUE);
+#endif
if (strlen(bmpfilefolder) == 0) {
g_strlcpy(bmpfilefolder, modulefile, sizeof(bmpfilefolder));
file_cutname(bmpfilefolder);
@@ -614,6 +614,12 @@ cb_bmpsave(GtkAction *action, gpointer u
if (utf8) {
path = g_filename_from_utf8(utf8, -1, NULL, NULL, NULL);
if (path) {
+ gchar *ext = file_getext(path);
+ if (strlen(ext) != 3 || file_cmpname(ext, "bmp")) {
+ gchar *tmp = g_strjoin(".", path, "bmp", NULL);
+ g_free(path);
+ path = tmp;
+ }
file_cpyname(bmpfilefolder, path, sizeof(bmpfilefolder));
sysmng_update(SYS_UPDATEOSCFG);
fh = file_create(path);
@@ -642,9 +648,6 @@ cb_change_font(GtkAction *action, gpoint
gchar *utf8, *path;
struct stat sb;
- UNUSED(action);
- UNUSED(user_data);
-
uninstall_idle_process();
dialog = gtk_file_chooser_dialog_new("Open a font file",
@@ -655,8 +658,7 @@ cb_change_font(GtkAction *action, gpoint
if (dialog == NULL)
goto end;
- g_object_set(G_OBJECT(dialog), "show-hidden", TRUE, NULL);
- gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);
+ gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog), TRUE);
utf8 = g_filename_to_utf8(np2cfg.fontfile, -1, NULL, NULL, NULL);
if (utf8) {
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), utf8);
@@ -708,8 +710,6 @@ cb_diskeject(GtkAction *action, gpointer
const gchar *name = gtk_action_get_name(action);
guint drive;
- UNUSED(user_data);
-
/* name = "disk?eject" */
if ((strlen(name) >= 5) && (g_ascii_isdigit(name[4]))) {
drive = g_ascii_digit_value(name[4]) - 1;
@@ -730,8 +730,6 @@ cb_diskopen(GtkAction *action, gpointer
const gchar *name = gtk_action_get_name(action);
guint drive;
- UNUSED(user_data);
-
if ((strlen(name) < 5) || (!g_ascii_isdigit(name[4])))
return;
drive = g_ascii_digit_value(name[4]) - 1;
@@ -746,8 +744,7 @@ cb_diskopen(GtkAction *action, gpointer
if (dialog == NULL)
goto end;
- g_object_set(G_OBJECT(dialog), "show-hidden", TRUE, NULL);
- gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);
+ gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog), TRUE);
utf8 = g_filename_to_utf8(fddfolder, -1, NULL, NULL, NULL);
if (utf8) {
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), utf8);
@@ -773,6 +770,7 @@ cb_diskopen(GtkAction *action, gpointer
gtk_file_filter_add_pattern(filter, "*.2[hH][dD]");
gtk_file_filter_add_pattern(filter, "*.[fF][dD][iI]");
gtk_file_filter_add_pattern(filter, "*.[fF][sS]");
+ gtk_file_filter_add_pattern(filter, "*.[fF][lL][pP]");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
}
filter = gtk_file_filter_new();
@@ -789,6 +787,7 @@ cb_diskopen(GtkAction *action, gpointer
gtk_file_filter_add_pattern(filter, "*.2[hH][dD]");
gtk_file_filter_add_pattern(filter, "*.[fF][dD][iI]");
gtk_file_filter_add_pattern(filter, "*.[fF][sS]");
+ gtk_file_filter_add_pattern(filter, "*.[fF][lL][pP]");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
}
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
@@ -833,8 +832,6 @@ cb_ataopen(GtkAction *action, gpointer u
const gchar *name = gtk_action_get_name(action);
guint channel, drive;
- UNUSED(user_data);
-
/* "ata??open" */
if ((strlen(name) < 5)
|| (!g_ascii_isdigit(name[3]))
@@ -857,8 +854,7 @@ cb_ataopen(GtkAction *action, gpointer u
if (dialog == NULL)
goto end;
- g_object_set(G_OBJECT(dialog), "show-hidden", TRUE, NULL);
- gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);
+ gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog), TRUE);
utf8 = g_filename_to_utf8(hddfolder, -1, NULL, NULL, NULL);
if (utf8) {
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), utf8);
@@ -910,8 +906,6 @@ cb_ataremove(GtkAction *action, gpointer
const gchar *name = gtk_action_get_name(GTK_ACTION(action));
guint channel, drive;
- UNUSED(user_data);
-
/* "ata??open" */
if ((strlen(name) < 5)
|| (!g_ascii_isdigit(name[3]))
@@ -936,9 +930,6 @@ cb_atapiopen(GtkAction *action, gpointer
gchar *utf8, *path;
struct stat sb;
- UNUSED(action);
- UNUSED(user_data);
-
uninstall_idle_process();
dialog = gtk_file_chooser_dialog_new("Open a ATAPI CD-ROM image",
@@ -949,8 +940,7 @@ cb_atapiopen(GtkAction *action, gpointer
if (dialog == NULL)
goto end;
- g_object_set(G_OBJECT(dialog), "show-hidden", TRUE, NULL);
- gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);
+ gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog), TRUE);
utf8 = g_filename_to_utf8(hddfolder, -1, NULL, NULL, NULL);
if (utf8) {
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), utf8);
@@ -1004,9 +994,6 @@ static void
cb_atapiremove(GtkAction *action, gpointer user_data)
{
- UNUSED(action);
- UNUSED(user_data);
-
sxsi_devclose(0x02);
}
#endif /* SUPPORT_IDEIO */
@@ -1015,9 +1002,6 @@ static void
cb_midipanic(GtkAction *action, gpointer user_data)
{
- UNUSED(action);
- UNUSED(user_data);
-
rs232c_midipanic();
mpu98ii_midipanic();
pc9861k_midipanic();
@@ -1046,9 +1030,6 @@ cb_newdisk(GtkAction *action, gpointer u
int kind;
int i;
- UNUSED(action);
- UNUSED(user_data);
-
uninstall_idle_process();
dialog = gtk_file_chooser_dialog_new("Create new disk image file",
@@ -1059,8 +1040,11 @@ cb_newdisk(GtkAction *action, gpointer u
if (dialog == NULL)
goto end;
- g_object_set(G_OBJECT(dialog), "show-hidden", TRUE, NULL);
- gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);
+ gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog), TRUE);
+#if GTK_MAJOR_VERSION >= 2 && GTK_MINOR_VERSION >= 8
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog),
+ TRUE);
+#endif
if (strlen(fddfolder) == 0) {
g_strlcpy(fddfolder, modulefile, sizeof(fddfolder));
file_cutname(fddfolder);
@@ -1078,7 +1062,7 @@ cb_newdisk(GtkAction *action, gpointer u
filter[0] = gtk_file_filter_new();
if (filter[0]) {
- gtk_file_filter_set_name(filter[0], "D88 floppy disk image");
+ gtk_file_filter_set_name(filter[0], "D88 floppy disk image (*.d88,*.d98,*.88d,*.98d)");
gtk_file_filter_add_pattern(filter[0], "*.[dD]88");
gtk_file_filter_add_pattern(filter[0], "*.88[dD]");
gtk_file_filter_add_pattern(filter[0], "*.[dD]98");
@@ -1087,19 +1071,19 @@ cb_newdisk(GtkAction *action, gpointer u
}
filter[1] = gtk_file_filter_new();
if (filter[1]) {
- gtk_file_filter_set_name(filter[1], "Anex86 hard disk image files");
+ gtk_file_filter_set_name(filter[1], "Anex86 hard disk image (*.hdi)");
gtk_file_filter_add_pattern(filter[1], "*.[hH][dD][iI]");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter[1]);
}
filter[2] = gtk_file_filter_new();
if (filter[2]) {
- gtk_file_filter_set_name(filter[2], "T98 hard disk image files");
+ gtk_file_filter_set_name(filter[2], "T98 hard disk image (*.thd)");
gtk_file_filter_add_pattern(filter[2], "*.[tT][hH][dD]");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter[2]);
}
filter[3] = gtk_file_filter_new();
if (filter[3]) {
- gtk_file_filter_set_name(filter[3], "T98-Next hard disk image files");
+ gtk_file_filter_set_name(filter[3], "T98-Next hard disk image (*.nhd)");
gtk_file_filter_add_pattern(filter[3], "*.[nN][hH][dD]");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter[3]);
}
@@ -1172,9 +1156,6 @@ static void
cb_reset(GtkAction *action, gpointer user_data)
{
- UNUSED(action);
- UNUSED(user_data);
-
pccore_cfgupdate();
pccore_reset();
}
@@ -1190,8 +1171,6 @@ cb_sasiopen(GtkAction *action, gpointer
const gchar *name = gtk_action_get_name(action);
guint drive;
- UNUSED(user_data);
-
if ((strlen(name) < 5) || (!g_ascii_isdigit(name[4])))
return;
drive = g_ascii_digit_value(name[4]) - 1;
@@ -1206,8 +1185,7 @@ cb_sasiopen(GtkAction *action, gpointer
if (dialog == NULL)
goto end;
- g_object_set(G_OBJECT(dialog), "show-hidden", TRUE, NULL);
- gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);
+ gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog), TRUE);
utf8 = g_filename_to_utf8(hddfolder, -1, NULL, NULL, NULL);
if (utf8) {
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), utf8);
@@ -1259,8 +1237,6 @@ cb_sasiremove(GtkAction *action, gpointe
const gchar *name = gtk_action_get_name(GTK_ACTION(action));
guint drive;
- UNUSED(user_data);
-
/* name = "sasi?eject" */
if ((strlen(name) >= 5) && (g_ascii_isdigit(name[4]))) {
drive = g_ascii_digit_value(name[4]) - 1;
@@ -1279,8 +1255,6 @@ cb_statsave(GtkAction *action, gpointer
char ext[4];
guint n;
- UNUSED(user_data);
-
/* name = "stat??save" */
if ((strlen(name) >= 6)
&& (g_ascii_isdigit(name[4]))
@@ -1299,8 +1273,6 @@ cb_statload(GtkAction *action, gpointer
char ext[4];
guint n;
- UNUSED(user_data);
-
/* name = "stat??load" */
if ((strlen(name) >= 6)
&& (g_ascii_isdigit(name[4]))
@@ -1318,8 +1290,6 @@ cb_dialog(GtkAction *action, gpointer us
{
const gchar *name = gtk_action_get_name(action);
- UNUSED(user_data);
-
if (g_ascii_strcasecmp(name, "configure") == 0) {
create_configure_dialog();
} else if (g_ascii_strcasecmp(name, "soundopt") == 0) {
@@ -1346,8 +1316,6 @@ cb_clockdisp(GtkToggleAction *action, gp
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2oscfg.DISPCLK & 1) ^ (b ? 1 : 0);
if (f) {
np2oscfg.DISPCLK ^= 1;
@@ -1363,8 +1331,6 @@ cb_dispvsync(GtkToggleAction *action, gp
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2cfg.DISPSYNC ? 1 : 0) ^ (b ? 1 : 0);
if (f) {
np2cfg.DISPSYNC = !np2cfg.DISPSYNC;
@@ -1378,8 +1344,6 @@ cb_framedisp(GtkToggleAction *action, gp
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2oscfg.DISPCLK & 2) ^ (b ? 2 : 0);
if (f) {
np2oscfg.DISPCLK ^= 2;
@@ -1395,8 +1359,6 @@ cb_jastsound(GtkToggleAction *action, gp
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2oscfg.jastsnd ? 1 : 0) ^ (b ? 1 : 0);
if (f) {
np2oscfg.jastsnd = !np2oscfg.jastsnd;
@@ -1410,8 +1372,6 @@ cb_joyrapid(GtkToggleAction *action, gpo
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2cfg.BTN_RAPID ? 1 : 0) ^ (b ? 1 : 0);
if (f) {
np2cfg.BTN_RAPID = !np2cfg.BTN_RAPID;
@@ -1425,8 +1385,6 @@ cb_joyreverse(GtkToggleAction *action, g
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2cfg.BTN_MODE ? 1 : 0) ^ (b ? 1 : 0);
if (f) {
np2cfg.BTN_MODE = !np2cfg.BTN_MODE;
@@ -1440,8 +1398,6 @@ cb_keydisplay(GtkToggleAction *action, g
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2oscfg.keydisp ? 1 : 0) ^ (b ? 1 : 0);
if (f) {
np2oscfg.keydisp = !np2oscfg.keydisp;
@@ -1460,8 +1416,6 @@ cb_mousemode(GtkToggleAction *action, gp
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2oscfg.MOUSE_SW ? 1 : 0) ^ (b ? 1 : 0);
if (f) {
mouse_running(MOUSE_XOR);
@@ -1476,8 +1430,6 @@ cb_mouserapid(GtkToggleAction *action, g
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2cfg.MOUSERAPID ? 1 : 0) ^ (b ? 1 : 0);
if (f) {
np2cfg.MOUSERAPID = !np2cfg.MOUSERAPID;
@@ -1491,8 +1443,6 @@ cb_nowait(GtkToggleAction *action, gpoin
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2oscfg.NOWAIT ? 1 : 0) ^ (b ? 1 : 0);
if (f) {
np2oscfg.NOWAIT = !np2oscfg.NOWAIT;
@@ -1506,8 +1456,6 @@ cb_realpalettes(GtkToggleAction *action,
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2cfg.RASTER ? 1 : 0) ^ (b ? 1 : 0);
if (f) {
np2cfg.RASTER = !np2cfg.RASTER;
@@ -1523,8 +1471,6 @@ cb_s98logging(GtkToggleAction *action, g
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (s98logging ? 1 : 0) ^ (b ? 1 : 0);
if (f) {
s98logging = !s98logging;
@@ -1546,8 +1492,6 @@ cb_seeksound(GtkToggleAction *action, gp
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2cfg.MOTOR ? 1 : 0) ^ (b ? 1 : 0);
if (f) {
np2cfg.MOTOR = !np2cfg.MOTOR;
@@ -1561,8 +1505,6 @@ cb_softkeyboard(GtkToggleAction *action,
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2oscfg.softkbd ? 1 : 0) ^ (b ? 1 : 0);
if (f) {
np2oscfg.softkbd = !np2oscfg.softkbd;
@@ -1581,8 +1523,6 @@ cb_toolwindow(GtkToggleAction *action, g
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2oscfg.toolwin ? 1 : 0) ^ (b ? 1 : 0);
if (f) {
np2oscfg.toolwin = !np2oscfg.toolwin;
@@ -1601,8 +1541,6 @@ cb_xctrlkey(GtkToggleAction *action, gpo
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2cfg.XSHIFT & 2) ^ (b ? 2 : 0);
if (f) {
np2cfg.XSHIFT ^= 2;
@@ -1617,8 +1555,6 @@ cb_xgrphkey(GtkToggleAction *action, gpo
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2cfg.XSHIFT & 4) ^ (b ? 4 : 0);
if (f) {
np2cfg.XSHIFT ^= 4;
@@ -1633,8 +1569,6 @@ cb_xshiftkey(GtkToggleAction *action, gp
gboolean b = gtk_toggle_action_get_active(action);
gboolean f;
- UNUSED(user_data);
-
f = (np2cfg.XSHIFT & 1) ^ (b ? 1 : 0);
if (f) {
np2cfg.XSHIFT ^= 1;
@@ -1788,12 +1722,10 @@ cb_soundboard(gint idx)
static void
cb_radio(GtkRadioAction *action, GtkRadioAction *current, gpointer user_data)
{
- guint value = (guint)gtk_radio_action_get_current_value(action);
+ gint value = gtk_radio_action_get_current_value(action);
guint menu_idx = (guint)GPOINTER_TO_INT(user_data);
gint i;
- UNUSED(current); /* emitted item */
-
if (menu_idx < n_radiomenu_entries) {
for (i = 0; i < radiomenu_entries[menu_idx].count; i++) {
if (radiomenu_entries[menu_idx].entry[i].value == value)
@@ -1821,8 +1753,6 @@ static gboolean
menubar_timeout(gpointer p)
{
- UNUSED(p);
-
if (menubar_timerid) {
g_source_remove(menubar_timerid);
menubar_timerid = 0;
@@ -1843,10 +1773,6 @@ static gboolean
enter_notify_evhandler(GtkWidget *w, GdkEventCrossing *ev, gpointer p)
{
- UNUSED(w);
- UNUSED(ev);
- UNUSED(p);
-
if (menubar_timerid) {
g_source_remove(menubar_timerid);
menubar_timerid = 0;
@@ -1863,10 +1789,6 @@ static gboolean
leave_notify_evhandler(GtkWidget *w, GdkEventCrossing *ev, gpointer p)
{
- UNUSED(w);
- UNUSED(ev);
- UNUSED(p);
-
if (menubar_timerid) {
g_source_remove(menubar_timerid);
menubar_timerid = 0;
@@ -2037,9 +1959,9 @@ create_menu(void)
gtk_widget_add_events(menubar, EVENT_MASK);
g_signal_connect(GTK_OBJECT(menubar), "enter_notify_event",
- GTK_SIGNAL_FUNC(enter_notify_evhandler), NULL);
+ G_CALLBACK(enter_notify_evhandler), NULL);
g_signal_connect(GTK_OBJECT(menubar), "leave_notify_event",
- GTK_SIGNAL_FUNC(leave_notify_evhandler), NULL);
+ G_CALLBACK(leave_notify_evhandler), NULL);
return menubar;
}
@@ -2062,7 +1984,7 @@ void
xmenu_toggle_menu(void)
{
- if (GTK_WIDGET_VISIBLE(menubar))
+ if (gtk_widget_get_visible(menubar))
xmenu_hide();
else
xmenu_show();