Customizing MenusThe information in this chapter describes how GNOME implements
menus and how you can customize menus.Introduction to MenusmenusintroductionThe way in which GNOME implements menus in the desktop enables you to
do the following:Customize the menu hierarchy easily. The menu hierarchy is
not based on the file system hierarchy. You can edit a small number of files
to customize the menu hierarchy. You do not need to modify your applications
or move files.Install applications easily. You do not need to provide information
about the menu hierarchy to applications when you install the applications.Configure menus so that users cannot modify the menus.Menus in the GNOME desktop use the following components:File abstraction layerVfoldersDesktop entry filesDirectory entry filesFile Abstraction Layermenusfile abstraction layerfile abstraction layer, and menusThe gnome-vfs file abstraction layer
provides a simplified and generalized way for applications to interact with
files. The file abstraction layer also provides Uniform Resource
Identifier (URI) locations that map to particular menu configuration
files. To add a menu or a menu item for all users, you must add the menu or
menu item to one of the URI locations.
lists the menus to which you can add items, and the URI locations that correspond
to the menus.
Menus and URI LocationsMenuURI LocationsApplications menu for all
usersapplications-all-users:///Desktop Preferences menu
for all userspreferences-all-users:///
VfoldersmenusvfoldersvfoldersIn general terms,
a vfolder is a virtual representation of items that
reside in a physical location or physical locations on your system. For example,
a vfolder might represent the contents of several directories. A vfolder is
an abstraction from one or more physical locations. In terms of menus in the
GNOME desktop, a vfolder is a representation in a menu of items that might
be physically located in several directories. menusvfolder information filesvfolder information filesA vfolder information file is an XML file that
describes a vfolder. Vfolder information files specify the structure of your
menus. Vfolder information files specify the names of your menus, and the
order in which applications appear in your menus. Vfolder information files
have a .vfolder-info file extension. The following is an excerpt from a vfolder information file:<?xml version="1.0"?>
<VFolderInfo>
.
.
.
<Folder>
<Name>Applications</Name>
<Desktop>Applications.directory</Desktop>
<Folder>
<Name>Accessories</Name>
<DontShowIfEmpty/>
<Desktop>Accessories.directory</Desktop>
<Query>
<And>
<Keyword>Application</Keyword>
<Keyword>Utility</Keyword>
</And>
</Query>
</Folder>
.
.
.
</Folder>
</VFolderInfo> describes some of the elements
in vfolder information files.
Vfolder Information File ElementsElementDescription<Folder>Contains the elements that define
the name, content, and structure of the menu.<Name>Specifies the name of the menu.<Desktop>Specifies the name of the directory
entry file that specifies the name, comment, and icon for the menu.<Query>Specifies a query to run on desktop
entry files. If a desktop entry file matches the requirements in the query,
the menu item is displayed in the menu. The query in the excerpt
searches for desktop entry files that contain the keywords Application and Utility in the Categories
key. Desktop entry files that match are displayed in the Applications menu.This element is optional.<DontShowIfEmpty/>If this
element is present, the menu is not displayed if the menu does not contain
any items.This element is optional.
Desktop Entry Filesdesktop entry files.desktop filesdesktop entry filesA desktop entry file is a data file that provides information about
an item in a menu. The desktop entry file specifies the details for the item
such as a name, a command to run, an icon, and so on. The desktop entry file
also contains keywords which determine the location of the item in the menu
hierarchy. Desktop entry files have a .desktop file extension.The following is a sample desktop entry file:[Desktop Entry]
Encoding=UTF-8
Name=Calculator
Comment=Perform simple calculations
Exec=gnome-calculator
Icon=gnome-calc3.png
Terminal=false
Type=Application
X-GNOME-DocPath=gnome-calculator/gnome-calculator.xml
Categories=GNOME;Application;Utility; describes the most important keys
in desktop entry files.
Desktop Entry KeysDesktop Entry KeyDescriptionEncodingSpecifies the encoding of the desktop entry file. NameSpecifies the name of the item. This name is displayed
on the item in the menu. CommentSpecifies a short description of the item. The comment
is displayed as a tooltip when you point to the item in the menu. ExecSpecifies a command to execute when you choose the item
from the menu. IconSpecifies the filename of an
icon that represents the item. Does not specify the path to the filename,
or the filename extension. TerminalSpecifies whether the command
in the Exec key runs in a terminal window. If the value
is true the command runs in a terminal window. If the command does not create a window in which to run, the value of this
key must be true.TypeSpecifies the type of item. This
value is one of the following: Application: Enter this option for an
item that starts an application.Link: Enter this option for an item that
links to a file, folder, or FTP site.X-GNOME-DocPathSpecifies
the help file to display when you choose Help on application_name from the menu item popup menu.CategoriesSpecifies the keywords that describe
the item. The keywords are separated with semicolons (;). To see a list of
the standard category keywords, see the following URL: http://www.freedesktop.org/standards/VFolderDesktops.txtThe vfolder information files map the keywords
to menus.
For more information on the keys in desktop entry files, see the following
URL: http://www.freedesktop.org/standards/desktop-entry-spec/desktop-entry-spec.htmlPanel launchers and desktop background objects also use desktop
entry files. The desktop entry files for launchers and desktop background
objects provide the same information as for items in a menu. For example,
the desktop entry files provide the command to run when a user chooses the
launcher or object.Directory Entry Filesdirectory entry files.directory filesdirectory entry filesA directory entry file is a data file that provides
information about a menu. The directory entry file specifies the details for
the menu such as a name, a tooltip, and an icon. Directory entry files have
a .directory file extension.The following is a sample directory entry file:[Desktop Entry]
Name=Accessories
Comment=Accessories menu
Icon=gnome-util.png
Type=Directory describes the most important keys
in directory entry files.
Directory Entry KeysDirectory Entry KeyDescriptionNameSpecifies the name of the menu.
This name is displayed on the menu. CommentSpecifies a short description
of the menu. The comment is displayed as a tooltip when you point to the menu. IconSpecifies the filename of an
icon that represents the menu. Does not specify the path to the filename,
or the filename extension. TypeSpecifies the type of menu. The value of this key is always Directory.
Editing MenusmenuseditingYou use the following desktop components to edit menus:Nautilus file managerMenus on panelsWhen you use the file manager to add menus or menu items for all users,
you must add the menu or menu item to a URI location.
lists the menus to which you can add items, and the URI locations that correspond
to the menus.When you use panels to customize menus for all users, you use the menu
item popup menu. For more information, see Working With Menus
in the GNOME 2.2 Desktop User Guide.You can also use menu configuration files and menu data files to customize
menus.Adding MenusYou can add menus for all users in the following ways: Use the file manager.Modify the menu configuration files and menu data files.To Add a Menu Using the File Managermenusadding using file managerfile manageradding menus withTo add a menu for all users,
perform the following steps:In a file manager window, access the location where you want
to add the menu. For example, to add a menu to the Applications
menu, type applications-all-users:/// in the Location field, then press Return.Choose FileNew Folder. An untitled folder is added to the
view pane. The name of the folder is selected.Type a name for the folder, then press Return.
The vfolder information file for the location that you accessed in step 1
is automatically updated with the details of the new menu. The name of the
folder is displayed as the name of the menu.You might need to reload the display of the file manager window
before you can type the name for the folder.The next time that users log in, the menu is in the assigned location.To Add a Menu Using Menu Filesmenusadding using menu filesTo add a menu for all users, perform the following steps:Create a directory entry file for the item that you want to
add. Create the directory entry file in the /usr/gnome/share/gnome/vfolders directory. For more information on directory entry files, see . Locate the vfolder information file for the location where
you want to add the menu. For example, to add a menu to the Applications menu, locate the file /usr/gnome/etc/gnome-vfs-2.0/vfolders/applications-all-users.vfolder-info. In the vfolder information file, add a <Folder> element for the new menu. For more information on vfolder information
files, see .The next time that users log in, the menu is in the assigned location.To Add an Item to a Menumenusadding items toTo add an item to a menu for all users, perform the following
steps:Create a desktop entry file for the item that you want to
add. For more information on desktop entry files, see . Open a file manager window. Choose FileNew Window to open a second
file manager window.In one window, access the location where you want to add the
menu item. For example, to add a menu item to the Preferences
menu, type preferences-all-users:/// in the Location field, then press Return.In the other window, select the desktop entry file that you
created for the menu item. Drag the desktop entry file to the location where
you want to add the menu item.Alternatively, you can copy the desktop entry file, then paste the file
into the location where you want to add the menu item.The next time that users log in, the menu item is in the assigned location.To Edit the Properties of a Menumenusediting properties ofTo edit the properties of a menu for all users, perform
the following steps:From a panel, open the menu that you want to edit. Right-click
on any item in the menu.Choose Entire menuProperties. A Launcher Properties dialog is displayed.Modify the properties of the menu in the Launcher Properties dialog. For more information on the elements in the Launcher Properties dialog, see Working With Panels in the GNOME 2.2 Desktop User Guide.Click OK.To Edit a Menu Itemmenusediting menu itemsTo edit a menu item, perform the following steps:From a panel, open the menu that contains the item that you
want to edit. Right-click on the item that you want to edit.Choose Properties. A Launcher Properties dialog is displayed.Modify the properties of the menu item in the Launcher Properties dialog. For more information on the elements in the Launcher Properties dialog, see Working With Panels in the GNOME 2.2 Desktop User Guide.Click OK.To Delete an Item from a Menumenusdeleting menu itemsTo delete an item from a menu, from a panel, open the menu
that contains the item that you want to delete. Right-click on the item that
you want to delete. Choose Remove this item. The next time that users log in, the menu item is not displayed in the
menu.To Configure Menus That Users Cannot Modifymenusconfiguring menus that users
cannot modifyUsers cannot modify a menu if the
following conditions are true:A vfolder information file that corresponds to the menu is
present in the /etc/gnome-vfs-2.0/vfolder directory.The vfolder information file has the same name as the URI
location that corresponds to the menu.The user permissions for the vfolder information file are
set to read only. To configure a menu so that users cannot modify the menu, perform the
following steps:Create a vfolder information file for the menu that you want
to configure in the /etc/gnome-vfs-2.0/vfolder directory.Give the vfolder information file the name of the URI location
that corresponds to the menu that you want to configure. For example, to configure
the Applications menu, create a vfolder information called applications.vfolder-info in the /etc/gnome-vfs-2.0/vfolder directory.Set the permissions on the vfolder information file to read
only.