Blob Blame History Raw
From 3c08b932af7eed795944e0970fcc0e5f49598502 Mon Sep 17 00:00:00 2001
From: NVieville <nicolas.vieville@uphf.fr>
Date: Sun, 16 Apr 2023 16:02:52 +0200
Subject: [PATCH] Add compatibility with Gnome-Shell < 3.34 - for example RHEL
 8 with 3.32.2 ModalDialog was converted to GObject.registerClass in 3.34

Signed-off-by: NVieville <nicolas.vieville@uphf.fr>
---
 .../extension.js                              | 90 ++++++++++---------
 1 file changed, 49 insertions(+), 41 deletions(-)

diff --git a/system-monitor@paradoxxx.zero.gmail.com/extension.js b/system-monitor@paradoxxx.zero.gmail.com/extension.js
index 146e279..a3b2fc8 100644
--- a/system-monitor@paradoxxx.zero.gmail.com/extension.js
+++ b/system-monitor@paradoxxx.zero.gmail.com/extension.js
@@ -283,47 +283,55 @@ const smStyleManager = class SystemMonitor_smStyleManager {
     }
 }
 
-const smDialog = GObject.registerClass(
-    class SystemMonitor_smDialog extends ModalDialog.ModalDialog {
-        constructor() {
-            super({styleClass: 'prompt-dialog'});
-            let mainContentBox = new St.BoxLayout({style_class: 'prompt-dialog-main-layout',
-                vertical: false});
-            this.contentLayout.add(mainContentBox,
-                {x_fill: true,
-                    y_fill: true});
-
-            let messageBox = new St.BoxLayout({style_class: 'prompt-dialog-message-layout',
-                vertical: true});
-            mainContentBox.add(messageBox,
-                {y_align: St.Align.START});
-
-            this._subjectLabel = new St.Label({style_class: 'prompt-dialog-headline',
-                text: _('System Monitor Extension')});
-
-            messageBox.add(this._subjectLabel,
-                {y_fill: false,
-                    y_align: St.Align.START});
-
-            this._descriptionLabel = new St.Label({style_class: 'prompt-dialog-description',
-                text: MESSAGE});
-
-            messageBox.add(this._descriptionLabel,
-                {y_fill: true,
-                    y_align: St.Align.START});
-
-
-            this.setButtons([
-                {
-                    label: _('Cancel'),
-                    action: () => {
-                        this.close();
-                    },
-                    key: Clutter.Escape
-                }
-            ]);
-        }
-    });
+var smDialog = class SystemMonitor_smDialog extends ModalDialog.ModalDialog {
+    _init() {
+        super._init({styleClass: 'prompt-dialog'});
+        let mainContentBox = new St.BoxLayout({style_class: 'prompt-dialog-main-layout',
+            vertical: false});
+        this.contentLayout.add(mainContentBox,
+            {x_fill: true,
+                y_fill: true});
+
+        let messageBox = new St.BoxLayout({style_class: 'prompt-dialog-message-layout',
+            vertical: true});
+        mainContentBox.add(messageBox,
+            {y_align: St.Align.START});
+
+        this._subjectLabel = new St.Label({style_class: 'prompt-dialog-headline',
+            text: _('System Monitor Extension')});
+
+        messageBox.add(this._subjectLabel,
+            {y_fill: false,
+                y_align: St.Align.START});
+
+        this._descriptionLabel = new St.Label({style_class: 'prompt-dialog-description',
+            text: MESSAGE});
+
+        messageBox.add(this._descriptionLabel,
+            {y_fill: true,
+                y_align: St.Align.START});
+
+
+        this.setButtons([
+            {
+                label: _('Cancel'),
+                action: () => {
+                    this.close();
+                },
+                key: Clutter.Escape
+            }
+        ]);
+    }
+}
+
+// Add compatibility with Gnome-Shell < 3.34 - for example RHEL 8 with 3.32.2
+// ModalDialog was converted to GObject.registerClass in 3.34
+if (shell_Version >= '3.34') {
+    smDialog = GObject.registerClass(
+        {GTypeName: 'smDialog'},
+        smDialog
+    );
+}
 
 const Chart = class SystemMonitor_Chart {
     constructor(width, height, parent) {
-- 
2.40.0