dd45d7
From 2e00e631c7def6d58bdb1eb0fa3254ae82a37574 Mon Sep 17 00:00:00 2001
dd45d7
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
dd45d7
Date: Wed, 17 May 2017 19:13:50 +0200
dd45d7
Subject: [PATCH 1/6] extensions: Resurrect systemMonitor extension
dd45d7
dd45d7
The extension was removed upstream because:
dd45d7
 - it hooks into the message tray that was removed
dd45d7
 - it was known to have performance issues
dd45d7
 - there are plenty of alternatives
dd45d7
dd45d7
Those aren't good enough reasons for dropping it downstream
dd45d7
as well though, so we need to bring it back ...
dd45d7
dd45d7
This reverts commit c9a6421f362cd156cf731289eadc11f44f6970ac.
dd45d7
---
dd45d7
 extensions/systemMonitor/extension.js     | 376 ++++++++++++++++++++++
dd45d7
 extensions/systemMonitor/meson.build      |   5 +
dd45d7
 extensions/systemMonitor/metadata.json.in |  11 +
dd45d7
 extensions/systemMonitor/stylesheet.css   |  35 ++
dd45d7
 meson.build                               |   1 +
dd45d7
 5 files changed, 428 insertions(+)
dd45d7
 create mode 100644 extensions/systemMonitor/extension.js
dd45d7
 create mode 100644 extensions/systemMonitor/meson.build
dd45d7
 create mode 100644 extensions/systemMonitor/metadata.json.in
dd45d7
 create mode 100644 extensions/systemMonitor/stylesheet.css
dd45d7
dd45d7
diff --git a/extensions/systemMonitor/extension.js b/extensions/systemMonitor/extension.js
dd45d7
new file mode 100644
dd45d7
index 0000000..7b09df0
dd45d7
--- /dev/null
dd45d7
+++ b/extensions/systemMonitor/extension.js
dd45d7
@@ -0,0 +1,376 @@
dd45d7
+/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
dd45d7
+
dd45d7
+const Clutter = imports.gi.Clutter;
dd45d7
+const GTop = imports.gi.GTop;
dd45d7
+const Lang = imports.lang;
dd45d7
+const Mainloop = imports.mainloop;
dd45d7
+const St = imports.gi.St;
dd45d7
+const Shell = imports.gi.Shell;
dd45d7
+
dd45d7
+const Main = imports.ui.main;
dd45d7
+const Tweener = imports.ui.tweener;
dd45d7
+
dd45d7
+const Gettext = imports.gettext.domain('gnome-shell-extensions');
dd45d7
+const _ = Gettext.gettext;
dd45d7
+
dd45d7
+const ExtensionUtils = imports.misc.extensionUtils;
dd45d7
+const Me = ExtensionUtils.getCurrentExtension();
dd45d7
+const Convenience = Me.imports.convenience;
dd45d7
+
dd45d7
+const INDICATOR_UPDATE_INTERVAL = 500;
dd45d7
+const INDICATOR_NUM_GRID_LINES = 3;
dd45d7
+
dd45d7
+const ITEM_LABEL_SHOW_TIME = 0.15;
dd45d7
+const ITEM_LABEL_HIDE_TIME = 0.1;
dd45d7
+const ITEM_HOVER_TIMEOUT = 300;
dd45d7
+
dd45d7
+const Indicator = new Lang.Class({
dd45d7
+    Name: 'SystemMonitor.Indicator',
dd45d7
+
dd45d7
+    _init: function() {
dd45d7
+        this._initValues();
dd45d7
+        this.drawing_area = new St.DrawingArea({ reactive: true });
dd45d7
+        this.drawing_area.connect('repaint', Lang.bind(this, this._draw));
dd45d7
+        this.drawing_area.connect('button-press-event', function() {
dd45d7
+            let app = Shell.AppSystem.get_default().lookup_app('gnome-system-monitor.desktop');
dd45d7
+            app.open_new_window(-1);
dd45d7
+            return true;
dd45d7
+        });
dd45d7
+
dd45d7
+        this.actor = new St.Bin({ style_class: "extension-systemMonitor-indicator-area",
dd45d7
+                                  reactive: true, track_hover: true,
dd45d7
+				  x_fill: true, y_fill: true });
dd45d7
+        this.actor.add_actor(this.drawing_area);
dd45d7
+
dd45d7
+        this._timeout = Mainloop.timeout_add(INDICATOR_UPDATE_INTERVAL, Lang.bind(this, function () {
dd45d7
+            this._updateValues();
dd45d7
+            this.drawing_area.queue_repaint();
dd45d7
+            return true;
dd45d7
+        }));
dd45d7
+    },
dd45d7
+
dd45d7
+    showLabel: function() {
dd45d7
+        if (this.label == null)
dd45d7
+            return;
dd45d7
+
dd45d7
+        this.label.opacity = 0;
dd45d7
+        this.label.show();
dd45d7
+
dd45d7
+        let [stageX, stageY] = this.actor.get_transformed_position();
dd45d7
+
dd45d7
+	let itemWidth = this.actor.allocation.x2 - this.actor.allocation.x1;
dd45d7
+        let itemHeight = this.actor.allocation.y2 - this.actor.allocation.y1;
dd45d7
+
dd45d7
+	let labelWidth = this.label.width;
dd45d7
+        let labelHeight = this.label.height;
dd45d7
+        let xOffset = Math.floor((itemWidth - labelWidth) / 2)
dd45d7
+
dd45d7
+        let x = stageX + xOffset;
dd45d7
+
dd45d7
+        let node = this.label.get_theme_node();
dd45d7
+        let yOffset = node.get_length('-y-offset');
dd45d7
+
dd45d7
+        let y = stageY - this.label.get_height() - yOffset;
dd45d7
+
dd45d7
+        this.label.set_position(x, y);
dd45d7
+        Tweener.addTween(this.label,
dd45d7
+                         { opacity: 255,
dd45d7
+                           time: ITEM_LABEL_SHOW_TIME,
dd45d7
+                           transition: 'easeOutQuad',
dd45d7
+                         });
dd45d7
+    },
dd45d7
+
dd45d7
+    setLabelText: function(text) {
dd45d7
+        if (this.label == null)
dd45d7
+            this.label = new St.Label({ style_class: 'extension-systemMonitor-indicator-label'});
dd45d7
+
dd45d7
+        this.label.set_text(text);
dd45d7
+        Main.layoutManager.addChrome(this.label);
dd45d7
+        this.label.hide();
dd45d7
+    },
dd45d7
+
dd45d7
+    hideLabel: function () {
dd45d7
+        Tweener.addTween(this.label,
dd45d7
+                         { opacity: 0,
dd45d7
+                           time: ITEM_LABEL_HIDE_TIME,
dd45d7
+                           transition: 'easeOutQuad',
dd45d7
+                           onComplete: Lang.bind(this, function() {
dd45d7
+                               this.label.hide();
dd45d7
+                           })
dd45d7
+                         });
dd45d7
+    },
dd45d7
+
dd45d7
+    destroy: function() {
dd45d7
+        Mainloop.source_remove(this._timeout);
dd45d7
+
dd45d7
+        this.actor.destroy();
dd45d7
+	if (this.label)
dd45d7
+	    this.label.destroy();
dd45d7
+    },
dd45d7
+
dd45d7
+    _initValues: function() {
dd45d7
+    },
dd45d7
+
dd45d7
+    _updateValues: function() {
dd45d7
+    },
dd45d7
+
dd45d7
+    _draw: function(area) {
dd45d7
+        let [width, height] = area.get_surface_size();
dd45d7
+        let themeNode = this.actor.get_theme_node();
dd45d7
+        let cr = area.get_context();
dd45d7
+
dd45d7
+        //draw the background grid
dd45d7
+        let color = themeNode.get_color(this.gridColor);
dd45d7
+        let gridOffset = Math.floor(height / (INDICATOR_NUM_GRID_LINES + 1));
dd45d7
+        for (let i = 1; i <= INDICATOR_NUM_GRID_LINES; ++i) {
dd45d7
+                cr.moveTo(0, i * gridOffset + .5);
dd45d7
+                cr.lineTo(width, i * gridOffset + .5);
dd45d7
+        }
dd45d7
+        Clutter.cairo_set_source_color(cr, color);
dd45d7
+        cr.setLineWidth(1);
dd45d7
+        cr.setDash([4,1], 0);
dd45d7
+        cr.stroke();
dd45d7
+
dd45d7
+        //draw the foreground
dd45d7
+
dd45d7
+        function makePath(values, reverse, nudge) {
dd45d7
+            if (nudge == null) {
dd45d7
+                nudge = 0;
dd45d7
+            }
dd45d7
+            //if we are going in reverse, we are completing the bottom of a chart, so use lineTo
dd45d7
+            if (reverse) {
dd45d7
+                cr.lineTo(values.length - 1, (1 - values[values.length - 1]) * height + nudge);
dd45d7
+                for (let k = values.length - 2; k >= 0; --k) {
dd45d7
+                    cr.lineTo(k, (1 - values[k]) * height + nudge);
dd45d7
+                }
dd45d7
+            } else {
dd45d7
+                cr.moveTo(0, (1 - values[0]) * height + nudge);
dd45d7
+                for (let k = 1; k < values.length; ++k) {
dd45d7
+                    cr.lineTo(k, (1 - values[k]) * height + nudge);
dd45d7
+                }
dd45d7
+
dd45d7
+            }
dd45d7
+        }
dd45d7
+
dd45d7
+        let renderStats = this.renderStats;
dd45d7
+
dd45d7
+        // Make sure we don't have more sample points than pixels
dd45d7
+        renderStats.map(Lang.bind(this, function(k){
dd45d7
+            let stat = this.stats[k];
dd45d7
+            if (stat.values.length > width) {
dd45d7
+                stat.values = stat.values.slice(stat.values.length - width, stat.values.length);
dd45d7
+            }
dd45d7
+        }));
dd45d7
+
dd45d7
+        for (let i = 0; i < renderStats.length; ++i) {
dd45d7
+            let stat = this.stats[renderStats[i]];
dd45d7
+            // We outline at full opacity and fill with 40% opacity
dd45d7
+            let outlineColor = themeNode.get_color(stat.color);
dd45d7
+            let color = new Clutter.Color(outlineColor);
dd45d7
+            color.alpha = color.alpha * .4;
dd45d7
+
dd45d7
+            // Render the background between us and the next level
dd45d7
+            makePath(stat.values, false);
dd45d7
+            // If there is a process below us, render the cpu between us and it, otherwise,
dd45d7
+            // render to the bottom of the chart
dd45d7
+            if (i == renderStats.length - 1) {
dd45d7
+                cr.lineTo(stat.values.length - 1, height);
dd45d7
+                cr.lineTo(0, height);
dd45d7
+                cr.closePath();
dd45d7
+            } else {
dd45d7
+                let nextStat = this.stats[renderStats[i+1]];
dd45d7
+                makePath(nextStat.values, true);
dd45d7
+            }
dd45d7
+            cr.closePath()
dd45d7
+            Clutter.cairo_set_source_color(cr, color);
dd45d7
+            cr.fill();
dd45d7
+
dd45d7
+            // Render the outline of this level
dd45d7
+            makePath(stat.values, false, .5);
dd45d7
+            Clutter.cairo_set_source_color(cr, outlineColor);
dd45d7
+            cr.setLineWidth(1.0);
dd45d7
+            cr.setDash([], 0);
dd45d7
+            cr.stroke();
dd45d7
+        }
dd45d7
+    }
dd45d7
+});
dd45d7
+
dd45d7
+const CpuIndicator = new Lang.Class({
dd45d7
+    Name: 'SystemMonitor.CpuIndicator',
dd45d7
+    Extends: Indicator,
dd45d7
+
dd45d7
+    _init: function() {
dd45d7
+        this.parent();
dd45d7
+
dd45d7
+        this.gridColor = '-grid-color';
dd45d7
+        this.renderStats = [ 'cpu-user', 'cpu-sys', 'cpu-iowait' ];
dd45d7
+
dd45d7
+        // Make sure renderStats is sorted as necessary for rendering
dd45d7
+        let renderStatOrder = {'cpu-total': 0, 'cpu-user': 1, 'cpu-sys': 2, 'cpu-iowait': 3};
dd45d7
+        this.renderStats = this.renderStats.sort(function(a,b) {
dd45d7
+            return renderStatOrder[a] - renderStatOrder[b];
dd45d7
+        });
dd45d7
+
dd45d7
+	this.setLabelText(_("CPU"));
dd45d7
+    },
dd45d7
+
dd45d7
+    _initValues: function() {
dd45d7
+        this._prev = new GTop.glibtop_cpu;
dd45d7
+        GTop.glibtop_get_cpu(this._prev);
dd45d7
+
dd45d7
+        this.stats = {
dd45d7
+                       'cpu-user': {color: '-cpu-user-color', values: []},
dd45d7
+                       'cpu-sys': {color: '-cpu-sys-color', values: []},
dd45d7
+                       'cpu-iowait': {color: '-cpu-iowait-color', values: []},
dd45d7
+                       'cpu-total': {color: '-cpu-total-color', values: []}
dd45d7
+                     };
dd45d7
+    },
dd45d7
+
dd45d7
+    _updateValues: function() {
dd45d7
+        let cpu = new GTop.glibtop_cpu;
dd45d7
+        let t = 0.0;
dd45d7
+        GTop.glibtop_get_cpu(cpu);
dd45d7
+        let total = cpu.total - this._prev.total;
dd45d7
+        let user = cpu.user - this._prev.user;
dd45d7
+        let sys = cpu.sys - this._prev.sys;
dd45d7
+        let iowait = cpu.iowait - this._prev.iowait;
dd45d7
+        let idle = cpu.idle - this._prev.idle;
dd45d7
+
dd45d7
+        t += iowait / total;
dd45d7
+        this.stats['cpu-iowait'].values.push(t);
dd45d7
+        t += sys / total;
dd45d7
+        this.stats['cpu-sys'].values.push(t);
dd45d7
+        t += user / total;
dd45d7
+        this.stats['cpu-user'].values.push(t);
dd45d7
+        this.stats['cpu-total'].values.push(1 - idle / total);
dd45d7
+
dd45d7
+        this._prev = cpu;
dd45d7
+    }
dd45d7
+});
dd45d7
+
dd45d7
+const MemoryIndicator = new Lang.Class({
dd45d7
+    Name: 'SystemMonitor.MemoryIndicator',
dd45d7
+    Extends: Indicator,
dd45d7
+
dd45d7
+    _init: function() {
dd45d7
+        this.parent();
dd45d7
+
dd45d7
+        this.gridColor = '-grid-color';
dd45d7
+        this.renderStats = [ 'mem-user', 'mem-other', 'mem-cached' ];
dd45d7
+
dd45d7
+        // Make sure renderStats is sorted as necessary for rendering
dd45d7
+        let renderStatOrder = { 'mem-cached': 0, 'mem-other': 1, 'mem-user': 2 };
dd45d7
+        this.renderStats = this.renderStats.sort(function(a,b) {
dd45d7
+            return renderStatOrder[a] - renderStatOrder[b];
dd45d7
+        });
dd45d7
+
dd45d7
+	this.setLabelText(_("Memory"));
dd45d7
+    },
dd45d7
+
dd45d7
+    _initValues: function() {
dd45d7
+        this.mem = new GTop.glibtop_mem;
dd45d7
+        this.stats = {
dd45d7
+                        'mem-user': { color: "-mem-user-color", values: [] },
dd45d7
+                        'mem-other': { color: "-mem-other-color", values: [] },
dd45d7
+                        'mem-cached': { color: "-mem-cached-color", values: [] }
dd45d7
+                     };
dd45d7
+    },
dd45d7
+
dd45d7
+    _updateValues: function() {
dd45d7
+        GTop.glibtop_get_mem(this.mem);
dd45d7
+
dd45d7
+        let t = this.mem.user / this.mem.total;
dd45d7
+        this.stats['mem-user'].values.push(t);
dd45d7
+        t += (this.mem.used - this.mem.user - this.mem.cached) / this.mem.total;
dd45d7
+        this.stats['mem-other'].values.push(t);
dd45d7
+        t += this.mem.cached / this.mem.total;
dd45d7
+        this.stats['mem-cached'].values.push(t);
dd45d7
+    }
dd45d7
+});
dd45d7
+
dd45d7
+const INDICATORS = [CpuIndicator, MemoryIndicator];
dd45d7
+
dd45d7
+const Extension = new Lang.Class({
dd45d7
+    Name: 'SystemMonitor.Extension',
dd45d7
+
dd45d7
+    _init: function() {
dd45d7
+	Convenience.initTranslations();
dd45d7
+
dd45d7
+	this._showLabelTimeoutId = 0;
dd45d7
+	this._resetHoverTimeoutId = 0;
dd45d7
+	this._labelShowing = false;
dd45d7
+    },
dd45d7
+
dd45d7
+    enable: function() {
dd45d7
+	this._box = new St.BoxLayout({ style_class: 'extension-systemMonitor-container',
dd45d7
+				       x_align: Clutter.ActorAlign.START,
dd45d7
+				       x_expand: true });
dd45d7
+	this._indicators = [ ];
dd45d7
+
dd45d7
+	for (let i = 0; i < INDICATORS.length; i++) {
dd45d7
+	    let indicator = new (INDICATORS[i])();
dd45d7
+
dd45d7
+            indicator.actor.connect('notify::hover', Lang.bind(this, function() {
dd45d7
+		this._onHover(indicator);
dd45d7
+	    }));
dd45d7
+	    this._box.add_actor(indicator.actor);
dd45d7
+	    this._indicators.push(indicator);
dd45d7
+	}
dd45d7
+
dd45d7
+	this._boxHolder = new St.BoxLayout({ x_expand: true,
dd45d7
+					     y_expand: true,
dd45d7
+					     x_align: Clutter.ActorAlign.START,
dd45d7
+					   });
dd45d7
+	let menuButton = Main.messageTray._messageTrayMenuButton.actor;
dd45d7
+	Main.messageTray.actor.remove_child(menuButton);
dd45d7
+	Main.messageTray.actor.add_child(this._boxHolder);
dd45d7
+
dd45d7
+	this._boxHolder.add_child(this._box);
dd45d7
+	this._boxHolder.add_child(menuButton);
dd45d7
+    },
dd45d7
+
dd45d7
+    disable: function() {
dd45d7
+	this._indicators.forEach(function(i) { i.destroy(); });
dd45d7
+
dd45d7
+	let menuButton = Main.messageTray._messageTrayMenuButton.actor;
dd45d7
+	this._boxHolder.remove_child(menuButton);
dd45d7
+	Main.messageTray.actor.add_child(menuButton);
dd45d7
+
dd45d7
+	this._box.destroy();
dd45d7
+	this._boxHolder.destroy();
dd45d7
+    },
dd45d7
+
dd45d7
+    _onHover: function (item) {
dd45d7
+        if (item.actor.get_hover()) {
dd45d7
+            if (this._showLabelTimeoutId == 0) {
dd45d7
+                let timeout = this._labelShowing ? 0 : ITEM_HOVER_TIMEOUT;
dd45d7
+                this._showLabelTimeoutId = Mainloop.timeout_add(timeout,
dd45d7
+                    Lang.bind(this, function() {
dd45d7
+                        this._labelShowing = true;
dd45d7
+                        item.showLabel();
dd45d7
+                        return false;
dd45d7
+                    }));
dd45d7
+                if (this._resetHoverTimeoutId > 0) {
dd45d7
+                    Mainloop.source_remove(this._resetHoverTimeoutId);
dd45d7
+                    this._resetHoverTimeoutId = 0;
dd45d7
+                }
dd45d7
+            }
dd45d7
+        } else {
dd45d7
+            if (this._showLabelTimeoutId > 0)
dd45d7
+                Mainloop.source_remove(this._showLabelTimeoutId);
dd45d7
+            this._showLabelTimeoutId = 0;
dd45d7
+            item.hideLabel();
dd45d7
+            if (this._labelShowing) {
dd45d7
+                this._resetHoverTimeoutId = Mainloop.timeout_add(ITEM_HOVER_TIMEOUT,
dd45d7
+                    Lang.bind(this, function() {
dd45d7
+                        this._labelShowing = false;
dd45d7
+                        return false;
dd45d7
+                    }));
dd45d7
+            }
dd45d7
+        }
dd45d7
+    },
dd45d7
+});
dd45d7
+
dd45d7
+function init() {
dd45d7
+    return new Extension();
dd45d7
+}
dd45d7
diff --git a/extensions/systemMonitor/meson.build b/extensions/systemMonitor/meson.build
dd45d7
new file mode 100644
dd45d7
index 0000000..48504f6
dd45d7
--- /dev/null
dd45d7
+++ b/extensions/systemMonitor/meson.build
dd45d7
@@ -0,0 +1,5 @@
dd45d7
+extension_data += configure_file(
dd45d7
+  input: metadata_name + '.in',
dd45d7
+  output: metadata_name,
dd45d7
+  configuration: metadata_conf
dd45d7
+)
dd45d7
diff --git a/extensions/systemMonitor/metadata.json.in b/extensions/systemMonitor/metadata.json.in
dd45d7
new file mode 100644
dd45d7
index 0000000..fa75007
dd45d7
--- /dev/null
dd45d7
+++ b/extensions/systemMonitor/metadata.json.in
dd45d7
@@ -0,0 +1,11 @@
dd45d7
+{
dd45d7
+    "shell-version": ["@shell_current@" ],
dd45d7
+    "uuid": "@uuid@",
dd45d7
+    "extension-id": "@extension_id@",
dd45d7
+    "settings-schema": "@gschemaname@",
dd45d7
+    "gettext-domain": "@gettext_domain@",
dd45d7
+    "original-author": "zaspire@rambler.ru",
dd45d7
+    "name": "SystemMonitor",
dd45d7
+    "description": "System monitor showing CPU and memory usage in the message tray.",
dd45d7
+    "url": "@url@"
dd45d7
+}
dd45d7
diff --git a/extensions/systemMonitor/stylesheet.css b/extensions/systemMonitor/stylesheet.css
dd45d7
new file mode 100644
dd45d7
index 0000000..13f95ec
dd45d7
--- /dev/null
dd45d7
+++ b/extensions/systemMonitor/stylesheet.css
dd45d7
@@ -0,0 +1,35 @@
dd45d7
+.extension-systemMonitor-container {
dd45d7
+    spacing: 5px;
dd45d7
+    padding-left: 5px;
dd45d7
+    padding-right: 5px;
dd45d7
+    padding-bottom: 10px;
dd45d7
+    padding-top: 10px;
dd45d7
+}
dd45d7
+
dd45d7
+.extension-systemMonitor-indicator-area {
dd45d7
+    border: 1px solid #8d8d8d;
dd45d7
+    border-radius: 3px;
dd45d7
+    width: 100px;
dd45d7
+    /* message tray is 72px, so 20px padding of the container,
dd45d7
+       2px of border, makes it 50px */
dd45d7
+    height: 50px;
dd45d7
+    -grid-color: #575757;
dd45d7
+    -cpu-total-color: rgb(0,154,62);
dd45d7
+    -cpu-user-color: rgb(69,154,0);
dd45d7
+    -cpu-sys-color: rgb(255,253,81);
dd45d7
+    -cpu-iowait-color: rgb(210,148,0);
dd45d7
+    -mem-user-color: rgb(210,148,0);
dd45d7
+    -mem-cached-color: rgb(90,90,90);
dd45d7
+    -mem-other-color: rgb(205,203,41);
dd45d7
+    background-color: #1e1e1e;
dd45d7
+}
dd45d7
+
dd45d7
+.extension-systemMonitor-indicator-label {
dd45d7
+    border-radius: 7px;
dd45d7
+    padding: 4px 12px;
dd45d7
+    background-color: rgba(0,0,0,0.9);
dd45d7
+    text-align: center;
dd45d7
+    -y-offset: 8px;
dd45d7
+    font-size: 9pt;
dd45d7
+    font-weight: bold;
dd45d7
+}
dd45d7
diff --git a/meson.build b/meson.build
dd45d7
index 6a2fdf0..afc0133 100644
dd45d7
--- a/meson.build
dd45d7
+++ b/meson.build
dd45d7
@@ -48,6 +48,7 @@ all_extensions += [
dd45d7
   'dash-to-dock',
dd45d7
   'native-window-placement',
dd45d7
   'panel-favorites',
dd45d7
+  'systemMonitor',
dd45d7
   'top-icons',
dd45d7
   'updates-dialog',
dd45d7
   'user-theme'
dd45d7
-- 
dd45d7
2.32.0
dd45d7
dd45d7
dd45d7
From 59927edac1f40239d7926f0285249c933ea42caf Mon Sep 17 00:00:00 2001
dd45d7
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
dd45d7
Date: Fri, 17 May 2019 22:55:48 +0000
dd45d7
Subject: [PATCH 2/6] systemMonitor: Modernise code
dd45d7
dd45d7
 - port to ES6 classes
dd45d7
 - replace Lang.bind()
dd45d7
 - replace Tweener
dd45d7
 - use standard align/expand properties
dd45d7
 - destructure imports
dd45d7
 - fix style issues (stray/missing spaces/semi-colons, indent, ...)
dd45d7
---
dd45d7
 extensions/systemMonitor/extension.js | 422 +++++++++++++-------------
dd45d7
 1 file changed, 212 insertions(+), 210 deletions(-)
dd45d7
dd45d7
diff --git a/extensions/systemMonitor/extension.js b/extensions/systemMonitor/extension.js
dd45d7
index 7b09df0..f7c6a4a 100644
dd45d7
--- a/extensions/systemMonitor/extension.js
dd45d7
+++ b/extensions/systemMonitor/extension.js
dd45d7
@@ -1,56 +1,57 @@
dd45d7
 /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
dd45d7
 
dd45d7
-const Clutter = imports.gi.Clutter;
dd45d7
-const GTop = imports.gi.GTop;
dd45d7
-const Lang = imports.lang;
dd45d7
-const Mainloop = imports.mainloop;
dd45d7
-const St = imports.gi.St;
dd45d7
-const Shell = imports.gi.Shell;
dd45d7
+/* exported init */
dd45d7
 
dd45d7
+const { Clutter, GLib, GTop, Shell, St } = imports.gi;
dd45d7
+
dd45d7
+const ExtensionUtils = imports.misc.extensionUtils;
dd45d7
 const Main = imports.ui.main;
dd45d7
-const Tweener = imports.ui.tweener;
dd45d7
 
dd45d7
 const Gettext = imports.gettext.domain('gnome-shell-extensions');
dd45d7
 const _ = Gettext.gettext;
dd45d7
 
dd45d7
-const ExtensionUtils = imports.misc.extensionUtils;
dd45d7
-const Me = ExtensionUtils.getCurrentExtension();
dd45d7
-const Convenience = Me.imports.convenience;
dd45d7
-
dd45d7
 const INDICATOR_UPDATE_INTERVAL = 500;
dd45d7
 const INDICATOR_NUM_GRID_LINES = 3;
dd45d7
 
dd45d7
-const ITEM_LABEL_SHOW_TIME = 0.15;
dd45d7
-const ITEM_LABEL_HIDE_TIME = 0.1;
dd45d7
+const ITEM_LABEL_SHOW_TIME = 150;
dd45d7
+const ITEM_LABEL_HIDE_TIME = 100;
dd45d7
 const ITEM_HOVER_TIMEOUT = 300;
dd45d7
 
dd45d7
-const Indicator = new Lang.Class({
dd45d7
-    Name: 'SystemMonitor.Indicator',
dd45d7
-
dd45d7
-    _init: function() {
dd45d7
+const Indicator = class {
dd45d7
+    constructor() {
dd45d7
         this._initValues();
dd45d7
-        this.drawing_area = new St.DrawingArea({ reactive: true });
dd45d7
-        this.drawing_area.connect('repaint', Lang.bind(this, this._draw));
dd45d7
-        this.drawing_area.connect('button-press-event', function() {
dd45d7
+        this._drawingArea = new St.DrawingArea({
dd45d7
+            reactive: true,
dd45d7
+            x_expand: true,
dd45d7
+            y_expand: true,
dd45d7
+        });
dd45d7
+        this._drawingArea.connect('repaint', this._draw.bind(this));
dd45d7
+        this._drawingArea.connect('button-press-event', () => {
dd45d7
             let app = Shell.AppSystem.get_default().lookup_app('gnome-system-monitor.desktop');
dd45d7
             app.open_new_window(-1);
dd45d7
             return true;
dd45d7
         });
dd45d7
 
dd45d7
-        this.actor = new St.Bin({ style_class: "extension-systemMonitor-indicator-area",
dd45d7
-                                  reactive: true, track_hover: true,
dd45d7
-				  x_fill: true, y_fill: true });
dd45d7
-        this.actor.add_actor(this.drawing_area);
dd45d7
+        this.actor = new St.Bin({
dd45d7
+            style_class: 'extension-systemMonitor-indicator-area',
dd45d7
+            reactive: true,
dd45d7
+            track_hover: true,
dd45d7
+        });
dd45d7
+        this.actor.add_actor(this._drawingArea);
dd45d7
+
dd45d7
+        this.actor.connect('destroy', this._onDestroy.bind(this));
dd45d7
 
dd45d7
-        this._timeout = Mainloop.timeout_add(INDICATOR_UPDATE_INTERVAL, Lang.bind(this, function () {
dd45d7
-            this._updateValues();
dd45d7
-            this.drawing_area.queue_repaint();
dd45d7
-            return true;
dd45d7
-        }));
dd45d7
-    },
dd45d7
+        this._timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
dd45d7
+            INDICATOR_UPDATE_INTERVAL,
dd45d7
+            () => {
dd45d7
+                this._updateValues();
dd45d7
+                this._drawingArea.queue_repaint();
dd45d7
+                return GLib.SOURCE_CONTINUE;
dd45d7
+            });
dd45d7
+    }
dd45d7
 
dd45d7
-    showLabel: function() {
dd45d7
-        if (this.label == null)
dd45d7
+    showLabel() {
dd45d7
+        if (this.label === null)
dd45d7
             return;
dd45d7
 
dd45d7
         this.label.opacity = 0;
dd45d7
@@ -58,12 +59,10 @@ const Indicator = new Lang.Class({
dd45d7
 
dd45d7
         let [stageX, stageY] = this.actor.get_transformed_position();
dd45d7
 
dd45d7
-	let itemWidth = this.actor.allocation.x2 - this.actor.allocation.x1;
dd45d7
-        let itemHeight = this.actor.allocation.y2 - this.actor.allocation.y1;
dd45d7
+        let itemWidth = this.actor.allocation.x2 - this.actor.allocation.x1;
dd45d7
 
dd45d7
-	let labelWidth = this.label.width;
dd45d7
-        let labelHeight = this.label.height;
dd45d7
-        let xOffset = Math.floor((itemWidth - labelWidth) / 2)
dd45d7
+        let labelWidth = this.label.width;
dd45d7
+        let xOffset = Math.floor((itemWidth - labelWidth) / 2);
dd45d7
 
dd45d7
         let x = stageX + xOffset;
dd45d7
 
dd45d7
@@ -73,116 +72,113 @@ const Indicator = new Lang.Class({
dd45d7
         let y = stageY - this.label.get_height() - yOffset;
dd45d7
 
dd45d7
         this.label.set_position(x, y);
dd45d7
-        Tweener.addTween(this.label,
dd45d7
-                         { opacity: 255,
dd45d7
-                           time: ITEM_LABEL_SHOW_TIME,
dd45d7
-                           transition: 'easeOutQuad',
dd45d7
-                         });
dd45d7
-    },
dd45d7
+        this.label.ease({
dd45d7
+            opacity: 255,
dd45d7
+            duration: ITEM_LABEL_SHOW_TIME,
dd45d7
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
dd45d7
+        });
dd45d7
+    }
dd45d7
 
dd45d7
-    setLabelText: function(text) {
dd45d7
-        if (this.label == null)
dd45d7
-            this.label = new St.Label({ style_class: 'extension-systemMonitor-indicator-label'});
dd45d7
+    setLabelText(text) {
dd45d7
+        if (this.label === null) {
dd45d7
+            this.label = new St.Label({
dd45d7
+                style_class: 'extension-systemMonitor-indicator-label',
dd45d7
+            });
dd45d7
+        }
dd45d7
 
dd45d7
         this.label.set_text(text);
dd45d7
         Main.layoutManager.addChrome(this.label);
dd45d7
         this.label.hide();
dd45d7
-    },
dd45d7
-
dd45d7
-    hideLabel: function () {
dd45d7
-        Tweener.addTween(this.label,
dd45d7
-                         { opacity: 0,
dd45d7
-                           time: ITEM_LABEL_HIDE_TIME,
dd45d7
-                           transition: 'easeOutQuad',
dd45d7
-                           onComplete: Lang.bind(this, function() {
dd45d7
-                               this.label.hide();
dd45d7
-                           })
dd45d7
-                         });
dd45d7
-    },
dd45d7
-
dd45d7
-    destroy: function() {
dd45d7
-        Mainloop.source_remove(this._timeout);
dd45d7
+    }
dd45d7
 
dd45d7
+    hideLabel() {
dd45d7
+        this.label.ease({
dd45d7
+            opacity: 0,
dd45d7
+            duration: ITEM_LABEL_HIDE_TIME,
dd45d7
+            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
dd45d7
+            onComplete: () => this.label.hide(),
dd45d7
+        });
dd45d7
+    }
dd45d7
+
dd45d7
+    destroy() {
dd45d7
         this.actor.destroy();
dd45d7
-	if (this.label)
dd45d7
-	    this.label.destroy();
dd45d7
-    },
dd45d7
+    }
dd45d7
 
dd45d7
-    _initValues: function() {
dd45d7
-    },
dd45d7
+    _onDestroy() {
dd45d7
+        GLib.source_remove(this._timeout);
dd45d7
 
dd45d7
-    _updateValues: function() {
dd45d7
-    },
dd45d7
+        if (this.label)
dd45d7
+            this.label.destroy();
dd45d7
+    }
dd45d7
+
dd45d7
+    _initValues() {
dd45d7
+    }
dd45d7
 
dd45d7
-    _draw: function(area) {
dd45d7
+    _updateValues() {
dd45d7
+    }
dd45d7
+
dd45d7
+    _draw(area) {
dd45d7
         let [width, height] = area.get_surface_size();
dd45d7
         let themeNode = this.actor.get_theme_node();
dd45d7
         let cr = area.get_context();
dd45d7
 
dd45d7
-        //draw the background grid
dd45d7
+        // draw the background grid
dd45d7
         let color = themeNode.get_color(this.gridColor);
dd45d7
         let gridOffset = Math.floor(height / (INDICATOR_NUM_GRID_LINES + 1));
dd45d7
         for (let i = 1; i <= INDICATOR_NUM_GRID_LINES; ++i) {
dd45d7
-                cr.moveTo(0, i * gridOffset + .5);
dd45d7
-                cr.lineTo(width, i * gridOffset + .5);
dd45d7
+            cr.moveTo(0, i * gridOffset + .5);
dd45d7
+            cr.lineTo(width, i * gridOffset + .5);
dd45d7
         }
dd45d7
         Clutter.cairo_set_source_color(cr, color);
dd45d7
         cr.setLineWidth(1);
dd45d7
-        cr.setDash([4,1], 0);
dd45d7
+        cr.setDash([4, 1], 0);
dd45d7
         cr.stroke();
dd45d7
 
dd45d7
-        //draw the foreground
dd45d7
+        // draw the foreground
dd45d7
 
dd45d7
-        function makePath(values, reverse, nudge) {
dd45d7
-            if (nudge == null) {
dd45d7
-                nudge = 0;
dd45d7
-            }
dd45d7
-            //if we are going in reverse, we are completing the bottom of a chart, so use lineTo
dd45d7
+        function makePath(values, reverse, nudge = 0) {
dd45d7
+            // if we are going in reverse, we are completing the bottom of a chart, so use lineTo
dd45d7
             if (reverse) {
dd45d7
                 cr.lineTo(values.length - 1, (1 - values[values.length - 1]) * height + nudge);
dd45d7
-                for (let k = values.length - 2; k >= 0; --k) {
dd45d7
+                for (let k = values.length - 2; k >= 0; --k)
dd45d7
                     cr.lineTo(k, (1 - values[k]) * height + nudge);
dd45d7
-                }
dd45d7
             } else {
dd45d7
                 cr.moveTo(0, (1 - values[0]) * height + nudge);
dd45d7
-                for (let k = 1; k < values.length; ++k) {
dd45d7
+                for (let k = 1; k < values.length; ++k)
dd45d7
                     cr.lineTo(k, (1 - values[k]) * height + nudge);
dd45d7
-                }
dd45d7
-
dd45d7
             }
dd45d7
         }
dd45d7
 
dd45d7
         let renderStats = this.renderStats;
dd45d7
 
dd45d7
         // Make sure we don't have more sample points than pixels
dd45d7
-        renderStats.map(Lang.bind(this, function(k){
dd45d7
+        renderStats.forEach(k => {
dd45d7
             let stat = this.stats[k];
dd45d7
-            if (stat.values.length > width) {
dd45d7
+            if (stat.values.length > width)
dd45d7
                 stat.values = stat.values.slice(stat.values.length - width, stat.values.length);
dd45d7
-            }
dd45d7
-        }));
dd45d7
+        });
dd45d7
 
dd45d7
         for (let i = 0; i < renderStats.length; ++i) {
dd45d7
             let stat = this.stats[renderStats[i]];
dd45d7
             // We outline at full opacity and fill with 40% opacity
dd45d7
             let outlineColor = themeNode.get_color(stat.color);
dd45d7
-            let color = new Clutter.Color(outlineColor);
dd45d7
-            color.alpha = color.alpha * .4;
dd45d7
+            let fillColor = new Clutter.Color(outlineColor);
dd45d7
+            fillColor.alpha *= .4;
dd45d7
 
dd45d7
             // Render the background between us and the next level
dd45d7
             makePath(stat.values, false);
dd45d7
             // If there is a process below us, render the cpu between us and it, otherwise,
dd45d7
             // render to the bottom of the chart
dd45d7
-            if (i == renderStats.length - 1) {
dd45d7
+            if (i === renderStats.length - 1) {
dd45d7
                 cr.lineTo(stat.values.length - 1, height);
dd45d7
                 cr.lineTo(0, height);
dd45d7
                 cr.closePath();
dd45d7
             } else {
dd45d7
-                let nextStat = this.stats[renderStats[i+1]];
dd45d7
+                let nextStat = this.stats[renderStats[i + 1]];
dd45d7
                 makePath(nextStat.values, true);
dd45d7
             }
dd45d7
-            cr.closePath()
dd45d7
-            Clutter.cairo_set_source_color(cr, color);
dd45d7
+            cr.closePath();
dd45d7
+            Clutter.cairo_set_source_color(cr, fillColor);
dd45d7
             cr.fill();
dd45d7
 
dd45d7
             // Render the outline of this level
dd45d7
@@ -193,41 +189,43 @@ const Indicator = new Lang.Class({
dd45d7
             cr.stroke();
dd45d7
         }
dd45d7
     }
dd45d7
-});
dd45d7
+};
dd45d7
 
dd45d7
-const CpuIndicator = new Lang.Class({
dd45d7
-    Name: 'SystemMonitor.CpuIndicator',
dd45d7
-    Extends: Indicator,
dd45d7
-
dd45d7
-    _init: function() {
dd45d7
-        this.parent();
dd45d7
+const CpuIndicator = class extends Indicator {
dd45d7
+    constructor() {
dd45d7
+        super();
dd45d7
 
dd45d7
         this.gridColor = '-grid-color';
dd45d7
-        this.renderStats = [ 'cpu-user', 'cpu-sys', 'cpu-iowait' ];
dd45d7
+        this.renderStats = ['cpu-user', 'cpu-sys', 'cpu-iowait'];
dd45d7
 
dd45d7
         // Make sure renderStats is sorted as necessary for rendering
dd45d7
-        let renderStatOrder = {'cpu-total': 0, 'cpu-user': 1, 'cpu-sys': 2, 'cpu-iowait': 3};
dd45d7
-        this.renderStats = this.renderStats.sort(function(a,b) {
dd45d7
+        let renderStatOrder = {
dd45d7
+            'cpu-total': 0,
dd45d7
+            'cpu-user': 1,
dd45d7
+            'cpu-sys': 2,
dd45d7
+            'cpu-iowait': 3,
dd45d7
+        };
dd45d7
+        this.renderStats = this.renderStats.sort((a, b) => {
dd45d7
             return renderStatOrder[a] - renderStatOrder[b];
dd45d7
         });
dd45d7
 
dd45d7
-	this.setLabelText(_("CPU"));
dd45d7
-    },
dd45d7
+        this.setLabelText(_('CPU'));
dd45d7
+    }
dd45d7
 
dd45d7
-    _initValues: function() {
dd45d7
-        this._prev = new GTop.glibtop_cpu;
dd45d7
+    _initValues() {
dd45d7
+        this._prev = new GTop.glibtop_cpu();
dd45d7
         GTop.glibtop_get_cpu(this._prev);
dd45d7
 
dd45d7
         this.stats = {
dd45d7
-                       'cpu-user': {color: '-cpu-user-color', values: []},
dd45d7
-                       'cpu-sys': {color: '-cpu-sys-color', values: []},
dd45d7
-                       'cpu-iowait': {color: '-cpu-iowait-color', values: []},
dd45d7
-                       'cpu-total': {color: '-cpu-total-color', values: []}
dd45d7
-                     };
dd45d7
-    },
dd45d7
-
dd45d7
-    _updateValues: function() {
dd45d7
-        let cpu = new GTop.glibtop_cpu;
dd45d7
+            'cpu-user': { color: '-cpu-user-color', values: [] },
dd45d7
+            'cpu-sys': { color: '-cpu-sys-color', values: [] },
dd45d7
+            'cpu-iowait': { color: '-cpu-iowait-color', values: [] },
dd45d7
+            'cpu-total': { color: '-cpu-total-color', values: [] },
dd45d7
+        };
dd45d7
+    }
dd45d7
+
dd45d7
+    _updateValues() {
dd45d7
+        let cpu = new GTop.glibtop_cpu();
dd45d7
         let t = 0.0;
dd45d7
         GTop.glibtop_get_cpu(cpu);
dd45d7
         let total = cpu.total - this._prev.total;
dd45d7
@@ -246,37 +244,34 @@ const CpuIndicator = new Lang.Class({
dd45d7
 
dd45d7
         this._prev = cpu;
dd45d7
     }
dd45d7
-});
dd45d7
+};
dd45d7
 
dd45d7
-const MemoryIndicator = new Lang.Class({
dd45d7
-    Name: 'SystemMonitor.MemoryIndicator',
dd45d7
-    Extends: Indicator,
dd45d7
-
dd45d7
-    _init: function() {
dd45d7
-        this.parent();
dd45d7
+const MemoryIndicator = class extends Indicator {
dd45d7
+    constructor() {
dd45d7
+        super();
dd45d7
 
dd45d7
         this.gridColor = '-grid-color';
dd45d7
-        this.renderStats = [ 'mem-user', 'mem-other', 'mem-cached' ];
dd45d7
+        this.renderStats = ['mem-user', 'mem-other', 'mem-cached'];
dd45d7
 
dd45d7
         // Make sure renderStats is sorted as necessary for rendering
dd45d7
         let renderStatOrder = { 'mem-cached': 0, 'mem-other': 1, 'mem-user': 2 };
dd45d7
-        this.renderStats = this.renderStats.sort(function(a,b) {
dd45d7
+        this.renderStats = this.renderStats.sort((a, b) => {
dd45d7
             return renderStatOrder[a] - renderStatOrder[b];
dd45d7
         });
dd45d7
 
dd45d7
-	this.setLabelText(_("Memory"));
dd45d7
-    },
dd45d7
+        this.setLabelText(_('Memory'));
dd45d7
+    }
dd45d7
 
dd45d7
-    _initValues: function() {
dd45d7
-        this.mem = new GTop.glibtop_mem;
dd45d7
+    _initValues() {
dd45d7
+        this.mem = new GTop.glibtop_mem();
dd45d7
         this.stats = {
dd45d7
-                        'mem-user': { color: "-mem-user-color", values: [] },
dd45d7
-                        'mem-other': { color: "-mem-other-color", values: [] },
dd45d7
-                        'mem-cached': { color: "-mem-cached-color", values: [] }
dd45d7
-                     };
dd45d7
-    },
dd45d7
+            'mem-user': { color: '-mem-user-color', values: [] },
dd45d7
+            'mem-other': { color: '-mem-other-color', values: [] },
dd45d7
+            'mem-cached': { color: '-mem-cached-color', values: [] },
dd45d7
+        };
dd45d7
+    }
dd45d7
 
dd45d7
-    _updateValues: function() {
dd45d7
+    _updateValues() {
dd45d7
         GTop.glibtop_get_mem(this.mem);
dd45d7
 
dd45d7
         let t = this.mem.user / this.mem.total;
dd45d7
@@ -286,90 +281,97 @@ const MemoryIndicator = new Lang.Class({
dd45d7
         t += this.mem.cached / this.mem.total;
dd45d7
         this.stats['mem-cached'].values.push(t);
dd45d7
     }
dd45d7
-});
dd45d7
+};
dd45d7
 
dd45d7
 const INDICATORS = [CpuIndicator, MemoryIndicator];
dd45d7
 
dd45d7
-const Extension = new Lang.Class({
dd45d7
-    Name: 'SystemMonitor.Extension',
dd45d7
-
dd45d7
-    _init: function() {
dd45d7
-	Convenience.initTranslations();
dd45d7
-
dd45d7
-	this._showLabelTimeoutId = 0;
dd45d7
-	this._resetHoverTimeoutId = 0;
dd45d7
-	this._labelShowing = false;
dd45d7
-    },
dd45d7
-
dd45d7
-    enable: function() {
dd45d7
-	this._box = new St.BoxLayout({ style_class: 'extension-systemMonitor-container',
dd45d7
-				       x_align: Clutter.ActorAlign.START,
dd45d7
-				       x_expand: true });
dd45d7
-	this._indicators = [ ];
dd45d7
-
dd45d7
-	for (let i = 0; i < INDICATORS.length; i++) {
dd45d7
-	    let indicator = new (INDICATORS[i])();
dd45d7
-
dd45d7
-            indicator.actor.connect('notify::hover', Lang.bind(this, function() {
dd45d7
-		this._onHover(indicator);
dd45d7
-	    }));
dd45d7
-	    this._box.add_actor(indicator.actor);
dd45d7
-	    this._indicators.push(indicator);
dd45d7
-	}
dd45d7
-
dd45d7
-	this._boxHolder = new St.BoxLayout({ x_expand: true,
dd45d7
-					     y_expand: true,
dd45d7
-					     x_align: Clutter.ActorAlign.START,
dd45d7
-					   });
dd45d7
-	let menuButton = Main.messageTray._messageTrayMenuButton.actor;
dd45d7
-	Main.messageTray.actor.remove_child(menuButton);
dd45d7
-	Main.messageTray.actor.add_child(this._boxHolder);
dd45d7
-
dd45d7
-	this._boxHolder.add_child(this._box);
dd45d7
-	this._boxHolder.add_child(menuButton);
dd45d7
-    },
dd45d7
-
dd45d7
-    disable: function() {
dd45d7
-	this._indicators.forEach(function(i) { i.destroy(); });
dd45d7
-
dd45d7
-	let menuButton = Main.messageTray._messageTrayMenuButton.actor;
dd45d7
-	this._boxHolder.remove_child(menuButton);
dd45d7
-	Main.messageTray.actor.add_child(menuButton);
dd45d7
-
dd45d7
-	this._box.destroy();
dd45d7
-	this._boxHolder.destroy();
dd45d7
-    },
dd45d7
-
dd45d7
-    _onHover: function (item) {
dd45d7
+class Extension {
dd45d7
+    constructor() {
dd45d7
+        ExtensionUtils.initTranslations();
dd45d7
+
dd45d7
+        this._showLabelTimeoutId = 0;
dd45d7
+        this._resetHoverTimeoutId = 0;
dd45d7
+        this._labelShowing = false;
dd45d7
+    }
dd45d7
+
dd45d7
+    enable() {
dd45d7
+        this._box = new St.BoxLayout({
dd45d7
+            style_class: 'extension-systemMonitor-container',
dd45d7
+            x_align: Clutter.ActorAlign.START,
dd45d7
+            x_expand: true,
dd45d7
+        });
dd45d7
+        this._indicators = [];
dd45d7
+
dd45d7
+        for (let i = 0; i < INDICATORS.length; i++) {
dd45d7
+            let indicator = new INDICATORS[i]();
dd45d7
+
dd45d7
+            indicator.actor.connect('notify::hover', () => {
dd45d7
+                this._onHover(indicator);
dd45d7
+            });
dd45d7
+            this._box.add_actor(indicator.actor);
dd45d7
+            this._indicators.push(indicator);
dd45d7
+        }
dd45d7
+
dd45d7
+        this._boxHolder = new St.BoxLayout({
dd45d7
+            x_expand: true,
dd45d7
+            y_expand: true,
dd45d7
+            x_align: Clutter.ActorAlign.START,
dd45d7
+        });
dd45d7
+        let menuButton = Main.messageTray._messageTrayMenuButton.actor;
dd45d7
+        Main.messageTray.actor.remove_child(menuButton);
dd45d7
+        Main.messageTray.actor.add_child(this._boxHolder);
dd45d7
+
dd45d7
+        this._boxHolder.add_child(this._box);
dd45d7
+        this._boxHolder.add_child(menuButton);
dd45d7
+    }
dd45d7
+
dd45d7
+    disable() {
dd45d7
+        this._indicators.forEach(i => i.destroy());
dd45d7
+
dd45d7
+        let menuButton = Main.messageTray._messageTrayMenuButton.actor;
dd45d7
+        this._boxHolder.remove_child(menuButton);
dd45d7
+        Main.messageTray.actor.add_child(menuButton);
dd45d7
+
dd45d7
+        this._box.destroy();
dd45d7
+        this._boxHolder.destroy();
dd45d7
+    }
dd45d7
+
dd45d7
+    _onHover(item) {
dd45d7
         if (item.actor.get_hover()) {
dd45d7
-            if (this._showLabelTimeoutId == 0) {
dd45d7
-                let timeout = this._labelShowing ? 0 : ITEM_HOVER_TIMEOUT;
dd45d7
-                this._showLabelTimeoutId = Mainloop.timeout_add(timeout,
dd45d7
-                    Lang.bind(this, function() {
dd45d7
-                        this._labelShowing = true;
dd45d7
-                        item.showLabel();
dd45d7
-                        return false;
dd45d7
-                    }));
dd45d7
-                if (this._resetHoverTimeoutId > 0) {
dd45d7
-                    Mainloop.source_remove(this._resetHoverTimeoutId);
dd45d7
-                    this._resetHoverTimeoutId = 0;
dd45d7
-                }
dd45d7
+            if (this._showLabelTimeoutId)
dd45d7
+                return;
dd45d7
+
dd45d7
+            let timeout = this._labelShowing ? 0 : ITEM_HOVER_TIMEOUT;
dd45d7
+            this._showLabelTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
dd45d7
+                timeout,
dd45d7
+                () => {
dd45d7
+                    this._labelShowing = true;
dd45d7
+                    item.showLabel();
dd45d7
+                    this._showLabelTimeoutId = 0;
dd45d7
+                    return GLib.SOURCE_REMOVE;
dd45d7
+                });
dd45d7
+
dd45d7
+            if (this._resetHoverTimeoutId > 0) {
dd45d7
+                GLib.source_remove(this._resetHoverTimeoutId);
dd45d7
+                this._resetHoverTimeoutId = 0;
dd45d7
             }
dd45d7
         } else {
dd45d7
             if (this._showLabelTimeoutId > 0)
dd45d7
-                Mainloop.source_remove(this._showLabelTimeoutId);
dd45d7
+                GLib.source_remove(this._showLabelTimeoutId);
dd45d7
             this._showLabelTimeoutId = 0;
dd45d7
             item.hideLabel();
dd45d7
-            if (this._labelShowing) {
dd45d7
-                this._resetHoverTimeoutId = Mainloop.timeout_add(ITEM_HOVER_TIMEOUT,
dd45d7
-                    Lang.bind(this, function() {
dd45d7
-                        this._labelShowing = false;
dd45d7
-                        return false;
dd45d7
-                    }));
dd45d7
-            }
dd45d7
+            if (!this._labelShowing)
dd45d7
+                return;
dd45d7
+
dd45d7
+            this._resetHoverTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
dd45d7
+                ITEM_HOVER_TIMEOUT,
dd45d7
+                () => {
dd45d7
+                    this._labelShowing = false;
dd45d7
+                    return GLib.SOURCE_REMOVE;
dd45d7
+                });
dd45d7
         }
dd45d7
-    },
dd45d7
-});
dd45d7
+    }
dd45d7
+}
dd45d7
 
dd45d7
 function init() {
dd45d7
     return new Extension();
dd45d7
-- 
dd45d7
2.32.0
dd45d7
dd45d7
dd45d7
From 71e275ba45b09c5f8c6ca5445a459196dc65474b Mon Sep 17 00:00:00 2001
dd45d7
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
dd45d7
Date: Wed, 26 May 2021 19:50:37 +0200
dd45d7
Subject: [PATCH 3/6] systemMonitor: Make label property private
dd45d7
dd45d7
There is no good reason to use a public property, and the name will
dd45d7
clash when we subclass St.Button.
dd45d7
---
dd45d7
 extensions/systemMonitor/extension.js | 35 ++++++++++++++-------------
dd45d7
 1 file changed, 18 insertions(+), 17 deletions(-)
dd45d7
dd45d7
diff --git a/extensions/systemMonitor/extension.js b/extensions/systemMonitor/extension.js
dd45d7
index f7c6a4a..bde25a1 100644
dd45d7
--- a/extensions/systemMonitor/extension.js
dd45d7
+++ b/extensions/systemMonitor/extension.js
dd45d7
@@ -19,6 +19,7 @@ const ITEM_HOVER_TIMEOUT = 300;
dd45d7
 
dd45d7
 const Indicator = class {
dd45d7
     constructor() {
dd45d7
+        this._label = null;
dd45d7
         this._initValues();
dd45d7
         this._drawingArea = new St.DrawingArea({
dd45d7
             reactive: true,
dd45d7
@@ -51,28 +52,28 @@ const Indicator = class {
dd45d7
     }
dd45d7
 
dd45d7
     showLabel() {
dd45d7
-        if (this.label === null)
dd45d7
+        if (this._label === null)
dd45d7
             return;
dd45d7
 
dd45d7
-        this.label.opacity = 0;
dd45d7
-        this.label.show();
dd45d7
+        this._label.opacity = 0;
dd45d7
+        this._label.show();
dd45d7
 
dd45d7
         let [stageX, stageY] = this.actor.get_transformed_position();
dd45d7
 
dd45d7
         let itemWidth = this.actor.allocation.x2 - this.actor.allocation.x1;
dd45d7
 
dd45d7
-        let labelWidth = this.label.width;
dd45d7
+        let labelWidth = this._label.width;
dd45d7
         let xOffset = Math.floor((itemWidth - labelWidth) / 2);
dd45d7
 
dd45d7
         let x = stageX + xOffset;
dd45d7
 
dd45d7
-        let node = this.label.get_theme_node();
dd45d7
+        let node = this._label.get_theme_node();
dd45d7
         let yOffset = node.get_length('-y-offset');
dd45d7
 
dd45d7
-        let y = stageY - this.label.get_height() - yOffset;
dd45d7
+        let y = stageY - this._label.get_height() - yOffset;
dd45d7
 
dd45d7
-        this.label.set_position(x, y);
dd45d7
-        this.label.ease({
dd45d7
+        this._label.set_position(x, y);
dd45d7
+        this._label.ease({
dd45d7
             opacity: 255,
dd45d7
             duration: ITEM_LABEL_SHOW_TIME,
dd45d7
             mode: Clutter.AnimationMode.EASE_OUT_QUAD,
dd45d7
@@ -80,23 +81,23 @@ const Indicator = class {
dd45d7
     }
dd45d7
 
dd45d7
     setLabelText(text) {
dd45d7
-        if (this.label === null) {
dd45d7
-            this.label = new St.Label({
dd45d7
+        if (this._label === null) {
dd45d7
+            this._label = new St.Label({
dd45d7
                 style_class: 'extension-systemMonitor-indicator-label',
dd45d7
             });
dd45d7
         }
dd45d7
 
dd45d7
-        this.label.set_text(text);
dd45d7
-        Main.layoutManager.addChrome(this.label);
dd45d7
-        this.label.hide();
dd45d7
+        this._label.set_text(text);
dd45d7
+        Main.layoutManager.addChrome(this._label);
dd45d7
+        this._label.hide();
dd45d7
     }
dd45d7
 
dd45d7
     hideLabel() {
dd45d7
-        this.label.ease({
dd45d7
+        this._label.ease({
dd45d7
             opacity: 0,
dd45d7
             duration: ITEM_LABEL_HIDE_TIME,
dd45d7
             mode: Clutter.AnimationMode.EASE_OUT_QUAD,
dd45d7
-            onComplete: () => this.label.hide(),
dd45d7
+            onComplete: () => this._label.hide(),
dd45d7
         });
dd45d7
     }
dd45d7
 
dd45d7
@@ -107,8 +108,8 @@ const Indicator = class {
dd45d7
     _onDestroy() {
dd45d7
         GLib.source_remove(this._timeout);
dd45d7
 
dd45d7
-        if (this.label)
dd45d7
-            this.label.destroy();
dd45d7
+        if (this._label)
dd45d7
+            this._label.destroy();
dd45d7
     }
dd45d7
 
dd45d7
     _initValues() {
dd45d7
-- 
dd45d7
2.32.0
dd45d7
dd45d7
dd45d7
From b310c3a5b532a18af38390021daa332961e404ef Mon Sep 17 00:00:00 2001
dd45d7
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
dd45d7
Date: Wed, 17 May 2017 19:31:58 +0200
dd45d7
Subject: [PATCH 4/6] systemMonitor: Move indicators to calendar
dd45d7
dd45d7
The message tray joined the invisible choir, so we have to find
dd45d7
a new home for the extension UI. The message list in the calendar
dd45d7
drop-down looks like the best option, given that it replaced the
dd45d7
old tray (and also took over the old keyboard shortcut to bring
dd45d7
it up quickly).
dd45d7
---
dd45d7
 extensions/systemMonitor/extension.js   | 106 +++++++++++-------------
dd45d7
 extensions/systemMonitor/stylesheet.css |  14 ----
dd45d7
 2 files changed, 50 insertions(+), 70 deletions(-)
dd45d7
dd45d7
diff --git a/extensions/systemMonitor/extension.js b/extensions/systemMonitor/extension.js
dd45d7
index bde25a1..1fd01ab 100644
dd45d7
--- a/extensions/systemMonitor/extension.js
dd45d7
+++ b/extensions/systemMonitor/extension.js
dd45d7
@@ -2,10 +2,11 @@
dd45d7
 
dd45d7
 /* exported init */
dd45d7
 
dd45d7
-const { Clutter, GLib, GTop, Shell, St } = imports.gi;
dd45d7
+const { Clutter, GLib, GObject, GTop, Shell, St } = imports.gi;
dd45d7
 
dd45d7
 const ExtensionUtils = imports.misc.extensionUtils;
dd45d7
 const Main = imports.ui.main;
dd45d7
+const MessageList = imports.ui.messageList;
dd45d7
 
dd45d7
 const Gettext = imports.gettext.domain('gnome-shell-extensions');
dd45d7
 const _ = Gettext.gettext;
dd45d7
@@ -17,30 +18,38 @@ const ITEM_LABEL_SHOW_TIME = 150;
dd45d7
 const ITEM_LABEL_HIDE_TIME = 100;
dd45d7
 const ITEM_HOVER_TIMEOUT = 300;
dd45d7
 
dd45d7
-const Indicator = class {
dd45d7
-    constructor() {
dd45d7
+const Indicator = GObject.registerClass({
dd45d7
+    Signals: {
dd45d7
+        'close': {},
dd45d7
+        'expanded': {},
dd45d7
+        'unexpanded': {},
dd45d7
+    },
dd45d7
+}, class Indicator extends St.Button {
dd45d7
+    _init() {
dd45d7
         this._label = null;
dd45d7
         this._initValues();
dd45d7
         this._drawingArea = new St.DrawingArea({
dd45d7
-            reactive: true,
dd45d7
             x_expand: true,
dd45d7
             y_expand: true,
dd45d7
         });
dd45d7
         this._drawingArea.connect('repaint', this._draw.bind(this));
dd45d7
-        this._drawingArea.connect('button-press-event', () => {
dd45d7
+
dd45d7
+        super._init({
dd45d7
+            style_class: 'message message-content extension-systemMonitor-indicator-area',
dd45d7
+            child: this._drawingArea,
dd45d7
+            x_expand: true,
dd45d7
+            can_focus: true,
dd45d7
+        });
dd45d7
+
dd45d7
+        this.connect('clicked', () => {
dd45d7
             let app = Shell.AppSystem.get_default().lookup_app('gnome-system-monitor.desktop');
dd45d7
             app.open_new_window(-1);
dd45d7
-            return true;
dd45d7
-        });
dd45d7
 
dd45d7
-        this.actor = new St.Bin({
dd45d7
-            style_class: 'extension-systemMonitor-indicator-area',
dd45d7
-            reactive: true,
dd45d7
-            track_hover: true,
dd45d7
+            Main.overview.hide();
dd45d7
+            Main.panel.closeCalendar();
dd45d7
         });
dd45d7
-        this.actor.add_actor(this._drawingArea);
dd45d7
 
dd45d7
-        this.actor.connect('destroy', this._onDestroy.bind(this));
dd45d7
+        this.connect('destroy', this._onDestroy.bind(this));
dd45d7
 
dd45d7
         this._timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
dd45d7
             INDICATOR_UPDATE_INTERVAL,
dd45d7
@@ -58,9 +67,9 @@ const Indicator = class {
dd45d7
         this._label.opacity = 0;
dd45d7
         this._label.show();
dd45d7
 
dd45d7
-        let [stageX, stageY] = this.actor.get_transformed_position();
dd45d7
+        let [stageX, stageY] = this.get_transformed_position();
dd45d7
 
dd45d7
-        let itemWidth = this.actor.allocation.x2 - this.actor.allocation.x1;
dd45d7
+        let itemWidth = this.allocation.x2 - this.allocation.x1;
dd45d7
 
dd45d7
         let labelWidth = this._label.width;
dd45d7
         let xOffset = Math.floor((itemWidth - labelWidth) / 2);
dd45d7
@@ -73,6 +82,7 @@ const Indicator = class {
dd45d7
         let y = stageY - this._label.get_height() - yOffset;
dd45d7
 
dd45d7
         this._label.set_position(x, y);
dd45d7
+        this._label.get_parent().set_child_above_sibling(this._label, null);
dd45d7
         this._label.ease({
dd45d7
             opacity: 255,
dd45d7
             duration: ITEM_LABEL_SHOW_TIME,
dd45d7
@@ -101,8 +111,12 @@ const Indicator = class {
dd45d7
         });
dd45d7
     }
dd45d7
 
dd45d7
-    destroy() {
dd45d7
-        this.actor.destroy();
dd45d7
+    /* MessageList.Message boilerplate */
dd45d7
+    canClose() {
dd45d7
+        return false;
dd45d7
+    }
dd45d7
+
dd45d7
+    clear() {
dd45d7
     }
dd45d7
 
dd45d7
     _onDestroy() {
dd45d7
@@ -120,7 +134,7 @@ const Indicator = class {
dd45d7
 
dd45d7
     _draw(area) {
dd45d7
         let [width, height] = area.get_surface_size();
dd45d7
-        let themeNode = this.actor.get_theme_node();
dd45d7
+        let themeNode = this.get_theme_node();
dd45d7
         let cr = area.get_context();
dd45d7
 
dd45d7
         // draw the background grid
dd45d7
@@ -190,11 +204,12 @@ const Indicator = class {
dd45d7
             cr.stroke();
dd45d7
         }
dd45d7
     }
dd45d7
-};
dd45d7
+});
dd45d7
 
dd45d7
-const CpuIndicator = class extends Indicator {
dd45d7
-    constructor() {
dd45d7
-        super();
dd45d7
+const CpuIndicator = GObject.registerClass(
dd45d7
+class CpuIndicator extends Indicator {
dd45d7
+    _init() {
dd45d7
+        super._init();
dd45d7
 
dd45d7
         this.gridColor = '-grid-color';
dd45d7
         this.renderStats = ['cpu-user', 'cpu-sys', 'cpu-iowait'];
dd45d7
@@ -245,11 +260,12 @@ const CpuIndicator = class extends Indicator {
dd45d7
 
dd45d7
         this._prev = cpu;
dd45d7
     }
dd45d7
-};
dd45d7
+});
dd45d7
 
dd45d7
-const MemoryIndicator = class extends Indicator {
dd45d7
-    constructor() {
dd45d7
-        super();
dd45d7
+const MemoryIndicator = GObject.registerClass(
dd45d7
+class MemoryIndicator extends Indicator {
dd45d7
+    _init() {
dd45d7
+        super._init();
dd45d7
 
dd45d7
         this.gridColor = '-grid-color';
dd45d7
         this.renderStats = ['mem-user', 'mem-other', 'mem-cached'];
dd45d7
@@ -282,7 +298,7 @@ const MemoryIndicator = class extends Indicator {
dd45d7
         t += this.mem.cached / this.mem.total;
dd45d7
         this.stats['mem-cached'].values.push(t);
dd45d7
     }
dd45d7
-};
dd45d7
+});
dd45d7
 
dd45d7
 const INDICATORS = [CpuIndicator, MemoryIndicator];
dd45d7
 
dd45d7
@@ -296,49 +312,27 @@ class Extension {
dd45d7
     }
dd45d7
 
dd45d7
     enable() {
dd45d7
-        this._box = new St.BoxLayout({
dd45d7
-            style_class: 'extension-systemMonitor-container',
dd45d7
-            x_align: Clutter.ActorAlign.START,
dd45d7
-            x_expand: true,
dd45d7
-        });
dd45d7
-        this._indicators = [];
dd45d7
+        this._section = new MessageList.MessageListSection(_('System Monitor'));
dd45d7
 
dd45d7
         for (let i = 0; i < INDICATORS.length; i++) {
dd45d7
             let indicator = new INDICATORS[i]();
dd45d7
 
dd45d7
-            indicator.actor.connect('notify::hover', () => {
dd45d7
+            indicator.connect('notify::hover', () => {
dd45d7
                 this._onHover(indicator);
dd45d7
             });
dd45d7
-            this._box.add_actor(indicator.actor);
dd45d7
-            this._indicators.push(indicator);
dd45d7
+            this._section.addMessage(indicator, false);
dd45d7
         }
dd45d7
 
dd45d7
-        this._boxHolder = new St.BoxLayout({
dd45d7
-            x_expand: true,
dd45d7
-            y_expand: true,
dd45d7
-            x_align: Clutter.ActorAlign.START,
dd45d7
-        });
dd45d7
-        let menuButton = Main.messageTray._messageTrayMenuButton.actor;
dd45d7
-        Main.messageTray.actor.remove_child(menuButton);
dd45d7
-        Main.messageTray.actor.add_child(this._boxHolder);
dd45d7
-
dd45d7
-        this._boxHolder.add_child(this._box);
dd45d7
-        this._boxHolder.add_child(menuButton);
dd45d7
+        Main.panel.statusArea.dateMenu._messageList._addSection(this._section);
dd45d7
+        this._section.get_parent().set_child_at_index(this._section, 0);
dd45d7
     }
dd45d7
 
dd45d7
     disable() {
dd45d7
-        this._indicators.forEach(i => i.destroy());
dd45d7
-
dd45d7
-        let menuButton = Main.messageTray._messageTrayMenuButton.actor;
dd45d7
-        this._boxHolder.remove_child(menuButton);
dd45d7
-        Main.messageTray.actor.add_child(menuButton);
dd45d7
-
dd45d7
-        this._box.destroy();
dd45d7
-        this._boxHolder.destroy();
dd45d7
+        this._section.destroy();
dd45d7
     }
dd45d7
 
dd45d7
     _onHover(item) {
dd45d7
-        if (item.actor.get_hover()) {
dd45d7
+        if (item.get_hover()) {
dd45d7
             if (this._showLabelTimeoutId)
dd45d7
                 return;
dd45d7
 
dd45d7
diff --git a/extensions/systemMonitor/stylesheet.css b/extensions/systemMonitor/stylesheet.css
dd45d7
index 13f95ec..978ac12 100644
dd45d7
--- a/extensions/systemMonitor/stylesheet.css
dd45d7
+++ b/extensions/systemMonitor/stylesheet.css
dd45d7
@@ -1,17 +1,4 @@
dd45d7
-.extension-systemMonitor-container {
dd45d7
-    spacing: 5px;
dd45d7
-    padding-left: 5px;
dd45d7
-    padding-right: 5px;
dd45d7
-    padding-bottom: 10px;
dd45d7
-    padding-top: 10px;
dd45d7
-}
dd45d7
-
dd45d7
 .extension-systemMonitor-indicator-area {
dd45d7
-    border: 1px solid #8d8d8d;
dd45d7
-    border-radius: 3px;
dd45d7
-    width: 100px;
dd45d7
-    /* message tray is 72px, so 20px padding of the container,
dd45d7
-       2px of border, makes it 50px */
dd45d7
     height: 50px;
dd45d7
     -grid-color: #575757;
dd45d7
     -cpu-total-color: rgb(0,154,62);
dd45d7
@@ -21,7 +8,6 @@
dd45d7
     -mem-user-color: rgb(210,148,0);
dd45d7
     -mem-cached-color: rgb(90,90,90);
dd45d7
     -mem-other-color: rgb(205,203,41);
dd45d7
-    background-color: #1e1e1e;
dd45d7
 }
dd45d7
 
dd45d7
 .extension-systemMonitor-indicator-label {
dd45d7
-- 
dd45d7
2.32.0
dd45d7
dd45d7
dd45d7
From 432f525336a5da1a545546ab40f882f44ac42bb7 Mon Sep 17 00:00:00 2001
dd45d7
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
dd45d7
Date: Thu, 18 May 2017 16:20:07 +0200
dd45d7
Subject: [PATCH 5/6] systemMonitor: Handle clicks on section title
dd45d7
dd45d7
While on 3.24.x only the event section still has a clickable title,
dd45d7
it's a generic message list feature in previous versions. It's easy
dd45d7
enough to support with a small subclass, so use that instead of
dd45d7
the generic baseclass.
dd45d7
dd45d7
Fixes: https://gitlab.gnome.org/GNOME/gnome-shell-extensions3
dd45d7
---
dd45d7
 extensions/systemMonitor/extension.js | 18 +++++++++++++++++-
dd45d7
 1 file changed, 17 insertions(+), 1 deletion(-)
dd45d7
dd45d7
diff --git a/extensions/systemMonitor/extension.js b/extensions/systemMonitor/extension.js
dd45d7
index 1fd01ab..57bdb51 100644
dd45d7
--- a/extensions/systemMonitor/extension.js
dd45d7
+++ b/extensions/systemMonitor/extension.js
dd45d7
@@ -300,6 +300,22 @@ class MemoryIndicator extends Indicator {
dd45d7
     }
dd45d7
 });
dd45d7
 
dd45d7
+const SystemMonitorSection = GObject.registerClass(
dd45d7
+class SystemMonitorSection extends MessageList.MessageListSection {
dd45d7
+    _init() {
dd45d7
+        super._init(_('System Monitor'));
dd45d7
+    }
dd45d7
+
dd45d7
+    _onTitleClicked() {
dd45d7
+        super._onTitleClicked();
dd45d7
+
dd45d7
+        let appSys = Shell.AppSystem.get_default();
dd45d7
+        let app = appSys.lookup_app('gnome-system-monitor.desktop');
dd45d7
+        if (app)
dd45d7
+            app.open_new_window(-1);
dd45d7
+    }
dd45d7
+});
dd45d7
+
dd45d7
 const INDICATORS = [CpuIndicator, MemoryIndicator];
dd45d7
 
dd45d7
 class Extension {
dd45d7
@@ -312,7 +328,7 @@ class Extension {
dd45d7
     }
dd45d7
 
dd45d7
     enable() {
dd45d7
-        this._section = new MessageList.MessageListSection(_('System Monitor'));
dd45d7
+        this._section = new SystemMonitorSection();
dd45d7
 
dd45d7
         for (let i = 0; i < INDICATORS.length; i++) {
dd45d7
             let indicator = new INDICATORS[i]();
dd45d7
-- 
dd45d7
2.32.0
dd45d7
dd45d7
dd45d7
From 657155f8f37a8d0ddf7c39dbff954d87202c681e Mon Sep 17 00:00:00 2001
dd45d7
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
dd45d7
Date: Thu, 18 May 2017 18:00:17 +0200
dd45d7
Subject: [PATCH 6/6] systemMonitor: Provide classic styling
dd45d7
dd45d7
The indicator tooltips currently don't work out in classic mode
dd45d7
(dark text on dark background), so provide some mode-specific
dd45d7
style.
dd45d7
dd45d7
Fixes: #4
dd45d7
---
dd45d7
 extensions/systemMonitor/classic.css | 6 ++++++
dd45d7
 extensions/systemMonitor/meson.build | 4 ++++
dd45d7
 2 files changed, 10 insertions(+)
dd45d7
 create mode 100644 extensions/systemMonitor/classic.css
dd45d7
dd45d7
diff --git a/extensions/systemMonitor/classic.css b/extensions/systemMonitor/classic.css
dd45d7
new file mode 100644
dd45d7
index 0000000..946863d
dd45d7
--- /dev/null
dd45d7
+++ b/extensions/systemMonitor/classic.css
dd45d7
@@ -0,0 +1,6 @@
dd45d7
+@import url("stylesheet.css");
dd45d7
+
dd45d7
+.extension-systemMonitor-indicator-label {
dd45d7
+    background-color: rgba(237,237,237,0.9);
dd45d7
+    border: 1px solid #a1a1a1;
dd45d7
+}
dd45d7
diff --git a/extensions/systemMonitor/meson.build b/extensions/systemMonitor/meson.build
dd45d7
index 48504f6..b6548b1 100644
dd45d7
--- a/extensions/systemMonitor/meson.build
dd45d7
+++ b/extensions/systemMonitor/meson.build
dd45d7
@@ -3,3 +3,7 @@ extension_data += configure_file(
dd45d7
   output: metadata_name,
dd45d7
   configuration: metadata_conf
dd45d7
 )
dd45d7
+
dd45d7
+if classic_mode_enabled
dd45d7
+  extension_data += files('classic.css')
dd45d7
+endif
dd45d7
-- 
dd45d7
2.32.0
dd45d7