]> icculus.org git repositories - dana/openbox.git/blob - obt/ddparse.h
Make the obt_watch functionality work without inotify (via manual refreshes).
[dana/openbox.git] / obt / ddparse.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    obt/ddparse.h for the Openbox window manager
4    Copyright (c) 2009        Dana Jansens
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #include <glib.h>
20
21 typedef struct _ObtDDParseGroup ObtDDParseGroup;
22
23 typedef enum {
24     OBT_DDPARSE_EXEC,
25     OBT_DDPARSE_STRING,
26     OBT_DDPARSE_LOCALESTRING,
27     OBT_DDPARSE_STRINGS,
28     OBT_DDPARSE_LOCALESTRINGS,
29     OBT_DDPARSE_BOOLEAN,
30     OBT_DDPARSE_NUMERIC,
31     OBT_DDPARSE_ENUM_TYPE,
32     OBT_DDPARSE_ENVIRONMENTS,
33     OBT_DDPARSE_NUM_VALUE_TYPES
34 } ObtDDParseValueType;
35
36 typedef enum {
37     OBT_DDPARSE_MATCH_NONE = 0,
38     OBT_DDPARSE_MATCH_FAIL,
39     OBT_DDPARSE_MATCH_LANG,
40     OBT_DDPARSE_MATCH_LANG_MODIFIER,
41     OBT_DDPARSE_MATCH_LANG_COUNTRY,
42     OBT_DDPARSE_MATCH_LANG_COUNTRY_MODIFIER
43 } ObtDDParseLangMatch;
44
45 typedef struct _ObtDDParseValue {
46     ObtDDParseValueType type;
47     union _ObtDDParseValueValue {
48         gchar *string;
49         struct _ObtDDParseValueStrings {
50             gchar **a;
51             gulong n;
52         } strings;
53         gboolean boolean;
54         gfloat numeric;
55         guint enumerable;
56         guint environments; /*!< A mask of flags from ObtLinkEnvMask */
57     } value;
58     ObtDDParseLangMatch language_match;
59 } ObtDDParseValue;
60
61 /*! Parse a .desktop file.
62   @param filename The full path to the .desktop file to be read.
63   @return Returns a hash table where the keys are groups, and the values are
64     ObtDDParseGroups */
65 GHashTable* obt_ddparse_file(const gchar *filename,
66                              const gchar *language,
67                              const gchar *country,
68                              const gchar *modifier);
69
70 /*! Get the keys in a group from a .desktop file.
71   The group comes from the hash table returned by obt_ddparse_file.
72   @return Returns a hash table where the keys are "keys" in the .desktop file,
73     represented as strings.  The values are "values" in the .desktop file, for
74     the group @g. Each value will be a pointer to an ObtDDParseValue structure.
75 */
76 GHashTable* obt_ddparse_group_keys(ObtDDParseGroup *g);
77
78 /*! Determine the id for a .desktop file.
79   @param filename The path to the .desktop file, _relative to_ some
80     basepath. filename must end with ".desktop" and be encoded in utf8.
81   @return Returns a string which is the id for the given .desktop file in its
82     current position.  Returns NULL if there is an error.
83 */
84 gchar* obt_ddparse_file_to_id(const gchar *filename);