@@ -29,20 +29,51 @@ var OpenWindowsInfoTracker = class {
2929 this . _prefsUtils = new PrefsUtils . PrefsUtils ( ) ;
3030 this . _settings = this . _prefsUtils . getSettings ( ) ;
3131
32- this . _endSessionProxy = new EndSessionDialogProxy ( Gio . DBus . session ,
33- 'org.gnome.Shell' ,
34- '/org/gnome/SessionManager/EndSessionDialog' ) ;
35-
36- this . _endSessionProxy . connectSignal ( 'ConfirmedLogout' , this . _onConfirmedLogout . bind ( this ) ) ;
37- this . _endSessionProxy . connectSignal ( 'ConfirmedReboot' , this . _onConfirmedReboot . bind ( this ) ) ;
38- this . _endSessionProxy . connectSignal ( 'ConfirmedShutdown' , this . _onConfirmedShutdown . bind ( this ) ) ;
39- this . _endSessionProxy . connectSignal ( 'Closed' , this . _onClose . bind ( this ) ) ;
40- this . _endSessionProxy . connectSignal ( 'Canceled' , this . _onCancel . bind ( this ) ) ;
32+ this . _confirmedLogoutId = 0 ;
33+ this . _confirmedRebootId = 0 ;
34+ this . _confirmedShutdownId = 0 ;
35+ this . _closedId = 0 ;
36+ this . _canceledId = 0 ;
37+
38+ this . _busWatchId = Gio . bus_watch_name (
39+ Gio . BusType . SESSION ,
40+ 'org.gnome.Shell' ,
41+ Gio . BusNameWatcherFlags . NONE ,
42+ this . _onNameAppeared . bind ( this ) ,
43+ this . _onNameVanished . bind ( this )
44+ ) ;
4145
4246 this . _display = global . display ;
4347 this . _displayId = this . _display . connect ( 'window-created' , this . _windowCreated . bind ( this ) ) ;
4448 }
4549
50+ _onNameAppeared ( ) {
51+ this . _endSessionProxy = new EndSessionDialogProxy ( Gio . DBus . session ,
52+ 'org.gnome.Shell' ,
53+ '/org/gnome/SessionManager/EndSessionDialog' ,
54+ ( proxy , error ) => {
55+ // If `error` is not `null` it will be an Error object indicating the
56+ // failure, and `proxy` will be `null` in this case.
57+ if ( error !== null ) {
58+ this . _log . error ( error ) ;
59+ return ;
60+ }
61+
62+ this . _confirmedLogoutId = this . _endSessionProxy . connectSignal ( 'ConfirmedLogout' , this . _onConfirmedLogout . bind ( this ) ) ;
63+ this . _confirmedRebootId = this . _endSessionProxy . connectSignal ( 'ConfirmedReboot' , this . _onConfirmedReboot . bind ( this ) ) ;
64+ this . _confirmedShutdownId = this . _endSessionProxy . connectSignal ( 'ConfirmedShutdown' , this . _onConfirmedShutdown . bind ( this ) ) ;
65+ this . _closedId = this . _endSessionProxy . connectSignal ( 'Closed' , this . _onClose . bind ( this ) ) ;
66+ this . _canceledId = this . _endSessionProxy . connectSignal ( 'Canceled' , this . _onCancel . bind ( this ) ) ;
67+ } ,
68+ null ,
69+ Gio . DBusProxyFlags . NONE
70+ ) ;
71+ }
72+
73+ _onNameVanished ( connection , name ) {
74+ this . _log . debug ( `Dbus name ${ name } vanished` ) ;
75+ }
76+
4677 _onClose ( ) {
4778 this . _log . debug ( `User closed endSessionDialog` ) ;
4879 }
@@ -127,6 +158,31 @@ var OpenWindowsInfoTracker = class {
127158 this . _displayId = 0 ;
128159 }
129160
161+ if ( this . _busWatchId ) {
162+ Gio . bus_unwatch_name ( this . _busWatchId ) ;
163+ this . _busWatchId = 0 ;
164+ }
165+
166+ if ( this . _confirmedLogoutId ) {
167+ this . _endSessionProxy ?. disconnectSignal ( this . _confirmedLogoutId ) ;
168+ this . _confirmedLogoutId = 0 ;
169+ }
170+ if ( this . _confirmedRebootId ) {
171+ this . _endSessionProxy ?. disconnectSignal ( this . _confirmedRebootId ) ;
172+ this . _confirmedRebootId = 0 ;
173+ }
174+ if ( this . _confirmedShutdownId ) {
175+ this . _endSessionProxy ?. disconnectSignal ( this . _confirmedShutdownId ) ;
176+ this . _confirmedShutdownId = 0 ;
177+ }
178+ if ( this . _closedId ) {
179+ this . _endSessionProxy ?. disconnectSignal ( this . _closedId ) ;
180+ this . _closedId = 0 ;
181+ }
182+ if ( this . _canceledId ) {
183+ this . _endSessionProxy ?. disconnectSignal ( this . _canceledId ) ;
184+ this . _canceledId = 0 ;
185+ }
130186 }
131187
132188}
0 commit comments