Move country/city set calls before longitude/latitude set calls

Changing the country and city values trigger the callback that
automatically sets the coordinates based on the city name. Thus, values
possibly entered after changing the city may update the already entered
values. The same problem occurs when a new chart is loaded with correct
coordinates but incorrect city name.
This commit is contained in:
Gergely Polonkai 2014-09-21 19:31:09 +02:00
parent 8ec87260df
commit e5c2b628b4

View File

@ -556,7 +556,7 @@ ag_window_set_house_system(GtkTreeModel *model,
void
ag_window_update_from_chart(AgWindow *window)
{
gchar *country,
const gchar *country,
*city;
AgWindowPrivate *priv = ag_window_get_instance_private(window);
GsweTimestamp *timestamp = gswe_moment_get_timestamp(
@ -566,6 +566,30 @@ ag_window_update_from_chart(AgWindow *window)
GSWE_MOMENT(priv->chart)
);
if ((country = ag_chart_get_country(priv->chart)) != NULL) {
gtk_entry_set_text(
GTK_ENTRY(priv->country),
ag_chart_get_country(priv->chart)
);
} else {
gtk_entry_set_text(
GTK_ENTRY(priv->country),
""
);
}
if ((city = ag_chart_get_city(priv->chart)) != NULL) {
gtk_entry_set_text(
GTK_ENTRY(priv->city),
ag_chart_get_city(priv->chart)
);
} else {
gtk_entry_set_text(
GTK_ENTRY(priv->city),
""
);
}
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(priv->year),
gswe_timestamp_get_gregorian_year(timestamp, NULL)
@ -619,30 +643,6 @@ ag_window_update_from_chart(AgWindow *window)
gtk_entry_set_text(GTK_ENTRY(priv->name), ag_chart_get_name(priv->chart));
if ((country = ag_chart_get_country(priv->chart)) != NULL) {
gtk_entry_set_text(
GTK_ENTRY(priv->country),
ag_chart_get_country(priv->chart)
);
} else {
gtk_entry_set_text(
GTK_ENTRY(priv->country),
""
);
}
if ((city = ag_chart_get_city(priv->chart)) != NULL) {
gtk_entry_set_text(
GTK_ENTRY(priv->city),
ag_chart_get_city(priv->chart)
);
} else {
gtk_entry_set_text(
GTK_ENTRY(priv->city),
""
);
}
if (ag_chart_get_note(priv->chart)) {
// TODO: maybe setting length to -1 here is not that good of an idea…
gtk_text_buffer_set_text(