edelib: edelib/DesktopFile.h Source File

edelib 1.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List

DesktopFile.h
1 /*
2 * $Id: DesktopFile.h 3576 2014-06-20 10:04:55Z karijes $
3 *
4 * .desktop file reader and writer
5 * Copyright (c) 2005-2014 edelib authors
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef __EDELIB_DESKTOPFILE_H__
22 #define __EDELIB_DESKTOPFILE_H__
23
24 #include "Config.h"
25 #include "String.h"
26 #include "List.h"
27
28 EDELIB_NS_BEGIN
29
34 enum DesktopFileErrors {
35 DESK_FILE_SUCCESS = 0,
36 DESK_FILE_EMPTY,
37 DESK_FILE_ERR_FILE,
38 DESK_FILE_ERR_BAD
39 };
40
45 enum DesktopFileType {
46 DESK_FILE_TYPE_UNKNOWN = 0,
47 DESK_FILE_TYPE_APPLICATION,
48 DESK_FILE_TYPE_LINK,
49 DESK_FILE_TYPE_DIRECTORY
50 };
51
74 class EDELIB_API DesktopFile : public Config {
75 private:
76 unsigned int errcode;
77 DesktopFileType dtype;
78
79 public:
83 DesktopFile();
84
88 ~DesktopFile();
89
95 bool load(const char* fname);
96
102 bool save(const char* fname);
103
108 void create_new(DesktopFileType t);
109
119 operator bool(void) const { return ((errcode == DESK_FILE_SUCCESS) ? 1 : 0); }
120
124 DesktopFileType type(void);
125
132 bool name(char* val, int len);
133
140 bool generic_name(char* val, int len);
141
148 bool comment(char* val, int len);
149
155 bool icon(char* val, int len);
156
164 bool exec(char* val, int len);
165
174 bool try_exec(bool& program_found);
175
180 bool path(char* val, int len);
181
186 bool url(char* val, int len);
187
191 bool mime_type(char* val, int len);
192
196 bool no_display(void);
197
201 bool hidden(void);
202
206 bool terminal(void);
207
211 bool startup_notify(void);
212
216 bool only_show_in(char* val, int len);
217
222 bool only_show_in(list<String>& lst);
223
228 bool not_show_in(char* val, int len);
229
234 bool not_show_in(list<String>& lst);
235
239 void set_type(DesktopFileType t);
240
244 void set_name(const char* val);
245
249 void set_generic_name(const char* val);
250
254 void set_comment(const char* val);
255
259 void set_icon(const char* val);
260
264 void set_exec(const char* val);
265
269 void set_try_exec(const char* val);
270
274 void set_path(const char* val);
275
279 void set_url(const char* val);
280
284 void set_mime_type(const char* val);
285
289 void set_no_display(bool val);
290
294 void set_hidden(bool val);
295
299 void set_terminal(bool val);
300
304 void set_startup_notify(bool val);
305
310 void set_only_show_in(const list<String>& lst);
311
316 void set_not_show_in(const list<String>& lst);
317 };
318
319 EDELIB_NS_END
320 #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)