Reputation: 507
I am writing an extension for gnome-shell.
But in gnome-shell 3.4 a menu is added with panel._menus
and in gnome-shell3.6 using with panel.menuManager
. How I to add menu that work on every version?
Upvotes: 0
Views: 300
Reputation: 56905
There's a few ways you can do this.
You could check for the existence of panel._menus
and use that if it exists, otherwise use panel.menuManager
:
let menuManager = panel._menus || panel.menuManager
// now do everything with menuManager
Or you could explicitly check the gnome-shell version:
const ShellVersion = imports.misc.config.PACKAGE_VERSION.split(".").map(
function (x) { return +x; }) // <-- converts from string to number
// this is now an array, e.g. if I am on gnome-shell 3.6.2 it is [3, 6, 2].
if (ShellVersion[1] === 4) {
// GNOME 3.4, use panel._menus
} else if (ShellVersion[1] === 6) {
// GNOME 3.6, use panel.menuManager
}
Upvotes: 1