edelib
2.1.0
|
.desktop file reader and writer More...
#include <edelib/DesktopFile.h>
Public Member Functions | |
DesktopFile () | |
~DesktopFile () | |
bool | load (const char *fname) |
bool | save (const char *fname) |
void | create_new (DesktopFileType t) |
operator bool (void) const | |
DesktopFileType | type (void) |
bool | name (char *val, int len) |
bool | generic_name (char *val, int len) |
bool | comment (char *val, int len) |
bool | icon (char *val, int len) |
bool | exec (char *val, int len) |
bool | try_exec (bool &program_found) |
bool | path (char *val, int len) |
bool | url (char *val, int len) |
bool | mime_type (char *val, int len) |
bool | no_display (void) |
bool | hidden (void) |
bool | terminal (void) |
bool | startup_notify (void) |
bool | only_show_in (char *val, int len) |
bool | only_show_in (list< String > &lst) |
bool | not_show_in (char *val, int len) |
bool | not_show_in (list< String > &lst) |
void | set_type (DesktopFileType t) |
void | set_name (const char *val) |
void | set_generic_name (const char *val) |
void | set_comment (const char *val) |
void | set_icon (const char *val) |
void | set_exec (const char *val) |
void | set_try_exec (const char *val) |
void | set_path (const char *val) |
void | set_url (const char *val) |
void | set_mime_type (const char *val) |
void | set_no_display (bool val) |
void | set_hidden (bool val) |
void | set_terminal (bool val) |
void | set_startup_notify (bool val) |
void | set_only_show_in (const list< String > &lst) |
void | set_not_show_in (const list< String > &lst) |
Public Member Functions inherited from Config | |
Config () | |
~Config () | |
bool | load (const char *fname) |
bool | save (const char *fname) |
operator bool (void) const | |
void | clear (void) |
bool | get (const char *section, const char *key, char *ret, unsigned int size) |
bool | get_localized (const char *section, const char *key, char *ret, unsigned int size) |
bool | get_allocated (const char *section, const char *key, char **ret, unsigned int &retsize) |
bool | get (const char *section, const char *key, bool &ret, bool dfl=false) |
bool | get (const char *section, const char *key, int &ret, int dfl=0) |
bool | get (const char *section, const char *key, float &ret, float dfl=0) |
bool | get (const char *section, const char *key, long &ret, long dfl=0) |
bool | get (const char *section, const char *key, double &ret, double dfl=0) |
bool | get (const char *section, const char *key, char &ret, char dfl=0) |
void | set (const char *section, const char *key, char *val) |
void | set (const char *section, const char *key, const char *val) |
void | set_localized (const char *section, const char *key, char *val) |
void | set_localized (const char *section, const char *key, const char *val) |
void | set (const char *section, const char *key, bool val) |
void | set (const char *section, const char *key, int val) |
void | set (const char *section, const char *key, long val) |
void | set (const char *section, const char *key, float val) |
void | set (const char *section, const char *key, double val) |
bool | exist (const char *section) |
bool | key_exist (const char *section, const char *key) |
unsigned int | num_sections (void) |
unsigned int | line (void) |
int | error (void) |
const char * | strerror (void) |
const char * | strerror (int code) |
.desktop file reader and writer
Desktop file (or desktop entries) are config files ending with .desktop extension. This is text file, readable with Config class. These files are (ab)used to describe desktop icons, menu entries and etc.
Current implementation conforms to http://www.freedesktop.org specification version 1.1.
In case you want to create .desktop file from scratch, make sure you call create_new() before you fill the data, so DesktopFile can setup mandatory data prior file saving, like:
create_new() will also clear all current hold conten
DesktopFile | ( | ) |
Initialize internal data
~DesktopFile | ( | ) |
Empty destructor
bool comment | ( | char * | val, |
int | len | ||
) |
Get value from Comment key. Returning value will match current locale.
val | is destination |
len | size of destination |
void create_new | ( | DesktopFileType | t | ) |
Create new .desktop context. To create new .desktop file, you must call this function first and then fill it
bool exec | ( | char * | val, |
int | len | ||
) |
Get value from Exec key. The value should be an executable program optionally followed by one or more arguments. If executable program wasn't specified with its full path, the executable is looked up in $PATH environment variable. If not found, this function will return false.
bool generic_name | ( | char * | val, |
int | len | ||
) |
Get value from GenericName key. Returning value will match current locale.
val | is destination |
len | size of destination |
bool hidden | ( | void | ) |
Get value from Hidden key.
bool icon | ( | char * | val, |
int | len | ||
) |
Get value from Icon key. Returned value can be absolute path (with given icon extension) or just icon name (without extension, which is often done). In latter case final application should figure out will use IconTheme or load icon directly.
bool load | ( | const char * | fname | ) |
Load file checking if is .desktop file
fname | is file to load |
bool mime_type | ( | char * | val, |
int | len | ||
) |
Get value from MimeType key.
bool name | ( | char * | val, |
int | len | ||
) |
Get value from Name key. Returning value will match current locale.
val | is destination |
len | size of destination |
bool no_display | ( | void | ) |
Get value from NoDisplay key.
bool not_show_in | ( | char * | val, |
int | len | ||
) |
Get full value from NotShowIn. This value will be in form: foo;baz;.
Get list of values from NotShowIn key. If key wasn't found, list will not be altered.
bool only_show_in | ( | char * | val, |
int | len | ||
) |
Get full value from OnlyShowIn. This value will be in form: foo;baz;.
Get list of values from OnlyShowIn key. If key wasn't found, list will not be altered.
|
inline |
Used to check if current loaded file is .desktop file. Can be used like:
References edelib::DESK_FILE_SUCCESS.
bool path | ( | char * | val, |
int | len | ||
) |
Get value from Path key. If value is not empty and type is DESK_FILE_TYPE_APPLICATION it will fill destination and return true. Otherwise, false.
bool save | ( | const char * | fname | ) |
Save file
fname | is file to be saved |
void set_comment | ( | const char * | val | ) |
Set Comment key
void set_exec | ( | const char * | val | ) |
Set Exec key
void set_generic_name | ( | const char * | val | ) |
Set GenericName key
void set_hidden | ( | bool | val | ) |
Set Hidden key
void set_icon | ( | const char * | val | ) |
Set Icon key
void set_mime_type | ( | const char * | val | ) |
Set MimeType key
void set_name | ( | const char * | val | ) |
Set Name key
void set_no_display | ( | bool | val | ) |
Set NoDisplay key
Set NotShowIn key. Note that only OnlyShowIn or NotShowIn keys can exists. If one of them is already set, this function will do nothing.
Set OnlyShowIn key. Note that only OnlyShowIn or NotShowIn keys can exists. If one of them is already set, this function will do nothing.
void set_path | ( | const char * | val | ) |
Set Path key
void set_startup_notify | ( | bool | val | ) |
Set StartupNotify key
void set_terminal | ( | bool | val | ) |
Set Terminal key
void set_try_exec | ( | const char * | val | ) |
Set TryExec key
void set_type | ( | DesktopFileType | t | ) |
Set type of desktop file
void set_url | ( | const char * | val | ) |
Set URL key
bool startup_notify | ( | void | ) |
Get value from StartupNotify key.
bool terminal | ( | void | ) |
Get value from Terminal key.
bool try_exec | ( | bool & | program_found | ) |
Get value from TryExec key. TryExec key contains program executable name and this function will try to determine if the program is actually installed. This will be done by looking either if full path was given or in $PATH environment variable.
program_found | will be true if program found; otherwise will be false |
DesktopFileType type | ( | void | ) |
Return type of desktop file. It will be one of DesktopFileType
bool url | ( | char * | val, |
int | len | ||
) |
Get value from URL key. If value is not empty and type is DESK_FILE_TYPE_LINK it will fill destination and return true. Otherwise, false.