1
그놈 쉘 용 확장 프로그램을 작성하고 있습니다. 그러나 gnome-shell 3.4에서는 메뉴가 panel._menus
으로 추가되었고 gnome-shell3.6에서는 panel.menuManager
이 사용되었습니다. 모든 버전에서 작동하는 메뉴를 어떻게 추가합니까?gnome-shell 3.4 및 3.6 용 확장 프로그램을 작성하십시오.
그놈 쉘 용 확장 프로그램을 작성하고 있습니다. 그러나 gnome-shell 3.4에서는 메뉴가 panel._menus
으로 추가되었고 gnome-shell3.6에서는 panel.menuManager
이 사용되었습니다. 모든 버전에서 작동하는 메뉴를 어떻게 추가합니까?gnome-shell 3.4 및 3.6 용 확장 프로그램을 작성하십시오.
몇 가지 방법이 있습니다.
당신은 panel._menus
의 존재를 확인하고있는 경우는 true, 그렇지 않은 경우는 panel.menuManager
사용하는 것이 사용할 수 있습니다
let menuManager = panel._menus || panel.menuManager
// now do everything with menuManager
를 또는 명시 적으로 그놈 쉘 버전을 확인할 수 있습니다 :
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
}
을