如何将整个popupsubmenumenuitem移动到汇总菜单上

发布于 2025-02-13 19:44:39 字数 1174 浏览 1 评论 0原文

我正在经过精心处理Gnome-shell的一些扩展。我在状态区域中的聚合菜单中添加了一个新的弹出菜单,但无法将其移至所需的位置。尝试菜单。moveMenuitem(item,position),但它仅移动“主”项目,而不是整个下拉列表(它看起来如何从优化)。我需要做什么才能将整个子菜单转移到特定的位置?

代码样本:

enable() {
    this._item = new PopupMenu.PopupSubMenuMenuItem('Thermal Management', true);
    this._item.icon.icon_name = 'applications-system-symbolic';
    let position = this._findMenuItemPosition(Main.panel.statusArea.aggregateMenu._power.menu) + 1;

    this._optimizedOption = this._createOptimizedOption();
    this._item.menu.addMenuItem(this._optimizedOption);

    this._quietOption = this._createQuietOption();
    this._item.menu.addMenuItem(this._quietOption);

    this._coolOption = this._createCoolOption();
    this._item.menu.addMenuItem(this._coolOption);

    this._ultraPerformanceOption = this._createUltraPerformanceOption();
    this._item.menu.addMenuItem(this._ultraPerformanceOption);

    Main.panel.statusArea.aggregateMenu.menu.addMenuItem(this._item);
    Main.panel.statusArea.aggregateMenu.menu.moveMenuItem(this._item, position);
}

I'm curently working on some extension to the gnome-shell. I added a new Popup menu into aggregate menu in status area, but can't move it to the desired position. Tried menu.moveMenuItem(item, position), but it moves only the "main" item, not the entire dropdown (How it looks - my PopupSubMenuMenuItem is named ThermalManagement, and submenu menu items starts from Optimized). What I need to do to move an entire submenu into specific position?

Code sample:

enable() {
    this._item = new PopupMenu.PopupSubMenuMenuItem('Thermal Management', true);
    this._item.icon.icon_name = 'applications-system-symbolic';
    let position = this._findMenuItemPosition(Main.panel.statusArea.aggregateMenu._power.menu) + 1;

    this._optimizedOption = this._createOptimizedOption();
    this._item.menu.addMenuItem(this._optimizedOption);

    this._quietOption = this._createQuietOption();
    this._item.menu.addMenuItem(this._quietOption);

    this._coolOption = this._createCoolOption();
    this._item.menu.addMenuItem(this._coolOption);

    this._ultraPerformanceOption = this._createUltraPerformanceOption();
    this._item.menu.addMenuItem(this._ultraPerformanceOption);

    Main.panel.statusArea.aggregateMenu.menu.addMenuItem(this._item);
    Main.panel.statusArea.aggregateMenu.menu.moveMenuItem(this._item, position);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文