From 73a40c55d282330eb4de113b6a232b4d8387bbeb Mon Sep 17 00:00:00 2001 From: Jens Lody Date: Mon, 19 Nov 2018 23:09:49 +0100 Subject: [PATCH] Fix for gnome.shell 3.30, only symbolic icons shown, if the stale is not explicitely set to regular. --- data/stylesheet.css | 8 ++++++ src/darksky_net.js | 6 ++--- src/extension.js | 54 +++++++++++++++------------------------ src/openweathermap_org.js | 6 ++--- 4 files changed, 34 insertions(+), 40 deletions(-) diff --git a/data/stylesheet.css b/data/stylesheet.css index d67fcf4..07cc58f 100644 --- a/data/stylesheet.css +++ b/data/stylesheet.css @@ -1,3 +1,11 @@ +.openweather-regular{ +-st-icon-style: regular; +} + +.openweather-symbolic{ +-st-icon-style: symbolic; +} + .openweather-button { border-radius: 32px; padding: 13px; diff --git a/src/darksky_net.js b/src/darksky_net.js index 49495d7..6e401fd 100644 --- a/src/darksky_net.js +++ b/src/darksky_net.js @@ -96,10 +96,10 @@ function getWeatherIcon(icon, windspeed, cloudcover, night) { break; } for (let i = 0; i < iconname.length; i++) { - if (this.hasIcon(iconname[i]) + this.getIconType()) - return iconname[i] + this.getIconType(); + if (this.hasIcon(iconname[i])) + return iconname[i]; } - return 'weather-severe-alert' + this.getIconType(); + return 'weather-severe-alert'; } function parseWeatherCurrent() { diff --git a/src/extension.js b/src/extension.js index e13545b..0d137be 100644 --- a/src/extension.js +++ b/src/extension.js @@ -182,8 +182,8 @@ const OpenweatherMenuButton = new Lang.Class({ }); this._weatherIcon = new St.Icon({ - icon_name: 'view-refresh' + this.getIconType(), - style_class: 'system-status-icon openweather-icon' + icon_name: 'view-refresh', + style_class: 'system-status-icon openweather-icon ' + this.getIconType() }); // Panel menu item - the current class @@ -1081,7 +1081,7 @@ const OpenweatherMenuButton = new Lang.Class({ }, hasIcon: function(icon) { - return Gtk.IconTheme.get_default().has_icon(icon + this.getIconType()); + return Gtk.IconTheme.get_default().has_icon(icon); }, toFahrenheit: function(t) { @@ -1169,28 +1169,11 @@ const OpenweatherMenuButton = new Lang.Class({ return (this._wind_direction) ? arrows[idx] : letters[idx]; }, - getIconType: function(icon_name) { - if (!icon_name) { + getIconType: function() { if (this._getIconType) { - - return "-symbolic"; - } else { - return ""; - } - } - - if (this._getIconType) { - if (String(icon_name).search("-symbolic") != -1) { - return icon_name; + return "openweather-symbolic"; } else { - return icon_name + "-symbolic"; - } - } else { - if (String(icon_name).search("-symbolic") != -1) { - return String(icon_name).replace("-symbolic", ""); - } else { - return icon_name; - } + return "openweather-regular"; } }, @@ -1444,33 +1427,36 @@ const OpenweatherMenuButton = new Lang.Class({ rebuildCurrentWeatherUi: function() { this._weatherInfo.text = (' '); - this._weatherIcon.icon_name = 'view-refresh' + this.getIconType(); + this._weatherIcon.icon_name = 'view-refresh'; + this._weatherIcon.remove_style_class_name('openweather-regular'); + this._weatherIcon.remove_style_class_name('openweather-symbolic'); + this._weatherIcon.add_style_class_name(this.getIconType()); this.destroyCurrentWeather(); // This will hold the icon for the current weather this._currentWeatherIcon = new St.Icon({ icon_size: 72, - icon_name: 'view-refresh' + this.getIconType(), - style_class: 'system-menu-action openweather-current-icon' + icon_name: 'view-refresh', + style_class: 'system-menu-action openweather-current-icon ' + this.getIconType() }); this._sunriseIcon = new St.Icon({ icon_size: 15, - icon_name: 'weather-clear' + this.getIconType(), - style_class: 'openweather-sunrise-icon' + icon_name: 'weather-clear', + style_class: 'openweather-sunrise-icon ' + this.getIconType() }); this._sunsetIcon = new St.Icon({ icon_size: 15, - icon_name: 'weather-clear-night' + this.getIconType(), - style_class: 'openweather-sunset-icon' + icon_name: 'weather-clear-night', + style_class: 'openweather-sunset-icon ' + this.getIconType() }); this._buildIcon = new St.Icon({ icon_size: 15, - icon_name: 'view-refresh' + this.getIconType(), - style_class: 'openweather-build-icon' + icon_name: 'view-refresh', + style_class: 'openweather-build-icon ' + this.getIconType() }); // The summary of the current weather @@ -1619,8 +1605,8 @@ const OpenweatherMenuButton = new Lang.Class({ forecastWeather.Icon = new St.Icon({ icon_size: 48, - icon_name: 'view-refresh' + this.getIconType(), - style_class: 'system-menu-action openweather-forecast-icon' + icon_name: 'view-refresh', + style_class: 'system-menu-action openweather-forecast-icon ' + this.getIconType() }); forecastWeather.Day = new St.Label({ style_class: 'popup-menu-item popup-status-menu-item openweather-forecast-day' diff --git a/src/openweathermap_org.js b/src/openweathermap_org.js index 53ceede..885dfd5 100644 --- a/src/openweathermap_org.js +++ b/src/openweathermap_org.js @@ -170,11 +170,11 @@ weather-storm.png = weather-storm-symbolic.svg for (let i = 0; i < iconname.length; i++) { if (night && this.hasIcon(iconname[i] + '-night')) - return iconname[i] + '-night' + this.getIconType(); + return iconname[i] + '-night'; if (this.hasIcon(iconname[i])) - return iconname[i] + this.getIconType(); + return iconname[i]; } - return 'weather-severe-alert' + this.getIconType(); + return 'weather-severe-alert'; } function getWeatherCondition(code) {