[gnome-weather] Use properties to set icon names



commit a47664c1d2ed698c68adcb192053743fc4a2f3ff
Author: Vitaly Dyachkov <obyknovenius me com>
Date:   Fri Nov 20 17:26:20 2020 +0100

    Use properties to set icon names
    
    It provides several advantages:
    - less code
    - icon sizes can be set once in UI files
    - icons looks sharper on HiDPI screens

 data/weather-widget.ui    | 1 +
 src/app/city.js           | 4 +---
 src/app/dailyForecast.js  | 4 +---
 src/app/hourlyForecast.js | 7 ++-----
 4 files changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/data/weather-widget.ui b/data/weather-widget.ui
index ba159d9..ce02930 100644
--- a/data/weather-widget.ui
+++ b/data/weather-widget.ui
@@ -139,6 +139,7 @@
                     <property name="can_focus">False</property>
                     <property name="halign">start</property>
                     <property name="valign">center</property>
+                    <property name="pixel_size">84</property>
                     <style>
                       <class name="icon-dropshadow"/>
                     </style>
diff --git a/src/app/city.js b/src/app/city.js
index 1be3c87..3b7dc25 100644
--- a/src/app/city.js
+++ b/src/app/city.js
@@ -202,9 +202,7 @@ var WeatherWidget = GObject.registerClass({
 
         this._worldView.refilter();
 
-        const iconTheme = Gtk.IconTheme.get_default();
-        const icon = iconTheme.load_icon(info.get_icon_name() + '-large', 84, 0);
-        this._conditionsImage.set_from_pixbuf(icon);
+        this._conditionsImage.iconName = info.get_icon_name() + '-large';
 
         const [, tempValue] = info.get_value_temp(GWeather.TemperatureUnit.DEFAULT);
         this._temperatureLabel.label = '%.0f°'.format(tempValue);
diff --git a/src/app/dailyForecast.js b/src/app/dailyForecast.js
index c400782..23888ec 100644
--- a/src/app/dailyForecast.js
+++ b/src/app/dailyForecast.js
@@ -180,9 +180,7 @@ var DailyForecastFrame = GObject.registerClass(class DailyForecastFrame extends
         let dateFormat = _('%e %b');
         dayEntry.dateLabel.label = day.format(dateFormat);
 
-        const iconTheme = Gtk.IconTheme.get_default();
-        const icon = iconTheme.load_icon(dayInfo.get_icon_name() + '-small', 32, 0);
-        dayEntry.image.set_from_pixbuf(icon);
+        dayEntry.image.iconName = dayInfo.get_icon_name() + '-small';
 
         dayEntry.maxTemperatureLabel.label = Util.getTempString(maxInfo);
         dayEntry.minTemperatureLabel.label = Util.getTempString(minInfo);
diff --git a/src/app/hourlyForecast.js b/src/app/hourlyForecast.js
index 5c3d2d5..7ebb670 100644
--- a/src/app/hourlyForecast.js
+++ b/src/app/hourlyForecast.js
@@ -111,12 +111,9 @@ var HourlyForecastFrame = GObject.registerClass(class ForecastFrame extends Gtk.
             timeFormat = '%R';
 
         let hourEntry = new HourEntry();
-        hourEntry.timeLabel.label = datetime.format(timeFormat);
-
-        const iconTheme = Gtk.IconTheme.get_default();
-        const icon = iconTheme.load_icon(info.get_icon_name() + '-small', 32, 0);
-        hourEntry.image.set_from_pixbuf(icon);
 
+        hourEntry.timeLabel.label = datetime.format(timeFormat);
+        hourEntry.image.iconName = info.get_icon_name() + '-small';
         hourEntry.temperatureLabel.label = Util.getTempString(info);
 
         this._box.pack_start(hourEntry, false, false, 0);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]