Skip to content

Commit

Permalink
Add compatibility with Gnome-Shell < 3.34 - for example RHEL 8 with 3…
Browse files Browse the repository at this point in the history
….32.2

ModalDialog was converted to GObject.registerClass in 3.34

Signed-off-by: NVieville <[email protected]>
  • Loading branch information
NVieville committed Apr 20, 2023
1 parent 21d7b4e commit 3c08b93
Showing 1 changed file with 49 additions and 41 deletions.
90 changes: 49 additions & 41 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3c08b93

Please sign in to comment.