@@ -15,6 +15,7 @@ const SessionItem = Me.imports.ui.sessionItem;
1515const SearchSessionItem = Me . imports . ui . searchSessionItem ;
1616const PopupMenuButtonItems = Me . imports . ui . popupMenuButtonItems ;
1717const IconFinder = Me . imports . utils . iconFinder ;
18+ const PrefsUtils = Me . imports . utils . prefsUtils ;
1819const Log = Me . imports . utils . log ;
1920
2021
@@ -23,6 +24,9 @@ class AwsIndicator extends PanelMenu.Button {
2324
2425 _init ( ) {
2526 super . _init ( 0.0 , "Another Window Session Manager" ) ;
27+
28+ this . _prefsUtils = new PrefsUtils . PrefsUtils ( ) ;
29+ this . _log = new Log . Log ( ) ;
2630
2731 this . _itemIndex = 0 ;
2832
@@ -111,20 +115,20 @@ class AwsIndicator extends PanelMenu.Button {
111115 return ;
112116 }
113117
114- Log . debug ( 'List all sessions to add session items' ) ;
118+ this . _log . debug ( 'List all sessions to add session items' ) ;
115119
116120 let sessionFileInfos = [ ] ;
117- FileUtils . listAllSessions ( null , false , ( file , info ) => {
121+ FileUtils . listAllSessions ( null , false , this . _prefsUtils . isDebug ( ) , ( file , info ) => {
118122 // We have an interest in regular and text files
119123
120124 const file_type = info . get_file_type ( ) ;
121125 if ( file_type !== Gio . FileType . REGULAR ) {
122- Log . debug ( `${ file . get_path ( ) } (file type is ${ file_type } ) is not a regular file, skipping` ) ;
126+ this . _log . debug ( `${ file . get_path ( ) } (file type is ${ file_type } ) is not a regular file, skipping` ) ;
123127 return ;
124128 }
125129 const content_type = info . get_content_type ( ) ;
126130 if ( content_type !== 'text/plain' ) {
127- Log . debug ( `${ file . get_path ( ) } (content type is ${ content_type } ) is not a text file, skipping` ) ;
131+ this . _log . debug ( `${ file . get_path ( ) } (content type is ${ content_type } ) is not a text file, skipping` ) ;
128132 return ;
129133 }
130134
@@ -139,7 +143,7 @@ class AwsIndicator extends PanelMenu.Button {
139143 } else {
140144 parentPath = parent . get_path ( ) ;
141145 }
142- Log . debug ( `Processing ${ file . get_path ( ) } under ${ parentPath } ` ) ;
146+ this . _log . debug ( `Processing ${ file . get_path ( ) } under ${ parentPath } ` ) ;
143147 sessionFileInfos . push ( {
144148 info : info ,
145149 file : file
@@ -196,8 +200,7 @@ class AwsIndicator extends PanelMenu.Button {
196200 // https://gjs-docs.gnome.org/gio20~2.66p/gio.filemonitor#signal-changed
197201 // Looks like the document is wrong ...
198202 _sessionPathChanged ( monitor , srcFile , descFile ) {
199- Log . debug ( `Session path changed, readd all session items from ${ this . _sessions_path } . ${ srcFile . get_path ( ) } was changed.` ) ;
200-
203+ this . _log . debug ( `Session path changed, readd all session items from ${ this . _sessions_path } . ${ srcFile . get_path ( ) } was changed.` ) ;
201204 this . _sessionsMenuSection . removeAll ( ) ;
202205 // It probably is a problem when there is large amount session files,
203206 // say thousands of them, but who creates that much?
@@ -241,6 +244,16 @@ class AwsIndicator extends PanelMenu.Button {
241244 this . _sessions_path = null ;
242245 }
243246
247+ if ( this . _prefsUtils ) {
248+ this . _prefsUtils . destroy ( ) ;
249+ this . _prefsUtils = null ;
250+ }
251+
252+ if ( this . _log ) {
253+ this . _log . destroy ( ) ;
254+ this . _log = null ;
255+ }
256+
244257 this . destroy ( ) ;
245258
246259 }
0 commit comments