1 /*
2  * GNT - The GLib Ncurses Toolkit
3  *
4  * GNT is the legal property of its developers, whose names are too numerous
5  * to list here.  Please refer to the COPYRIGHT file distributed with this
6  * source distribution.
7  *
8  * This library is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
21  */
22 
23 #ifndef GNT_STYLE_H
24 #define GNT_STYLE_H
25 /**
26  * SECTION:gntstyle
27  * @section_id: libgnt-gntstyle
28  * @title: Styles
29  * @short_description: Styling from a configuration file
30  */
31 
32 #include "gnt.h"
33 #include "gntwm.h"
34 
35 typedef enum
36 {
37 	GNT_STYLE_SHADOW = 0,
38 	GNT_STYLE_COLOR = 1,
39 	GNT_STYLE_MOUSE = 2,
40 	GNT_STYLE_WM = 3,
41 	GNT_STYLE_REMPOS = 4,
42 	GNT_STYLES
43 } GntStyle;
44 
45 /**
46  * gnt_style_read_configure_file:
47  * @filename:  The filename to read configuration from.
48  *
49  * Read configuration from a file.
50  */
51 void gnt_style_read_configure_file(const char *filename);
52 
53 /**
54  * gnt_style_get:
55  * @style:  The style.
56  *
57  * Get the user-setting for a style.
58  *
59  * Returns:  The user-setting, or %NULL.
60  */
61 const char *gnt_style_get(GntStyle style);
62 
63 /**
64  * gnt_style_get_from_name:
65  * @group:   The name of the group in the keyfile. If %NULL, the prgname
66  *                will be used first, if available. Otherwise, "general" will be used.
67  * @key:     The key
68  *
69  * Get the value of a preference in ~/.gntrc.
70  *
71  * Returns:  The value of the setting as a string, or %NULL
72  *
73  * Since: 2.1.0
74  */
75 char *gnt_style_get_from_name(const char *group, const char *key);
76 
77 /**
78  * gnt_style_get_string_list:
79  * @group:  The name of the group in the keyfile. If %NULL, the prgname
80  *          will be used first, if available. Otherwise, "general" will be used.
81  * @key:    The key
82  * @length: Return location for the number of strings returned, or NULL
83  *
84  * Get the value of a preference in ~/.gntrc.
85  *
86  * Returns: (transfer full): %NULL terminated string array. The array should be
87  *          freed with g_strfreev().
88  *
89  * Since: 2.4.0
90  */
91 char **gnt_style_get_string_list(const char *group, const char *key, gsize *length);
92 
93 /**
94  * gnt_style_get_color:
95  * @group:   The name of the group in the keyfile. If %NULL, the prgname
96  *                will be used first, if available. Otherwise, "general" will be used.
97  * @key:     The key
98  *
99  * Get the value of a color pair in ~/.gntrc.
100  *
101  * Returns:  The value of the color as an int, or 0 on error.
102  *
103  * Since: 2.4.0
104  */
105 int gnt_style_get_color(char *group, char *key);
106 
107 /**
108  * gnt_style_parse_bool:
109  * @value:   The value of the boolean setting as a string
110  *
111  * Parse a boolean preference. For example, if 'value' is "false" (ignoring case)
112  * or "0", the return value will be %FALSE, otherwise %TRUE.
113  *
114  * Returns:    The boolean value
115  *
116  * Since: 2.1.0
117  */
118 gboolean gnt_style_parse_bool(const char *value);
119 
120 /**
121  * gnt_style_get_bool:
122  * @style:  The style.
123  * @def:    The default value (i.e, the value if the user didn't define
124  *               any value)
125  *
126  * Get the boolean value for a user-setting.
127  *
128  * Returns:  The value of the setting.
129  */
130 gboolean gnt_style_get_bool(GntStyle style, gboolean def);
131 
132 #ifndef GNT_DISABLE_DEPRECATED
133 /**
134  * gnt_styles_get_keyremaps:
135  *
136  * Internal function -- do not use.
137  *
138  * Deprecated: 2.14.0
139  */
140 void gnt_styles_get_keyremaps(GType type, GHashTable *hash) G_GNUC_DEPRECATED;
141 #endif
142 
143 /**
144  * gnt_style_read_actions:
145  *
146  * Internal function -- do not use.
147  */
148 void gnt_style_read_actions(GType type, GntBindableClass *klass);
149 
150 /**
151  * gnt_style_read_menu_accels:
152  * @name:  The name of the window.
153  * @table: The hastable to store the accel information.
154  *
155  * Read menu-accels from ~/.gntrc
156  *
157  * Returns:  %TRUE if some accels were read, %FALSE otherwise.
158  */
159 gboolean gnt_style_read_menu_accels(const char *name, GHashTable *table);
160 
161 #ifndef GNT_DISABLE_DEPRECATED
162 /**
163  * gnt_style_read_workspaces:
164  *
165  * Reads workspace information.
166  *
167  * Internal function -- do not use.
168  *
169  * Deprecated: 2.14.0
170  */
171 void gnt_style_read_workspaces(GntWM *wm) G_GNUC_DEPRECATED;
172 #endif
173 
174 /**
175  * gnt_init_styles:
176  *
177  * Initialize style settings.
178  */
179 void gnt_init_styles(void);
180 
181 /**
182  * gnt_uninit_styles:
183  *
184  * Uninitialize style settings.
185  */
186 void gnt_uninit_styles(void);
187 
188 #endif /* GNT_STYLE_H */
189