-
Notifications
You must be signed in to change notification settings - Fork 45
/
configure_dialog.c
150 lines (126 loc) · 4.95 KB
/
configure_dialog.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/* Copyright (C)
* 2018 - John Melton, G0ORX/N6LYT
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <gtk/gtk.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#ifdef SOAPYSDR
#include <SoapySDR/Device.h>
#endif
#include "bpsk.h"
#include "receiver.h"
#include "transmitter.h"
#include "wideband.h"
#include "discovered.h"
#include "adc.h"
#include "dac.h"
#include "radio.h"
#include "main.h"
#include "radio_dialog.h"
#include "transmitter_dialog.h"
#include "puresignal_dialog.h"
#include "pa_dialog.h"
#include "eer_dialog.h"
#include "oc_dialog.h"
#include "xvtr_dialog.h"
#include "receiver_dialog.h"
#include "about_dialog.h"
#include "wideband_dialog.h"
#ifdef MIDI
#include "midi.h"
#include "midi_dialog.h"
#endif
int rx_base=3; // number of tabs before receivers
static GtkWidget *notebook;
static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) {
RADIO *radio=(RADIO *)data;
int i;
save_xvtr();
configure_midi_device(false);
radio->dialog=NULL;
for(i=0;i<radio->discovered->supported_receivers;i++) {
if(radio->receiver[i]!=NULL) {
radio->receiver[i]->dialog=NULL;
radio->receiver[i]->band_grid=NULL;
radio->receiver[i]->mode_grid=NULL;
radio->receiver[i]->filter_frame=NULL;
radio->receiver[i]->filter_grid=NULL;
}
}
return FALSE;
}
static gboolean switch_page_event(GtkNotebook *notebook,GtkWidget *page,guint page_num,gpointer data) {
GtkWidget *label=gtk_notebook_get_tab_label(notebook,page);
const char *text=gtk_label_get_text(GTK_LABEL(label));
g_print("switch_page: %d %s\n",page_num,text);
if(strncmp("RX",text,2)==0) {
int rx=atoi(&text[3]);
//g_print("switch_page: %d %s rx=%d\n",page_num,text,rx);
update_receiver_dialog(radio->receiver[rx]);
}
if(strncmp("TX",text,2)==0) {
update_transmitter_dialog(radio->transmitter);
}
return TRUE;
}
GtkWidget *create_configure_dialog(RADIO *radio,int tab) {
int i;
gchar title[64];
g_snprintf((gchar *)&title,sizeof(title),"Linux HPSDR: %s %s",radio->discovered->name,inet_ntoa(radio->discovered->info.network.address.sin_addr));
GtkWidget *dialog=gtk_dialog_new();
gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(main_window));
gtk_window_set_title(GTK_WINDOW(dialog),title);
g_signal_connect (dialog,"delete_event",G_CALLBACK(delete_event),(gpointer)radio);
GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog));
notebook=gtk_notebook_new();
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),create_radio_dialog(radio),gtk_label_new("Radio"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),create_oc_dialog(radio),gtk_label_new("OC"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),create_xvtr_dialog(radio),gtk_label_new("XVTR"));
for(i=0;i<radio->discovered->supported_receivers;i++) {
if(radio->receiver[i]!=NULL) {
g_snprintf((gchar *)&title,sizeof(title),"RX-%d",radio->receiver[i]->channel);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),create_receiver_dialog(radio->receiver[i]),gtk_label_new(title));
}
}
if(radio->can_transmit) {
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),create_transmitter_dialog(radio->transmitter),gtk_label_new("TX"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),create_puresignal_dialog(radio->transmitter),gtk_label_new("Pure Signal"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),create_pa_dialog(radio),gtk_label_new("PA"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),create_eer_dialog(radio),gtk_label_new("EER"));
}
if(radio->wideband) {
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),create_wideband_dialog(radio->wideband),gtk_label_new("Wideband"));
}
#ifdef MIDI
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),create_midi_dialog(radio),gtk_label_new("MIDI"));
#endif
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),create_about_dialog(radio),gtk_label_new("About"));
gtk_container_add(GTK_CONTAINER(content),notebook);
gtk_widget_show_all(dialog);
gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook),tab);
g_signal_connect (notebook,"switch-page",G_CALLBACK(switch_page_event),(gpointer)radio);
return dialog;
}
void configure_dialog_set_tab(int tab) {
gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook),tab);
}