isDipesh / gnome-shell-extension-sensors

Gnome shell extension: Shows CPU temperature, HDD temperature, voltage and fan RPM
https://motorscript.com/gnome-shell-extension-sensors/
161 stars 153 forks source link

Gnome 3.10 some changes #108

Closed jacek007 closed 10 years ago

jacek007 commented 10 years ago

1/ label on panel is aligned to the vertical center 2/ bolding is not working for me so I made a dot 3/ some changes on destroy nad redraw. Now not generate any warnings

--- /tmp/a/gnome-shell-extension-sensors/src/extension.js   2014-05-14 22:14:30.102637684 +0200
+++ extension.js    2014-05-15 01:27:27.611901748 +0200
@@ -11,6 +11,7 @@
 const Utilities = Me.imports.utilities;
 const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']);
 const _ = Gettext.gettext;
+const Clutter = imports.gi.Clutter;

 let settings;
 let metadata = Me.metadata;
@@ -40,8 +41,8 @@
     },

     setMainSensor: function() {
-        //this.setShowDot(true);
-        this.actor.add_style_class_name('popup-subtitle-menu-item'); //bold
+        this.setOrnament(PopupMenu.Ornament.DOT);
+        //this.actor.add_style_class_name('popup-subtitle-menu-item'); //bold
     },

     getLabel: function() {
@@ -55,17 +56,16 @@
     Extends: PanelMenu.Button,

     _init: function(){
-        this.parent(0.0, 'sensorMenu');
+        this.parent(null, 'sensorMenu');

         this._sensorsOutput = '';
         this._hddtempOutput = '';

-        this.statusLabel = new St.Label({ text: '\u2026' });
-
+        this.statusLabel = new St.Label({ text: "--", y_expand: true, y_align: Clutter.ActorAlign.CENTER });
+        //this.statusLabel = new St.Label({ text: '\u2026' });
         // destroy all previously created children, and add our statusLabel
-        this.actor.get_children().forEach(function(c) {
-            c.destroy()
-        });
+
+        this.menu.removeAll();
         this.actor.add_actor(this.statusLabel);

         this.sensorsArgv = Utilities.detectSensors();
@@ -95,6 +95,7 @@

     _onDestroy: function(){
         Mainloop.source_remove(this._eventLoop);
+        this.menu.removeAll();
         settings.disconnect(this._settingsChanged);
     },

@@ -142,10 +143,7 @@
         tempInfo.sort(function(a,b) { return a['label'].localeCompare(b['label']) });
         fanInfo.sort(function(a,b) { return a['label'].localeCompare(b['label']) });
         voltageInfo.sort(function(a,b) { return a['label'].localeCompare(b['label']) });
-
-        this.menu.box.get_children().forEach(function(c) {
-            c.destroy()
-        });
+        this.menu.removeAll();
         let section = new PopupMenu.PopupMenuSection("Temperature");
         if (this.sensorsArgv && tempInfo.length > 0){
             let sensorsList = new Array();
@@ -260,9 +258,10 @@

 function enable() {
     sensorsMenu = new SensorsMenuButton();
-    Main.panel.addToStatusArea('sensorsMenu', sensorsMenu);
+    Main.panel.addToStatusArea('sensorsMenu', sensorsMenu,1,'right');
 }

 function disable() {
     sensorsMenu.destroy();
+    sensorsMenu=null;
 }
adrianbroher commented 10 years ago

Thanks for your contribution, I added all of your suggestions to master.