From d04010b342e7d77d2fda55f13f09ef5b05e076b1 Mon Sep 17 00:00:00 2001 From: evilynux Date: Fri, 12 Jan 2007 23:45:51 +0000 Subject: [PATCH] Added some idiot proof protection. Still needs improvements. --- desmume/src/gtk-glade/callbacks.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/desmume/src/gtk-glade/callbacks.c b/desmume/src/gtk-glade/callbacks.c index 98ceeaf6f..78c8838a6 100755 --- a/desmume/src/gtk-glade/callbacks.c +++ b/desmume/src/gtk-glade/callbacks.c @@ -191,9 +191,29 @@ void on_menu_controls_activate (GtkMenuItem *menuitem, gpointer user_data) void on_menu_joy_controls_activate (GtkMenuItem *menuitem, gpointer user_data) { - GtkDialog * dlg = (GtkDialog*)glade_xml_get_widget(xml, "wJoyConfDlg"); - init_joy_labels(); - gtk_dialog_run(dlg); + GtkDialog * dlg; + GtkDialog * msgbox; + + if(nbr_joy>0) /* At least one joystick */ + { + dlg = (GtkDialog*)glade_xml_get_widget(xml, "wJoyConfDlg"); + init_joy_labels(); + gtk_dialog_run(dlg); + } + else + { + dlg = (GtkDialog*)glade_xml_get_widget(xml, "wMainW"); + msgbox = + gtk_message_dialog_new(dlg, + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_CLOSE, + "You don't have any joystick!" + ); + g_signal_connect(G_OBJECT(msgbox), "response", G_CALLBACK(gtk_widget_destroy), NULL); + + gtk_dialog_run( msgbox ); + } } void on_menu_audio_on_activate (GtkMenuItem *menuitem, gpointer user_data) {