Codebase list gnome-shell-extension-appindicator / b50bdcb
dbusMenu: Use GCancellable to stop pending async operations Fixes #212 Marco Trevisan (TreviƱo) 4 years ago
1 changed file(s) with 23 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
205205 var DBusClient = class AppIndicators_DBusClient {
206206
207207 constructor(busName, busPath) {
208 this._proxy = new BusClientProxy(Gio.DBus.session, busName, busPath, this._clientReady.bind(this))
208 this._cancellable = new Gio.Cancellable();
209 this._proxy = new BusClientProxy(Gio.DBus.session,
210 busName,
211 busPath,
212 this._clientReady.bind(this),
213 this._cancellable)
209214 this._items = { 0: new DbusMenuItem(this, 0, { 'children-display': GLib.Variant.new_string('submenu') }, []) }
210215
211216 // will be set to true if a layout update is requested while one is already in progress
248253 }
249254
250255 _beginRequestProperties() {
251 this._proxy.GetGroupPropertiesRemote(this._propertiesRequestedFor, [], this._endRequestProperties.bind(this))
256 this._proxy.GetGroupPropertiesRemote(this._propertiesRequestedFor,
257 [],
258 this._cancellable,
259 this._endRequestProperties.bind(this))
252260
253261 this._propertiesRequestedFor = []
254262
257265
258266 _endRequestProperties(result, error) {
259267 if (error) {
260 Util.Logger.warn("Could not retrieve properties: "+error)
268 if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
269 Util.Logger.warn(`Could not retrieve properties: ${error}`);
261270 return
262271 }
263272
293302 _beginLayoutUpdate() {
294303 // we only read the type property, because if the type changes after reading all properties,
295304 // the view would have to replace the item completely which we try to avoid
296 this._proxy.GetLayoutRemote(0, -1, [ 'type', 'children-display' ], this._endLayoutUpdate.bind(this))
305 this._proxy.GetLayoutRemote(0, -1,
306 [ 'type', 'children-display' ],
307 this._cancellable,
308 this._endLayoutUpdate.bind(this))
297309
298310 this._flagLayoutUpdateRequired = false
299311 this._flagLayoutUpdateInProgress = true
301313
302314 _endLayoutUpdate(result, error) {
303315 if (error) {
304 Util.Logger.warn("While reading menu layout on proxy '"+this._proxy.g_name_owner+": "+error)
316 if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
317 Util.Logger.warn(`While reading menu layout on proxy ${this._proxy.g_name_owner}: ${error}`);
305318 return
306319 }
307320
365378
366379 _clientReady(result, error) {
367380 if (error) {
368 Util.Logger.warn("Could not initialize menu proxy: "+error)
381 if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
382 Util.Logger.warn(`Could not initialize menu proxy: ${error}`);
369383 return;
370384 }
371385
410424 if (!this._proxy)
411425 return
412426
413 this._proxy.EventRemote(id, event, params, timestamp, function(result, error) { /* we don't care */ })
427 this._proxy.EventRemote(id, event, params, timestamp, this._cancellable,
428 () => { /* we don't care */ })
414429 }
415430
416431 _onLayoutUpdated() {
438453 destroy() {
439454 this.emit('destroy')
440455
456 this._cancellable.cancel();
441457 Signals._disconnectAll.apply(this._proxy)
442458
443459 this._proxy = null