}
gboolean
-settings_dialog_gps(void)
+settings_dialog_gps(Gps *gps)
{
GtkWidget *dialog;
GtkWidget *notebook;
GtkWidget *label;
GtkWidget *cmb_gps_type;
GtkWidget *txt_rcvr_mac;
+GtkWidget *spn_rcvr_port;
GtkWidget *btn_scan;
GtkCellRenderer *renderer;
GtkTreeIter active;
GtkListStore *store;
GtkTreeIter iter;
ScanInfo scan_info = { 0 };
-gboolean rcvr_changed=TRUE;
+gboolean rcvr_changed=TRUE, settype=FALSE;
GpsTypes *gpstypes;
gint i=0;
+/* Don't allow configuring GPS if it's connected */
+if (gps->io.conn!=RCVR_OFF) {
+ popup_error(_window, "Disable GPS before re-configuring.");
+ return FALSE;
+}
+
dialog = gtk_dialog_new_with_buttons(_("GPS Settings"), GTK_WINDOW(_window), GTK_DIALOG_MODAL,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
help_dialog_help_enable(GTK_DIALOG(dialog), HELP_ID_SETTINGS_GPS);
while (gpstypes->type!=0) {
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, gpstypes->type, 1, gpstypes->name, -1);
+ if (gps->io.type==gpstypes->type) {
+ active=iter;
+ settype=TRUE;
+ }
gpstypes++;
}
-#if 0
-gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &active);
+if (settype==FALSE)
+ gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &active);
+
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(cmb_gps_type), &active);
-#endif
/* Receiver MAC Address. */
hbox = gtk_hbox_new(FALSE, 3);
gtk_box_pack_start(GTK_BOX(hbox), label = gtk_label_new(_("Address")), TRUE, TRUE, 0);
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
gtk_box_pack_start(GTK_BOX(hbox), txt_rcvr_mac = gtk_entry_new(), TRUE, TRUE, 0);
+gtk_box_pack_start(GTK_BOX(hbox), spn_rcvr_port = gtk_spin_button_new_with_range(0, 65535, 1), TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(hbox), btn_scan = gtk_button_new_with_label(_("Scan...")), FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
scan_info.settings_dialog = dialog;
scan_info.txt_rcvr_mac = txt_rcvr_mac;
g_signal_connect(G_OBJECT(btn_scan), "clicked", G_CALLBACK(scan_bluetooth), &scan_info);
-gtk_entry_set_text(GTK_ENTRY(txt_rcvr_mac), _gps->io.address ? _gps->io.address : "");
+gtk_entry_set_text(GTK_ENTRY(txt_rcvr_mac), gps->io.address ? gps->io.address : "");
+gtk_spin_button_set_value(spn_rcvr_port, gps->io.port);
gtk_window_set_default_size(GTK_WINDOW(dialog), 500, -1);
gtk_widget_show_all(dialog);
-if (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
+while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
/* Set _rcvr_mac if necessary. */
+ if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(cmb_gps_type), &iter)==TRUE) {
+ gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &(gps->io.type), -1);
+ g_debug("GPS: %d", gps->io.type);
+ } else {
+ popup_error(_window, "Please select GPS type");
+ continue;
+ }
+
if (!*gtk_entry_get_text(GTK_ENTRY(txt_rcvr_mac))) {
/* User specified no rcvr mac - set _rcvr_mac to NULL. */
- if (_gps->io.address) {
- g_free(_gps->io.address);
- _gps->io.address=NULL;
+ if (gps->io.address) {
+ g_free(gps->io.address);
+ gps->io.address=NULL;
rcvr_changed=TRUE;
set_action_sensitive("gps_details", FALSE);
}
- if (_enable_gps) {
+ gps->io.type=GPS_IO_SIMULATION;
+ if (gps->io.type!=GPS_IO_SIMULATION) {
set_action_activate("gps_details", FALSE);
popup_error(dialog, _("No GPS Receiver MAC provided.\nGPS will be disabled."));
rcvr_changed=TRUE;
set_action_sensitive("gps_details", FALSE);
}
- } else if (!_gps->io.address || strcmp(_gps->io.address, gtk_entry_get_text(GTK_ENTRY(txt_rcvr_mac)))) {
+ } else if (!gps->io.address || strcmp(gps->io.address, gtk_entry_get_text(GTK_ENTRY(txt_rcvr_mac)))) {
/* User specified a new rcvr mac. */
- g_free(_gps->io.address);
- _gps->io.address=g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_rcvr_mac)));
+ g_free(gps->io.address);
+ gps->io.address=g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_rcvr_mac)));
+ gps->io.port=(guint)gtk_spin_button_get_value(spn_rcvr_port);
rcvr_changed=TRUE;
}
- /* Sensitize menus based on whether we have a database conn. */
- gtk_widget_set_sensitive(_cmenu_loc_add_poi, _db != NULL);
- gtk_widget_set_sensitive(_cmenu_way_add_poi, _db != NULL);
- gtk_widget_set_sensitive(_cmenu_poi, _db != NULL);
-
config_save();
+ break;
}
gtk_widget_destroy(dialog);
return rcvr_changed;
} else {
_mapper_db=NULL;
}
- /* Sensitize menus based on whether we have a database conn. */
- gtk_widget_set_sensitive(_cmenu_loc_add_poi, _db != NULL);
- gtk_widget_set_sensitive(_cmenu_way_add_poi, _db != NULL);
- gtk_widget_set_sensitive(_cmenu_poi, _db != NULL);
config_save();
}
gtk_widget_destroy(dialog);
+
+/* Sensitize menus based on whether we have a database conn. */
+gtk_widget_set_sensitive(_cmenu_loc_add_poi, _db != NULL);
+gtk_widget_set_sensitive(_cmenu_way_add_poi, _db != NULL);
+gtk_widget_set_sensitive(_cmenu_poi, _db != NULL);
+
return TRUE;
}