6.3 Menu Items


6.3 Menu Items

If you have a graphical application, you should put it into your GNOME application menu. All you have to do is create appname .desktop , where appname is your application's name , and install this file into $(PREFIX)/share/applications . Here is an example, miracletext.desktop :

 [Desktop Entry] Name=Example Comment=MiracleText Word Processor Comment[de]=MiracleText Textverarbeitung Comment[es]=MiracleText procesador de textos Name=Edit documents with MiracleText Name[de]=Dokumente bearbeiten mit MiracleText Name[es]=Edita documentos con MiracleText TryExec=example Exec=example %U Icon=example.png Terminal=0 Type=Application Categories=Application 

Like many other files that you have seen so far, there are keys and values here, and you can specify a locale with square brackets ( [] ). You must use UTF-8 for all values with a locale identifier and ASCII for the rest. The key meanings are as follows :

  • Version : The .desktop file format, currently 1.0.

  • Type : For applications, this is always Application .

  • Encoding : Character encoding; set this to UTF-8 .

  • Name : The name of the application that should show up in the menu item. If there's enough space, include a very short blurb indicating the application's purpose.

  • Comment : A fairly detailed description of what the user can do with the application. Use a verb's imperative form in the phrase: for example, "Set the system clock" or "Automatically upload to websites ."

  • TryExec : The name of the application's executable without options.

  • Exec : The executable's syntax. You may use any of the following placeholders:

    • %f A filename.

    • %F A set of filenames.

    • %u A URI.

    • %U A set of URIs.

    • %d A directory.

    • %D A set of directories.

    • %n A filename without a path .

    • %N A set of filenames without paths.

    As you can see, MiracleText is a fairly modern application, accepting URIs on the command line.

  • Icon : The icon for the menu; the path should be relative to $(PREFIX)/share/ pixmaps .

  • Terminal : Set this to true if the application must run in a terminal emulator window, and false otherwise .

  • Categories : A semicolon-delimited category path for the application. Use one of the following:

     GNOME;Application;AudioVideo;      GNOME;Application;Development;      GNOME;Application;Game;      GNOME;Application;Graphics;      GNOME;Application;Network;      GNOME;Application;Office;      GNOME;Application;Settings;      GNOME;Application;Utility; 

A new menu item should appear as soon as you copy its .desktop file into $(PREFIX)/share/applications .

For more information on the file format, see [Brown]. You can also edit a .desktop graphically with gnome-desktop-item-edit .




The Official GNOME 2 Developers Guide
The Official GNOME 2 Developers Guide
ISBN: 1593270305
EAN: 2147483647
Year: 2004
Pages: 108

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net