KDE 4.9 PyKDE API Reference

- KDE's Python API

# KDesktopFile Class Reference

`from PyKDE4.kdecore import *`

Inherits: KConfig → KConfigBase

## Detailed Description

\class KDesktopFile kdesktopfile.h <KDesktopFile>

KDE Desktop File Management. This class implements %KDE's support for the freedesktop.org <em>Desktop Entry Spec</em>.

Author:
  Pietro Iglio <iglio@kde.org>

See also:
  KConfigBase KConfig

See also:
  Desktop Entry Spec

## Methods
| __init__ (self, QString resourceType, QString fileName)
| __init__ (self, QString fileName)
| __init__ (self, KDesktopFile a0)
KConfigGroup | actionGroup (self, QString group)
KDesktopFile | copyTo (self, QString file)
KConfigGroup | desktopGroup (self)
QString | fileName (self)
bool | hasActionGroup (self, QString group)
bool | hasApplicationType (self)
bool | hasDeviceType (self)
bool | hasLinkType (self)
bool | hasMimeTypeType (self)
bool | noDisplay (self)
QStringList | readActions (self)
QString | readComment (self)
QString | readDevice (self)
QString | readDocPath (self)
QString | readGenericName (self)
QString | readIcon (self)
QString | readName (self)
QString | readPath (self)
QString | readType (self)
QString | readUrl (self)
QString | resource (self)
QStringList | sortOrder (self)
bool | tryExec (self)
## Static Methods
bool | isAuthorizedDesktopFile (QString path)
bool | isDesktopFile (QString path)
QString | locateLocal (QString path)

## Method Documentation

__init__ | ( | self, |
|  | QString | resourceType,
|  | QString | fileName
| ) |  |  |

Constructs a KDesktopFile object.

See KStandardDirs for more information on resources.

Parameters:

  | resourceType | Allows you to change what sort of resource to search for if fileName is not absolute. For instance, you might want to specify "config".
  | fileName | The name or path of the desktop file. If it is not absolute, it will be located using the resource type resType.

__init__ | ( | self, |
|  | QString | fileName
| ) |  |  |

Constructs a KDesktopFile object.

See KStandardDirs for more information on resources.

Parameters:

  | fileName | The name or path of the desktop file. If it is not absolute, it will be located using the resource type "apps"

__init__ | ( | self, |
|  | KDesktopFile | a0
| ) |  |  |

KConfigGroup actionGroup | ( | self, |
|  | QString | group
| ) |  |  |

Sets the desktop action group.

Parameters:

  | group | the new action group

KDesktopFile copyTo | ( | self, |
|  | QString | file
| ) |  |  |

Copies all entries from this config object to a new KDesktopFile object that will save itself to file.

Actual saving to file happens when the returned object is destructed or when sync() is called upon it.

Parameters:

  | file | the new KDesktopFile object it will save itself to.

KConfigGroup desktopGroup | ( |  | self ) |

QString fileName | ( |  | self ) |

bool hasActionGroup | ( | self, |
|  | QString | group
| ) |  |  |

Returns true if the action group exists, false otherwise

Parameters:

  | group | the action group to test

Returns:
  true if the action group exists

bool hasApplicationType | ( |  | self ) |

Checks whether there is an entry "Type=Application".

Returns:
  true if there is a "Type=Application" entry

bool hasDeviceType | ( |  | self ) |

Checks whether there is an entry "Type=FSDevice".

Returns:
  true if there is a "Type=FSDevice" entry

bool hasLinkType | ( |  | self ) |

Checks whether there is a "Type=Link" entry.

The link points to the "URL=" entry.

Returns:
  true if there is a "Type=Link" entry

bool hasMimeTypeType | ( |  | self ) |

Checks whether there is an entry "Type=MimeType".

Returns:
  true if there is a "Type=MimeType" entry

bool noDisplay | ( |  | self ) |

Whether the entry should be suppressed in menus. This handles the NoDisplay key, but also OnlyShowIn / NotShowIn.

Returns:
  true to suppress this service

Since:
  4.1

QStringList readActions | ( |  | self ) |

Returns a list of the "Actions=" entries.

Returns:
  the list of actions

QString readComment | ( |  | self ) |

Returns the value of the "Comment=" entry.

Returns:
  the comment or QString() if not specified

QString readDevice | ( |  | self ) |

Returns the value of the "Dev=" entry.

Returns:
  the device or QString() if not specified

QString readDocPath | ( |  | self ) |

Returns the value of the "X-DocPath=" Or "DocPath=" entry.

Returns:
  The value of the "X-DocPath=" Or "DocPath=" entry.

QString readGenericName | ( |  | self ) |

Returns the value of the "GenericName=" entry.

Returns:
  the generic name or QString() if not specified

QString readIcon | ( |  | self ) |

Returns the value of the "Icon=" entry.

Returns:
  the icon or QString() if not specified

QString readName | ( |  | self ) |

Returns the value of the "Name=" entry.

Returns:
  the name or QString() if not specified

QString readPath | ( |  | self ) |

Returns the value of the "Path=" entry.

Returns:
  the path or QString() if not specified

QString readType | ( |  | self ) |

Returns the value of the "Type=" entry.

Returns:
  the type or QString() if not specified

QString readUrl | ( |  | self ) |

Returns the value of the "URL=" entry.

Returns:
  the URL or QString() if not specified

QString resource | ( |  | self ) |

QStringList sortOrder | ( |  | self ) |

Returns the entry of the "SortOrder=" entry.

Returns:
  the value of the "SortOrder=" entry.

bool tryExec | ( |  | self ) |

Checks whether the TryExec field contains a binary which is found on the local system.

Returns:
  true if TryExec contains an existing binary

## Static Method Documentation

bool isAuthorizedDesktopFile | ( | QString | path
| ) |  |  |

Checks whether the user is authorized to run this desktop file. By default users are authorized to run all desktop files but the KIOSK framework can be used to activate certain restrictions. See README.kiosk for more information.

Note: Since KDE 4.3, there are more restrictions on authorized desktop files to prevent users from inadvertently running trojan desktop files. Your application launchers should have the executable bit set to prevent issues. To see if a restriction is due to KIOSK, see KAuthorized.

Parameters:

  | path | the file to check

Returns:
  true if the user is authorized to run the file

bool isDesktopFile | ( | QString | path
| ) |  |  |

Checks whether this is really a desktop file.

The check is performed looking at the file extension (the file is not opened). Currently, the only valid extension is ".desktop".

Parameters:

  | path | the path of the file to check

Returns:
  true if the file appears to be a desktop file.

QString locateLocal | ( | QString | path
| ) |  |  |

Returns the location where changes for the .desktop file path should be written to.