User Tools

Site Tools


k15:k15.2:start

15.2 Class DesktopFile (gb. desktop)

This class is still under development. You can use this class to create and edit the so-called “desktop entries” as desktop configuration files (application/x-desktop) later on. These configuration files describe, for example, how a program is started or how a program appears in a menu. Some distributions have menu editors, others - like Lubuntu - do not have them. Obviously, the DesktopFile class has therefore been included in the gb. desktop component.

However, you can already get the exact specification of files for desktop entries under the link: http://standards.freedesktop.org/desktop-entry-spec/latest/ in the current version because Gambas follows this specification.

15.2.1 Format of a configuration file

A desktop configuration file consists of the following elements:

  • Comments - A comment line begins with the # character
  • Group sections - A group name is enclosed by square brackets. The group name is followed by a list of key-value pairs
  • Lists of key-value pairs - A key-value pair consists of a (standardized) keyword followed by an equal sign. Some keys are required, others are optional.

15.2.2 Example of a configuration file:

#
# Starter für die IDE von Gambas 3
# Pfad: ~/.local/share/applications/gambas341.desktop
#
[Desktop Entry]
# Erforderliche Einträge
Type=Application
Name=Gambas 3.4.1
Exec=/usr/bin/gambas3
# Optionale Einträge
Icon=/home/hans/gb341/app/src/gambas3/img/logo/logo-64.png
Categories=Development
Comment=Start der GAMBAS-IDE
Version=3.4.1
Terminal=false

You can write the above lines with an editor of your choice and save the file in the user directory:

~/.local/share/applications/gambas341.desktop

to save them. No root privileges are required. However, if the desktop configuration file is to be system-wide, it must be saved in the following directory with root privileges:

/usr/share/applications/gambas341.desktop

After saving you will see the sub-menu 'Gambas 341' in the' Software development' section of the applications menu.

If you also want the starter to be visible on your desktop, you also need to copy the desktop configuration file to the ~/Workspace directory under Ubuntu 12.04. The configuration file must be copied to the directory ~/Workspace under Ubuntu 12.04 as well. You should change the name in the properties of the configuration file to a short form like 'GB 3.4.1' and make the file executable under Ubuntu!

It remains to be seen when this class is released for use.

Download

15.2 Klasse DesktopFile (gb.desktop)

Diese Klasse befindet sich gegenwärtig noch in der Entwicklung. Mit dieser Klasse können Sie später die so genannten “Desktop-Einträge” als Desktop-Konfigurationsdateien (application/x-desktop) anlegen und bearbeiten. Diese Konfigurationsdateien beschreiben zum Beispiel wie ein Programm gestartet wird oder wie ein Programm in einem Menü erscheint. Einige Distributionen verfügen über Menü-Editoren, andere – wie Lubuntu – besitzen diese nicht. Offensichtlich ist die Klasse DesktopFile deshalb in die Komponente gb.desktop aufgenommen worden.

Sie können sich aber bereits schon jetzt die genaue Spezifikation von Dateien für Desktop-Einträge unter dem Link: http://standards.freedesktop.org/desktop-entry-spec/latest/ in der aktuellen Version ansehen, weil Gambas dieser Spezifikation folgt.

15.2.1 Format einer Konfigurationsdatei

Eine Desktop-Konfigurationsdatei besteht aus folgenden Elementen:

  • Kommentare – Eine Kommentar-Zeile beginnt mit dem #-Zeichen
  • Gruppensektionen – Ein Gruppenname wird von eckigen Klammern eingeschlossen. Dem Gruppennamen folgt eine Liste von Schlüssel-Wert-Paaren
  • Listen von Schlüssel-Wert-Paaren – Ein Schlüssel-Wert-Paar besteht aus einem (standardisierten) Schlüsselwort, dem nach einem Gleichheitszeichen der Wert folgt. Einige Schlüssel sind erforderlich, andere optional.

15.2.2 Beispiel für eine Konfigurationsdatei:

#
# Starter für die IDE von Gambas 3
# Pfad: ~/.local/share/applications/gambas341.desktop
#
[Desktop Entry]
# Erforderliche Einträge
Type=Application
Name=Gambas 3.4.1
Exec=/usr/bin/gambas3
# Optionale Einträge
Icon=/home/hans/gb341/app/src/gambas3/img/logo/logo-64.png
Categories=Development
Comment=Start der GAMBAS-IDE
Version=3.4.1
Terminal=false

Sie können die o.a. Zeilen mit einem Editor der Wahl schreiben und die Datei im Benutzerverzeichnis:

~/.local/share/applications/gambas341.desktop

abspeichern. Root-Rechte sind nicht erforderlich. Soll die Desktop-Konfigurationsdatei jedoch systemweit gelten, dann muss sie im folgenden Verzeichnis mit Root-Rechten abgespeichert werden:

/usr/share/applications/gambas341.desktop

Nach dem Speichern sehen Sie im Menü der Anwendungen in der Rubrik 'Software-Entwicklung' das Unter-Menü 'Gambas 341'.

Wenn der Starter auch auf dem Desktop zu sehen sein soll, dann muss die Desktop-Konfigurationsdatei auch in das Desktop-Verzeichnis ~/Arbeitsfläche unter Ubuntu 12.04 kopiert werden. Sie sollten dort in den Eigenschaften der Konfigurationsdatei noch den Namen in eine Kurzform wie 'GB 3.4.1' ändern und die Datei unter Ubuntu ausführbar machen!

Es bleibt abzuwarten, wann diese Klasse zur Nutzung freigegeben wird.

Download

The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k15/k15.2/start.txt · Last modified: 02.07.2018 (external edit)

Page Tools