[gnome-weather] main: Export location information to gnome-shell
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-weather] main: Export location information to gnome-shell
- Date: Thu, 1 Aug 2019 18:11:35 +0000 (UTC)
commit e1952460f3146c2467de36d76d7cb812ff79bf05
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Jul 23 00:23:27 2019 +0200
main: Export location information to gnome-shell
Currently gnome-shell integrates Weather by picking up our settings
and showing a corresponding forecast. However that only works when
gnome-weather is installed on the host, but not from a flatpak, as
the setting is "hidden away" in a container in that case.
To address this, export the relevant information over D-Bus instead,
so that gnome-shell can pick it up without poking at our GSettings
schema.
https://gitlab.gnome.org/GNOME/gnome-shell/issues/1158
data/ShellWeatherIntegration.xml | 16 +++++++++++
data/org.gnome.Weather.data.gresource.xml | 3 ++
src/app/main.js | 48 +++++++++++++++++++++++++++++++
3 files changed, 67 insertions(+)
---
diff --git a/data/ShellWeatherIntegration.xml b/data/ShellWeatherIntegration.xml
new file mode 100644
index 0000000..1e89bbe
--- /dev/null
+++ b/data/ShellWeatherIntegration.xml
@@ -0,0 +1,16 @@
+<node>
+
+ <!--
+ org.gnome.Shell.WeatherIntegration:
+ @short_description: Weather integration interface
+
+ The interface used for exporting location settings to GNOME Shell's
+ weather integration.
+ -->
+ <interface name="org.gnome.Shell.WeatherIntegration">
+
+ <property name="AutomaticLocation" type="b" access="read"/>
+ <property name="Locations" type="av" access="read"/>
+
+ </interface>
+</node>
diff --git a/data/org.gnome.Weather.data.gresource.xml b/data/org.gnome.Weather.data.gresource.xml
index 6a04a87..9913ed5 100644
--- a/data/org.gnome.Weather.data.gresource.xml
+++ b/data/org.gnome.Weather.data.gresource.xml
@@ -17,4 +17,7 @@
<file>weather-snow.jpg</file>
<file>weather-storm.jpg</file>
</gresource>
+ <gresource prefix="/org/gnome/shell">
+ <file>ShellWeatherIntegration.xml</file>
+ </gresource>
</gresources>
diff --git a/src/app/main.js b/src/app/main.js
index f036046..158254b 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -25,6 +25,7 @@ pkg.require({ 'Gdk': '3.0',
'Gtk': '3.0',
'GWeather': '3.0' });
+const ByteArray = imports.byteArray;
const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
@@ -37,6 +38,9 @@ const Window = imports.app.window;
const World = imports.shared.world;
const CurrentLocationController = imports.app.currentLocationController;
+const ShellIntegrationInterface = ByteArray.toString(
+ Gio.resources_lookup_data('/org/gnome/shell/ShellWeatherIntegration.xml', 0).get_data());
+
function initEnvironment() {
window.getApp = function() {
return Gio.Application.get_default();
@@ -167,6 +171,16 @@ const Application = GObject.registerClass(
this.add_accelerator("<Primary>q", "app.quit", null);
}
+ vfunc_dbus_register(conn, path) {
+ this._shellIntegration = new ShellIntegration();
+ this._shellIntegration.export(conn, path);
+ return true;
+ }
+
+ vfunc_dbus_unregister(conn, path) {
+ this._shellIntegration.unexport(conn);
+ }
+
_createWindow() {
return new Window.MainWindow({ application: this });
}
@@ -213,6 +227,40 @@ const Application = GObject.registerClass(
}
});
+let ShellIntegration = class ShellIntegration {
+ constructor() {
+ this._impl = Gio.DBusExportedObject.wrapJSObject(
+ ShellIntegrationInterface, this);
+
+ this._settings = new Gio.Settings({ schema_id: 'org.gnome.Weather' });
+
+ this._settings.connect('changed::automatic-location', () => {
+ this._impl.emit_property_changed('AutomaticLocation',
+ new GLib.Variant('b', this.AutomaticLocation));
+ });
+ this._settings.connect('changed::locations', () => {
+ this._impl.emit_property_changed('Locations',
+ new GLib.Variant('av', this.Locations));
+ });
+ }
+
+ export(connection, path) {
+ return this._impl.export(connection, path);
+ }
+
+ unexport(connection) {
+ return this._impl.unexport_from_connection(connection);
+ }
+
+ get AutomaticLocation() {
+ return this._settings.get_boolean('automatic-location');
+ }
+
+ get Locations() {
+ return this._settings.get_value('locations').deep_unpack();
+ }
+};
+
function main(argv) {
initEnvironment();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]