edelib
2.0.0
|
00001 /* 00002 * $Id: DesktopFile.h 2852 2009-10-02 12:11:05Z karijes $ 00003 * 00004 * .desktop file reader and writer 00005 * Copyright (c) 2005-2007 edelib authors 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public License 00018 * along with this library. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #ifndef __EDELIB_DESKTOPFILE_H__ 00022 #define __EDELIB_DESKTOPFILE_H__ 00023 00024 #include "Config.h" 00025 #include "String.h" 00026 00027 EDELIB_NS_BEGIN 00028 00033 enum DesktopFileErrors { 00034 DESK_FILE_SUCCESS = 0, 00035 DESK_FILE_EMPTY, 00036 DESK_FILE_ERR_FILE, 00037 DESK_FILE_ERR_BAD 00038 }; 00039 00044 enum DesktopFileType { 00045 DESK_FILE_TYPE_UNKNOWN = 0, 00046 DESK_FILE_TYPE_APPLICATION, 00047 DESK_FILE_TYPE_LINK, 00048 DESK_FILE_TYPE_DIRECTORY 00049 }; 00050 00076 class EDELIB_API DesktopFile : public Config { 00077 private: 00078 unsigned int errcode; 00079 DesktopFileType dtype; 00080 00081 public: 00085 DesktopFile(); 00086 00090 ~DesktopFile(); 00091 00097 bool load(const char* fname); 00098 00104 bool save(const char* fname); 00105 00110 void create_new(DesktopFileType t); 00111 00121 operator bool(void) const { return ((errcode == DESK_FILE_SUCCESS) ? 1 : 0); } 00122 00126 DesktopFileType type(void); 00127 00134 bool name(char* val, int len); 00135 00142 bool generic_name(char* val, int len); 00143 00150 bool comment(char* val, int len); 00151 00157 bool icon(char* val, int len); 00158 00166 bool exec(char* val, int len); 00167 00176 bool try_exec(bool& program_found); 00177 00182 bool path(char* val, int len); 00183 00188 bool url(char* val, int len); 00189 00193 bool mime_type(char* val, int len); 00194 00198 bool no_display(void); 00199 00203 bool hidden(void); 00204 00208 bool terminal(void); 00209 00213 bool startup_notify(void); 00214 00219 bool only_show_in(char* val, int len); 00220 00225 bool only_show_in(list<String>& lst); 00226 00231 bool not_show_in(char* val, int len); 00232 00237 bool not_show_in(list<String>& lst); 00238 00242 void set_type(DesktopFileType t); 00243 00247 void set_name(const char* val); 00248 00252 void set_generic_name(const char* val); 00253 00257 void set_comment(const char* val); 00258 00262 void set_icon(const char* val); 00263 00267 void set_exec(const char* val); 00268 00272 void set_try_exec(const char* val); 00273 00277 void set_path(const char* val); 00278 00282 void set_url(const char* val); 00283 00287 void set_mime_type(const char* val); 00288 00292 void set_no_display(bool val); 00293 00297 void set_hidden(bool val); 00298 00302 void set_terminal(bool val); 00303 00307 void set_startup_notify(bool val); 00308 00313 void set_only_show_in(const list<String>& lst); 00314 00319 void set_not_show_in(const list<String>& lst); 00320 }; 00321 00322 EDELIB_NS_END 00323 #endif