Skip to content

Commit f2f0356

Browse files
committed
preferences fixes to pave way for cat control
1 parent 4dcb024 commit f2f0356

File tree

8 files changed

+223
-27
lines changed

8 files changed

+223
-27
lines changed

blueprints/preferences.blp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Adw.PreferencesDialog prefs_dialog {
128128
}
129129
}
130130
Adw.PreferencesPage radio_page {
131-
title: _("Radio");
131+
title: _("CAT Control");
132132
icon-name: "radio-console-symbolic";
133133

134134
Adw.PreferencesGroup radio_connection_group {
@@ -149,11 +149,11 @@ Adw.PreferencesDialog prefs_dialog {
149149

150150
/* Serial/USB settings group */
151151
Adw.PreferencesGroup serial_settings_group {
152-
title: _("Serial/USB Settings");
152+
title: _("Serial Settings");
153153

154-
Adw.EntryRow row_device_path {
155-
title: _("Device Path");
156-
text: "/dev/ttyUSB0";
154+
Adw.ComboRow row_device_path {
155+
title: _("Serial Port");
156+
subtitle: _("The path to your rig");
157157
}
158158

159159
Adw.ComboRow row_baud_rate {

src/RadioControl.vapi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ public struct RadioConfiguration {
2525
public int baud_rate;
2626
}
2727

28+
[CCode (cname = "RadioModel", has_type_id = false)]
29+
public struct RadioModel {
30+
public int model_id;
31+
public unowned string display_name;
32+
}
33+
2834
[CCode (cname = "RadioControl", cheader_filename="../src/radio_control.h")]
2935
public class RadioControl : GLib.Object {
3036
// Constructor
@@ -43,6 +49,8 @@ public class RadioControl : GLib.Object {
4349
// Property
4450
public bool is_rig_connected { get; }
4551

52+
public static unowned RadioModel[] get_radio_models ();
53+
4654
// Signals
4755
[CCode (cname = "radio-connected")]
4856
public signal void radio_connected ();

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ mathlib = cc.find_library('m', required: true)
3434

3535
artemis_vala_deps = [
3636
dependency('gtk4'),
37+
dependency('gudev-1.0'),
3738
dependency('libsoup-3.0'),
3839
dependency('json-glib-1.0'),
3940
dependency('libadwaita-1', version: '>= 1.4'),

src/preferences.vala

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020

2121
using Gee;
22+
using GUdev;
2223

2324
public sealed class PreferencesDialog : Object {
2425
private Adw.PreferencesDialog dialog;
@@ -31,12 +32,13 @@ public sealed class PreferencesDialog : Object {
3132

3233
private Adw.ComboRow row_connection_type;
3334
private Adw.ComboRow row_radio_model;
34-
private Adw.EntryRow row_device_path;
35+
private Adw.ComboRow row_device_path;
3536
private Adw.ComboRow row_baud_rate;
3637
private Adw.EntryRow row_network_host;
3738
private Adw.SpinRow row_network_port;
3839
private Adw.PreferencesGroup serial_settings_group;
3940
private Adw.PreferencesGroup network_settings_group;
41+
private Adw.PreferencesGroup radio_test_group;
4042

4143
private Adw.SwitchRow row_enable_logging;
4244
private Adw.SwitchRow row_use_metric;
@@ -54,20 +56,24 @@ public sealed class PreferencesDialog : Object {
5456
private Gtk.Label connection_status_label;
5557

5658
private File? logbook_csv = null;
59+
private GUdev.Client udev_client;
5760

5861
public PreferencesDialog () {
59-
var builder = new Gtk.Builder.from_resource (
60-
"/com/k0vcz/artemis/ui/preferences.ui");
62+
Object ();
63+
}
64+
65+
construct {
66+
var builder = new Gtk.Builder.from_resource ("/com/k0vcz/artemis/ui/preferences.ui");
6167

6268
dialog = builder.get_object ("prefs_dialog") as Adw.PreferencesDialog;
6369

64-
get_widgets (builder);
65-
setup_bindings ();
66-
setup_signals ();
67-
update_connection_groups_visibility ();
68-
}
70+
udev_client = new GUdev.Client ({"tty"});
71+
udev_client.uevent.connect ((action, device) => {
72+
if (row_device_path != null) {
73+
row_device_path.model = get_serial_devices ();
74+
}
75+
});
6976

70-
void get_widgets (Gtk.Builder builder) {
7177
row_callsign = builder.get_object ("row_callsign") as Adw.EntryRow;
7278
row_location = builder.get_object ("row_location") as Adw.EntryRow;
7379
row_spot_message = builder.get_object ("row_spot_message") as Adw.
@@ -81,10 +87,20 @@ public sealed class PreferencesDialog : Object {
8187

8288
row_connection_type = builder.get_object ("row_connection_type") as Adw.
8389
ComboRow;
84-
row_radio_model = builder.get_object ("row_radio_model") as Adw.ComboRow
85-
;
86-
row_device_path = builder.get_object ("row_device_path") as Adw.EntryRow
87-
;
90+
91+
row_radio_model = builder.get_object ("row_radio_model") as Adw.ComboRow;
92+
var radio_models = RadioControl.get_radio_models ();
93+
var radio_model_list = new Gtk.StringList ({_("None")});
94+
for (var i = 0; i < radio_models.length; i++) {
95+
radio_model_list.append (radio_models[i].display_name);
96+
}
97+
row_radio_model.model = radio_model_list;
98+
row_radio_model.enable_search = true;
99+
row_radio_model.search_match_mode = Gtk.StringFilterMatchMode.SUBSTRING;
100+
101+
row_device_path = builder.get_object ("row_device_path") as Adw.ComboRow;
102+
row_device_path.model = get_serial_devices ();
103+
88104
row_baud_rate = builder.get_object ("row_baud_rate") as Adw.ComboRow;
89105
row_network_host = builder.get_object ("row_network_host") as Adw.
90106
EntryRow;
@@ -93,8 +109,9 @@ public sealed class PreferencesDialog : Object {
93109
serial_settings_group = builder.get_object ("serial_settings_group") as
94110
Adw.PreferencesGroup;
95111
network_settings_group = builder.get_object ("network_settings_group")
96-
as
97-
Adw.PreferencesGroup;
112+
as Adw.PreferencesGroup;
113+
radio_test_group = builder.get_object ("radio_test_group") as Adw.PreferencesGroup;
114+
98115
row_hide_qrt = builder.get_object ("row_hide_qrt") as Adw.SwitchRow;
99116
row_show_scale = builder.get_object ("row_show_scale") as Adw.SwitchRow;
100117
row_hide_hunted = builder.get_object ("row_hide_hunted") as Adw.
@@ -121,6 +138,10 @@ public sealed class PreferencesDialog : Object {
121138
Gtk.Image;
122139
connection_status_label = builder.get_object ("connection_status_label")
123140
as Gtk.Label;
141+
142+
setup_bindings ();
143+
setup_signals ();
144+
update_connection_groups_visibility ();
124145
} /* get_widgets */
125146

126147
public void present (Gtk.Window parent) {
@@ -144,12 +165,10 @@ public sealed class PreferencesDialog : Object {
144165
bind_combo_to_string_setting ("default-mode", row_default_mode);
145166
bind_combo_to_string_setting ("radio-connection-type",
146167
row_connection_type);
168+
bind_combo_to_string_setting ("radio-device", row_device_path);
147169

148170
Application.settings.bind ("radio-model", row_radio_model, "selected",
149171
SettingsBindFlags.DEFAULT);
150-
Application.settings.bind ("radio-device", row_device_path, "text",
151-
SettingsBindFlags
152-
.DEFAULT);
153172
bind_baud_rate_combo ();
154173
Application.settings.bind ("radio-network-host", row_network_host,
155174
"text",
@@ -272,12 +291,21 @@ public sealed class PreferencesDialog : Object {
272291
case "usb":
273292
serial_settings_group.visible = true;
274293
network_settings_group.visible = false;
294+
row_radio_model.visible = true;
295+
radio_test_group.visible = true;
275296
break;
276297
case "network":
298+
row_radio_model.visible = true;
299+
row_radio_model.selected = 1;
300+
row_radio_model.selectable = false;
301+
277302
serial_settings_group.visible = false;
278303
network_settings_group.visible = true;
304+
radio_test_group.visible = true;
279305
break;
280306
default:
307+
radio_test_group.visible = false;
308+
row_radio_model.visible = false;
281309
serial_settings_group.visible = false;
282310
network_settings_group.visible = false;
283311
break;
@@ -392,4 +420,15 @@ public sealed class PreferencesDialog : Object {
392420
}
393421
});
394422
}
423+
424+
Gtk.StringList get_serial_devices () {
425+
var devices = udev_client.query_by_subsystem ("tty");
426+
var model = new Gtk.StringList ({});
427+
428+
devices.foreach ((device) => {
429+
model.append (device.get_device_file ());
430+
});
431+
432+
return model;
433+
}
395434
} /* class PreferencesDialog */

src/radio_control.c

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,128 @@
44
#include <libdex.h>
55
#include <hamlib/rig.h>
66
#include <sched.h>
7-
#include <signal.h>
87
#include <stdint.h>
98
#include <sys/types.h>
109
#include <unistd.h>
1110

11+
static const RadioModel RADIO_MODELS[] = {
12+
{ RIG_MODEL_NETRIGCTL, "NET rigctl" },
13+
{ RIG_MODEL_FLRIG, "FLRig" },
14+
15+
{ RIG_MODEL_K2, "Elecraft - K2" },
16+
{ RIG_MODEL_K3, "Elecraft - K3" },
17+
{ RIG_MODEL_K3S, "Elecraft - K3S" },
18+
{ RIG_MODEL_K4, "Elecraft - K4" },
19+
{ RIG_MODEL_KX2, "Elecraft - KX2" },
20+
{ RIG_MODEL_KX3, "Elecraft - KX3" },
21+
22+
{ RIG_MODEL_F6K, "FlexRadio - 6xxx Series" },
23+
24+
{ RIG_MODEL_IC703, "Icom - IC-703" },
25+
{ RIG_MODEL_IC705, "Icom - IC-705" },
26+
{ RIG_MODEL_IC706, "Icom - IC-706" },
27+
{ RIG_MODEL_IC706MKII, "Icom - IC-706MkII" },
28+
{ RIG_MODEL_IC706MKIIG, "Icom - IC-706MkIIG" },
29+
{ RIG_MODEL_IC707, "Icom - IC-707" },
30+
{ RIG_MODEL_IC718, "Icom - IC-718" },
31+
{ RIG_MODEL_IC746, "Icom - IC-746" },
32+
{ RIG_MODEL_IC746PRO, "Icom - IC-746PRO" },
33+
{ RIG_MODEL_IC756, "Icom - IC-756" },
34+
{ RIG_MODEL_IC756PRO, "Icom - IC-756PRO" },
35+
{ RIG_MODEL_IC756PROII, "Icom - IC-756PROII" },
36+
{ RIG_MODEL_IC756PROIII, "Icom - IC-756PROIII" },
37+
{ RIG_MODEL_IC7000, "Icom - IC-7000" },
38+
{ RIG_MODEL_IC7100, "Icom - IC-7100" },
39+
{ RIG_MODEL_IC7200, "Icom - IC-7200" },
40+
{ RIG_MODEL_IC7300, "Icom - IC-7300" },
41+
{ RIG_MODEL_IC7600, "Icom - IC-7600" },
42+
{ RIG_MODEL_IC7610, "Icom - IC-7610" },
43+
{ RIG_MODEL_IC7700, "Icom - IC-7700" },
44+
{ RIG_MODEL_IC7800, "Icom - IC-7800" },
45+
{ RIG_MODEL_IC785x, "Icom - IC-7850/7851" },
46+
{ RIG_MODEL_IC905, "Icom - IC-905" },
47+
{ RIG_MODEL_IC9100, "Icom - IC-9100" },
48+
{ RIG_MODEL_IC9700, "Icom - IC-9700" },
49+
50+
{ RIG_MODEL_TS50, "Kenwood - TS-50S" },
51+
{ RIG_MODEL_TS140S, "Kenwood - TS-140S" },
52+
{ RIG_MODEL_TS440, "Kenwood - TS-440S" },
53+
{ RIG_MODEL_TS450S, "Kenwood - TS-450S" },
54+
{ RIG_MODEL_TS480, "Kenwood - TS-480" },
55+
{ RIG_MODEL_TS570D, "Kenwood - TS-570D" },
56+
{ RIG_MODEL_TS570S, "Kenwood - TS-570S" },
57+
{ RIG_MODEL_TS590S, "Kenwood - TS-590S" },
58+
{ RIG_MODEL_TS590SG, "Kenwood - TS-590SG" },
59+
{ RIG_MODEL_TS680S, "Kenwood - TS-680S" },
60+
{ RIG_MODEL_TS690S, "Kenwood - TS-690S" },
61+
{ RIG_MODEL_TS790, "Kenwood - TS-790" },
62+
{ RIG_MODEL_TS850, "Kenwood - TS-850" },
63+
{ RIG_MODEL_TS870S, "Kenwood - TS-870S" },
64+
{ RIG_MODEL_TS890S, "Kenwood - TS-890S" },
65+
{ RIG_MODEL_TS940, "Kenwood - TS-940S" },
66+
{ RIG_MODEL_TS950S, "Kenwood - TS-950S" },
67+
{ RIG_MODEL_TS950SDX, "Kenwood - TS-950SDX" },
68+
{ RIG_MODEL_TS990S, "Kenwood - TS-990S" },
69+
{ RIG_MODEL_TS2000, "Kenwood - TS-2000" },
70+
71+
{ RIG_MODEL_TT516, "Ten-Tec - TT-516 Argonaut V" },
72+
{ RIG_MODEL_TT538, "Ten-Tec - TT-538 Jupiter" },
73+
{ RIG_MODEL_TT565, "Ten-Tec - TT-565/566 Orion I/II" },
74+
{ RIG_MODEL_TT588, "Ten-Tec - TT-588 Omni VII" },
75+
{ RIG_MODEL_TT599, "Ten-Tec - TT-599 Eagle" },
76+
77+
{ RIG_MODEL_G90, "Xiegu - G90" },
78+
{ RIG_MODEL_X108G, "Xiegu - X108G" },
79+
{ RIG_MODEL_X5105, "Xiegu - X5105" },
80+
{ RIG_MODEL_X6100, "Xiegu - X6100" },
81+
{ RIG_MODEL_X6200, "Xiegu - X6200" },
82+
83+
{ RIG_MODEL_FT100, "Yaesu - FT-100" },
84+
{ RIG_MODEL_FT1000D, "Yaesu - FT-1000D" },
85+
{ RIG_MODEL_FT1000MP, "Yaesu - FT-1000MP" },
86+
{ RIG_MODEL_FT450, "Yaesu - FT-450/450D" },
87+
{ RIG_MODEL_FT710, "Yaesu - FT-710" },
88+
{ RIG_MODEL_FT736R, "Yaesu - FT-736R" },
89+
{ RIG_MODEL_FT747, "Yaesu - FT-747GX" },
90+
{ RIG_MODEL_FT757, "Yaesu - FT-757GX" },
91+
{ RIG_MODEL_FT757GXII, "Yaesu - FT-757GXII" },
92+
{ RIG_MODEL_FT767, "Yaesu - FT-767GX" },
93+
{ RIG_MODEL_FT817, "Yaesu - FT-817" },
94+
{ RIG_MODEL_FT818, "Yaesu - FT-818" },
95+
{ RIG_MODEL_FT840, "Yaesu - FT-840" },
96+
{ RIG_MODEL_FT847, "Yaesu - FT-847" },
97+
{ RIG_MODEL_FT857, "Yaesu - FT-857" },
98+
{ RIG_MODEL_FT890, "Yaesu - FT-890" },
99+
{ RIG_MODEL_FT891, "Yaesu - FT-891" },
100+
{ RIG_MODEL_FT897, "Yaesu - FT-897" },
101+
{ RIG_MODEL_FT897D, "Yaesu - FT-897D" },
102+
{ RIG_MODEL_FT900, "Yaesu - FT-900" },
103+
{ RIG_MODEL_FT920, "Yaesu - FT-920" },
104+
{ RIG_MODEL_FT950, "Yaesu - FT-950" },
105+
{ RIG_MODEL_FT980, "Yaesu - FT-980" },
106+
{ RIG_MODEL_FT990, "Yaesu - FT-990" },
107+
{ RIG_MODEL_FT991, "Yaesu - FT-991" },
108+
{ RIG_MODEL_FT2000, "Yaesu - FT-2000" },
109+
{ RIG_MODEL_FTDX10, "Yaesu - FTDX-10" },
110+
{ RIG_MODEL_FTDX101D, "Yaesu - FTDX-101D" },
111+
{ RIG_MODEL_FTDX101MP, "Yaesu - FTDX-101MP" },
112+
{ RIG_MODEL_FTDX1200, "Yaesu - FTDX-1200" },
113+
{ RIG_MODEL_FTDX3000, "Yaesu - FTDX-3000" },
114+
{ RIG_MODEL_FTDX5000, "Yaesu - FTDX-5000" },
115+
{ RIG_MODEL_FT9000, "Yaesu - FTDX-9000" },
116+
{ RIG_MODEL_FT1000MPMKV, "Yaesu - MARK-V FT-1000MP" },
117+
{ RIG_MODEL_FT1000MPMKVFLD, "Yaesu - MARK-V Field FT-1000MP" }
118+
};
119+
120+
static size_t get_radio_models_count(void) {
121+
return sizeof(RADIO_MODELS) / sizeof(RADIO_MODELS[0]);
122+
}
123+
124+
const RadioModel* radio_control_get_radio_models(gint *count) {
125+
*count = get_radio_models_count();
126+
return RADIO_MODELS;
127+
}
128+
12129
static enum RadioMode
13130
map_hamlib_mode(rmode_t mode)
14131
{

src/radio_control.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ typedef struct {
4040
gint baud_rate;
4141
} RadioConfiguration;
4242

43+
44+
typedef struct {
45+
int model_id;
46+
const char *display_name;
47+
} RadioModel;
48+
49+
const
50+
RadioModel* radio_control_get_radio_models(gint *count);
51+
4352
void
4453
radio_configuration_destroy(RadioConfiguration *config);
4554

0 commit comments

Comments
 (0)