【问题标题】:Write extension for gnome-shell 3.4 and 3.6为 gnome-shell 3.4 和 3.6 编写扩展
【发布时间】:2012-12-10 07:33:35
【问题描述】:

我正在为 gnome-shell 编写一个扩展。 但是在 gnome-shell 3.4 中添加了一个带有 panel._menus 的菜单,在 gnome-shell3.6 中使用了 panel.menuManager。如何添加适用于每个版本的菜单?

【问题讨论】:

    标签: gnome-shell gjs


    【解决方案1】:

    有几种方法可以做到这一点。

    您可以检查panel._menus 是否存在,如果存在则使用它,否则使用panel.menuManager

    let menuManager = panel._menus || panel.menuManager
    // now do everything with menuManager
    

    或者您可以明确检查 gnome-shell 版本:

    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
    }
    

    【讨论】:

      猜你喜欢
      • 2012-01-08
      • 2012-09-01
      • 2021-12-24
      • 2017-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-04
      相关资源
      最近更新 更多