From e5c2b628b46d7b34394b580b6c9e4ff0e4181eb9 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sun, 21 Sep 2014 19:31:09 +0200 Subject: [PATCH] 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. --- src/ag-window.c | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/ag-window.c b/src/ag-window.c index f184f44..962b34d 100644 --- a/src/ag-window.c +++ b/src/ag-window.c @@ -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(