From afb75191b8ada1889c318cfd8ff97df458825e77 Mon Sep 17 00:00:00 2001 From: Marcin Jakubowski Date: Thu, 23 Dec 2021 17:12:38 +0100 Subject: [PATCH] fixed prefs issue with earlier gnome shell versions (#2) --- prefs.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/prefs.js b/prefs.js index 2e20b8d..378370c 100644 --- a/prefs.js +++ b/prefs.js @@ -31,6 +31,15 @@ const Utils = Me.imports.utils; const Gettext = imports.gettext; const _ = Gettext.domain('notification-banner-reloaded').gettext; +// API change 3 -> 4 +function addBox(box, child) { + if (imports.gi.versions.Gtk.startsWith("3")) { + box.add(child); + } + else { + box.append(child); + } +} function init() { let localeDir = Me.dir.get_child('locale'); @@ -126,7 +135,7 @@ class Preferences { if (input instanceof Gtk.Switch) { inputWidget = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL,}); - inputWidget.append(input); + addBox(inputWidget, input); } if (label) { @@ -171,7 +180,11 @@ class Preferences { }; function buildPrefsWidget() { + let frame = new Gtk.Box(); let widget = new Preferences(); - return widget.main; + addBox(frame, widget.main); + if (frame.show_all) + frame.show_all(); + return frame; }