[gnome-weather] ui: Show current temperature in the forecast chart
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-weather] ui: Show current temperature in the forecast chart
- Date: Wed, 22 Sep 2021 01:04:51 +0000 (UTC)
commit f2c66d35e536cc91528853e84626104e8e708e9b
Author: Vitaly Dyachkov <obyknovenius me com>
Date: Thu Aug 12 19:44:54 2021 +0200
ui: Show current temperature in the forecast chart
src/app/city.js | 5 +----
src/app/dailyForecast.js | 6 ++++--
src/app/hourlyForecast.js | 40 ++++++++++++++++++++++++++--------------
3 files changed, 31 insertions(+), 20 deletions(-)
---
diff --git a/src/app/city.js b/src/app/city.js
index 3777103..cf669c8 100644
--- a/src/app/city.js
+++ b/src/app/city.js
@@ -234,11 +234,8 @@ var WeatherWidget = GObject.registerClass({
const [, apparentValue] = info.get_value_apparent(GWeather.TemperatureUnit.DEFAULT);
this._apparentLabel.label = _('Feels like %.0f°').format(apparentValue);
- let forecasts = info.get_forecast_list();
- let coords = info.location.get_coords();
- let tz = GLib.TimeZone.new(GWeather.Location.get_world().find_nearest_city(coords[0],
coords[1]).get_timezone().get_tzid());
for (let t of ['hourly', 'daily'])
- this._forecasts[t].update(forecasts, tz);
+ this._forecasts[t].update(info);
if (this._updatedTimeTimeoutId)
GLib.Source.remove(this._updatedTimeTimeoutId);
diff --git a/src/app/dailyForecast.js b/src/app/dailyForecast.js
index b5d87e5..800669f 100644
--- a/src/app/dailyForecast.js
+++ b/src/app/dailyForecast.js
@@ -74,8 +74,10 @@ var DailyForecastBox = GObject.registerClass(class DailyForecastBox extends Gtk.
return weekInfos;
}
- update(infos) {
- let weekInfos = this._preprocess(infos);
+ update(info) {
+ let forecasts = info.get_forecast_list();
+
+ let weekInfos = this._preprocess(forecasts);
if (weekInfos.length > 0) {
for (let i = 0; i < weekInfos.length; i++) {
diff --git a/src/app/hourlyForecast.js b/src/app/hourlyForecast.js
index 1e7a11f..543753a 100644
--- a/src/app/hourlyForecast.js
+++ b/src/app/hourlyForecast.js
@@ -69,11 +69,20 @@ var HourlyForecastBox = GObject.registerClass(class HourlyForecastBox extends Gt
return ret;
}
- update(infos, tz) {
+ update(info) {
+ let forecasts = info.get_forecast_list();
+
+ let coords = info.location.get_coords();
+ let nearestCity = GWeather.Location.get_world().find_nearest_city(coords[0], coords[1]);
+ let tz = GLib.TimeZone.new(nearestCity.get_timezone().get_tzid());
let now = GLib.DateTime.new_now(tz);
- let hourlyInfo = this._preprocess(now, infos);
+
+ let hourlyInfo = this._preprocess(now, forecasts);
if (hourlyInfo.length > 0) {
+ this._addHourEntry(info, tz, _('Now'));
+ this._addSeparator();
+
for (let i = 0; i < hourlyInfo.length; i++) {
let info = hourlyInfo[i];
this._addHourEntry(info, tz);
@@ -91,22 +100,25 @@ var HourlyForecastBox = GObject.registerClass(class HourlyForecastBox extends Gt
this._hourlyInfo = hourlyInfo;
}
- _addHourEntry(info, tz) {
- let [ok, date] = info.get_value_update();
- let datetime = GLib.DateTime.new_from_unix_utc(date).to_timezone(tz);
+ _addHourEntry(info, tz, timeLabel) {
+ let hourEntry = new HourEntry();
- let timeSetting = this._settings.get_string('clock-format');
- let timeFormat = null;
+ if (!timeLabel) {
+ let [ok, date] = info.get_value_update();
+ let datetime = GLib.DateTime.new_from_unix_utc(date).to_timezone(tz);
- if (timeSetting == '12h')
- /* Translators: this is a time format without date used for AM/PM */
- timeFormat = _('%l∶%M %p');
- else
- timeFormat = '%R';
+ let timeSetting = this._settings.get_string('clock-format');
+ let timeFormat = null;
- let hourEntry = new HourEntry();
+ if (timeSetting == '12h')
+ /* Translators: this is a time format without date used for AM/PM */
+ timeFormat = _('%l∶%M %p');
+ else
+ timeFormat = '%R';
- hourEntry.timeLabel.label = datetime.format(timeFormat);
+ timeLabel = datetime.format(timeFormat);
+ }
+ hourEntry.timeLabel.label = timeLabel;
hourEntry.image.iconName = info.get_icon_name() + '-small';
hourEntry.temperatureLabel.label = Util.getTempString(info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]