Gnome-menus
gnome-menus는 freedesktop.org의 Desktop Menu Specification을 구현한 라이브러리로, GNOME 데스크톱 환경의 애플리케이션 메뉴 구조를 생성하고 관리한다.
개요
.desktop 파일들과 .menu XML 파일을 읽어서 카테고리별로 분류된 애플리케이션 메뉴 트리를 구성한다. GNOME Shell의 앱 그리드나 기타 메뉴 기반 런처가 이 라이브러리를 사용하여 설치된 앱 목록을 표시한다.
동작 흐름
-
.menuXML 파일에서 메뉴 구조(카테고리 계층)를 읽는다. -
.desktop파일들의Categories=필드를 기준으로 앱을 카테고리에 매칭한다. - 정렬된 메뉴 트리를 애플리케이션에 제공한다.
관련 파일
| 경로 | 설명 |
| | 메뉴 구조를 정의하는 XML 파일 |
| | 카테고리(디렉토리) 이름 및 아이콘 정의 |
| | 개별 앱의 데스크톱 엔트리 |
.menu 파일 예시
<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
"http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">
<Menu>
<Name>Applications</Name>
<Directory>X-GNOME-Menu-Applications.directory</Directory>
<Menu>
<Name>Accessories</Name>
<Directory>Utility.directory</Directory>
<Include>
<And>
<Category>Utility</Category>
<Not><Category>System</Category></Not>
</And>
</Include>
</Menu>
<Menu>
<Name>Graphics</Name>
<Directory>Graphics.directory</Directory>
<Include>
<Category>Graphics</Category>
</Include>
</Menu>
</Menu>
.directory 파일 예시
[Desktop Entry]
Name=Accessories
Comment=Desktop accessories
Icon=applications-accessories
Type=Directory
제공 구성 요소
| 구성 요소 | 설명 |
| | C 라이브러리 (GObject Introspection 지원) |
| | Python 등에서 GI 바인딩을 통해 접근 가능 |
Python 사용 예시
import gi
gi.require_version('GMenu', '3.0')
from gi.repository import GMenu
tree = GMenu.Tree.new('gnome-applications.menu', GMenu.TreeFlags.NONE)
tree.load_sync()
root = tree.get_root_directory()
it = root.iter()
while True:
item_type = it.next()
if item_type == GMenu.TreeItemType.INVALID:
break
elif item_type == GMenu.TreeItemType.DIRECTORY:
directory = it.get_directory()
print(directory.get_name())
관련 스펙
| 스펙 | 설명 |
| 메뉴 구조 및 카테고리 정의 표준 | |
| |