@@ -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,16 +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- if ( this . _settings . get_boolean ( 'show-sensor-history-graph' ) )
71- this . _values . loadTimeSeries ( this . _historyCachePath ) ;
7264 this . _menuLayout = new St . BoxLayout ( {
7365 vertical : false ,
7466 clip_to_allocation : true ,
@@ -88,16 +80,8 @@ var VitalsMenuButton = GObject.registerClass({
8880 this . _addSettingChangedSignal ( 'position-in-panel' , this . _positionInPanelChanged . bind ( this ) ) ;
8981 this . _addSettingChangedSignal ( 'menu-centered' , this . _positionInPanelChanged . bind ( this ) ) ;
9082 this . _addSettingChangedSignal ( 'icon-style' , this . _iconStyleChanged . bind ( this ) ) ;
91- this . _addSettingChangedSignal ( 'show-sensor-history-graph' , ( ) => {
92- if ( ! this . _settings . get_boolean ( 'show-sensor-history-graph' ) ) {
93- this . _hideHistoryPopout ( ) ;
94- this . _values . clearTimeSeries ( this . _historyCachePath ) ;
95- } else {
96- this . _values . loadTimeSeries ( this . _historyCachePath ) ;
97- }
98- } ) ;
9983
100- 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' ] ;
10185 for ( let setting of Object . values ( settings ) )
10286 this . _addSettingChangedSignal ( setting , this . _redrawMenu . bind ( this ) ) ;
10387
@@ -106,7 +90,6 @@ var VitalsMenuButton = GObject.registerClass({
10690 this . _addSettingChangedSignal ( 'show-' + sensor , this . _showHideSensorsChanged . bind ( this ) ) ;
10791
10892 this . _initializeMenu ( ) ;
109- this . _createHistoryPopout ( ) ;
11093
11194 // start off with fresh sensors
11295 this . _querySensors ( ) ;
@@ -193,214 +176,8 @@ var VitalsMenuButton = GObject.registerClass({
193176
194177 // refresh sensors now
195178 this . _querySensors ( ) ;
196- } else {
197- this . _hideHistoryPopout ( ) ;
198- }
199- } ) ;
200- }
201-
202- _createHistoryPopout ( ) {
203- const popoutWidth = 280 ;
204- const popoutHeight = 145 ;
205- this . _historyPopout = new St . BoxLayout ( {
206- vertical : true ,
207- style_class : 'vitals-history-popout' ,
208- width : popoutWidth ,
209- height : popoutHeight ,
210- reactive : true ,
211- visible : false
212- } ) ;
213- this . _historyPopout . clip_to_allocation = true ;
214- this . _historyGraph = new HistoryGraph . HistoryGraph ( ) ;
215- this . _historyTitleLabel = new St . Label ( {
216- text : '' ,
217- style_class : 'vitals-history-popout-label' ,
218- x_align : Clutter . ActorAlign . END
219- } ) ;
220- this . _historyPopout . add_child ( this . _historyTitleLabel ) ;
221- this . _historyGraphRow = new St . BoxLayout ( {
222- vertical : false ,
223- x_expand : true ,
224- style_class : 'vitals-history-graph-row'
225- } ) ;
226- this . _historyYAxis = new St . BoxLayout ( {
227- vertical : true ,
228- width : 56 ,
229- style_class : 'vitals-history-y-axis'
230- } ) ;
231- this . _historyYMax = new St . Label ( {
232- text : '' ,
233- style_class : 'vitals-history-popout-axis' ,
234- x_align : Clutter . ActorAlign . END
235- } ) ;
236- this . _historyYMin = new St . Label ( {
237- text : '' ,
238- style_class : 'vitals-history-popout-axis' ,
239- x_align : Clutter . ActorAlign . END
240- } ) ;
241- this . _historyYSpacer = new St . BoxLayout ( { vertical : true , y_expand : true } ) ;
242- this . _historyYAxis . add_child ( this . _historyYMax ) ;
243- this . _historyYAxis . add_child ( this . _historyYSpacer ) ;
244- this . _historyYAxis . add_child ( this . _historyYMin ) ;
245- this . _historyGraphRow . add_child ( this . _historyYAxis ) ;
246- this . _historyGraphRow . add_child ( this . _historyGraph ) ;
247- this . _historyGraphRightSpacer = new St . BoxLayout ( {
248- vertical : true ,
249- width : 18 ,
250- style_class : 'vitals-history-graph-right-spacer'
251- } ) ;
252- this . _historyGraphRow . add_child ( this . _historyGraphRightSpacer ) ;
253- this . _historyPopout . add_child ( this . _historyGraphRow ) ;
254- this . _historyXWrap = new St . BoxLayout ( {
255- vertical : false ,
256- x_expand : true ,
257- style_class : 'vitals-history-x-wrap'
258- } ) ;
259- this . _historyXSpacer = new St . BoxLayout ( {
260- vertical : true ,
261- width : 62 ,
262- style_class : 'vitals-history-x-spacer'
263- } ) ;
264- this . _historyXRow = new St . BoxLayout ( {
265- vertical : false ,
266- x_expand : true ,
267- style_class : 'vitals-history-x-row'
268- } ) ;
269- this . _historyXLeft = new St . Label ( {
270- text : '' ,
271- style_class : 'vitals-history-popout-axis' ,
272- x_align : Clutter . ActorAlign . START ,
273- x_expand : true
274- } ) ;
275- this . _historyXRight = new St . Label ( {
276- text : _ ( 'now' ) ,
277- style_class : 'vitals-history-popout-axis' ,
278- x_align : Clutter . ActorAlign . END
279- } ) ;
280- this . _historyXRow . add_child ( this . _historyXLeft ) ;
281- this . _historyXRow . add_child ( this . _historyXRight ) ;
282- this . _historyXWrap . add_child ( this . _historyXSpacer ) ;
283- this . _historyXWrap . add_child ( this . _historyXRow ) ;
284- this . _historyPopout . add_child ( this . _historyXWrap ) ;
285- this . _historyPopout . connect ( 'enter-event' , ( ) => {
286- if ( this . _historyHideTimeoutId ) {
287- GLib . Source . remove ( this . _historyHideTimeoutId ) ;
288- this . _historyHideTimeoutId = null ;
289179 }
290180 } ) ;
291- this . _historyPopout . connect ( 'leave-event' , ( ) => {
292- this . _scheduleHistoryPopoutHide ( ) ;
293- } ) ;
294- }
295-
296- _updateHistoryGraph ( key , label , samples ) {
297- const historyDuration = Math . max ( 60 , this . _settings . get_int ( 'sensor-history-duration' ) ) ;
298- const nowSec = Date . now ( ) / 1000 ;
299- const cutoff = nowSec - historyDuration ;
300- const windowed = samples . filter ( s => s . t >= cutoff ) ;
301- while ( windowed . length > 0 && windowed [ 0 ] . v === null ) windowed . shift ( ) ;
302- const base = Math . max ( 1 , Math . ceil ( windowed . length / 200 ) ) ;
303- this . _historyGraph . setData ( windowed , label , '' , base ) ;
304- const actualSpan = this . _historyGraph . getTimeSpan ( ) ;
305- const displayDuration = actualSpan > 0 ? Math . min ( historyDuration , Math . round ( actualSpan ) ) : historyDuration ;
306- this . _historyXLeft . text = this . _values . formatDuration ( displayDuration ) + ' ' + _ ( 'ago' ) ;
307- const rawRange = this . _historyGraph . getRawRange ( ) ;
308- if ( rawRange ) {
309- this . _historyYMax . text = this . _values . formatValue ( key , rawRange . max ) ;
310- this . _historyYMin . text = this . _values . formatValue ( key , rawRange . min ) ;
311- this . _historyYAxis . show ( ) ;
312- } else {
313- this . _historyYMax . text = '' ;
314- this . _historyYMin . text = '' ;
315- this . _historyYAxis . hide ( ) ;
316- }
317- }
318-
319- _showHistoryPopout ( key , label , itemActor ) {
320- if ( ! this . _settings . get_boolean ( 'show-sensor-history-graph' ) ) return ;
321- const samples = this . _values . getTimeSeries ( key ) ;
322- if ( samples . length === 0 ) return ;
323- this . _historyPopoutSensorKey = key ;
324- this . _historyPopoutLabel = label ;
325- try {
326- this . _historyTitleLabel . text = label + ' ' + _ ( 'history' ) ;
327- this . _historyTitleLabel . show ( ) ;
328- this . _updateHistoryGraph ( key , label , samples ) ;
329- } catch ( e ) {
330- this . _historyYMax . text = '' ;
331- this . _historyYMin . text = '' ;
332- }
333- const parent = this . menu . actor . get_parent ( ) ;
334- if ( ! parent ) return ;
335- if ( this . _historyPopout . get_parent ( ) !== parent ) {
336- if ( this . _historyPopout . get_parent ( ) )
337- this . _historyPopout . get_parent ( ) . remove_child ( this . _historyPopout ) ;
338- parent . add_child ( this . _historyPopout ) ;
339- }
340- const menuX = this . menu . actor . get_x ( ) ;
341- const menuY = this . menu . actor . get_y ( ) ;
342- let popoutY = menuY ;
343- if ( itemActor ) {
344- let relY = 0 ;
345- let node = itemActor ;
346- while ( node && node !== this . menu . actor ) {
347- relY += node . get_y ( ) ;
348- node = node . get_parent ( ) ;
349- }
350- const rowH = itemActor . get_height ( ) ;
351- const popoutH = this . _historyPopout . get_height ( ) ;
352- popoutY = menuY + relY + Math . round ( ( rowH - popoutH ) / 2 ) ;
353- popoutY = Math . max ( 0 , popoutY ) ;
354- }
355- const popoutW = this . _historyPopout . get_width ( ) ;
356- const menuW = this . menu . actor . get_width ( ) ;
357- let popoutX = menuX - popoutW - 8 ;
358- if ( popoutX < 0 )
359- popoutX = menuX + menuW + 8 ;
360- this . _historyPopout . set_position ( popoutX , popoutY ) ;
361- this . _historyPopout . show ( ) ;
362- if ( this . _historyHideTimeoutId ) {
363- GLib . Source . remove ( this . _historyHideTimeoutId ) ;
364- this . _historyHideTimeoutId = null ;
365- }
366- }
367-
368- _scheduleHistoryPopoutHide ( ) {
369- if ( this . _historyHideTimeoutId ) return ;
370- this . _historyHideTimeoutId = GLib . timeout_add ( GLib . PRIORITY_DEFAULT , 250 , ( ) => {
371- this . _hideHistoryPopout ( ) ;
372- this . _historyHideTimeoutId = null ;
373- return GLib . SOURCE_REMOVE ;
374- } ) ;
375- }
376-
377- _hideHistoryPopout ( ) {
378- if ( this . _historyHideTimeoutId ) {
379- GLib . Source . remove ( this . _historyHideTimeoutId ) ;
380- this . _historyHideTimeoutId = null ;
381- }
382- if ( this . _historyPopout && this . _historyPopout . get_parent ( ) ) {
383- this . _historyPopout . hide ( ) ;
384- this . _historyPopout . get_parent ( ) . remove_child ( this . _historyPopout ) ;
385- }
386- this . _historyPopoutSensorKey = null ;
387- this . _historyPopoutLabel = null ;
388- }
389-
390- _refreshHistoryPopout ( ) {
391- const key = this . _historyPopoutSensorKey ;
392- const label = this . _historyPopoutLabel ;
393- if ( ! key || ! label ) return ;
394- if ( ! this . _historyPopout || ! this . _historyPopout . visible ) return ;
395-
396- const samples = this . _values . getTimeSeries ( key ) ;
397- if ( samples . length === 0 ) return ;
398-
399- try {
400- this . _updateHistoryGraph ( key , label , samples ) ;
401- } catch ( e ) {
402- // ignore
403- }
404181 }
405182
406183 _initializeMenuGroup ( groupName , optionName , menuSuffix = '' , position = - 1 ) {
@@ -468,7 +245,7 @@ var VitalsMenuButton = GObject.registerClass({
468245 GLib . PRIORITY_DEFAULT ,
469246 update_time ,
470247 ( self ) => {
471- // always query sensors (for panel display when hot, and for history graph data )
248+ // always query sensors (for panel display when hot)
472249 this . _querySensors ( ) ;
473250 return GLib . SOURCE_CONTINUE ;
474251 }
@@ -570,7 +347,6 @@ var VitalsMenuButton = GObject.registerClass({
570347 }
571348
572349 _redrawMenu ( ) {
573- this . _hideHistoryPopout ( ) ;
574350 this . _removeHotItems ( ) ;
575351
576352 for ( let key in this . _sensorMenuItems ) {
@@ -607,7 +383,6 @@ var VitalsMenuButton = GObject.registerClass({
607383
608384 _updateTimeSettingChanged ( ) {
609385 this . _destroyTimer ( ) ;
610- this . _values . clearTimeSeries ( this . _historyCachePath ) ;
611386 this . _initializeTimer ( ) ;
612387 }
613388
@@ -705,25 +480,6 @@ var VitalsMenuButton = GObject.registerClass({
705480 }
706481
707482 this . _groups [ type ] . menu . addMenuItem ( item , i ) ;
708-
709- if ( this . _settings . get_boolean ( 'show-sensor-history-graph' ) ) {
710- const key = item . key ;
711- const label = item . label ;
712- item . actor . connect ( 'enter-event' , ( ) => {
713- const samples = this . _values . getTimeSeries ( key ) ;
714- if ( this . _historyHideTimeoutId ) {
715- GLib . Source . remove ( this . _historyHideTimeoutId ) ;
716- this . _historyHideTimeoutId = null ;
717- }
718- if ( samples . length > 0 )
719- this . _showHistoryPopout ( key , label , item . actor ) ;
720- else
721- this . _hideHistoryPopout ( ) ;
722- } ) ;
723- item . actor . connect ( 'leave-event' , ( ) => {
724- this . _scheduleHistoryPopoutHide ( ) ;
725- } ) ;
726- }
727483 }
728484
729485 _defaultLabel ( ) {
@@ -865,8 +621,6 @@ var VitalsMenuButton = GObject.registerClass({
865621 this . _notify ( 'Vitals' , this . _warnings . join ( "\n" ) , 'folder-symbolic' ) ;
866622 this . _warnings = [ ] ;
867623 }
868-
869- this . _refreshHistoryPopout ( ) ;
870624 }
871625
872626 _notify ( msg , details , icon ) {
@@ -878,14 +632,7 @@ var VitalsMenuButton = GObject.registerClass({
878632 }
879633
880634 destroy ( ) {
881- this . _hideHistoryPopout ( ) ;
882- if ( this . _historyPopout ) {
883- this . _historyPopout . destroy ( ) ;
884- this . _historyPopout = null ;
885- }
886635 this . _destroyTimer ( ) ;
887- if ( this . _settings . get_boolean ( 'show-sensor-history-graph' ) )
888- this . _values . saveTimeSeries ( this . _historyCachePath ) ;
889636 this . _sensors . destroy ( ) ;
890637
891638 for ( let signal of Object . values ( this . _settingChangedSignals ) )
0 commit comments