@@ -51,7 +51,7 @@ var VitalsMenuButton = GObject.registerClass({
5151 this . _warnings = [ ] ;
5252 this . _sensorMenuItems = { } ;
5353 this . _hotLabels = { } ;
54- this . _hotIcons = { } ;
54+ this . _hotItems = { } ;
5555 this . _groups = { } ;
5656 this . _widths = { } ;
5757 this . _numGpus = 1 ;
@@ -67,7 +67,8 @@ var VitalsMenuButton = GObject.registerClass({
6767 x_align : Clutter . ActorAlign . START ,
6868 y_align : Clutter . ActorAlign . CENTER ,
6969 reactive : true ,
70- x_expand : true
70+ x_expand : true ,
71+ style_class : 'vitals-panel-menu'
7172 } ) ;
7273
7374 this . _drawMenu ( ) ;
@@ -219,8 +220,7 @@ var VitalsMenuButton = GObject.registerClass({
219220 // removes sensors that are no longer available
220221 if ( ! this . _sensorMenuItems [ sensor ] ) {
221222 hotSensors . splice ( i , 1 ) ;
222- this . _removeHotLabel ( sensor ) ;
223- this . _removeHotIcon ( sensor ) ;
223+ this . _removeHotItem ( sensor ) ;
224224 }
225225 }
226226
@@ -255,9 +255,16 @@ var VitalsMenuButton = GObject.registerClass({
255255 }
256256
257257 _createHotItem ( key , value ) {
258- let icon = this . _defaultIcon ( key ) ;
259- this . _hotIcons [ key ] = icon ;
260- this . _menuLayout . add_child ( icon )
258+ let item = new St . BoxLayout ( {
259+ style_class : 'vitals-panel-item' ,
260+ } ) ;
261+ this . _hotItems [ key ] = item ;
262+ this . _menuLayout . add_child ( item ) ;
263+
264+ if ( ! this . _settings . get_boolean ( 'hide-icons' ) || key == '_default_icon_' ) {
265+ let icon = this . _defaultIcon ( key ) ;
266+ item . add_child ( icon ) ;
267+ }
261268
262269 // don't add a label when no sensors are in the panel
263270 if ( key == '_default_icon_' ) return ;
@@ -268,18 +275,15 @@ var VitalsMenuButton = GObject.registerClass({
268275 y_expand : true ,
269276 y_align : Clutter . ActorAlign . CENTER
270277 } ) ;
271-
272278 // attempt to prevent ellipsizes
273279 label . get_clutter_text ( ) . ellipsize = 0 ;
274-
275280 // keep track of label for removal later
276281 this . _hotLabels [ key ] = label ;
277-
278282 // prevent "called on the widget" "which is not in the stage" errors by adding before width below
279- this . _menuLayout . add_child ( label ) ;
283+ item . add_child ( label ) ;
280284
281285 // support for fixed widths #55, save label (text) width
282- this . _widths [ key ] = label . width ;
286+ this . _widths [ key ] = label . get_clutter_text ( ) . width ;
283287 }
284288
285289 _showHideSensorsChanged ( self , sensor ) {
@@ -329,35 +333,23 @@ var VitalsMenuButton = GObject.registerClass({
329333 this . _redrawMenu ( ) ;
330334 }
331335
332- _removeHotLabel ( key ) {
333- if ( key in this . _hotLabels ) {
334- let label = this . _hotLabels [ key ] ;
335- delete this . _hotLabels [ key ] ;
336- // make sure set_label is not called on non existent actor
337- label . destroy ( ) ;
336+ _removeHotItems ( ) {
337+ for ( let key in this . _hotItems ) {
338+ this . _removeHotItem ( key ) ;
338339 }
339340 }
340341
341- _removeHotLabels ( ) {
342- for ( let key in this . _hotLabels )
343- this . _removeHotLabel ( key ) ;
344- }
345-
346- _removeHotIcon ( key ) {
347- if ( key in this . _hotIcons ) {
348- this . _hotIcons [ key ] . destroy ( ) ;
349- delete this . _hotIcons [ key ] ;
342+ _removeHotItem ( key ) {
343+ if ( key in this . _hotItems ) {
344+ this . _hotItems [ key ] . destroy ( ) ;
345+ delete this . _hotItems [ key ] ;
346+ delete this . _hotLabels [ key ] ;
347+ delete this . _widths [ key ] ;
350348 }
351349 }
352350
353- _removeHotIcons ( ) {
354- for ( let key in this . _hotIcons )
355- this . _removeHotIcon ( key ) ;
356- }
357-
358351 _redrawMenu ( ) {
359- this . _removeHotIcons ( ) ;
360- this . _removeHotLabels ( ) ;
352+ this . _removeHotItems ( ) ;
361353
362354 for ( let key in this . _sensorMenuItems ) {
363355 if ( key . includes ( '-group' ) ) continue ;
@@ -452,8 +444,7 @@ var VitalsMenuButton = GObject.registerClass({
452444 } else {
453445 // remove selected sensor from panel
454446 hotSensors . splice ( hotSensors . indexOf ( self . key ) , 1 ) ;
455- this . _removeHotLabel ( self . key ) ;
456- this . _removeHotIcon ( self . key ) ;
447+ this . _removeHotItem ( self . key ) ;
457448 }
458449
459450 if ( hotSensors . length <= 0 ) {
@@ -465,7 +456,7 @@ var VitalsMenuButton = GObject.registerClass({
465456 if ( defIconPos >= 0 ) {
466457 // remove generic icon from panel when sensors are selected
467458 hotSensors . splice ( defIconPos , 1 ) ;
468- this . _removeHotIcon ( '_default_icon_' ) ;
459+ this . _removeHotItem ( '_default_icon_' ) ;
469460 }
470461 }
471462
@@ -508,7 +499,7 @@ var VitalsMenuButton = GObject.registerClass({
508499 // don't use the default system icon if the type is a gpu; use the universal gpu icon instead
509500 if ( type == 'default' || ( ! ( type in this . _sensorIcons ) && ! type . startsWith ( 'gpu' ) ) ) {
510501 icon . gicon = Gio . icon_new_for_string ( this . _sensorIconPath ( 'system' ) ) ;
511- } else if ( ! this . _settings . get_boolean ( 'hide-icons' ) ) { // support for hide icons #80
502+ } else { // support for hide icons #80
512503 let iconObj = ( split . length == 2 ) ?'icon-' + split [ 1 ] :'icon' ;
513504 icon . gicon = Gio . icon_new_for_string ( this . _sensorIconPath ( type , iconObj ) ) ;
514505 }
0 commit comments