[Xfce4-commits] <xfce4-weather-plugin:master> Revert "Config dialog: Remove timezone-related code (UI only)."
Harald Judt
noreply at xfce.org
Fri Feb 1 16:20:03 CET 2013
Updating branch refs/heads/master
to 22f612278466f00a95f2b41d093c04568fd0897b (commit)
from e06203e457818903ffdd7ae8e57f7a50f0850f32 (commit)
commit 22f612278466f00a95f2b41d093c04568fd0897b
Author: Harald Judt <h.judt at gmx.at>
Date: Thu Jan 31 15:50:36 2013 +0100
Revert "Config dialog: Remove timezone-related code (UI only)."
This reverts commit 0e4a2bee11fb3ac73f65ee2e75704cd47bce1f63.
Conflicts:
panel-plugin/weather.c
panel-plugin/weather-config.c | 51 ++++++++++++++++++++++++++++++++++------
panel-plugin/weather-debug.c | 2 +
panel-plugin/weather.c | 20 ++++++++++++++-
3 files changed, 63 insertions(+), 10 deletions(-)
diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index 9c83d50..e7097d6 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -272,7 +272,7 @@ cb_lookup_timezone(SoupSession *session,
static void
-lookup_altitude(const gpointer user_data)
+lookup_altitude_timezone(const gpointer user_data)
{
xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
gchar *url, *latstr, *lonstr;
@@ -292,6 +292,13 @@ lookup_altitude(const gpointer user_data)
cb_lookup_altitude, user_data);
g_free(url);
+ /* lookup timezone */
+ url = g_strdup_printf("http://www.earthtools.org/timezone/%s/%s",
+ latstr, lonstr);
+ weather_http_queue_request(dialog->pd->session, url,
+ cb_lookup_timezone, user_data);
+ g_free(url);
+
g_free(lonstr);
g_free(latstr);
}
@@ -312,7 +319,7 @@ auto_locate_cb(const gchar *loc_name,
string_to_double(lat, 0));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->spin_lon),
string_to_double(lon, 0));
- lookup_altitude(user_data);
+ lookup_altitude_timezone(user_data);
} else
gtk_entry_set_text(GTK_ENTRY(dialog->text_loc_name), _("Unset"));
setup_units(dialog, units);
@@ -359,7 +366,7 @@ cb_findlocation(GtkButton *button,
}
free_search_dialog(sdialog);
- lookup_altitude(user_data);
+ lookup_altitude_timezone(user_data);
gtk_widget_set_sensitive(GTK_WIDGET(button), TRUE);
return FALSE;
@@ -452,6 +459,17 @@ spin_alt_value_changed(const GtkWidget *spin,
}
+static void
+spin_timezone_value_changed(const GtkWidget *spin,
+ gpointer user_data)
+{
+ xfceweather_dialog *dialog = (xfceweather_dialog *) user_data;
+
+ dialog->pd->timezone =
+ gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin));
+}
+
+
static GtkWidget *
create_location_page(xfceweather_dialog *dialog)
{
@@ -504,7 +522,7 @@ create_location_page(xfceweather_dialog *dialog)
SET_TOOLTIP(dialog->spin_lat,
_("Latitude specifies the north-south position of a point on "
"the Earth's surface. If you change this value manually, "
- "you should provide the correct altitude too."));
+ "you need to provide altitude and timezone manually too."));
label = gtk_label_new("°");
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
@@ -518,7 +536,7 @@ create_location_page(xfceweather_dialog *dialog)
SET_TOOLTIP(dialog->spin_lon,
_("Longitude specifies the east-west position of a point on "
"the Earth's surface. If you change this value manually, "
- "you should provide the correct altitude too."));
+ "you need to provide altitude and timezone manually too."));
label = gtk_label_new("°");
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
@@ -547,13 +565,28 @@ create_location_page(xfceweather_dialog *dialog)
gtk_box_pack_start(GTK_BOX(hbox), dialog->label_alt_unit, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, BORDER);
- /* instructions for correction of altitude */
+ /* timezone */
+ hbox = gtk_hbox_new(FALSE, BORDER);
+ ADD_LABEL(_("_Timezone:"), sg_label);
+ ADD_SPIN(dialog->spin_timezone, -25, 25, 0.5,
+ dialog->pd->timezone, 1, sg_spin);
+ SET_TOOLTIP
+ (dialog->spin_timezone,
+ _("If the chosen location is not in your current timezone, this "
+ "value which is auto-detected using the EarthTools web service "
+ "will be used for correcting the time differences. Please adjust "
+ "it manually to accomodate for daylight summer time or if it "
+ "is not correct."));
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, BORDER);
+
+ /* instructions for correction of altitude and timezone */
hbox = gtk_hbox_new(FALSE, BORDER);
label = gtk_label_new(NULL);
gtk_label_set_markup
(GTK_LABEL(label),
- _("\n\n\n\n<i>Please change the location name to your liking and\n"
- "revise the altitude if not auto-detected correctly.</i>"));
+ _("<i>Please change location name to your liking and "
+ "correct\naltitude and timezone if they are "
+ "not auto-detected correctly.</i>"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, BORDER/2);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, BORDER/2);
@@ -1870,6 +1903,8 @@ setup_notebook_signals(xfceweather_dialog *dialog)
G_CALLBACK(spin_lon_value_changed), dialog);
g_signal_connect(GTK_SPIN_BUTTON(dialog->spin_alt), "value-changed",
G_CALLBACK(spin_alt_value_changed), dialog);
+ g_signal_connect(GTK_SPIN_BUTTON(dialog->spin_timezone), "value-changed",
+ G_CALLBACK(spin_timezone_value_changed), dialog);
/* units page */
g_signal_connect(dialog->combo_unit_temperature, "changed",
diff --git a/panel-plugin/weather-debug.c b/panel-plugin/weather-debug.c
index f06f595..4baf9bb 100644
--- a/panel-plugin/weather-debug.c
+++ b/panel-plugin/weather-debug.c
@@ -430,6 +430,7 @@ weather_dump_plugindata(const plugin_data *data)
" latitude: %s\n"
" longitude: %s\n"
" msl: %d\n"
+ " timezone: %.1f\n"
" night time: %s\n"
" --------------------------------------------\n"
" icon theme dir: %s\n"
@@ -463,6 +464,7 @@ weather_dump_plugindata(const plugin_data *data)
data->lat,
data->lon,
data->msl,
+ data->timezone,
YESNO(data->night_time),
(data->icon_theme) ? (data->icon_theme->dir) : NULL,
data->tooltip_style,
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index 92f3123..30ba298 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -773,6 +773,13 @@ xfceweather_read_config(XfcePanelPlugin *plugin,
data->msl = xfce_rc_read_int_entry(rc, "msl", 0);
constrain_to_limits(&data->msl, -420, 10000);
+ value = xfce_rc_read_entry(rc, "timezone", 0);
+ data->timezone = string_to_double(value, 0);
+ if (data->timezone < -25.0)
+ data->timezone = -25;
+ if (data->timezone > 25.0)
+ data->timezone = 25;
+
data->cache_file_max_age =
xfce_rc_read_int_entry(rc, "cache_file_max_age", CACHE_FILE_MAX_AGE);
@@ -883,6 +890,10 @@ xfceweather_write_config(XfcePanelPlugin *plugin,
xfce_rc_write_int_entry(rc, "msl", data->msl);
+ value = double_to_string(data->timezone, "%.1f");
+ xfce_rc_write_entry(rc, "timezone", value);
+ g_free(value);
+
xfce_rc_write_int_entry(rc, "cache_file_max_age",
data->cache_file_max_age);
@@ -978,6 +989,9 @@ write_cache_file(plugin_data *data)
CACHE_APPEND("lon=%s\n", data->lon);
g_string_append_printf(out, "msl=%d\n", data->msl);
g_string_append_printf(out, "timeslices=%d\n", wd->timeslices->len);
+ value = double_to_string(data->timezone, "%.1f");
+ CACHE_APPEND("timezone=%s\n", value);
+ g_free(value);
if (G_LIKELY(data->weather_update)) {
value = format_date(data->weather_update->last, date_format, FALSE);
CACHE_APPEND("last_weather_download=%s\n", value);
@@ -1081,7 +1095,7 @@ read_cache_file(plugin_data *data)
struct tm cache_date_tm;
gchar *file, *locname = NULL, *lat = NULL, *lon = NULL, *group = NULL;
gchar *timestring;
- gdouble diff;
+ gdouble timezone, diff;
gint msl, num_timeslices = 0, i, j;
g_assert(data != NULL);
@@ -1123,10 +1137,12 @@ read_cache_file(plugin_data *data)
}
msl = g_key_file_get_integer(keyfile, group, "msl", err);
if (!err)
+ timezone = g_key_file_get_double(keyfile, group, "timezone", err);
+ if (!err)
num_timeslices = g_key_file_get_integer(keyfile, group,
"timeslices", err);
if (err || strcmp(lat, data->lat) || strcmp(lon, data->lon) ||
- msl != data->msl || num_timeslices < 1) {
+ msl != data->msl || timezone != data->timezone || num_timeslices < 1) {
CACHE_FREE_VARS();
weather_debug("The required values are not present in the cache file "
"or do not match the current plugin data. Reading "
More information about the Xfce4-commits
mailing list