当前位置: 首页 > java >正文

GNOME开始菜单

和Cinnamon差不多,又有一点区别。

参考

/usr/share/gnome-shell/extensions/arcmenu@arcmenu.com/menulayouts/baseMenuLayout.js

Cinnamon开始菜单(1):获取应用数据-CSDN博客

使用 PopupSubMenu (二级弹出菜单) 显示数据。

import Gio from 'gi://Gio';
import St from 'gi://St';
import Shell from 'gi://Shell';
import GMenu from 'gi://GMenu';import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';export default class DatetimeExtension extends Extension {enable() {this._indicator = new PanelMenu.Button(0.0, this.metadata.name, false);let gicon = Gio.icon_new_for_string(this.dir.get_path() + '/gnome.svg');const icon = new St.Icon({gicon: gicon,style_class: 'system-status-icon'});this._indicator.add_child(icon);// /usr/share/gnome-shell/extensions/arcmenu@arcmenu.com/menulayouts/baseMenuLayout.jsthis.appSys = Shell.AppSystem.get_default();this._tree = new GMenu.Tree({ menu_basename: 'applications.menu' });this._tree.load_sync();const root = this._tree.get_root_directory();const iter = root.iter();let nextType;while ((nextType = iter.next())) {if (nextType == GMenu.TreeItemType.DIRECTORY) {const dir = iter.get_directory();//console.log(dir.get_name());// https://gjs.guide/extensions/topics/popup-menu.html#popupsubmenumenuitemlet menuItem = new PopupMenu.PopupSubMenuMenuItem(dir.get_name(), true, {});// /usr/share/gnome-shell/extensions/arcmenu@arcmenu.com/menulayouts/utils.jsconsole.log(dir.get_icon().to_string());menuItem.icon.icon_name = dir.get_icon().to_string();this._indicator.menu.addMenuItem(menuItem);let iter1 = dir.iter();let nextType1;while (nextType1 = iter1.next()) {if (nextType1 == GMenu.TreeItemType.ENTRY) {let id = iter1.get_entry().get_desktop_file_id();let app = this.appSys.lookup_app(id);// https://gjs.guide/extensions/topics/popup-menu.html, addAction(title, callback, icon)menuItem.menu.addAction(app.get_name(), () => app.open_new_window(-1), app.get_icon().to_string());                        }    }}}        Main.panel.addToStatusArea(this.uuid, this._indicator);}disable() {}    }

http://www.xdnf.cn/news/10553.html

相关文章:

  • gcc编译构建流程-动态链接库
  • YOLO机械臂丨使用unity搭建仿真环境,YOLO算法识别,Moveit2控制
  • 残差神经网络ResNet
  • Webpack依赖
  • 前端面试准备-6
  • unity随机生成未知符号教程
  • 字节跳动社招面经 —— BSP驱动工程师(5)
  • webfuture:如何屏蔽后台发文界面的保存为新文章按钮?
  • 使用 fastai 进行文本分类的简明指南 - Fastai Part 5
  • 【仿muduo库实现并发服务器】使用正则表达式提取HTTP元素
  • java基础学习(二十一)
  • oscp练习 PG Wombo
  • 「完整」AI文档库 | 5月20最新发布,221页,《北京大学AI+Agent与Agentic+AI的原理和应用洞察与未来展望》
  • ChatOn:智能AI聊天助手,开启高效互动新时代
  • pikachu靶场通关笔记09 XSS关卡05-DOM型XSS-X
  • 第18讲、Odoo接口开发详解:原理、类型与实践
  • 【软件测试】火狐驱动下载镜像
  • Golang学习之旅
  • linux驱动 - 5: simple usb device驱动
  • 小白的进阶之路系列之十----人工智能从初步到精通pytorch综合运用的讲解第三部分
  • CppCon 2014 学习:Exception-Safe Coding
  • [免费]微信小程序网上花店系统(SpringBoot后端+Vue管理端)【论文+源码+SQL脚本】
  • Cesium快速入门到精通系列教程四:加载渲染GEOJSON数据
  • BA-SAM: 用于 Segment Anything 模型的可扩展偏置模式注意力掩码
  • vue-13(延迟加载路由)
  • Oracle的Hint
  • 2025/6月最新Cursor(0.50.5版本)一键自动更换邮箱无限续杯教程
  • Spring 5 响应式编程:构建高性能全栈应用的关键
  • 数据库系统概论(十二)SQL 基于派生表的查询 超详细讲解(附带例题表格对比带你一步步掌握)
  • MySQL-多表关系、多表查询