hillpig的个人博客分享 http://blog.sciencenet.cn/u/hillpig 畅想ing,思考ing,前行ing Email:bluevaley@gmail.com

博文

如何在RHEL中为应用增加一个菜单项

已有 3937 次阅读 2013-2-14 01:58 |个人分类:linux|系统分类:科研笔记| rhel, 增加一个菜单项

在为一个应用程序制作RPM安装包时,有时候会想在系统的菜单项里增加一个菜单项,那如何做呢?
首先,列出需要学习的材料:
[1] Desktop Menu Specificationl, http://standards.freedesktop.org/menu-spec/menu-spec-1.0.html
[2] Desktop Entry Specification, http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.0.html
[3] Icon Theme Specification, http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
[4] Red Hat Desktop: Deployment Guide: Chapter 3. Menu Editing and Configuration, https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/4/html/Desktop_Deployment_Guide/ch-ddg-menus.html

根据参考[1],摘录其中的例子如下:
Example
The company ShinyThings Inc. has developed an application namedWebMirror 1.0 and would like to add its own        submenu to the system menus consisting of a WebMirrormenu item and a WebMirror Admin Toolmenu item. The company will use "shinythings" as its vendor id.        For the purpose of this example all menu items will be available        in two languages, English and Dutch.        The language code for Dutch is nl.
First the company needs to create two .desktop files that describe        the two menu items:
datadir
/applications/shinythings-webmirror.desktop:

 [Desktop Entry]          
Encoding=UTF-8          
Type=Application
 Exec=webmirror
         Icon=webmirror          
Name=WebMirror          
Name[nl]=WebSpiegel

and
datadir
/applications/shinythings-webmirror-admin.desktop:          

[Desktop Entry]          
Encoding=UTF-8          
Type=Application          
Exec=webmirror-admintool
         Icon=webmirror-admintool          
Name=WebMirror Admin Tool
         Name[nl]=WebSpiegel Administratie Tool


A .directory file needs to be installed to provide a title and icon        for the sub-menu itself:
datadir
/desktop-directories/shinythings-webmirror.directory:          

[Desktop Entry]          
Encoding=UTF-8
Icon=webmirror          Name=WebMirror          
Name[nl]=WebSpiegel


And finally, a .menu file needs to be provided that links it all        togther:

         sysconfdir/menus/application-merged/shinythings-webmirror.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>
  <Menu>
     <Name>WebMirror</Name>              
     <Directory>shinythings-webmirror.directory</Directory>              
     <Include>
             <Filename>shinythings-webmirror.desktop</Filename>
             <Filename>shinythings-webmirror-admin.desktop</Filename>              
      </Include>
  </Menu>
</Menu>

这时,有朋友就会问icon的目录是如何寻找的,根据参考[3],知道会递归遍历/usr/share/icons/hicolor目录,但是有朋友又会问,为什么我把图片拷贝到其中的一个目录(例如/usr/share/icons/hicolor/32x32/apps/)了,为什么菜单项里的图标还是没有?这时你还需执行命令:

gtk-update-icon-cache /usr/share/icons/hicolor
以更新icons的cache,才能生效。


加我私人微信,交流技术。




https://wap.sciencenet.cn/blog-419883-661662.html

上一篇:RHEL 6.3 U盘启动
下一篇:RHEL下关闭某个端口
收藏 IP: 223.72.72.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-20 21:17

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部