/usr/share/org.gnome.Weather.Application/main.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 | // -*- 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
pkg.initSubmodule('libgd');
pkg.initGettext();
pkg.initFormat();
pkg.initResources();
pkg.require({ 'Gd': '1.0',
'Gdk': '3.0',
'GdkPixbuf': '2.0',
'Gio': '2.0',
'GLib': '2.0',
'GObject': '2.0',
'Gtk': '3.0',
'GWeather': '3.0',
'Lang': '',
'Mainloop': '',
'Params': '1.0',
'System': '' });
const Util = imports.util;
const Window = imports.window;
const World = imports.world;
const SearchProvider = imports.searchProvider;
function initEnvironment() {
window.getApp = function() {
return Gio.Application.get_default();
};
}
const Application = new Lang.Class({
Name: 'WeatherApplication',
Extends: Gtk.Application,
_init: function() {
this.parent({ application_id: pkg.name,
flags: Gio.ApplicationFlags.IS_SERVICE,
inactivity_timeout: 60000 });
GLib.set_application_name(_("Weather"));
this._searchProvider = new SearchProvider.SearchProvider(this);
},
_onQuit: function() {
this.quit();
},
_initAppMenu: function() {
let builder = new Gtk.Builder();
builder.add_from_resource('/org/gnome/weather/app-menu.ui');
let menu = builder.get_object('app-menu');
this.set_app_menu(menu);
},
vfunc_dbus_register: function(connection, path) {
this.parent(connection, path);
this._searchProvider.export(connection, path);
return true;
},
vfunc_dbus_unregister: function(connection, path) {
this._searchProvider.unexport(connection);
this.parent(connection, path);
},
vfunc_startup: function() {
this.parent();
Gd.ensure_types();
Util.loadStyleSheet('/org/gnome/weather/application.css');
let settings = Gtk.Settings.get_for_screen(Gdk.Screen.get_default());
settings.gtk_application_prefer_dark_theme = true;
this.world = GWeather.Location.get_world();
this.model = new World.WorldModel(this.world);
this.model.connect('notify::loading', Lang.bind(this, function() {
if (this.model.loading)
this.mark_busy();
else
this.unmark_busy();
}));
if (this.model.loading)
this.mark_busy();
Util.initActions(this,
[{ name: 'quit',
activate: this._onQuit }]);
let gwSettings = new Gio.Settings({ schema: 'org.gnome.GWeather' });
this.add_action(gwSettings.create_action('temperature-unit'));
this._initAppMenu();
this.add_accelerator("Escape", "win.selection-mode(false)", null);
this.add_accelerator("<Primary>a", "win.select-all", null);
if (pkg.pkgdatadir != pkg.moduledir) // running from source
this.activate();
},
vfunc_activate: function() {
let win = new Window.MainWindow({ application: this });
if (this.model.loading) {
let id = this.model.connect('notify::loading', function(model) {
model.disconnect(id);
win.show();
});
} else {
win.show();
}
},
vfunc_shutdown: function() {
GWeather.Info.store_cache();
this.parent();
}
});
function main(argv) {
initEnvironment();
return (new Application()).run(argv);
}
|