|
|
| version 1.1, 2004/07/15 14:24:33 | version 1.3, 2005/03/12 12:36:57 |
|---|---|
| Line 12 | Line 12 |
| * 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright |
| * notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the |
| * documentation and/or other materials provided with the distribution. | * documentation and/or other materials provided with the distribution. |
| * 3. The name of the author may not be used to endorse or promote products | |
| * derived from this software without specific prior written permission. | |
| * | * |
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| Line 83 static BYTE mpuopt; | Line 81 static BYTE mpuopt; |
| static void | static void |
| ok_button_clicked(GtkButton *b, gpointer d) | ok_button_clicked(GtkButton *b, gpointer d) |
| { | { |
| const gchar *p; | const gchar *utf8; |
| gchar *p; | |
| BOOL enable; | BOOL enable; |
| UINT update; | UINT update; |
| int i; | int i; |
| Line 94 ok_button_clicked(GtkButton *b, gpointer | Line 93 ok_button_clicked(GtkButton *b, gpointer |
| if (np2cfg.mpuopt != mpuopt) { | if (np2cfg.mpuopt != mpuopt) { |
| update |= SYS_UPDATECFG | SYS_UPDATEMIDI; | update |= SYS_UPDATECFG | SYS_UPDATEMIDI; |
| } | } |
| p = gtk_entry_get_text(GTK_ENTRY(mpu98_midiout_entry)); | utf8 = gtk_entry_get_text(GTK_ENTRY(mpu98_midiout_entry)); |
| if (p != NULL) { | if (utf8 != NULL) { |
| if (milstr_cmp(np2oscfg.mpu.mout, p)) { | p = g_filename_from_utf8(utf8, -1, NULL, NULL, NULL); |
| milstr_ncpy(np2oscfg.mpu.mout, p, sizeof(np2oscfg.mpu.mout)); | if (p != NULL) { |
| update |= SYS_UPDATECFG | SYS_UPDATEMIDI; | if (milstr_cmp(np2oscfg.mpu.mout, p)) { |
| } | milstr_ncpy(np2oscfg.mpu.mout, p, sizeof(np2oscfg.mpu.mout)); |
| } | update |= SYS_UPDATECFG | SYS_UPDATEMIDI; |
| p = gtk_entry_get_text(GTK_ENTRY(mpu98_midiin_entry)); | } |
| if (p != NULL) { | g_free(p); |
| if (milstr_cmp(np2oscfg.mpu.min, p)) { | } |
| milstr_ncpy(np2oscfg.mpu.min, p, sizeof(np2oscfg.mpu.min)); | } |
| update |= SYS_UPDATECFG | SYS_UPDATEMIDI; | utf8 = gtk_entry_get_text(GTK_ENTRY(mpu98_midiin_entry)); |
| } | if (utf8 != NULL) { |
| } | p = g_filename_from_utf8(utf8, -1, NULL, NULL, NULL); |
| p = gtk_entry_get_text(GTK_ENTRY(mpu98_module_entry)); | if (p != NULL) { |
| if (p != NULL) { | if (milstr_cmp(np2oscfg.mpu.min, p)) { |
| if (milstr_cmp(np2oscfg.mpu.mdl, p)) { | milstr_ncpy(np2oscfg.mpu.min, p, sizeof(np2oscfg.mpu.min)); |
| milstr_ncpy(np2oscfg.mpu.mdl, p, sizeof(np2oscfg.mpu.mdl)); | update |= SYS_UPDATECFG | SYS_UPDATEMIDI; |
| update |= SYS_UPDATECFG | SYS_UPDATEMIDI; | } |
| g_free(p); | |
| } | |
| } | |
| utf8 = gtk_entry_get_text(GTK_ENTRY(mpu98_module_entry)); | |
| if (utf8 != NULL) { | |
| p = g_filename_from_utf8(utf8, -1, NULL, NULL, NULL); | |
| if (p != NULL) { | |
| if (milstr_cmp(np2oscfg.mpu.mdl, p)) { | |
| milstr_ncpy(np2oscfg.mpu.mdl, p, sizeof(np2oscfg.mpu.mdl)); | |
| update |= SYS_UPDATECFG | SYS_UPDATEMIDI; | |
| } | |
| g_free(p); | |
| } | } |
| } | } |
| /* MIMPI def enable/file */ | /* MIMPI def enable/file */ |
| enable = GTK_TOGGLE_BUTTON(mpu98_mimpi_def_checkbutton)->active ? 1 : 0; | enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mpu98_mimpi_def_checkbutton)) ? 1 : 0; |
| if (np2oscfg.mpu.def_en != enable) { | if (np2oscfg.mpu.def_en != enable) { |
| np2oscfg.mpu.def_en = enable; | np2oscfg.mpu.def_en = enable; |
| if (cm_mpu98) { | if (cm_mpu98) { |
| Line 125 ok_button_clicked(GtkButton *b, gpointer | Line 136 ok_button_clicked(GtkButton *b, gpointer |
| } | } |
| update |= SYS_UPDATEOSCFG; | update |= SYS_UPDATEOSCFG; |
| } | } |
| p = gtk_entry_get_text(GTK_ENTRY(mpu98_mimpi_def_entry)); | utf8 = gtk_entry_get_text(GTK_ENTRY(mpu98_mimpi_def_entry)); |
| if (p != NULL) { | if (utf8 != NULL) { |
| if (milstr_cmp(np2oscfg.mpu.def, p)) { | p = g_filename_from_utf8(utf8, -1, NULL, NULL, NULL); |
| milstr_ncpy(np2oscfg.mpu.def, p, sizeof(np2oscfg.mpu.def)); | if (p != NULL) { |
| if (cm_mpu98) { | if (milstr_cmp(np2oscfg.mpu.def, p)) { |
| (*cm_mpu98->msg)(cm_mpu98, COMMSG_MIMPIDEFFILE, (long)p); | milstr_ncpy(np2oscfg.mpu.def, p, sizeof(np2oscfg.mpu.def)); |
| if (cm_mpu98) { | |
| (*cm_mpu98->msg)(cm_mpu98, COMMSG_MIMPIDEFFILE, (long)p); | |
| } | |
| update |= SYS_UPDATEOSCFG; | |
| } | } |
| update |= SYS_UPDATEOSCFG; | g_free(p); |
| } | } |
| } | } |
| /* MIDI-IN/OUT device */ | /* MIDI-IN/OUT device */ |
| for (i = 0; i < NELEMENTS(mpu98_devname_str); i++) { | for (i = 0; i < NELEMENTS(mpu98_devname_str); i++) { |
| p = gtk_entry_get_text(GTK_ENTRY(mpu98_devname_entry[i])); | utf8 = gtk_entry_get_text(GTK_ENTRY(mpu98_devname_entry[i])); |
| if (p != NULL) { | if (utf8 != NULL) { |
| if (milstr_cmp(np2oscfg.MIDIDEV[i], p)) { | p = g_filename_from_utf8(utf8, -1, NULL, NULL, NULL); |
| milstr_ncpy(np2oscfg.MIDIDEV[i], p, sizeof(np2oscfg.MIDIDEV[0])); | if (p != NULL) { |
| update |= SYS_UPDATEOSCFG; | if (milstr_cmp(np2oscfg.MIDIDEV[i], p)) { |
| milstr_ncpy(np2oscfg.MIDIDEV[i], p, sizeof(np2oscfg.MIDIDEV[0])); | |
| update |= SYS_UPDATEOSCFG; | |
| } | |
| g_free(p); | |
| } | } |
| } | } |
| } | } |
| Line 167 dialog_destroy(GtkWidget *w, GtkWidget * | Line 186 dialog_destroy(GtkWidget *w, GtkWidget * |
| static void | static void |
| mpu98_ioport_entry_changed(GtkEditable *e, gpointer d) | mpu98_ioport_entry_changed(GtkEditable *e, gpointer d) |
| { | { |
| const gchar *p; | const gchar *utf8; |
| gchar *p; | |
| BYTE val; | BYTE val; |
| UNUSED(d); | UNUSED(d); |
| p = gtk_entry_get_text(GTK_ENTRY(e)); | |
| if ((p != NULL) && (strlen(p) >= 4)) { | utf8 = gtk_entry_get_text(GTK_ENTRY(e)); |
| val = (milstr_solveHEX(p) >> 6) & 0xf0; | if (utf8 != NULL) { |
| mpuopt &= ~0xf0; | p = g_filename_from_utf8(utf8, -1, NULL, NULL, NULL); |
| mpuopt |= val; | if (p != NULL) { |
| if (strlen(p) >= 4) { | |
| val = (milstr_solveHEX(p) >> 6) & 0xf0; | |
| mpuopt &= ~0xf0; | |
| mpuopt |= val; | |
| } | |
| g_free(p); | |
| } | |
| } | } |
| } | } |
| static void | static void |
| mpu98_intr_entry_changed(GtkEditable *e, gpointer d) | mpu98_intr_entry_changed(GtkEditable *e, gpointer d) |
| { | { |
| const gchar *p; | const gchar *utf8; |
| gchar *p; | |
| BYTE val; | BYTE val; |
| UNUSED(d); | UNUSED(d); |
| p = gtk_entry_get_text(GTK_ENTRY(e)); | utf8 = gtk_entry_get_text(GTK_ENTRY(e)); |
| if ((p != NULL) && (strlen(p) >= 4)) { | if (utf8 != NULL) { |
| val = p[3] - '0'; | p = g_filename_from_utf8(utf8, -1, NULL, NULL, NULL); |
| if (val >= 3) | if (p != NULL) { |
| val = 3; | if (strlen(p) >= 4) { |
| mpuopt &= ~0x03; | val = p[3] - '0'; |
| mpuopt |= val; | if (val >= 3) |
| val = 3; | |
| mpuopt &= ~0x03; | |
| mpuopt |= val; | |
| } | |
| g_free(p); | |
| } | |
| } | } |
| } | } |
| Line 225 mpu98_mimpi_def_button_clicked(GtkButton | Line 259 mpu98_mimpi_def_button_clicked(GtkButton |
| GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
| NULL); | NULL); |
| if (dialog == NULL) | if (dialog == NULL) |
| return; | goto end; |
| g_object_set(G_OBJECT(dialog), "show-hidden", TRUE, NULL); | 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_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE); |
| utf8 = g_filename_to_utf8(np2oscfg.mpu.def, -1, NULL, NULL, NULL); | if (np2oscfg.mpu.def[0] != '\0') { |
| if (utf8) { | utf8 = g_filename_to_utf8(np2oscfg.mpu.def, -1, NULL, NULL, NULL); |
| gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), utf8); | if (utf8) { |
| g_free(utf8); | gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), utf8); |
| g_free(utf8); | |
| } | |
| } | } |
| filter = gtk_file_filter_new(); | filter = gtk_file_filter_new(); |
| Line 249 mpu98_mimpi_def_button_clicked(GtkButton | Line 285 mpu98_mimpi_def_button_clicked(GtkButton |
| gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); | gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); |
| } | } |
| if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { | if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK) |
| utf8 = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | goto end; |
| if (utf8) { | |
| path = g_filename_from_utf8(utf8, -1, NULL, NULL, NULL); | utf8 = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
| if (path) { | if (utf8) { |
| if ((stat(path, &sb) == 0) && S_ISREG(sb.st_mode) && (sb.st_mode & S_IRUSR)) { | path = g_filename_from_utf8(utf8, -1, NULL, NULL, NULL); |
| gtk_entry_set_text(GTK_ENTRY(mpu98_mimpi_def_entry), utf8); | if (path) { |
| } | if ((stat(path, &sb) == 0) && S_ISREG(sb.st_mode) && (sb.st_mode & S_IRUSR)) { |
| g_free(path); | gtk_entry_set_text(GTK_ENTRY(mpu98_mimpi_def_entry), utf8); |
| } | } |
| g_free(utf8); | g_free(path); |
| } | } |
| g_free(utf8); | |
| } | } |
| gtk_widget_destroy(dialog); | |
| end: | |
| if (dialog) | |
| gtk_widget_destroy(dialog); | |
| } | } |
| void | void |
| Line 290 create_midi_dialog(void) | Line 330 create_midi_dialog(void) |
| GtkWidget *ok_button; | GtkWidget *ok_button; |
| GtkWidget *cancel_button; | GtkWidget *cancel_button; |
| GtkWidget *mpu98_default_button; | GtkWidget *mpu98_default_button; |
| gchar *utf8; | |
| int i; | int i; |
| uninstall_idle_process(); | uninstall_idle_process(); |
| Line 317 create_midi_dialog(void) | Line 358 create_midi_dialog(void) |
| 0, 1, 0, 1); | 0, 1, 0, 1); |
| ioport_combo = gtk_combo_box_entry_new_text(); | ioport_combo = gtk_combo_box_entry_new_text(); |
| gtk_widget_set_size_request(ioport_combo, 80, -1); | |
| gtk_widget_show(ioport_combo); | gtk_widget_show(ioport_combo); |
| gtk_table_attach_defaults(GTK_TABLE(main_widget), ioport_combo, | gtk_table_attach_defaults(GTK_TABLE(main_widget), ioport_combo, |
| 1, 2, 0, 1); | 1, 2, 0, 1); |
| Line 342 create_midi_dialog(void) | Line 382 create_midi_dialog(void) |
| 0, 1, 1, 2); | 0, 1, 1, 2); |
| intr_combo = gtk_combo_box_entry_new_text(); | intr_combo = gtk_combo_box_entry_new_text(); |
| gtk_widget_set_size_request(intr_combo, 80, -1); | |
| gtk_widget_show(intr_combo); | gtk_widget_show(intr_combo); |
| gtk_table_attach_defaults(GTK_TABLE(main_widget), intr_combo, | gtk_table_attach_defaults(GTK_TABLE(main_widget), intr_combo, |
| 1, 2, 1, 2); | 1, 2, 1, 2); |
| Line 385 create_midi_dialog(void) | Line 424 create_midi_dialog(void) |
| gtk_table_attach_defaults(GTK_TABLE(deviceframe_widget), | gtk_table_attach_defaults(GTK_TABLE(deviceframe_widget), |
| mpu98_devname_entry[i], 1, 6, i, i + 1); | mpu98_devname_entry[i], 1, 6, i, i + 1); |
| gtk_entry_set_text(GTK_ENTRY(mpu98_devname_entry[i]), | if (np2oscfg.MIDIDEV[i][0] != '\0') { |
| np2oscfg.MIDIDEV[i]); | utf8 = g_filename_to_utf8(np2oscfg.MIDIDEV[i], -1, NULL, NULL, NULL); |
| if (utf8 != NULL) { | |
| gtk_entry_set_text(GTK_ENTRY(mpu98_devname_entry[i]), np2oscfg.MIDIDEV[i]); | |
| g_free(utf8); | |
| } | |
| } | |
| } | } |
| /* MIDI-IN disable */ | /* MIDI-IN disable */ |
| gtk_widget_set_sensitive(mpu98_devname_entry[1], FALSE); | gtk_widget_set_sensitive(mpu98_devname_entry[1], FALSE); |
| Line 512 create_midi_dialog(void) | Line 556 create_midi_dialog(void) |
| gtk_table_attach(GTK_TABLE(assignframe_widget), mpu98_mimpi_def_entry, | gtk_table_attach(GTK_TABLE(assignframe_widget), mpu98_mimpi_def_entry, |
| 0, 5, 4, 5, GTK_FILL, GTK_FILL, 3, 3); | 0, 5, 4, 5, GTK_FILL, GTK_FILL, 3, 3); |
| gtk_widget_set_sensitive(mpu98_mimpi_def_entry, FALSE); | gtk_widget_set_sensitive(mpu98_mimpi_def_entry, FALSE); |
| gtk_entry_set_text(GTK_ENTRY(mpu98_mimpi_def_entry), np2oscfg.mpu.def); | if (np2oscfg.mpu.def[0] != '\0') { |
| utf8 = g_filename_to_utf8(np2oscfg.mpu.def, -1, NULL, NULL, NULL); | |
| if (utf8 != NULL) { | |
| gtk_entry_set_text(GTK_ENTRY(mpu98_mimpi_def_entry), np2oscfg.mpu.def); | |
| g_free(utf8); | |
| } | |
| } | |
| mimpi_button = gtk_button_new_with_label("..."); | mimpi_button = gtk_button_new_with_label("..."); |
| gtk_widget_show(mimpi_button); | gtk_widget_show(mimpi_button); |
| gtk_table_attach(GTK_TABLE(assignframe_widget), mimpi_button, | gtk_table_attach(GTK_TABLE(assignframe_widget), mimpi_button, |
| 5, 6, 4, 5, GTK_FILL, GTK_FILL, 3, 3); | 5, 6, 4, 5, GTK_FILL, GTK_FILL, 3, 3); |
| g_signal_connect(GTK_OBJECT(mimpi_button), "clicked", | g_signal_connect(GTK_OBJECT(mimpi_button), "clicked", |
| GTK_SIGNAL_FUNC(mpu98_mimpi_def_button_clicked), 0); | GTK_SIGNAL_FUNC(mpu98_mimpi_def_button_clicked), midi_dialog); |
| /* | /* |
| * "Default" button | * "Default" button |