From f4de202472ece3e0c38eda2af2fc6d4a0eac74dc Mon Sep 17 00:00:00 2001 From: c vw Date: Tue, 1 Jun 2021 16:41:07 +0200 Subject: [PATCH] Do not display "Switch" menu if there is no controller --- new_menu.c | 72 +++++++++++++++--------------------------------------- 1 file changed, 20 insertions(+), 52 deletions(-) diff --git a/new_menu.c b/new_menu.c index e1ed1e1..c732a50 100644 --- a/new_menu.c +++ b/new_menu.c @@ -186,11 +186,13 @@ static gboolean rigctl_cb (GtkWidget *widget, GdkEventButton *event, gpointer da return TRUE; } +#ifdef GPIO static gboolean encoder_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { cleanup(); encoder_menu(top_window); return TRUE; } +#endif static gboolean switch_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { cleanup(); @@ -407,47 +409,6 @@ static gboolean ps_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) } #endif -#ifdef GPIO -/* -void start_encoder(int encoder) { - int old_menu=active_menu; - cleanup(); - switch(encoder) { - case 2: - if(old_menu!=E2_MENU) { - encoder_menu(top_window,encoder); - active_menu=E2_MENU; - } - break; - case 3: - if(old_menu!=E3_MENU) { - encoder_menu(top_window,encoder); - active_menu=E3_MENU; - } - break; - case 4: - if(old_menu!=E4_MENU) { - encoder_menu(top_window,encoder); - active_menu=E4_MENU; - } - break; - case 5: - if(old_menu!=E5_MENU) { - encoder_menu(top_window,encoder); - active_menu=E5_MENU; - } - break; - } -} - -static gboolean encoder_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { - int encoder=(int)data; - start_encoder(encoder); - return TRUE; -} -*/ -#endif - void start_test() { cleanup(); test_menu(top_window); @@ -627,19 +588,26 @@ void new_menu() gtk_grid_attach(GTK_GRID(grid),rigctl_b,(i%5),i/5,1,1); i++; + switch(controller) { + case NO_CONTROLLER: + break; + case CONTROLLER1: + case CONTROLLER2_V1: + case CONTROLLER2_V2: + { #ifdef GPIO - GtkWidget *encoders_b=gtk_button_new_with_label("Encoders"); - g_signal_connect (encoders_b, "button-press-event", G_CALLBACK(encoder_cb), NULL); - gtk_grid_attach(GTK_GRID(grid),encoders_b,(i%5),i/5,1,1); - i++; - - if(controller==CONTROLLER2_V1 || controller==CONTROLLER2_V2) { - GtkWidget *switches_b=gtk_button_new_with_label("Switches"); - g_signal_connect (switches_b, "button-press-event", G_CALLBACK(switch_cb), NULL); - gtk_grid_attach(GTK_GRID(grid),switches_b,(i%5),i/5,1,1); - i++; - } + GtkWidget *encoders_b=gtk_button_new_with_label("Encoders"); + g_signal_connect (encoders_b, "button-press-event", G_CALLBACK(encoder_cb), NULL); + gtk_grid_attach(GTK_GRID(grid),encoders_b,(i%5),i/5,1,1); + i++; #endif + GtkWidget *switches_b=gtk_button_new_with_label("Switches"); + g_signal_connect (switches_b, "button-press-event", G_CALLBACK(switch_cb), NULL); + gtk_grid_attach(GTK_GRID(grid),switches_b,(i%5),i/5,1,1); + i++; + } + break; + } #ifdef MIDI GtkWidget *midi_b=gtk_button_new_with_label("MIDI"); -- 2.45.2