static GtkWidget *dialog = NULL;
static GtkWidget *table = NULL;
static GtkWidget *label = NULL;
+ static GtkWidget *label_lat_lon = NULL;
static GtkWidget *txt_scroll = NULL;
static GtkWidget *txt_desc = NULL;
+ static int last_deg_format = 0;
+
printf("%s()\n", __PRETTY_FUNCTION__);
+ unit2latlon(unitx, unity, lat, lon);
+
+ gint fallback_deg_format = _degformat;
+
+ if(!coord_system_check_lat_lon (lat, lon, &fallback_deg_format))
+ {
+ last_deg_format = _degformat;
+ _degformat = fallback_deg_format;
+
+ if(dialog != NULL) gtk_widget_destroy(dialog);
+ dialog = NULL;
+ }
+ else if(_degformat != last_deg_format)
+ {
+ last_deg_format = _degformat;
+
+ if(dialog != NULL) gtk_widget_destroy(dialog);
+ dialog = NULL;
+ }
+
+
if(dialog == NULL)
{
dialog = gtk_dialog_new_with_buttons(_("Add Waypoint"),
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
table = gtk_table_new(2, 2, FALSE), TRUE, TRUE, 0);
+
+
+ if(DEG_FORMAT_ENUM_TEXT[_degformat].field_2_in_use)
+ p_latlon = g_strdup_printf("%s, %s",
+ DEG_FORMAT_ENUM_TEXT[_degformat].short_field_1,
+ DEG_FORMAT_ENUM_TEXT[_degformat].short_field_2);
+ else
+ p_latlon = g_strdup_printf("%s", DEG_FORMAT_ENUM_TEXT[_degformat].short_field_1);
+
gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Lat, Lon:")),
+ label = gtk_label_new(p_latlon),
0, 1, 0, 1, GTK_FILL, 0, 2, 4);
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
- unit2latlon(unitx, unity, lat, lon);
- lat_format(lat, tmp1);
- lon_format(lon, tmp2);
- p_latlon = g_strdup_printf("%s, %s", tmp1, tmp2);
+ g_free(p_latlon);
+
gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(p_latlon),
+ label_lat_lon = gtk_label_new(_("") ),
1, 2, 0, 1, GTK_FILL, 0, 2, 4);
- gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
- g_free(p_latlon);
+ gtk_misc_set_alignment(GTK_MISC(label_lat_lon), 0.0f, 0.5f);
+
gtk_table_attach(GTK_TABLE(table),
label = gtk_label_new(_("Description")),
gtk_widget_set_size_request(GTK_WIDGET(txt_scroll), 400, 60);
}
+ format_lat_lon(lat, lon, tmp1, tmp2);
+
+ if(DEG_FORMAT_ENUM_TEXT[_degformat].field_2_in_use)
+ p_latlon = g_strdup_printf("%s, %s", tmp1, tmp2);
+ else
+ p_latlon = g_strdup_printf("%s", tmp1);
+
+
+ gtk_label_set_text(GTK_LABEL(label_lat_lon), p_latlon);
+ g_free(p_latlon);
+
gtk_text_buffer_set_text(
gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_desc)), "", 0);
break;
}
gtk_widget_hide(dialog);
+
+ _degformat = last_deg_format;
+
vprintf("%s(): return\n", __PRETTY_FUNCTION__);
}
static GtkTextIter begin, end;
static DeletePOI dpoi = {NULL, NULL, 0};
static PoiCategoryEditInfo pcedit;
+ static int last_deg_format = 0;
+
printf("%s()\n", __PRETTY_FUNCTION__);
+ unit2latlon(unitx, unity, poi.lat, poi.lon);
+
+
+ gint fallback_deg_format = _degformat;
+
+ if(!coord_system_check_lat_lon (poi.lat, poi.lon, &fallback_deg_format))
+ {
+ last_deg_format = _degformat;
+ _degformat = fallback_deg_format;
+
+ if(dialog != NULL) gtk_widget_destroy(dialog);
+ dialog = NULL;
+ }
+ else if(_degformat != last_deg_format)
+ {
+ last_deg_format = _degformat;
+
+ if(dialog != NULL) gtk_widget_destroy(dialog);
+ dialog = NULL;
+ }
+
+
+
+
if(dialog == NULL)
{
dialog = gtk_dialog_new_with_buttons(_("Add POI"),
table = gtk_table_new(6, 4, FALSE), TRUE, TRUE, 0);
gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Lat")),
+ label = gtk_label_new(DEG_FORMAT_ENUM_TEXT[_degformat].short_field_1),
0, 1, 0, 1, GTK_FILL, 0, 2, 0);
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
gtk_table_attach(GTK_TABLE(table),
txt_lat = gtk_entry_new(),
- 1, 2, 0, 1, GTK_FILL, 0, 2, 0);
-
- gtk_table_attach(GTK_TABLE(table),
- label = gtk_label_new(_("Lon")),
- 2, 3, 0, 1, GTK_FILL, 0, 2, 0);
- gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
- gtk_table_attach(GTK_TABLE(table),
- txt_lon = gtk_entry_new(),
- 3, 4, 0, 1, GTK_FILL, 0, 2, 0);
+ 1, (DEG_FORMAT_ENUM_TEXT[_degformat].field_2_in_use ? 2 : 4),
+ 0, 1, GTK_FILL, 0, 2, 0);
+ if(DEG_FORMAT_ENUM_TEXT[_degformat].field_2_in_use )
+ {
+ gtk_table_attach(GTK_TABLE(table),
+ label = gtk_label_new(DEG_FORMAT_ENUM_TEXT[_degformat].short_field_2),
+ 2, 3, 0, 1, GTK_FILL, 0, 2, 0);
+ gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
+ gtk_table_attach(GTK_TABLE(table),
+ txt_lon = gtk_entry_new(),
+ 3, 4, 0, 1, GTK_FILL, 0, 2, 0);
+ }
+
gtk_table_attach(GTK_TABLE(table),
label = gtk_label_new(_("Label")),
0, 1, 1, 2, GTK_FILL, 0, 2, 0);
poi.cat_id = -1;
poi.clabel = NULL;
poi.desc = g_strdup("");
- unit2latlon(unitx, unity, poi.lat, poi.lon);
/* Lat/Lon */
{
//lon_format(poi.lon, tmp2);
gtk_entry_set_text(GTK_ENTRY(txt_lat), tmp1);
- gtk_entry_set_text(GTK_ENTRY(txt_lon), tmp2);
+
+ if(txt_lon != NULL)
+ gtk_entry_set_text(GTK_ENTRY(txt_lon), tmp2);
}
/* Label */
while(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog)))
{
GtkTreeIter iter;
- const gchar *text;
- gchar *error_check;
+ const gchar *lat, *lon = NULL;
- text = gtk_entry_get_text(GTK_ENTRY(txt_lat));
- poi.lat = strdmstod(text, &error_check);
- if(text == error_check || poi.lat < -90. || poi.lat > 90.) {
- popup_error(dialog, _("Invalid Latitude"));
- continue;
- }
-
- text = gtk_entry_get_text(GTK_ENTRY(txt_lon));
- poi.lon = strdmstod(text, &error_check);
- if(text == error_check || poi.lon < -180. || poi.lon > 180.) {
- popup_error(dialog, _("Invalid Longitude"));
- continue;
+ lat = gtk_entry_get_text(GTK_ENTRY(txt_lat));
+
+ if(txt_lon != NULL)
+ lon = gtk_entry_get_text(GTK_ENTRY(txt_lon));
+
+ if(!parse_coords(lat, lon, &poi.lat, &poi.lon))
+ {
+ popup_error(dialog, _("Invalid Coordinate specified"));
+ continue;
}
-
+
if(strlen(gtk_entry_get_text(GTK_ENTRY(txt_label))))
{
if(poi.label)
gtk_widget_hide(dialog);
+ _degformat = last_deg_format;
+
vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
return !dpoi.deleted;
}
printf("%s()\n", __PRETTY_FUNCTION__);
-
- if(_degformat != last_deg_format)
+ gint fallback_deg_format = _degformat;
+
+ if(!coord_system_check_lat_lon (poi->lat, poi->lon, &fallback_deg_format))
+ {
+ last_deg_format = _degformat;
+ _degformat = fallback_deg_format;
+
+ if(dialog != NULL) gtk_widget_destroy(dialog);
+ dialog = NULL;
+ }
+ else if(_degformat != last_deg_format)
{
last_deg_format = _degformat;
while(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog)))
{
- const gchar *text, *text_lat, *text_lon;
- gchar *error_check;
+ const gchar *text_lat, *text_lon;
text_lat = gtk_entry_get_text(GTK_ENTRY(txt_lat));
text_lon = gtk_entry_get_text(GTK_ENTRY(txt_lon));
gtk_widget_hide(dialog); /* Destroying causes a crash.... ??? */
+ _degformat = last_deg_format;
+
vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
return !dpoi.deleted;
}
void
map_render_aprs()
{
-
printf("%s()\n", __PRETTY_FUNCTION__);
- int mm;
if(_poi_zoom > _zoom)
{