[gnome-shell] dateMenu: Use AppSettingsMonitor for world clocks
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] dateMenu: Use AppSettingsMonitor for world clocks
- Date: Mon, 27 Feb 2017 19:03:01 +0000 (UTC)
commit 0353ebde5dd8ae408cc246330db793664e8029ba
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Feb 23 22:54:32 2017 +0100
dateMenu: Use AppSettingsMonitor for world clocks
When gnome-clocks is installed, there is currently a race between the
GSettings schema being added to the database and the world clocks
session trying to use it. The prize if we win that race is an abort
in GIO, so use the newly added AppSettingsMonitor skip the race
altogether.
https://bugzilla.gnome.org/show_bug.cgi?id=766410
js/ui/dateMenu.js | 38 ++++++++++----------------------------
1 files changed, 10 insertions(+), 28 deletions(-)
---
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 36c7950..eab55b4 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -87,9 +87,7 @@ const WorldClocksSection = new Lang.Class({
_init: function() {
this._clock = new GnomeDesktop.WallClock();
- this._settings = null;
this._clockNotifyId = 0;
- this._changedId = 0;
this._locations = [];
@@ -98,8 +96,7 @@ const WorldClocksSection = new Lang.Class({
can_focus: true });
this.actor.connect('clicked', Lang.bind(this,
function() {
- let app = this._getClockApp();
- app.activate();
+ this._clockAppMon.activateApp();
Main.overview.hide();
Main.panel.closeCalendar();
@@ -112,40 +109,25 @@ const WorldClocksSection = new Lang.Class({
this.actor.child = this._grid;
- Shell.AppSystem.get_default().connect('installed-changed',
- Lang.bind(this, this._sync));
+ this._clockAppMon = new Util.AppSettingsMonitor('org.gnome.clocks.desktop',
+ 'org.gnome.clocks');
+ this._clockAppMon.connect('available-changed',
+ Lang.bind(this, this._sync));
+ this._clockAppMon.watchSetting('world-clocks',
+ Lang.bind(this, this._clocksChanged));
this._sync();
},
- _getClockApp: function() {
- return Shell.AppSystem.get_default().lookup_app('org.gnome.clocks.desktop');
- },
-
_sync: function() {
- this.actor.visible = (this._getClockApp() != null);
-
- if (this.actor.visible) {
- if (!this._settings) {
- this._settings = new Gio.Settings({ schema_id: 'org.gnome.clocks' });
- this._changedId =
- this._settings.connect('changed::world-clocks',
- Lang.bind(this, this._clocksChanged));
- this._clocksChanged();
- }
- } else {
- if (this._settings)
- this._settings.disconnect(this._changedId);
- this._settings = null;
- this._changedId = 0;
- }
+ this.actor.visible = this._clockAppMon.available;
},
- _clocksChanged: function() {
+ _clocksChanged: function(settings) {
this._grid.destroy_all_children();
this._locations = [];
let world = GWeather.Location.get_world();
- let clocks = this._settings.get_value('world-clocks').deep_unpack();
+ let clocks = settings.get_value('world-clocks').deep_unpack();
for (let i = 0; i < clocks.length; i++) {
let l = world.deserialize(clocks[i].location);
this._locations.push({ location: l });
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]