DesktopFile.h
/*
* $Id: DesktopFile.h 3576 2014-06-20 10:04:55Z karijes $
*
* .desktop file reader and writer
* Copyright (c) 2005-2014 edelib authors
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __EDELIB_DESKTOPFILE_H__
#define __EDELIB_DESKTOPFILE_H__
#include "Config.h"
#include "String.h"
#include "List.h"
EDELIB_NS_BEGIN
enum DesktopFileErrors {
DESK_FILE_SUCCESS = 0,
DESK_FILE_EMPTY,
DESK_FILE_ERR_FILE,
DESK_FILE_ERR_BAD
};
enum DesktopFileType {
DESK_FILE_TYPE_UNKNOWN = 0,
DESK_FILE_TYPE_APPLICATION,
DESK_FILE_TYPE_LINK,
DESK_FILE_TYPE_DIRECTORY
};
class EDELIB_API DesktopFile : public Config {
private:
unsigned int errcode;
DesktopFileType dtype;
public:
DesktopFile();
~DesktopFile();
bool load(const char* fname);
bool save(const char* fname);
void create_new(DesktopFileType t);
operator bool(void) const { return ((errcode == DESK_FILE_SUCCESS) ? 1 : 0); }
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);
};
EDELIB_NS_END
#endif
edelib::DESK_FILE_SUCCESS
successful operation
Definition: DesktopFile.h:35
edelib::Config
A config file reader.
Definition: Config.h:112
edelib::DesktopFile
.desktop file reader and writer
Definition: DesktopFile.h:74
edelib::DESK_FILE_TYPE_APPLICATION
Application type.
Definition: DesktopFile.h:47
edelib::list
Linked list class.
Definition: List.h:160
edelib::Config::load
bool load(const char *fname)
edelib::DESK_FILE_TYPE_LINK
Link type.
Definition: DesktopFile.h:48
edelib::DesktopFileErrors
DesktopFileErrors
Error codes from DesktopFile class.
Definition: DesktopFile.h:34
edelib::DESK_FILE_ERR_BAD
malformed file, or not .desktop file
Definition: DesktopFile.h:38
edelib::DesktopFileType
DesktopFileType
Reported file type from DesktopFile::type()
Definition: DesktopFile.h:45
edelib::DESK_FILE_EMPTY
file not loaded
Definition: DesktopFile.h:36
edelib::DESK_FILE_TYPE_DIRECTORY
Directory type.
Definition: DesktopFile.h:49
edelib::DESK_FILE_ERR_FILE
trouble accessing config file or directory
Definition: DesktopFile.h:37
edelib::DESK_FILE_TYPE_UNKNOWN
Unknown type (Type key)
Definition: DesktopFile.h:46
edelib::Config::save
bool save(const char *fname)