@@ -17,7 +17,6 @@ import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js';
1717import * as Values from './values.js' ;
1818import * as Config from 'resource:///org/gnome/shell/misc/config.js' ;
1919import * as MenuItem from './menuItem.js' ;
20- import * as HistoryGraph from './history.js' ;
2120
2221let vitalsMenu ;
2322
@@ -59,15 +58,9 @@ var VitalsMenuButton = GObject.registerClass({
5958 this . _newGpuDetected = false ;
6059 this . _newGpuDetectedCount = 0 ;
6160 this . _last_query = new Date ( ) . getTime ( ) ;
62- this . _historyPopout = null ;
63- this . _historyHideTimeoutId = null ;
64- this . _historyPopoutSensorKey = null ;
65- this . _historyPopoutLabel = null ;
6661
6762 this . _sensors = new Sensors . Sensors ( this . _settings , this . _sensorIcons ) ;
6863 this . _values = new Values . Values ( this . _settings , this . _sensorIcons ) ;
69- this . _historyCachePath = GLib . get_user_cache_dir ( ) + '/vitals/history.json' ;
70- this . _values . loadTimeSeries ( this . _historyCachePath ) ;
7164 this . _menuLayout = new St . BoxLayout ( {
7265 vertical : false ,
7366 clip_to_allocation : true ,
@@ -88,7 +81,7 @@ var VitalsMenuButton = GObject.registerClass({
8881 this . _addSettingChangedSignal ( 'menu-centered' , this . _positionInPanelChanged . bind ( this ) ) ;
8982 this . _addSettingChangedSignal ( 'icon-style' , this . _iconStyleChanged . bind ( this ) ) ;
9083
91- let settings = [ 'use-higher-precision' , 'alphabetize' , 'hide-zeros' , 'fixed-widths' , 'hide-icons' , 'unit' , 'memory-measurement' , 'include-public-ip' , 'network-speed-format' , 'storage-measurement' , 'include-static-info' , 'include-static-gpu-info' , 'show-sensor-history-graph' ] ;
84+ let settings = [ 'use-higher-precision' , 'alphabetize' , 'hide-zeros' , 'fixed-widths' , 'hide-icons' , 'unit' , 'memory-measurement' , 'include-public-ip' , 'network-speed-format' , 'storage-measurement' , 'include-static-info' , 'include-static-gpu-info' ] ;
9285 for ( let setting of Object . values ( settings ) )
9386 this . _addSettingChangedSignal ( setting , this . _redrawMenu . bind ( this ) ) ;
9487
@@ -97,7 +90,6 @@ var VitalsMenuButton = GObject.registerClass({
9790 this . _addSettingChangedSignal ( 'show-' + sensor , this . _showHideSensorsChanged . bind ( this ) ) ;
9891
9992 this . _initializeMenu ( ) ;
100- this . _createHistoryPopout ( ) ;
10193
10294 // start off with fresh sensors
10395 this . _querySensors ( ) ;
@@ -184,214 +176,8 @@ var VitalsMenuButton = GObject.registerClass({
184176
185177 // refresh sensors now
186178 this . _querySensors ( ) ;
187- } else {
188- this . _hideHistoryPopout ( ) ;
189- }
190- } ) ;
191- }
192-
193- _createHistoryPopout ( ) {
194- const popoutWidth = 280 ;
195- const popoutHeight = 145 ;
196- this . _historyPopout = new St . BoxLayout ( {
197- vertical : true ,
198- style_class : 'vitals-history-popout' ,
199- width : popoutWidth ,
200- height : popoutHeight ,
201- reactive : true ,
202- visible : false
203- } ) ;
204- this . _historyPopout . clip_to_allocation = true ;
205- this . _historyGraph = new HistoryGraph . HistoryGraph ( ) ;
206- this . _historyTitleLabel = new St . Label ( {
207- text : '' ,
208- style_class : 'vitals-history-popout-label' ,
209- x_align : Clutter . ActorAlign . END
210- } ) ;
211- this . _historyPopout . add_child ( this . _historyTitleLabel ) ;
212- this . _historyGraphRow = new St . BoxLayout ( {
213- vertical : false ,
214- x_expand : true ,
215- style_class : 'vitals-history-graph-row'
216- } ) ;
217- this . _historyYAxis = new St . BoxLayout ( {
218- vertical : true ,
219- width : 56 ,
220- style_class : 'vitals-history-y-axis'
221- } ) ;
222- this . _historyYMax = new St . Label ( {
223- text : '' ,
224- style_class : 'vitals-history-popout-axis' ,
225- x_align : Clutter . ActorAlign . END
226- } ) ;
227- this . _historyYMin = new St . Label ( {
228- text : '' ,
229- style_class : 'vitals-history-popout-axis' ,
230- x_align : Clutter . ActorAlign . END
231- } ) ;
232- this . _historyYSpacer = new St . BoxLayout ( { vertical : true , y_expand : true } ) ;
233- this . _historyYAxis . add_child ( this . _historyYMax ) ;
234- this . _historyYAxis . add_child ( this . _historyYSpacer ) ;
235- this . _historyYAxis . add_child ( this . _historyYMin ) ;
236- this . _historyGraphRow . add_child ( this . _historyYAxis ) ;
237- this . _historyGraphRow . add_child ( this . _historyGraph ) ;
238- this . _historyGraphRightSpacer = new St . BoxLayout ( {
239- vertical : true ,
240- width : 18 ,
241- style_class : 'vitals-history-graph-right-spacer'
242- } ) ;
243- this . _historyGraphRow . add_child ( this . _historyGraphRightSpacer ) ;
244- this . _historyPopout . add_child ( this . _historyGraphRow ) ;
245- this . _historyXWrap = new St . BoxLayout ( {
246- vertical : false ,
247- x_expand : true ,
248- style_class : 'vitals-history-x-wrap'
249- } ) ;
250- this . _historyXSpacer = new St . BoxLayout ( {
251- vertical : true ,
252- width : 62 ,
253- style_class : 'vitals-history-x-spacer'
254- } ) ;
255- this . _historyXRow = new St . BoxLayout ( {
256- vertical : false ,
257- x_expand : true ,
258- style_class : 'vitals-history-x-row'
259- } ) ;
260- this . _historyXLeft = new St . Label ( {
261- text : '' ,
262- style_class : 'vitals-history-popout-axis' ,
263- x_align : Clutter . ActorAlign . START ,
264- x_expand : true
265- } ) ;
266- this . _historyXRight = new St . Label ( {
267- text : _ ( 'now' ) ,
268- style_class : 'vitals-history-popout-axis' ,
269- x_align : Clutter . ActorAlign . END
270- } ) ;
271- this . _historyXRow . add_child ( this . _historyXLeft ) ;
272- this . _historyXRow . add_child ( this . _historyXRight ) ;
273- this . _historyXWrap . add_child ( this . _historyXSpacer ) ;
274- this . _historyXWrap . add_child ( this . _historyXRow ) ;
275- this . _historyPopout . add_child ( this . _historyXWrap ) ;
276- this . _historyPopout . connect ( 'enter-event' , ( ) => {
277- if ( this . _historyHideTimeoutId ) {
278- GLib . Source . remove ( this . _historyHideTimeoutId ) ;
279- this . _historyHideTimeoutId = null ;
280179 }
281180 } ) ;
282- this . _historyPopout . connect ( 'leave-event' , ( ) => {
283- this . _scheduleHistoryPopoutHide ( ) ;
284- } ) ;
285- }
286-
287- _updateHistoryGraph ( key , label , samples ) {
288- const historyDuration = Math . max ( 60 , this . _settings . get_int ( 'sensor-history-duration' ) ) ;
289- const nowSec = Date . now ( ) / 1000 ;
290- const cutoff = nowSec - historyDuration ;
291- const windowed = samples . filter ( s => s . t >= cutoff ) ;
292- while ( windowed . length > 0 && windowed [ 0 ] . v === null ) windowed . shift ( ) ;
293- const base = Math . max ( 1 , Math . ceil ( windowed . length / 200 ) ) ;
294- this . _historyGraph . setData ( windowed , label , '' , base ) ;
295- const actualSpan = this . _historyGraph . getTimeSpan ( ) ;
296- const displayDuration = actualSpan > 0 ? Math . min ( historyDuration , Math . round ( actualSpan ) ) : historyDuration ;
297- this . _historyXLeft . text = this . _values . formatDuration ( displayDuration ) + ' ' + _ ( 'ago' ) ;
298- const rawRange = this . _historyGraph . getRawRange ( ) ;
299- if ( rawRange ) {
300- this . _historyYMax . text = this . _values . formatValue ( key , rawRange . max ) ;
301- this . _historyYMin . text = this . _values . formatValue ( key , rawRange . min ) ;
302- this . _historyYAxis . show ( ) ;
303- } else {
304- this . _historyYMax . text = '' ;
305- this . _historyYMin . text = '' ;
306- this . _historyYAxis . hide ( ) ;
307- }
308- }
309-
310- _showHistoryPopout ( key , label , itemActor ) {
311- if ( ! this . _settings . get_boolean ( 'show-sensor-history-graph' ) ) return ;
312- const samples = this . _values . getTimeSeries ( key ) ;
313- if ( samples . length === 0 ) return ;
314- this . _historyPopoutSensorKey = key ;
315- this . _historyPopoutLabel = label ;
316- try {
317- this . _historyTitleLabel . text = label + ' ' + _ ( 'history' ) ;
318- this . _historyTitleLabel . show ( ) ;
319- this . _updateHistoryGraph ( key , label , samples ) ;
320- } catch ( e ) {
321- this . _historyYMax . text = '' ;
322- this . _historyYMin . text = '' ;
323- }
324- const parent = this . menu . actor . get_parent ( ) ;
325- if ( ! parent ) return ;
326- if ( this . _historyPopout . get_parent ( ) !== parent ) {
327- if ( this . _historyPopout . get_parent ( ) )
328- this . _historyPopout . get_parent ( ) . remove_child ( this . _historyPopout ) ;
329- parent . add_child ( this . _historyPopout ) ;
330- }
331- const menuX = this . menu . actor . get_x ( ) ;
332- const menuY = this . menu . actor . get_y ( ) ;
333- let popoutY = menuY ;
334- if ( itemActor ) {
335- let relY = 0 ;
336- let node = itemActor ;
337- while ( node && node !== this . menu . actor ) {
338- relY += node . get_y ( ) ;
339- node = node . get_parent ( ) ;
340- }
341- const rowH = itemActor . get_height ( ) ;
342- const popoutH = this . _historyPopout . get_height ( ) ;
343- popoutY = menuY + relY + Math . round ( ( rowH - popoutH ) / 2 ) ;
344- popoutY = Math . max ( 0 , popoutY ) ;
345- }
346- const popoutW = this . _historyPopout . get_width ( ) ;
347- const menuW = this . menu . actor . get_width ( ) ;
348- let popoutX = menuX - popoutW - 8 ;
349- if ( popoutX < 0 )
350- popoutX = menuX + menuW + 8 ;
351- this . _historyPopout . set_position ( popoutX , popoutY ) ;
352- this . _historyPopout . show ( ) ;
353- if ( this . _historyHideTimeoutId ) {
354- GLib . Source . remove ( this . _historyHideTimeoutId ) ;
355- this . _historyHideTimeoutId = null ;
356- }
357- }
358-
359- _scheduleHistoryPopoutHide ( ) {
360- if ( this . _historyHideTimeoutId ) return ;
361- this . _historyHideTimeoutId = GLib . timeout_add ( GLib . PRIORITY_DEFAULT , 250 , ( ) => {
362- this . _hideHistoryPopout ( ) ;
363- this . _historyHideTimeoutId = null ;
364- return GLib . SOURCE_REMOVE ;
365- } ) ;
366- }
367-
368- _hideHistoryPopout ( ) {
369- if ( this . _historyHideTimeoutId ) {
370- GLib . Source . remove ( this . _historyHideTimeoutId ) ;
371- this . _historyHideTimeoutId = null ;
372- }
373- if ( this . _historyPopout && this . _historyPopout . get_parent ( ) ) {
374- this . _historyPopout . hide ( ) ;
375- this . _historyPopout . get_parent ( ) . remove_child ( this . _historyPopout ) ;
376- }
377- this . _historyPopoutSensorKey = null ;
378- this . _historyPopoutLabel = null ;
379- }
380-
381- _refreshHistoryPopout ( ) {
382- const key = this . _historyPopoutSensorKey ;
383- const label = this . _historyPopoutLabel ;
384- if ( ! key || ! label ) return ;
385- if ( ! this . _historyPopout || ! this . _historyPopout . visible ) return ;
386-
387- const samples = this . _values . getTimeSeries ( key ) ;
388- if ( samples . length === 0 ) return ;
389-
390- try {
391- this . _updateHistoryGraph ( key , label , samples ) ;
392- } catch ( e ) {
393- // ignore
394- }
395181 }
396182
397183 _initializeMenuGroup ( groupName , optionName , menuSuffix = '' , position = - 1 ) {
@@ -459,7 +245,7 @@ var VitalsMenuButton = GObject.registerClass({
459245 GLib . PRIORITY_DEFAULT ,
460246 update_time ,
461247 ( self ) => {
462- // always query sensors (for panel display when hot, and for history graph data )
248+ // always query sensors (for panel display when hot)
463249 this . _querySensors ( ) ;
464250 return GLib . SOURCE_CONTINUE ;
465251 }
@@ -561,7 +347,6 @@ var VitalsMenuButton = GObject.registerClass({
561347 }
562348
563349 _redrawMenu ( ) {
564- this . _hideHistoryPopout ( ) ;
565350 this . _removeHotItems ( ) ;
566351
567352 for ( let key in this . _sensorMenuItems ) {
@@ -598,7 +383,6 @@ var VitalsMenuButton = GObject.registerClass({
598383
599384 _updateTimeSettingChanged ( ) {
600385 this . _destroyTimer ( ) ;
601- this . _values . clearTimeSeries ( this . _historyCachePath ) ;
602386 this . _initializeTimer ( ) ;
603387 }
604388
@@ -696,25 +480,6 @@ var VitalsMenuButton = GObject.registerClass({
696480 }
697481
698482 this . _groups [ type ] . menu . addMenuItem ( item , i ) ;
699-
700- if ( this . _settings . get_boolean ( 'show-sensor-history-graph' ) ) {
701- const key = item . key ;
702- const label = item . label ;
703- item . actor . connect ( 'enter-event' , ( ) => {
704- const samples = this . _values . getTimeSeries ( key ) ;
705- if ( this . _historyHideTimeoutId ) {
706- GLib . Source . remove ( this . _historyHideTimeoutId ) ;
707- this . _historyHideTimeoutId = null ;
708- }
709- if ( samples . length > 0 )
710- this . _showHistoryPopout ( key , label , item . actor ) ;
711- else
712- this . _hideHistoryPopout ( ) ;
713- } ) ;
714- item . actor . connect ( 'leave-event' , ( ) => {
715- this . _scheduleHistoryPopoutHide ( ) ;
716- } ) ;
717- }
718483 }
719484
720485 _defaultLabel ( ) {
@@ -856,8 +621,6 @@ var VitalsMenuButton = GObject.registerClass({
856621 this . _notify ( 'Vitals' , this . _warnings . join ( "\n" ) , 'folder-symbolic' ) ;
857622 this . _warnings = [ ] ;
858623 }
859-
860- this . _refreshHistoryPopout ( ) ;
861624 }
862625
863626 _notify ( msg , details , icon ) {
@@ -869,13 +632,7 @@ var VitalsMenuButton = GObject.registerClass({
869632 }
870633
871634 destroy ( ) {
872- this . _hideHistoryPopout ( ) ;
873- if ( this . _historyPopout ) {
874- this . _historyPopout . destroy ( ) ;
875- this . _historyPopout = null ;
876- }
877635 this . _destroyTimer ( ) ;
878- this . _values . saveTimeSeries ( this . _historyCachePath ) ;
879636 this . _sensors . destroy ( ) ;
880637
881638 for ( let signal of Object . values ( this . _settingChangedSignals ) )
0 commit comments