@ -118,6 +118,26 @@ WeatherMenuButton.prototype = {
PanelMenu . Button . prototype . _init . call ( this , menuAlignment ) ;
}
this . _sunriseIcon = new St . Icon ( {
icon _type : this . _icon _type ,
icon _size : 15 ,
icon _name : 'weather-clear' + ( this . _icon _type == St . IconType . SYMBOLIC ? '-symbolic' : '' ) ,
style _class : 'weather-sunrise-icon'
} ) ;
this . _sunsetIcon = new St . Icon ( {
icon _type : this . _icon _type ,
icon _size : 15 ,
icon _name : 'weather-clear-night' + ( this . _icon _type == St . IconType . SYMBOLIC ? '-symbolic' : '' ) ,
style _class : 'weather-sunset-icon'
} ) ;
var schemaInterface = "org.gnome.desktop.interface" ;
if ( Gio . Settings . list _schemas ( ) . indexOf ( schemaInterface ) == - 1 )
throw _ ( "Schema \"%s\" not found." ) . replace ( "%s" , schemaInterface ) ;
var settingsInterface = new Gio . Settings ( { schema : schemaInterface } ) ;
this . _clockFormat = settingsInterface . get _string ( "clock-format" ) ;
// Putting the panel item together
let topBox = new St . BoxLayout ( ) ;
topBox . add _actor ( this . _weatherIcon ) ;
@ -390,7 +410,7 @@ global.log(a);
} ,
get _weather _url : function ( ) {
return encodeURI ( 'http://query.yahooapis.com/v1/public/yql?format=json&q=select location,wind,atmosphere,units,item.condition,item.forecast from weather.forecast where location in (select id from xml where url="http://xoap.weather.com/search/search?where=' + encodeURI ( this . _city ) + '" and itemPath="search.loc") and u="' + this . unit _to _url ( ) + '"' ) ;
return encodeURI ( 'http://query.yahooapis.com/v1/public/yql?format=json&q=select location,wind,atmosphere,units,item.condition,item.forecast,astronomy from weather.forecast where location in (select id from xml where url="http://xoap.weather.com/search/search?where=' + encodeURI ( this . _city ) + '" and itemPath="search.loc") and u="' + this . unit _to _url ( ) + '"' ) ;
/* see http://jonathantrevor.net/?p=40 */
} ,
@ -696,6 +716,16 @@ global.log(a);
let wind = weather . wind . speed ;
let wind _unit = weather . units . speed ;
let iconname = this . get _weather _icon _safely ( weather _c . code ) ;
let sunrise = weather . astronomy . sunrise ;
let sunset = weather . astronomy . sunset ;
if ( this . _clockFormat == "24h" )
{
sunrise = new Date ( "3 Mar 1999 " + sunrise ) ;
sunrise = sunrise . getHours ( ) + ":" + sunrise . getMinutes ( ) ;
sunset = new Date ( "3 Mar 1999 " + sunset ) ;
sunset = sunset . getHours ( ) + ":" + sunset . getMinutes ( ) ;
}
this . _currentWeatherIcon . icon _name = this . _weatherIcon . icon _name = iconname ;
@ -710,6 +740,8 @@ global.log(a);
this . _currentWeatherHumidity . text = humidity ;
this . _currentWeatherPressure . text = pressure + ' ' + pressure _unit ;
this . _currentWeatherWind . text = ( wind _direction && wind > 0 ? wind _direction + ' ' : '' ) + wind + ' ' + wind _unit ;
this . _currentWeatherSunrise . text = sunrise ;
this . _currentWeatherSunset . text = sunset ;
// Refresh forecast
let date _string = [ _ ( 'Today' ) , _ ( 'Tomorrow' ) ] ;
@ -783,6 +815,19 @@ global.log(a);
bb . add _actor ( this . _currentWeatherLocation ) ;
bb . add _actor ( this . _currentWeatherSummary ) ;
this . _currentWeatherSunrise = new St . Label ( { text : '-' } ) ;
this . _currentWeatherSunset = new St . Label ( { text : '-' } ) ;
let ab = new St . BoxLayout ( {
style _class : 'weather-current-astronomy'
} ) ;
ab . add _actor ( this . _sunriseIcon ) ;
ab . add _actor ( this . _currentWeatherSunrise ) ;
ab . add _actor ( this . _sunsetIcon ) ;
ab . add _actor ( this . _currentWeatherSunset ) ;
bb . add _actor ( ab ) ;
// Other labels
this . _currentWeatherTemperature = new St . Label ( { text : '...' } ) ;
this . _currentWeatherHumidity = new St . Label ( { text : '...' } ) ;