LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 10047|回复: 58

Redhat 8.0 9.0之Gnome菜单编辑解决方案及gnome菜单编辑器

[复制链接]
发表于 2002-11-25 16:23:39 | 显示全部楼层 |阅读模式
This mini-tutorial should give you the information you need to customize your GNOME menus in Red Hat 8.0. Soon, hopefully, the instructions in this tutorial will be obsoleted by an errata update from Red Hat that will allow editing of menus via Nautilus. Feel free to direct any comments or suggestions to me at mknepher at bluethingy.com

UPDATE - 11/18/2002: Havoc Pennington posted this message to the RH 8.0 mailing list stating that, due to issues with the fixes in GNOME 2.0.2 breaking compatibility with KDE, getting a fix into Red Hat 8.0 has been delayed.
How the menus work

Red Hat's system menus use the vfolder spec - so the menus are "virtual folders" that are built using the XML file /etc/X11/desktop-menus/applications.menu This file references the *.directory files in /usr/share/desktop-menu-files, and the *.desktop files scattered about the system (the new default location is /usr/share/applications).
The applications.menu file

The applications.menu file begins with a list of directories to be merged in order to find all of the *.desktop files to be included as menu entries.

I would recommend reading carefully through applications.menu to familiarize yourself with the file's structure before making any changes. Be sure to make a backup of the original file before making any changes. The basic structure is as follows:

<VFolderInfo>
    <MergeDir></MergeDir>
    <DesktopDir></DesktopDir>

    <Folder>
        <Name>Foo</Name>
        <Desktop>Foobar.directory</Desktop>
        <Query>
            <And>
                <Keyword>Category</Keyword>
            <Not>
                <Keyword>Category</Keyword>
            </Not>
            </And>
        </Query>
        <Include>appname.desktop</Include>
        <Exclude>appname2.desktop</Exclude>

        <Folder>
        ...
        </Folder>

    </Folder>
</VFolderInfo>

The *.directory files

The *.directory files in /usr/share/desktop-menu-files hold the properties for the menu directories. Following is an abridged version of Applications.desktop:

    [Desktop Entry]
    Name=Applications
    Name[da]=Programmer
    Name[de]=Anwendungen
    Comment=Applications
    Comment[da]=Programmer
    Comment[de]=Anwendungen
    Icon=gnome-applications.png
    Type=Directory
    Encoding=UTF-8

The "Name" entry provides the name of the menu/directory as it is actually displayed, regardless of the value of the <Name></Name> tag in applications.menu.
The *.desktop files

The *.desktop files are similar, and hold the properties for the individual menu entries. Here is a brief version of the galeon.desktop file:

    [Desktop Entry]
    Name=Galeon
    Comment=Galeon Web Browser
    Exec=galeon
    Terminal=0
    Type=Application
    Icon=galeon.png
    Categories=Application;Network;X-Red-Hat-Extras;

The *.desktop files are queried on the values of "Categories". By default, the main menu directories restrict their queries to *.desktop files that are categorized by X-Red-Hat-Base or X-Red-Hat-Base-Only. For example, the default Applications -> Internet menu is defined like the following:

<!-- Internet -->
<Folder>
    <Name>Internet</Name>
    <Desktop>Internet.directory</Desktop>
    <Query>
        <And>
            <Keyword>X-Red-Hat-Base</Keyword>
            <Keyword>Application</Keyword>
            <Keyword>Network</Keyword>
        </And>
    </Query>
    <DontShowIfEmpty/>
</Folder>

The Extras menu folder will then display all *.desktop items that are not categorized under X-Red-Hat-Base or X-Red-Hat-Base-Only. (Note: If you look carefully at applications.menu, you will notice that the Extras subfolders reference the same *.directory entries as the main-level menu folders.)
Editing the Menus

The easiest way to add a new menu item is to find its *.desktop file and add an <Include>app.desktop</Include> line in the appropriate folder in applications.menu. If, for instance, you wanted to move the galeon entry from Extras -> Internet, you would add the following line to the main Internet section in applications.menu:

    <Include>galeon.desktop</Include>

You could then also add the following line:

    <Exclude>galeon.desktop</Exclude>

to the Internet folder under the Extras section.

If you want to add something to the menu that does not have a *.desktop file, you can easily copy an existing one and modify it to suit your needs. Then follow the same steps above to add the entry to the menu.
Creating submenus

To create a submenu, simply add a <Folder></Folder> entry within the section in which you want to put the new menu folder. Create a *.directory file in /usr/share/desktop-menu-files to set the name and other properties of the menu.
What if I want different users to have different menus?

Simply save a copy of applications.menu in ~/.gnome2/vfolders as applications.vfolder-info (you may need to create the vfolders directory) and make the appropriate changes for each user.
I don't like the Extras menu

You have several options:

   1. Put every item in its menu under the main sections -- i.e., all internet apps appear directly under Applications->Internet. To do this, remove the X-Red-Hat-Base and X-Red-Hat-Base-Only keyword entries from the main-level folders, and delete the extras section. Depending on your installation, you may now have a boatload of entries in some menus.
   2. Move the "Extras" menus so that they become submenus under the main menu sections -- i.e., Applications -> Internet -> Internet. If you want the submenu to have a different label (like, say, More Internet Apps), you will need to create a new *.directory file for the submenu with the appropriate name.
   3. I don't need any of those stinking extras - just delete the whole extras section.

Once you're familiar with applications.menu, you'll be able to set up your menus just about any way you want. If you're lucky, Red Hat will release an errata update to allow changing menus in Nautilus the day after you get your menus just right.
发表于 2002-11-25 21:36:25 | 显示全部楼层
cool!
谢谢!
有中文的吗?
发表于 2002-11-26 00:38:30 | 显示全部楼层
这个不错,咱们可以改造一下,试试看再说。。好资料。。。。
 楼主| 发表于 2002-11-26 14:13:56 | 显示全部楼层
不过*.desktop文件中各语言用的是UTF-8的编码。。。好乱。。。

Name[de]=Zugriffsm枚glichkeit
Name[el]=?| ?~A慰?~C尾伪?~C喂渭?~L?~D畏?~D伪
Name[es]=Accesibilidad
Name[fr]=Accessibilit茅
Name[is]=A冒gengi
Name[it]=Accessibilit?|
Name[ja]=?~B&#8364;~B~B汇~B枫~C~S?~C~C~F?~B?
Name[ko]=臧~\?~]? ?~Dれ| ~U
Name[ms]=Kebolehcapaian
Name[nl]=Toegankelijkheid
Name[no]=Tilgjengelighet
Name[pt]=Acessibilidade
Name[ru]=小锌械?~F懈邪谢?~L薪?~K械 胁芯蟹屑芯卸薪芯?~A?~B懈
Name[sv]=?~Etkomlighet
Name[tr]=Eri?~_ilebilirlik
Name[zh_CN]=?~O?~W~@?
Name[zh_TW]=杓~T?~J╁伐?~E?
发表于 2002-12-6 17:33:35 | 显示全部楼层

gnome菜单编辑解决方案

怎样在rh8 gnome里面编辑菜单呢?

菜单编辑器下载[原创:dany兄]

www.linuxsir.cn.cn/software/dany/menucreate-0.2-1.i386.rpm


安装:
#rpm -Uvh menu*.rpm --nodeps --force
调用:

[root@linuxsir01 root]# menuedit2

北南 加注

(我在此将  菜单栏里面的 其他 以及其它里面的子目录以外的菜单栏 通称为一级目录,比如图像,互联网都是一级目录。)
和gnome菜单显示相关的有三个个目录:/usr/share/applications,
/usr/share/gnome/apps和
/etc/X11/applnk/
对于前者即/usr/share/applications里面都是
以desktop为后缀的文档;对于后者/usr/share/gnome/apps和/etc/X11/applnk/里面是一些目录,它们可以是
Network,
Office,
Graphics,
AudioVideo,
System,
Development,
Utility,
Settings等
一般在这些目录里面也是以desktop为结尾的文件这些文件对应的菜单项一般是让它们在其它里面显示(我想也应该可以在第一级目录里面显示,呵呵没有试过).对于/usr/share/applications里面的文件,既可在其它里面显示也可在第一级菜单里面显示。
下面来看一下以.desktop结尾的文件的格式,低下是一个模板:

[Desktop Entry]
Name=
Name[zh_CN]=
Exec=
Icon=
Terminal=
Type=
Categories=Application;;;
Encoding=UTF-8
Comment=
Comment[zh_CN]=
OnlyShowIn=
X-Desktop-File-Install-Version=0.3


对上面的每一项我逐一解释:
Name--你原意给程序取的名字
Name[zh_CN]--程序对应local为中文是的名字
Exec要执行的应用程序路径
Icon你想要显示的图标路径
Type程序的种类,一般为Application即可。
下面的Categories是关键,注意上面的几个分号,第一个之前一般为Application即可
第二个之前可以为Network,
Office,
Graphics,
AudioVideo,
System,
Development,
Utility,
Settings
之一。
它们分别对应如下:
互联网 Network
办公 Office
图像 Graphics
声音和视频 AudioVideo
系统工具 System
编程 Development
辅助选项 Utility
首选项 Settings。
也就是说如果这一项是Network就会在互联网栏里面显示,这一项是Utility,你创建的菜单项就会在辅助选项里面显示,如此类推。
第二个分号之后的内容可以为X-Red-Hat-Base加X-Red-Hat-Base-Only或者X-Red-Hat-Extra。(注意只要加了X-Red-Hat-Base就不会在其他里面显示了)对于
X-Red-Hat-Base加X-Red-Hat-Base-Only
将在一级菜单里面显示,对于X-Red-Hat-Extra将在其它里面显示。
下面看我的两个个实例:

[Desktop Entry]
Name=redoffice
Name[zh_CN]=红色办公Office
Exec=redoffice
Icon=/usr/share/pixmaps/redhat-word-processor.png
Terminal=false
Type=Application
Categories=Application;Office;X-Red-Hat-Extra;
Encoding=UTF-8
Comment=RedOffice1.2
Comment[zh_CN]=Office工具
X-Desktop-File-Install-Version=0.3

将在 其他办公 里面显示我的菜单.

[Desktop Entry]
Name=redoffice
Name[zh_CN]=红色办公Office
Exec=redoffice
Icon=/usr/share/pixmaps/redhat-word-processor.png
Terminal=false
Type=Application
Categories=Application;Office;X-Red-Hat-Base;X-Red-Hat-Base-Only;
Encoding=UTF-8
Comment=RedOffice1.2
Comment[zh_CN]=Office工具
X-Desktop-File-Install-Version=0.3


将在第一级菜单 办公[/b ]里面显示我的菜单
如下的几个是编码和说明以及是否在终端运行。OnlyShowIn指的是在kde里面还是gnome里面显示其值为GNOME或KDE
另外kde里面的菜单和/usr/share/applnk/的文件有关当然对应有[Kde Desktop Entry]我是用的gnome,没有试KDE.
发表于 2002-12-6 17:37:03 | 显示全部楼层
因此,对于gnome用户在/usr/share/applications/目录里面新建一个以desktop为后缀的文件,在里面指定相应的参数是最好不过了。.当然也可以在另外的那些目录里面指定.我个人感觉到在/usr/share/applications/下面比较好。
发表于 2002-12-6 17:39:41 | 显示全部楼层
l另外在编辑文件的是后用gedit,否则中文无法显示
发表于 2002-12-6 17:49:06 | 显示全部楼层
对于上面的解决方案,有些参数还可以取其他的值,我没有试过,不过对于大家一般的应用也就够了。呵呵,还望赐教!
发表于 2002-12-6 20:22:19 | 显示全部楼层
好,最新研究成果 ,咱们也有了思路,请弟兄们根据自己所需,编一个菜单试试看。
多谢dany兄,为弟兄们传道、授业、解惑!
发表于 2002-12-6 23:15:54 | 显示全部楼层

嗯~不错!

回去试试用~
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表