如何将整个popupsubmenumenuitem移动到汇总菜单上
我正在经过精心处理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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论