## XfceDesktopEntry

XfceDesktopEntry — A GObject that wraps a .desktop file.

## Synopsis

    #include <libxfce4util/libxfce4util.h>

    struct      XfceDesktopEntry;
    XfceDesktopEntry* xfce_desktop_entry_new    (const char *file,
                                                 const char **categories,
                                                 int num_categories);
    XfceDesktopEntry* xfce_desktop_entry_new_from_data
                                                (const char *data,
                                                 const char **categories,
                                                 int num_categories);
    gboolean    xfce_desktop_entry_parse        (XfceDesktopEntry *desktop_entry);
    char*       xfce_desktop_entry_get_file     (XfceDesktopEntry *desktop_entry);
    gboolean    xfce_desktop_entry_get_string   (XfceDesktopEntry *desktop_entry,
                                                 const char *key,
                                                 gboolean translated,
                                                 char **value);
    gboolean    xfce_desktop_entry_get_int      (XfceDesktopEntry *desktop_entry,
                                                 const char *key,
                                                 int *value);

## Object Hierarchy

      GObject
       +----XfceDesktopEntry

## Description

XfceDesktopEntry is a wrapper for a so-called desktop entry file. The desktop entry format is defined on Freedesktop.org.

## Details

### struct XfceDesktopEntry

    struct XfceDesktopEntry;

All the fields in the XfceDesktopEntry structure are private to the XfceDesktopEntry implementation and should never be accessed directly. Instead, you should use the functions listed below.

### xfce_desktop_entry_new ()

    XfceDesktopEntry* xfce_desktop_entry_new    (const char *file,
                                                 const char **categories,
                                                 int num_categories);

Create a new XfceDesktopEntry object from a desktop entry stored in memory.

`file` : | full path to the desktop entry file to use.
`categories` : | array of categories, not necessarily NULL terminated.
`num_categories` : | number of items in `categories`.
Returns : | newly created XfceDesktopEntry or NULL if something goes wrong.

Since 4.2

### xfce_desktop_entry_new_from_data ()

    XfceDesktopEntry* xfce_desktop_entry_new_from_data
                                                (const char *data,
                                                 const char **categories,
                                                 int num_categories);

Create a new XfceDesktopEntry object from a desktop entry stored in memory.

`data` : | pointer to the desktop entry inline data.
`categories` : | array of categories, not necessarily NULL terminated.
`num_categories` : | number of items in `categories`.
Returns : | newly created XfceDesktopEntry or NULL if something goes wrong.

Since 4.2

### xfce_desktop_entry_parse ()

    gboolean    xfce_desktop_entry_parse        (XfceDesktopEntry *desktop_entry);

### Warning

`xfce_desktop_entry_parse` is deprecated and should not be used in newly-written code.

Parses the desktop entry file and fills in the values for all categories.

`desktop_entry` : | an XfceDesktopEntry.
Returns : | TRUE on success, FALSE on failure.

Since 4.2

### xfce_desktop_entry_get_file ()

    char*       xfce_desktop_entry_get_file     (XfceDesktopEntry *desktop_entry);

Obtain the path to the desktop entry file associated with the XfceDesktopEntry.

`desktop_entry` : | an XfceDesktopEntry.
Returns : | path of the desktop entry file used to create `desktop_entry`. The return value should be considered read-only and must not be freed by the caller.

Since 4.2

### xfce_desktop_entry_get_string ()

    gboolean    xfce_desktop_entry_get_string   (XfceDesktopEntry *desktop_entry,
                                                 const char *key,
                                                 gboolean translated,
                                                 char **value);

Finds the value for `key`. When `translated` is TRUE the function will use the translated value (using the current locale settings) if available or the untranslated value if no translation can be found.

`desktop_entry` : | an XfceDesktopEntry
`key` : | category to find value for.
`translated` : | set to TRUE if the translated value is preferred.
`value` : | location for the value, which will be newly allocated.
Returns : | TRUE on success, FALSE on failure. `value` must be freed.

Since 4.2

### xfce_desktop_entry_get_int ()

    gboolean    xfce_desktop_entry_get_int      (XfceDesktopEntry *desktop_entry,
                                                 const char *key,
                                                 int *value);

Gets a value from `desktop_entry` as integer. Therefore finds the value for `key` and returns its integer representation.

`desktop_entry` : | an XfceDesktopEntry.
`key` : | category to find value for.
`value` : | location for the value.
Returns : | TRUE on success, FALSE on failure.

Since 4.2