You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

267 lines
12 KiB

  1. /* gkeyfile.h - desktop entry file parser
  2. *
  3. * Copyright 2004 Red Hat, Inc.
  4. *
  5. * Ray Strode <halfline@hawaii.rr.com>
  6. *
  7. * GLib is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2 of the
  10. * License, or (at your option) any later version.
  11. *
  12. * GLib 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
  18. * License along with GLib; see the file COPYING.LIB. If not,
  19. * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20. * Boston, MA 02111-1307, USA.
  21. */
  22. #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  23. #error "Only <glib.h> can be included directly."
  24. #endif
  25. #ifndef __G_KEY_FILE_H__
  26. #define __G_KEY_FILE_H__
  27. #include <glib/gerror.h>
  28. G_BEGIN_DECLS
  29. typedef enum
  30. {
  31. G_KEY_FILE_ERROR_UNKNOWN_ENCODING,
  32. G_KEY_FILE_ERROR_PARSE,
  33. G_KEY_FILE_ERROR_NOT_FOUND,
  34. G_KEY_FILE_ERROR_KEY_NOT_FOUND,
  35. G_KEY_FILE_ERROR_GROUP_NOT_FOUND,
  36. G_KEY_FILE_ERROR_INVALID_VALUE
  37. } GKeyFileError;
  38. #define G_KEY_FILE_ERROR g_key_file_error_quark()
  39. GQuark g_key_file_error_quark (void);
  40. typedef struct _GKeyFile GKeyFile;
  41. typedef enum
  42. {
  43. G_KEY_FILE_NONE = 0,
  44. G_KEY_FILE_KEEP_COMMENTS = 1 << 0,
  45. G_KEY_FILE_KEEP_TRANSLATIONS = 1 << 1
  46. } GKeyFileFlags;
  47. GKeyFile *g_key_file_new (void);
  48. void g_key_file_free (GKeyFile *key_file);
  49. void g_key_file_set_list_separator (GKeyFile *key_file,
  50. gchar separator);
  51. gboolean g_key_file_load_from_file (GKeyFile *key_file,
  52. const gchar *file,
  53. GKeyFileFlags flags,
  54. GError **error);
  55. gboolean g_key_file_load_from_data (GKeyFile *key_file,
  56. const gchar *data,
  57. gsize length,
  58. GKeyFileFlags flags,
  59. GError **error);
  60. gboolean g_key_file_load_from_dirs (GKeyFile *key_file,
  61. const gchar *file,
  62. const gchar **search_dirs,
  63. gchar **full_path,
  64. GKeyFileFlags flags,
  65. GError **error);
  66. gboolean g_key_file_load_from_data_dirs (GKeyFile *key_file,
  67. const gchar *file,
  68. gchar **full_path,
  69. GKeyFileFlags flags,
  70. GError **error);
  71. gchar *g_key_file_to_data (GKeyFile *key_file,
  72. gsize *length,
  73. GError **error) G_GNUC_MALLOC;
  74. gchar *g_key_file_get_start_group (GKeyFile *key_file) G_GNUC_MALLOC;
  75. gchar **g_key_file_get_groups (GKeyFile *key_file,
  76. gsize *length) G_GNUC_MALLOC;
  77. gchar **g_key_file_get_keys (GKeyFile *key_file,
  78. const gchar *group_name,
  79. gsize *length,
  80. GError **error) G_GNUC_MALLOC;
  81. gboolean g_key_file_has_group (GKeyFile *key_file,
  82. const gchar *group_name);
  83. gboolean g_key_file_has_key (GKeyFile *key_file,
  84. const gchar *group_name,
  85. const gchar *key,
  86. GError **error);
  87. gchar *g_key_file_get_value (GKeyFile *key_file,
  88. const gchar *group_name,
  89. const gchar *key,
  90. GError **error) G_GNUC_MALLOC;
  91. void g_key_file_set_value (GKeyFile *key_file,
  92. const gchar *group_name,
  93. const gchar *key,
  94. const gchar *value);
  95. gchar *g_key_file_get_string (GKeyFile *key_file,
  96. const gchar *group_name,
  97. const gchar *key,
  98. GError **error) G_GNUC_MALLOC;
  99. void g_key_file_set_string (GKeyFile *key_file,
  100. const gchar *group_name,
  101. const gchar *key,
  102. const gchar *string);
  103. gchar *g_key_file_get_locale_string (GKeyFile *key_file,
  104. const gchar *group_name,
  105. const gchar *key,
  106. const gchar *locale,
  107. GError **error) G_GNUC_MALLOC;
  108. void g_key_file_set_locale_string (GKeyFile *key_file,
  109. const gchar *group_name,
  110. const gchar *key,
  111. const gchar *locale,
  112. const gchar *string);
  113. gboolean g_key_file_get_boolean (GKeyFile *key_file,
  114. const gchar *group_name,
  115. const gchar *key,
  116. GError **error);
  117. void g_key_file_set_boolean (GKeyFile *key_file,
  118. const gchar *group_name,
  119. const gchar *key,
  120. gboolean value);
  121. gint g_key_file_get_integer (GKeyFile *key_file,
  122. const gchar *group_name,
  123. const gchar *key,
  124. GError **error);
  125. void g_key_file_set_integer (GKeyFile *key_file,
  126. const gchar *group_name,
  127. const gchar *key,
  128. gint value);
  129. gint64 g_key_file_get_int64 (GKeyFile *key_file,
  130. const gchar *group_name,
  131. const gchar *key,
  132. GError **error);
  133. void g_key_file_set_int64 (GKeyFile *key_file,
  134. const gchar *group_name,
  135. const gchar *key,
  136. gint64 value);
  137. guint64 g_key_file_get_uint64 (GKeyFile *key_file,
  138. const gchar *group_name,
  139. const gchar *key,
  140. GError **error);
  141. void g_key_file_set_uint64 (GKeyFile *key_file,
  142. const gchar *group_name,
  143. const gchar *key,
  144. guint64 value);
  145. gdouble g_key_file_get_double (GKeyFile *key_file,
  146. const gchar *group_name,
  147. const gchar *key,
  148. GError **error);
  149. void g_key_file_set_double (GKeyFile *key_file,
  150. const gchar *group_name,
  151. const gchar *key,
  152. gdouble value);
  153. gchar **g_key_file_get_string_list (GKeyFile *key_file,
  154. const gchar *group_name,
  155. const gchar *key,
  156. gsize *length,
  157. GError **error) G_GNUC_MALLOC;
  158. void g_key_file_set_string_list (GKeyFile *key_file,
  159. const gchar *group_name,
  160. const gchar *key,
  161. const gchar * const list[],
  162. gsize length);
  163. gchar **g_key_file_get_locale_string_list (GKeyFile *key_file,
  164. const gchar *group_name,
  165. const gchar *key,
  166. const gchar *locale,
  167. gsize *length,
  168. GError **error) G_GNUC_MALLOC;
  169. void g_key_file_set_locale_string_list (GKeyFile *key_file,
  170. const gchar *group_name,
  171. const gchar *key,
  172. const gchar *locale,
  173. const gchar * const list[],
  174. gsize length);
  175. gboolean *g_key_file_get_boolean_list (GKeyFile *key_file,
  176. const gchar *group_name,
  177. const gchar *key,
  178. gsize *length,
  179. GError **error) G_GNUC_MALLOC;
  180. void g_key_file_set_boolean_list (GKeyFile *key_file,
  181. const gchar *group_name,
  182. const gchar *key,
  183. gboolean list[],
  184. gsize length);
  185. gint *g_key_file_get_integer_list (GKeyFile *key_file,
  186. const gchar *group_name,
  187. const gchar *key,
  188. gsize *length,
  189. GError **error) G_GNUC_MALLOC;
  190. void g_key_file_set_double_list (GKeyFile *key_file,
  191. const gchar *group_name,
  192. const gchar *key,
  193. gdouble list[],
  194. gsize length);
  195. gdouble *g_key_file_get_double_list (GKeyFile *key_file,
  196. const gchar *group_name,
  197. const gchar *key,
  198. gsize *length,
  199. GError **error) G_GNUC_MALLOC;
  200. void g_key_file_set_integer_list (GKeyFile *key_file,
  201. const gchar *group_name,
  202. const gchar *key,
  203. gint list[],
  204. gsize length);
  205. gboolean g_key_file_set_comment (GKeyFile *key_file,
  206. const gchar *group_name,
  207. const gchar *key,
  208. const gchar *comment,
  209. GError **error);
  210. gchar *g_key_file_get_comment (GKeyFile *key_file,
  211. const gchar *group_name,
  212. const gchar *key,
  213. GError **error) G_GNUC_MALLOC;
  214. gboolean g_key_file_remove_comment (GKeyFile *key_file,
  215. const gchar *group_name,
  216. const gchar *key,
  217. GError **error);
  218. gboolean g_key_file_remove_key (GKeyFile *key_file,
  219. const gchar *group_name,
  220. const gchar *key,
  221. GError **error);
  222. gboolean g_key_file_remove_group (GKeyFile *key_file,
  223. const gchar *group_name,
  224. GError **error);
  225. /* Defines for handling freedesktop.org Desktop files */
  226. #define G_KEY_FILE_DESKTOP_GROUP "Desktop Entry"
  227. #define G_KEY_FILE_DESKTOP_KEY_TYPE "Type"
  228. #define G_KEY_FILE_DESKTOP_KEY_VERSION "Version"
  229. #define G_KEY_FILE_DESKTOP_KEY_NAME "Name"
  230. #define G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME "GenericName"
  231. #define G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY "NoDisplay"
  232. #define G_KEY_FILE_DESKTOP_KEY_COMMENT "Comment"
  233. #define G_KEY_FILE_DESKTOP_KEY_ICON "Icon"
  234. #define G_KEY_FILE_DESKTOP_KEY_HIDDEN "Hidden"
  235. #define G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN "OnlyShowIn"
  236. #define G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN "NotShowIn"
  237. #define G_KEY_FILE_DESKTOP_KEY_TRY_EXEC "TryExec"
  238. #define G_KEY_FILE_DESKTOP_KEY_EXEC "Exec"
  239. #define G_KEY_FILE_DESKTOP_KEY_PATH "Path"
  240. #define G_KEY_FILE_DESKTOP_KEY_TERMINAL "Terminal"
  241. #define G_KEY_FILE_DESKTOP_KEY_MIME_TYPE "MimeType"
  242. #define G_KEY_FILE_DESKTOP_KEY_CATEGORIES "Categories"
  243. #define G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY "StartupNotify"
  244. #define G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS "StartupWMClass"
  245. #define G_KEY_FILE_DESKTOP_KEY_URL "URL"
  246. #define G_KEY_FILE_DESKTOP_TYPE_APPLICATION "Application"
  247. #define G_KEY_FILE_DESKTOP_TYPE_LINK "Link"
  248. #define G_KEY_FILE_DESKTOP_TYPE_DIRECTORY "Directory"
  249. G_END_DECLS
  250. #endif /* __G_KEY_FILE_H__ */