/usr/share/org.gnome.Weather.Application/city.js is in gnome-weather 3.10.1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | // -*- Mode: js; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*-
//
// Copyright (c) 2012 Giovanni Campagna <scampa.giovanni@gmail.com>
//
// Gnome Weather is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// Gnome Weather is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with Gnome Weather; if not, write to the Free Software Foundation,
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
const Forecast = imports.forecast;
const Util = imports.util;
const SPINNER_SIZE = 128;
const WeatherWidget = new Lang.Class({
Name: 'WeatherWidget',
Extends: Gtk.Frame,
_init: function(params) {
params = Params.fill(params, { shadow_type: Gtk.ShadowType.NONE,
name: 'weather-page' });
this.parent(params);
this._currentStyle = null;
let builder = new Gtk.Builder();
builder.add_from_resource('/org/gnome/weather/city.ui');
let outerBox = builder.get_object('outer-box');
this._contentFrame = builder.get_object('content-frame');
let outerGrid = builder.get_object('outer-grid');
this._icon = builder.get_object('conditions-image');
this._temperature = builder.get_object('temperature-label');
this._conditions = builder.get_object('conditions-label');
this._revealButton = builder.get_object('reveal-button');
this._revealer = builder.get_object('revealer');
this._forecasts = new Forecast.ForecastBox({ hexpand: true });
outerGrid.attach(this._forecasts, 0, 1, 1, 1);
this._today = new Forecast.TodaySidebar({ vexpand: true,
name: 'today-sidebar' });
this._revealer.child = this._today;
this._revealButton.connect('clicked', Lang.bind(this, function() {
if (this._revealer.reveal_child) {
this._revealer.reveal_child = false;
this._revealButton.get_child().icon_name = 'go-previous-symbolic';
} else {
this._revealer.reveal_child = true;
this._revealButton.get_child().icon_name = 'go-next-symbolic';
}
}));
this.add(outerBox);
},
clear: function() {
this._forecasts.clear();
this._today.clear();
},
_get_style_class: function(info) {
let icon = info.get_icon_name();
let name = icon.replace(/(-\d{3})/, "");
return name;
},
update: function(info) {
this._conditions.label = Util.getWeatherConditions(info);
this._temperature.label = info.get_temp_summary();
this._icon.icon_name = info.get_symbolic_icon_name();
let context = this._contentFrame.get_style_context();
if (this._currentStyle)
context.remove_class(this._currentStyle);
this._currentStyle = this._get_style_class(info);
context.add_class(this._currentStyle);
let forecasts = info.get_forecast_list();
if (forecasts.length > 0) {
this._forecasts.update(forecasts);
this._forecasts.show();
this._today.update(info);
this._revealButton.show();
this._revealer.show();
} else {
this._forecasts.hide();
this._revealButton.hide();
this._revealer.hide();
}
}
});
const WeatherView = new Lang.Class({
Name: 'WeatherView',
Extends: Gtk.Stack,
_init: function(params) {
this.parent(params);
let loadingPage = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL,
halign: Gtk.Align.CENTER,
valign: Gtk.Align.CENTER });
this._spinner = new Gtk.Spinner({ height_request: SPINNER_SIZE,
width_request: SPINNER_SIZE });
loadingPage.add(this._spinner);
loadingPage.add(new Gtk.Label({ label: _("Loading…"),
name: "loading-label" }));
this.add_named(loadingPage, 'loading');
this._infoPage = new WeatherWidget();
this.add_named(this._infoPage, 'info');
this._info = null;
this._updateId = 0;
},
get info() {
return this._info;
},
set info(info) {
if (this._updateId) {
this._info.disconnect(this._updateId);
this._updateId = 0;
this._infoPage.clear();
}
this._info = info;
if (info) {
this._updateId = this._info.connect('updated',
Lang.bind(this, this._onUpdate));
if (info.is_valid())
this._onUpdate(info);
}
},
vfunc_destroy: function() {
if (this._updateId) {
this._info.disconnect(this._updateId);
this._updateId = 0;
}
this.parent();
},
update: function() {
this.visible_child_name = 'loading';
this._spinner.start();
this._infoPage.clear();
getApp().model.updateInfo(this._info);
},
_onUpdate: function(info) {
this._infoPage.clear();
this._infoPage.update(info);
this._spinner.stop();
this.visible_child_name = 'info';
}
});
|