@ -26,7 +26,6 @@
* < http : //www.gnu.org/licenses/>.
* < http : //www.gnu.org/licenses/>.
*
*
* /
* /
const Gtk = imports . gi . Gtk ;
const Gtk = imports . gi . Gtk ;
const GObject = imports . gi . GObject ;
const GObject = imports . gi . GObject ;
const GtkBuilder = Gtk . Builder ;
const GtkBuilder = Gtk . Builder ;
@ -62,14 +61,12 @@ Soup.Session.prototype.add_feature.call(_httpSession, new Soup.ProxyResolverDefa
let mCities = null ;
let mCities = null ;
const WeatherPrefsWidget = new GObject . Class (
const WeatherPrefsWidget = new GObject . Class ( {
{
Name : 'WeatherExtension.Prefs.Widget' ,
Name : 'WeatherExtension.Prefs.Widget' ,
GTypeName : 'WeatherExtensionPrefsWidget' ,
GTypeName : 'WeatherExtensionPrefsWidget' ,
Extends : Gtk . Box ,
Extends : Gtk . Box ,
_init : function ( params )
_init : function ( params ) {
{
this . parent ( params ) ;
this . parent ( params ) ;
this . initWindow ( ) ;
this . initWindow ( ) ;
@ -81,8 +78,7 @@ Extends: Gtk.Box,
Window : new Gtk . Builder ( ) ,
Window : new Gtk . Builder ( ) ,
initWindow : function ( )
initWindow : function ( ) {
{
let that = this ;
let that = this ;
mCities = null ;
mCities = null ;
@ -93,18 +89,15 @@ Extends: Gtk.Box,
this . liststore = this . Window . get _object ( "liststore" ) ;
this . liststore = this . Window . get _object ( "liststore" ) ;
this . Iter = this . liststore . get _iter _first ( ) ;
this . Iter = this . liststore . get _iter _first ( ) ;
this . Window . get _object ( "tree-toolbutton-add" ) . connect ( "clicked" , function ( )
this . Window . get _object ( "tree-toolbutton-add" ) . connect ( "clicked" , function ( ) {
{
that . addCity ( ) ;
that . addCity ( ) ;
} ) ;
} ) ;
this . Window . get _object ( "tree-toolbutton-remove" ) . connect ( "clicked" , function ( )
this . Window . get _object ( "tree-toolbutton-remove" ) . connect ( "clicked" , function ( ) {
{
that . removeCity ( ) ;
that . removeCity ( ) ;
} ) ;
} ) ;
this . Window . get _object ( "treeview-selection" ) . connect ( "changed" , function ( selection )
this . Window . get _object ( "treeview-selection" ) . connect ( "changed" , function ( selection ) {
{
that . selectionChanged ( selection ) ;
that . selectionChanged ( selection ) ;
} ) ;
} ) ;
@ -116,8 +109,7 @@ Extends: Gtk.Box,
let renderer = new Gtk . CellRendererText ( ) ;
let renderer = new Gtk . CellRendererText ( ) ;
column . pack _start ( renderer , null ) ;
column . pack _start ( renderer , null ) ;
column . set _cell _data _func ( renderer , function ( )
column . set _cell _data _func ( renderer , function ( ) {
{
arguments [ 1 ] . markup = arguments [ 2 ] . get _value ( arguments [ 3 ] , 0 ) ;
arguments [ 1 ] . markup = arguments [ 2 ] . get _value ( arguments [ 3 ] , 0 ) ;
} ) ;
} ) ;
@ -142,8 +134,7 @@ Extends: Gtk.Box,
this . addSwitch ( "comment_in_panel" ) ;
this . addSwitch ( "comment_in_panel" ) ;
} ,
} ,
refreshUI : function ( )
refreshUI : function ( ) {
{
this . MainWidget = this . Window . get _object ( "main-widget" ) ;
this . MainWidget = this . Window . get _object ( "main-widget" ) ;
this . treeview = this . Window . get _object ( "tree-treeview" ) ;
this . treeview = this . Window . get _object ( "tree-treeview" ) ;
this . liststore = this . Window . get _object ( "liststore" ) ;
this . liststore = this . Window . get _object ( "liststore" ) ;
@ -151,13 +142,11 @@ Extends: Gtk.Box,
this . Window . get _object ( "tree-toolbutton-remove" ) . sensitive = Boolean ( this . city . length ) ;
this . Window . get _object ( "tree-toolbutton-remove" ) . sensitive = Boolean ( this . city . length ) ;
if ( mCities != this . city )
if ( mCities != this . city ) {
{
if ( typeof this . liststore != "undefined" )
if ( typeof this . liststore != "undefined" )
this . liststore . clear ( ) ;
this . liststore . clear ( ) ;
if ( this . city . length > 0 )
if ( this . city . length > 0 ) {
{
let city = String ( this . city ) . split ( " && " ) ;
let city = String ( this . city ) . split ( " && " ) ;
if ( city && typeof city == "string" )
if ( city && typeof city == "string" )
@ -165,8 +154,7 @@ Extends: Gtk.Box,
let current = this . liststore . get _iter _first ( ) ;
let current = this . liststore . get _iter _first ( ) ;
for ( let i in city )
for ( let i in city ) {
{
current = this . liststore . append ( ) ;
current = this . liststore . append ( ) ;
this . liststore . set _value ( current , 0 , this . extractLocation ( city [ i ] ) ) ;
this . liststore . set _value ( current , 0 , this . extractLocation ( city [ i ] ) ) ;
}
}
@ -183,8 +171,7 @@ Extends: Gtk.Box,
config [ i ] [ 0 ] . active = this [ config [ i ] [ 1 ] ] ;
config [ i ] [ 0 ] . active = this [ config [ i ] [ 1 ] ] ;
} ,
} ,
initConfigWidget : function ( )
initConfigWidget : function ( ) {
{
this . inc ( 1 ) ;
this . inc ( 1 ) ;
let a = this . Window . get _object ( "right-widget-table" ) ;
let a = this . Window . get _object ( "right-widget-table" ) ;
a . visible = 1 ;
a . visible = 1 ;
@ -198,10 +185,8 @@ Extends: Gtk.Box,
configWidgets : [ ] ,
configWidgets : [ ] ,
inc : function ( )
inc : function ( ) {
{
if ( arguments [ 0 ] ) {
if ( arguments [ 0 ] )
{
this . x [ 0 ] = 0 ;
this . x [ 0 ] = 0 ;
this . x [ 1 ] = 1 ;
this . x [ 1 ] = 1 ;
this . y [ 0 ] = 0 ;
this . y [ 0 ] = 0 ;
@ -209,33 +194,31 @@ Extends: Gtk.Box,
return 0 ;
return 0 ;
}
}
if ( this . x [ 0 ] == 1 )
if ( this . x [ 0 ] == 1 ) {
{
this . x [ 0 ] = 0 ;
this . x [ 0 ] = 0 ;
this . x [ 1 ] = 1 ;
this . x [ 1 ] = 1 ;
this . y [ 0 ] += 1 ;
this . y [ 0 ] += 1 ;
this . y [ 1 ] += 1 ;
this . y [ 1 ] += 1 ;
return 0 ;
return 0 ;
}
} else {
else
{
this . x [ 0 ] += 1 ;
this . x [ 0 ] += 1 ;
this . x [ 1 ] += 1 ;
this . x [ 1 ] += 1 ;
return 0 ;
return 0 ;
}
}
} ,
} ,
addLabel : function ( text )
addLabel : function ( text ) {
{
let l = new Gtk . Label ( {
let l = new Gtk . Label ( { label : text , xalign : 0 } ) ;
label : text ,
xalign : 0
} ) ;
l . visible = 1 ;
l . visible = 1 ;
l . can _focus = 0 ;
l . can _focus = 0 ;
this . right _widget . attach ( l , this . x [ 0 ] , this . x [ 1 ] , this . y [ 0 ] , this . y [ 1 ] , 0 , 0 , 0 , 0 ) ;
this . right _widget . attach ( l , this . x [ 0 ] , this . x [ 1 ] , this . y [ 0 ] , this . y [ 1 ] , 0 , 0 , 0 , 0 ) ;
this . inc ( ) ;
this . inc ( ) ;
} ,
} ,
addComboBox : function ( a , b )
addComboBox : function ( a , b ) {
{
let that = this ;
let that = this ;
let cf = new Gtk . ComboBoxText ( ) ;
let cf = new Gtk . ComboBoxText ( ) ;
this . configWidgets . push ( [ cf , b ] ) ;
this . configWidgets . push ( [ cf , b ] ) ;
@ -245,26 +228,28 @@ Extends: Gtk.Box,
for ( let i in a )
for ( let i in a )
cf . append _text ( a [ i ] ) ;
cf . append _text ( a [ i ] ) ;
cf . active = this [ b ] ;
cf . active = this [ b ] ;
cf . connect ( "changed" , function ( ) { that [ b ] = arguments [ 0 ] . active ; } ) ;
cf . connect ( "changed" , function ( ) {
that [ b ] = arguments [ 0 ] . active ;
} ) ;
this . right _widget . attach ( cf , this . x [ 0 ] , this . x [ 1 ] , this . y [ 0 ] , this . y [ 1 ] , 0 , 0 , 0 , 0 ) ;
this . right _widget . attach ( cf , this . x [ 0 ] , this . x [ 1 ] , this . y [ 0 ] , this . y [ 1 ] , 0 , 0 , 0 , 0 ) ;
this . inc ( ) ;
this . inc ( ) ;
} ,
} ,
addSwitch : function ( a )
addSwitch : function ( a ) {
{
let that = this ;
let that = this ;
let sw = new Gtk . Switch ( ) ;
let sw = new Gtk . Switch ( ) ;
this . configWidgets . push ( [ sw , a ] ) ;
this . configWidgets . push ( [ sw , a ] ) ;
sw . visible = 1 ;
sw . visible = 1 ;
sw . can _focus = 0 ;
sw . can _focus = 0 ;
sw . active = this [ a ] ;
sw . active = this [ a ] ;
sw . connect ( "notify::active" , function ( ) { that [ a ] = arguments [ 0 ] . active ; } ) ;
sw . connect ( "notify::active" , function ( ) {
that [ a ] = arguments [ 0 ] . active ;
} ) ;
this . right _widget . attach ( sw , this . x [ 0 ] , this . x [ 1 ] , this . y [ 0 ] , this . y [ 1 ] , 0 , 0 , 0 , 0 ) ;
this . right _widget . attach ( sw , this . x [ 0 ] , this . x [ 1 ] , this . y [ 0 ] , this . y [ 1 ] , 0 , 0 , 0 , 0 ) ;
this . inc ( ) ;
this . inc ( ) ;
} ,
} ,
selectionChanged : function ( select )
selectionChanged : function ( select ) {
{
let a = select . get _selected _rows ( this . liststore ) [ 0 ] [ 0 ] ;
let a = select . get _selected _rows ( this . liststore ) [ 0 ] [ 0 ] ;
if ( typeof a != "undefined" )
if ( typeof a != "undefined" )
@ -272,11 +257,12 @@ Extends: Gtk.Box,
this . actual _city = parseInt ( a . to _string ( ) ) ;
this . actual _city = parseInt ( a . to _string ( ) ) ;
} ,
} ,
addCity : function ( )
addCity : function ( ) {
{
let that = this ;
let that = this ;
let textDialog = _ ( "Name of the city" ) ;
let textDialog = _ ( "Name of the city" ) ;
let dialog = new Gtk . Dialog ( { title : "" } ) ;
let dialog = new Gtk . Dialog ( {
title : ""
} ) ;
let entry = new Gtk . Entry ( ) ;
let entry = new Gtk . Entry ( ) ;
let completion = new Gtk . EntryCompletion ( ) ;
let completion = new Gtk . EntryCompletion ( ) ;
entry . set _completion ( completion ) ;
entry . set _completion ( completion ) ;
@ -286,10 +272,8 @@ Extends: Gtk.Box,
completion . set _text _column ( 0 ) ;
completion . set _text _column ( 0 ) ;
completion . set _popup _single _match ( true ) ;
completion . set _popup _single _match ( true ) ;
completion . set _minimum _key _length ( 1 ) ;
completion . set _minimum _key _length ( 1 ) ;
completion . set _match _func ( function ( completion , key , iter )
completion . set _match _func ( function ( completion , key , iter ) {
{
if ( iter ) {
if ( iter )
{
if ( completionModel . get _value ( iter , 0 ) )
if ( completionModel . get _value ( iter , 0 ) )
return true ;
return true ;
}
}
@ -297,7 +281,9 @@ Extends: Gtk.Box,
} ) ;
} ) ;
entry . margin _top = 12 ;
entry . margin _top = 12 ;
entry . margin _bottom = 12 ;
entry . margin _bottom = 12 ;
let label = new Gtk . Label ( { label : textDialog } ) ;
let label = new Gtk . Label ( {
label : textDialog
} ) ;
dialog . set _border _width ( 12 ) ;
dialog . set _border _width ( 12 ) ;
dialog . set _modal ( 1 ) ;
dialog . set _modal ( 1 ) ;
@ -313,8 +299,7 @@ Extends: Gtk.Box,
dialog . set _default ( d ) ;
dialog . set _default ( d ) ;
entry . activates _default = true ;
entry . activates _default = true ;
let testLocation = function ( location )
let testLocation = function ( location ) {
{
if ( location . search ( /\[/ ) == - 1 || location . search ( /\]/ ) == - 1 )
if ( location . search ( /\[/ ) == - 1 || location . search ( /\]/ ) == - 1 )
return 0 ;
return 0 ;
@ -322,8 +307,7 @@ Extends: Gtk.Box,
if ( ! woeid )
if ( ! woeid )
return 0 ;
return 0 ;
that . loadJsonAsync ( encodeURI ( 'http://query.yahooapis.com/v1/public/yql?q=select woeid from geo.places where woeid = "' + woeid + '" limit 1&format=json' ) , function ( )
that . loadJsonAsync ( encodeURI ( 'http://query.yahooapis.com/v1/public/yql?q=select woeid from geo.places where woeid = "' + woeid + '" limit 1&format=json' ) , function ( ) {
{
d . sensitive = 0 ;
d . sensitive = 0 ;
if ( typeof arguments [ 0 ] . query == "undefined" )
if ( typeof arguments [ 0 ] . query == "undefined" )
return 0 ;
return 0 ;
@ -338,12 +322,10 @@ Extends: Gtk.Box,
return 0 ;
return 0 ;
} ;
} ;
let searchLocation = function ( )
let searchLocation = function ( ) {
{
let location = entry . get _text ( ) ;
let location = entry . get _text ( ) ;
if ( testLocation ( location ) == 0 )
if ( testLocation ( location ) == 0 )
that . loadJsonAsync ( encodeURI ( 'http://query.yahooapis.com/v1/public/yql?q=select woeid,name,admin1,country from geo.places where text = "*' + location + '*" or text = "' + location + '"&format=json' ) , function ( )
that . loadJsonAsync ( encodeURI ( 'http://query.yahooapis.com/v1/public/yql?q=select woeid,name,admin1,country from geo.places where text = "*' + location + '*" or text = "' + location + '"&format=json' ) , function ( ) {
{
if ( ! arguments [ 0 ] )
if ( ! arguments [ 0 ] )
return 0 ;
return 0 ;
let city = arguments [ 0 ] . query ;
let city = arguments [ 0 ] . query ;
@ -356,10 +338,8 @@ Extends: Gtk.Box,
let current = this . liststore . get _iter _first ( ) ;
let current = this . liststore . get _iter _first ( ) ;
if ( n > 1 )
if ( n > 1 ) {
{
for ( var i in city ) {
for ( var i in city )
{
if ( typeof m == "undefined" )
if ( typeof m == "undefined" )
var m = { } ;
var m = { } ;
@ -380,9 +360,7 @@ Extends: Gtk.Box,
completionModel . set _value ( current , 0 , cityText ) ;
completionModel . set _value ( current , 0 , cityText ) ;
}
}
}
} else {
else
{
current = completionModel . append ( ) ;
current = completionModel . append ( ) ;
let cityText = city . name ;
let cityText = city . name ;
if ( city . admin1 )
if ( city . admin1 )
@ -406,8 +384,7 @@ Extends: Gtk.Box,
dialog _area . pack _start ( label , 0 , 0 , 0 ) ;
dialog _area . pack _start ( label , 0 , 0 , 0 ) ;
dialog _area . pack _start ( entry , 0 , 0 , 0 ) ;
dialog _area . pack _start ( entry , 0 , 0 , 0 ) ;
dialog . connect ( "response" , function ( w , response _id ) {
dialog . connect ( "response" , function ( w , response _id ) {
if ( response _id )
if ( response _id ) {
{
if ( entry . get _text ( ) . search ( /\[/ ) == - 1 || entry . get _text ( ) . search ( /\]/ ) == - 1 )
if ( entry . get _text ( ) . search ( /\[/ ) == - 1 || entry . get _text ( ) . search ( /\]/ ) == - 1 )
return 0 ;
return 0 ;
@ -415,8 +392,7 @@ Extends: Gtk.Box,
if ( ! woeid )
if ( ! woeid )
return 0 ;
return 0 ;
that . loadJsonAsync ( encodeURI ( 'http://query.yahooapis.com/v1/public/yql?format=json&q=select woeid,name,admin1,country from geo.places where woeid = "' + woeid + '" limit 1' ) , function ( )
that . loadJsonAsync ( encodeURI ( 'http://query.yahooapis.com/v1/public/yql?format=json&q=select woeid,name,admin1,country from geo.places where woeid = "' + woeid + '" limit 1' ) , function ( ) {
{
let city = arguments [ 0 ] . query ;
let city = arguments [ 0 ] . query ;
if ( Number ( city . count ) > 0 )
if ( Number ( city . count ) > 0 )
city = city . results . place ;
city = city . results . place ;
@ -444,16 +420,19 @@ Extends: Gtk.Box,
dialog . show _all ( ) ;
dialog . show _all ( ) ;
} ,
} ,
removeCity : function ( )
removeCity : function ( ) {
{
let that = this ;
let that = this ;
let city = this . city . split ( " && " ) ;
let city = this . city . split ( " && " ) ;
if ( ! city . length )
if ( ! city . length )
return 0 ;
return 0 ;
let ac = this . actual _city ;
let ac = this . actual _city ;
let textDialog = _ ( "Remove %s ?" ) . replace ( "%s" , this . extractLocation ( city [ ac ] ) ) ;
let textDialog = _ ( "Remove %s ?" ) . replace ( "%s" , this . extractLocation ( city [ ac ] ) ) ;
let dialog = new Gtk . Dialog ( { title : "" } ) ;
let dialog = new Gtk . Dialog ( {
let label = new Gtk . Label ( { label : textDialog } ) ;
title : ""
} ) ;
let label = new Gtk . Label ( {
label : textDialog
} ) ;
label . margin _bottom = 12 ;
label . margin _bottom = 12 ;
dialog . set _border _width ( 12 ) ;
dialog . set _border _width ( 12 ) ;
@ -469,10 +448,8 @@ Extends: Gtk.Box,
let dialog _area = dialog . get _content _area ( ) ;
let dialog _area = dialog . get _content _area ( ) ;
dialog _area . pack _start ( label , 0 , 0 , 0 ) ;
dialog _area . pack _start ( label , 0 , 0 , 0 ) ;
dialog . connect ( "response" , function ( w , response _id )
dialog . connect ( "response" , function ( w , response _id ) {
{
if ( response _id ) {
if ( response _id )
{
if ( city . length == 0 )
if ( city . length == 0 )
city = [ ] ;
city = [ ] ;
@ -497,8 +474,7 @@ Extends: Gtk.Box,
return 0 ;
return 0 ;
} ,
} ,
changeSelection : function ( )
changeSelection : function ( ) {
{
let path = this . actual _city ;
let path = this . actual _city ;
if ( arguments [ 0 ] )
if ( arguments [ 0 ] )
path = arguments [ 0 ] ;
path = arguments [ 0 ] ;
@ -506,37 +482,30 @@ Extends: Gtk.Box,
this . treeview . get _selection ( ) . select _path ( path ) ;
this . treeview . get _selection ( ) . select _path ( path ) ;
} ,
} ,
loadJsonAsync : function ( url , fun , id )
loadJsonAsync : function ( url , fun , id ) {
{
let here = this ;
let here = this ;
let message = Soup . Message . new ( 'GET' , url ) ;
let message = Soup . Message . new ( 'GET' , url ) ;
if ( typeof this . asyncSession == "undefined" )
if ( typeof this . asyncSession == "undefined" )
this . asyncSession = { } ;
this . asyncSession = { } ;
if ( typeof this . asyncSession [ id ] != "undefined" && this . asyncSession [ id ] )
if ( typeof this . asyncSession [ id ] != "undefined" && this . asyncSession [ id ] ) {
{
_httpSession . abort ( ) ;
_httpSession . abort ( ) ;
this . asyncSession [ id ] = 0 ;
this . asyncSession [ id ] = 0 ;
}
}
this . asyncSession [ id ] = 1 ;
this . asyncSession [ id ] = 1 ;
_httpSession . queue _message ( message , function ( _httpSession , message )
_httpSession . queue _message ( message , function ( _httpSession , message ) {
{
here . asyncSession [ id ] = 0 ;
here . asyncSession [ id ] = 0 ;
if ( ! message . response _body . data )
if ( ! message . response _body . data ) {
{
fun . call ( here , 0 ) ;
fun . call ( here , 0 ) ;
return 0 ;
return 0 ;
}
}
try
try {
{
let jp = JSON . parse ( message . response _body . data ) ;
let jp = JSON . parse ( message . response _body . data ) ;
fun . call ( here , jp ) ;
fun . call ( here , jp ) ;
}
} catch ( e ) {
catch ( e )
{
fun . call ( here , 0 ) ;
fun . call ( here , 0 ) ;
return 0 ;
return 0 ;
}
}
@ -544,85 +513,75 @@ Extends: Gtk.Box,
} ) ;
} ) ;
} ,
} ,
loadConfig : function ( )
loadConfig : function ( ) {
{
let that = this ;
let that = this ;
this . Settings = Convenience . getSettings ( WEATHER _SETTINGS _SCHEMA ) ;
this . Settings = Convenience . getSettings ( WEATHER _SETTINGS _SCHEMA ) ;
this . Settings . connect ( "changed" , function ( ) { that . refreshUI ( ) ; } ) ;
this . Settings . connect ( "changed" , function ( ) {
that . refreshUI ( ) ;
} ) ;
} ,
} ,
get units ( )
get units ( ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
return this . Settings . get _enum ( WEATHER _UNIT _KEY ) ;
return this . Settings . get _enum ( WEATHER _UNIT _KEY ) ;
} ,
} ,
set units ( v )
set units ( v ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
this . Settings . set _enum ( WEATHER _UNIT _KEY , v ) ;
this . Settings . set _enum ( WEATHER _UNIT _KEY , v ) ;
} ,
} ,
get pressure _unit ( )
get pressure _unit ( ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
return this . Settings . get _enum ( WEATHER _PRESSURE _UNIT _KEY ) ;
return this . Settings . get _enum ( WEATHER _PRESSURE _UNIT _KEY ) ;
} ,
} ,
set pressure _unit ( v )
set pressure _unit ( v ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
this . Settings . set _enum ( WEATHER _PRESSURE _UNIT _KEY , v ) ;
this . Settings . set _enum ( WEATHER _PRESSURE _UNIT _KEY , v ) ;
} ,
} ,
get wind _speed _unit ( )
get wind _speed _unit ( ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
return this . Settings . get _enum ( WEATHER _WIND _SPEED _UNIT _KEY ) ;
return this . Settings . get _enum ( WEATHER _WIND _SPEED _UNIT _KEY ) ;
} ,
} ,
set wind _speed _unit ( v )
set wind _speed _unit ( v ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
this . Settings . set _enum ( WEATHER _WIND _SPEED _UNIT _KEY , v ) ;
this . Settings . set _enum ( WEATHER _WIND _SPEED _UNIT _KEY , v ) ;
} ,
} ,
get wind _direction ( )
get wind _direction ( ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
return this . Settings . get _boolean ( WEATHER _WIND _DIRECTION _KEY ) ;
return this . Settings . get _boolean ( WEATHER _WIND _DIRECTION _KEY ) ;
} ,
} ,
set wind _direction ( v )
set wind _direction ( v ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
return this . Settings . set _boolean ( WEATHER _WIND _DIRECTION _KEY , v ) ;
return this . Settings . set _boolean ( WEATHER _WIND _DIRECTION _KEY , v ) ;
} ,
} ,
get city ( )
get city ( ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
return this . Settings . get _string ( WEATHER _CITY _KEY ) ;
return this . Settings . get _string ( WEATHER _CITY _KEY ) ;
} ,
} ,
set city ( v )
set city ( v ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
this . Settings . set _string ( WEATHER _CITY _KEY , v ) ;
this . Settings . set _string ( WEATHER _CITY _KEY , v ) ;
} ,
} ,
get actual _city ( )
get actual _city ( ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
let a = this . Settings . get _int ( WEATHER _ACTUAL _CITY _KEY ) ;
let a = this . Settings . get _int ( WEATHER _ACTUAL _CITY _KEY ) ;
@ -645,8 +604,7 @@ Extends: Gtk.Box,
return a ;
return a ;
} ,
} ,
set actual _city ( a )
set actual _city ( a ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
let citys = this . city . split ( " && " ) ;
let citys = this . city . split ( " && " ) ;
@ -668,112 +626,96 @@ Extends: Gtk.Box,
this . Settings . set _int ( WEATHER _ACTUAL _CITY _KEY , a ) ;
this . Settings . set _int ( WEATHER _ACTUAL _CITY _KEY , a ) ;
} ,
} ,
get translate _condition ( )
get translate _condition ( ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
return this . Settings . get _boolean ( WEATHER _TRANSLATE _CONDITION _KEY ) ;
return this . Settings . get _boolean ( WEATHER _TRANSLATE _CONDITION _KEY ) ;
} ,
} ,
set translate _condition ( v )
set translate _condition ( v ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
this . Settings . set _boolean ( WEATHER _TRANSLATE _CONDITION _KEY , v ) ;
this . Settings . set _boolean ( WEATHER _TRANSLATE _CONDITION _KEY , v ) ;
} ,
} ,
get icon _type ( )
get icon _type ( ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
return this . Settings . get _boolean ( WEATHER _USE _SYMBOLIC _ICONS _KEY ) ;
return this . Settings . get _boolean ( WEATHER _USE _SYMBOLIC _ICONS _KEY ) ;
} ,
} ,
set icon _type ( v )
set icon _type ( v ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
this . Settings . set _boolean ( WEATHER _USE _SYMBOLIC _ICONS _KEY , v ) ;
this . Settings . set _boolean ( WEATHER _USE _SYMBOLIC _ICONS _KEY , v ) ;
} ,
} ,
get text _in _panel ( )
get text _in _panel ( ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
return this . Settings . get _boolean ( WEATHER _SHOW _TEXT _IN _PANEL _KEY ) ;
return this . Settings . get _boolean ( WEATHER _SHOW _TEXT _IN _PANEL _KEY ) ;
} ,
} ,
set text _in _panel ( v )
set text _in _panel ( v ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
this . Settings . set _boolean ( WEATHER _SHOW _TEXT _IN _PANEL _KEY , v ) ;
this . Settings . set _boolean ( WEATHER _SHOW _TEXT _IN _PANEL _KEY , v ) ;
} ,
} ,
get position _in _panel ( )
get position _in _panel ( ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
return this . Settings . get _enum ( WEATHER _POSITION _IN _PANEL _KEY ) ;
return this . Settings . get _enum ( WEATHER _POSITION _IN _PANEL _KEY ) ;
} ,
} ,
set position _in _panel ( v )
set position _in _panel ( v ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
this . Settings . set _enum ( WEATHER _POSITION _IN _PANEL _KEY , v ) ;
this . Settings . set _enum ( WEATHER _POSITION _IN _PANEL _KEY , v ) ;
} ,
} ,
get comment _in _panel ( )
get comment _in _panel ( ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
return this . Settings . get _boolean ( WEATHER _SHOW _COMMENT _IN _PANEL _KEY ) ;
return this . Settings . get _boolean ( WEATHER _SHOW _COMMENT _IN _PANEL _KEY ) ;
} ,
} ,
set comment _in _panel ( v )
set comment _in _panel ( v ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
this . Settings . set _boolean ( WEATHER _SHOW _COMMENT _IN _PANEL _KEY , v ) ;
this . Settings . set _boolean ( WEATHER _SHOW _COMMENT _IN _PANEL _KEY , v ) ;
} ,
} ,
get refresh _interval ( )
get refresh _interval ( ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
return this . Settings . get _int ( WEATHER _REFRESH _INTERVAL ) ;
return this . Settings . get _int ( WEATHER _REFRESH _INTERVAL ) ;
} ,
} ,
set refresh _interval ( v )
set refresh _interval ( v ) {
{
if ( ! this . Settings )
if ( ! this . Settings )
this . loadConfig ( ) ;
this . loadConfig ( ) ;
this . Settings . set _int ( WEATHER _REFRESH _INTERVAL , v ) ;
this . Settings . set _int ( WEATHER _REFRESH _INTERVAL , v ) ;
} ,
} ,
extractLocation : function ( a )
extractLocation : function ( a ) {
{
if ( a . search ( ">" ) == - 1 )
if ( a . search ( ">" ) == - 1 )
return _ ( "Invalid city" ) ;
return _ ( "Invalid city" ) ;
return a . split ( ">" ) [ 1 ] ;
return a . split ( ">" ) [ 1 ] ;
} ,
} ,
extractWoeid : function ( a )
extractWoeid : function ( a ) {
{
if ( a . search ( ">" ) == - 1 )
if ( a . search ( ">" ) == - 1 )
return 0 ;
return 0 ;
return a . split ( ">" ) [ 0 ] ;
return a . split ( ">" ) [ 0 ] ;
}
}
} ) ;
} ) ;
function init ( )
function init ( ) {
{
Convenience . initTranslations ( 'gnome-shell-extension-weather' ) ;
Convenience . initTranslations ( 'gnome-shell-extension-weather' ) ;
}
}
function buildPrefsWidget ( )
function buildPrefsWidget ( ) {
{
let widget = new WeatherPrefsWidget ( ) ;
let widget = new WeatherPrefsWidget ( ) ;
widget . show _all ( ) ;
widget . show _all ( ) ;
return widget ;
return widget ;