edelib 0.0

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

- File List

DesktopFile.h
1 /*
2 * $Id: DesktopFile.h 2852 2009-10-02 12:11:05Z karijes $
3 *
4 * .desktop file reader and writer
5 * Copyright (c) 2005-2007 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
27 EDELIB_NS_BEGIN
28
33 enum DesktopFileErrors {
34 DESK_FILE_SUCCESS = 0,
35 DESK_FILE_EMPTY,
36 DESK_FILE_ERR_FILE,
37 DESK_FILE_ERR_BAD
38 };
39
44 enum DesktopFileType {
45 DESK_FILE_TYPE_UNKNOWN = 0,
46 DESK_FILE_TYPE_APPLICATION,
47 DESK_FILE_TYPE_LINK,
48 DESK_FILE_TYPE_DIRECTORY
49 };
50
76 class EDELIB_API DesktopFile : public Config {
77 private:
78 unsigned int errcode;
79 DesktopFileType dtype;
80
81 public:
85 DesktopFile();
86
90 ~DesktopFile();
91
97 bool load(const char* fname);
98
104 bool save(const char* fname);
105
110 void create_new(DesktopFileType t);
111
121 operator bool(void) const { return ((errcode == DESK_FILE_SUCCESS) ? 1 : 0); }
122
126 DesktopFileType type(void);
127
134 bool name(char* val, int len);
135
142 bool generic_name(char* val, int len);
143
150 bool comment(char* val, int len);
151
157 bool icon(char* val, int len);
158
166 bool exec(char* val, int len);
167
176 bool try_exec(bool& program_found);
177
182 bool path(char* val, int len);
183
188 bool url(char* val, int len);
189
193 bool mime_type(char* val, int len);
194
198 bool no_display(void);
199
203 bool hidden(void);
204
208 bool terminal(void);
209
213 bool startup_notify(void);
214
219 bool only_show_in(char* val, int len);
220
225 bool only_show_in(list<String>& lst);
226
231 bool not_show_in(char* val, int len);
232
237 bool not_show_in(list<String>& lst);
238
242 void set_type(DesktopFileType t);
243
247 void set_name(const char* val);
248
252 void set_generic_name(const char* val);
253
257 void set_comment(const char* val);
258
262 void set_icon(const char* val);
263
267 void set_exec(const char* val);
268
272 void set_try_exec(const char* val);
273
277 void set_path(const char* val);
278
282 void set_url(const char* val);
283
287 void set_mime_type(const char* val);
288
292 void set_no_display(bool val);
293
297 void set_hidden(bool val);
298
302 void set_terminal(bool val);
303
307 void set_startup_notify(bool val);
308
313 void set_only_show_in(const list<String>& lst);
314
319 void set_not_show_in(const list<String>& lst);
320 };
321
322 EDELIB_NS_END
323 #endif