Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Gtk+/Gnome Application Development
Prev Home Next

.desktop Entries

Gnome programs come with ".desktop entries," which are simply small files describing how the application should appear in menus. Installing a .desktop entry causes your application to show up in the Gnome panel menu. Here is gnome-hello.desktop:


[Desktop Entry]
Name=Gnome Hello
Name[es]=Gnome Hola
Name[fi]=GNOME-hei
Name[gl]=Ola GNOME
Name[no]=Gnome hallo
Name[sv]=Gnome Hej
Name[pl]=Halo GNOME
Comment=Hello World
Comment[es]=Hola Mundo
Comment[fi]=Hei, maailma
Comment[gl]=Ola Mundo
Comment[sv]=Hej Världen
Comment[no]=Hallo verden
Comment[pl]=Witaj ¶wiecie
Exec=gnome-hello
Icon=gnome-hello-logo.png
Terminal=0
Type=Application


The file consists of key-value pairs. The Name key specifies the name of your application in the default (C) locale; any key can have translations with a locale appended in brackets, such as Name[es]. The Comment key is a "tooltip" or hint describing the application in more detail. Exec is the command line to use to execute the program. Terminal is a boolean value; if non-zero, the program will be run inside a terminal. Type should always be "Application" in this context.

Installing a .desktop entry is simple; here is the toplevel Makefile.am from GnomeHello again:


SUBDIRS = macros po intl src pixmaps doc

## We dist autogen.sh since this is an example program
## Real-world programs do not need to distribute autogen.sh
EXTRA_DIST = \
        gnome-hello.desktop \
    autogen.sh

Applicationsdir = $(datadir)/gnome/apps/Applications
Applications_DATA = gnome-hello.desktop


Notice that there is a directory tree under $(datadir)/gnome/apps/ with subdirectories that arrange programs into categories. GnomeHello installs itself in the "Applications" category; other programs might choose "Games," "Graphics," "Internet," or whatever is appropriate. Try to choose a category that already exists, rather than inventing your own.

Gtk+/Gnome Application Development
Prev Home Next

 
 
  Published under free license. Design by Interspire