1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = 
27  * outPack = glib
28  * outFile = OptionGroup
29  * strct   = GOptionGroup
30  * realStrct=
31  * ctorStrct=
32  * clss    = OptionGroup
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_option_group_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * structWrap:
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module glib.OptionGroup;
54 
55 public  import gtkc.glibtypes;
56 
57 private import gtkc.glib;
58 private import glib.ConstructionException;
59 
60 
61 private import glib.Str;
62 
63 
64 
65 
66 /**
67  * Description
68  * The GOption commandline parser is intended to be a simpler replacement
69  * for the popt library. It supports short and long commandline options,
70  * as shown in the following example:
71  * testtreemodel -r 1 --max-size 20 --rand --display=:1.0 -vb -- file1 file2
72  * The example demonstrates a number of features of the GOption
73  * commandline parser
74  *  Options can be single letters, prefixed by a single dash. Multiple
75  *  short options can be grouped behind a single dash.
76  *  Long options are prefixed by two consecutive dashes.
77  *  Options can have an extra argument, which can be a number, a string or
78  *  a filename. For long options, the extra argument can be appended with
79  *  an equals sign after the option name, which is useful if the extra
80  *  argument starts with a dash, which would otherwise cause it to be
81  *  interpreted as another option.
82  *  Non-option arguments are returned to the application as rest arguments.
83  *  An argument consisting solely of two dashes turns off further parsing,
84  *  any remaining arguments (even those starting with a dash) are returned
85  *  to the application as rest arguments.
86  * Another important feature of GOption is that it can automatically
87  * generate nicely formatted help output. Unless it is explicitly turned
88  * off with g_option_context_set_help_enabled(), GOption will recognize
89  * the --help, -?,
90  * --help-all and
91  * --help-groupname options
92  * (where groupname is the name of a
93  * GOptionGroup) and write a text similar to the one shown in the
94  * following example to stdout.
95  * $(DDOC_COMMENT example)
96  * GOption groups options in GOptionGroups, which makes it easy to
97  * incorporate options from multiple sources. The intended use for this is
98  * to let applications collect option groups from the libraries it uses,
99  * add them to their GOptionContext, and parse all options by a single call
100  * to g_option_context_parse(). See gtk_get_option_group() for an example.
101  * If an option is declared to be of type string or filename, GOption takes
102  * care of converting it to the right encoding; strings are returned in
103  * UTF-8, filenames are returned in the GLib filename encoding. Note that
104  * this only works if setlocale() has been called before
105  * g_option_context_parse().
106  * Here is a complete example of setting up GOption to parse the example
107  * commandline above and produce the example help output.
108  * $(DDOC_COMMENT example)
109  */
110 public class OptionGroup
111 {
112 	
113 	/** the main Gtk struct */
114 	protected GOptionGroup* gOptionGroup;
115 	
116 	
117 	public GOptionGroup* getOptionGroupStruct()
118 	{
119 		return gOptionGroup;
120 	}
121 	
122 	
123 	/** the main Gtk struct as a void* */
124 	protected void* getStruct()
125 	{
126 		return cast(void*)gOptionGroup;
127 	}
128 	
129 	/**
130 	 * Sets our main struct and passes it to the parent class
131 	 */
132 	public this (GOptionGroup* gOptionGroup)
133 	{
134 		this.gOptionGroup = gOptionGroup;
135 	}
136 	
137 	/**
138 	 */
139 	
140 	/**
141 	 * Creates a new GOptionGroup.
142 	 * Since 2.6
143 	 * Params:
144 	 * name = the name for the option group, this is used to provide
145 	 * help for the options in this group with --help-name
146 	 * description = a description for this group to be shown in
147 	 * --help. This string is translated using the translation
148 	 * domain or translation function of the group
149 	 * helpDescription = a description for the --help-name option.
150 	 * This string is translated using the translation domain or translation function
151 	 * of the group
152 	 * userData = user data that will be passed to the pre- and post-parse hooks,
153 	 * the error hook and to callbacks of G_OPTION_ARG_CALLBACK options, or NULL
154 	 * destroy = a function that will be called to free user_data, or NULL
155 	 * Throws: ConstructionException GTK+ fails to create the object.
156 	 */
157 	public this (string name, string description, string helpDescription, void* userData, GDestroyNotify destroy)
158 	{
159 		// GOptionGroup * g_option_group_new (const gchar *name,  const gchar *description,  const gchar *help_description,  gpointer user_data,  GDestroyNotify destroy);
160 		auto p = g_option_group_new(Str.toStringz(name), Str.toStringz(description), Str.toStringz(helpDescription), userData, destroy);
161 		if(p is null)
162 		{
163 			throw new ConstructionException("null returned by g_option_group_new(Str.toStringz(name), Str.toStringz(description), Str.toStringz(helpDescription), userData, destroy)");
164 		}
165 		this(cast(GOptionGroup*) p);
166 	}
167 	
168 	/**
169 	 * Frees a GOptionGroup. Note that you must not
170 	 * free groups which have been added to a GOptionContext.
171 	 * Since 2.6
172 	 */
173 	public void free()
174 	{
175 		// void g_option_group_free (GOptionGroup *group);
176 		g_option_group_free(gOptionGroup);
177 	}
178 	
179 	/**
180 	 * Adds the options specified in entries to group.
181 	 * Since 2.6
182 	 * Params:
183 	 * entries = a NULL-terminated array of GOptionEntrys
184 	 */
185 	public void addEntries(GOptionEntry* entries)
186 	{
187 		// void g_option_group_add_entries (GOptionGroup *group,  const GOptionEntry *entries);
188 		g_option_group_add_entries(gOptionGroup, entries);
189 	}
190 	
191 	/**
192 	 * Associates two functions with group which will be called
193 	 * from g_option_context_parse() before the first option is parsed
194 	 * and after the last option has been parsed, respectively.
195 	 * Note that the user data to be passed to pre_parse_func and
196 	 * post_parse_func can be specified when constructing the group
197 	 * with g_option_group_new().
198 	 * Since 2.6
199 	 * Params:
200 	 * preParseFunc = a function to call before parsing, or NULL
201 	 * postParseFunc = a function to call after parsing, or NULL
202 	 */
203 	public void setParseHooks(GOptionParseFunc preParseFunc, GOptionParseFunc postParseFunc)
204 	{
205 		// void g_option_group_set_parse_hooks (GOptionGroup *group,  GOptionParseFunc pre_parse_func,  GOptionParseFunc post_parse_func);
206 		g_option_group_set_parse_hooks(gOptionGroup, preParseFunc, postParseFunc);
207 	}
208 	
209 	/**
210 	 * Associates a function with group which will be called
211 	 * from g_option_context_parse() when an error occurs.
212 	 * Note that the user data to be passed to error_func can be
213 	 * specified when constructing the group with g_option_group_new().
214 	 * Since 2.6
215 	 * Params:
216 	 * errorFunc = a function to call when an error occurs
217 	 */
218 	public void setErrorHook(GOptionErrorFunc errorFunc)
219 	{
220 		// void g_option_group_set_error_hook (GOptionGroup *group,  GOptionErrorFunc error_func);
221 		g_option_group_set_error_hook(gOptionGroup, errorFunc);
222 	}
223 	
224 	/**
225 	 * Sets the function which is used to translate user-visible
226 	 * strings, for --help output. Different
227 	 * groups can use different GTranslateFuncs. If func
228 	 * is NULL, strings are not translated.
229 	 * If you are using gettext(), you only need to set the translation
230 	 * domain, see g_option_group_set_translation_domain().
231 	 * Since 2.6
232 	 * Params:
233 	 * func = the GTranslateFunc, or NULL
234 	 * data = user data to pass to func, or NULL
235 	 * destroyNotify = a function which gets called to free data, or NULL
236 	 */
237 	public void setTranslateFunc(GTranslateFunc func, void* data, GDestroyNotify destroyNotify)
238 	{
239 		// void g_option_group_set_translate_func (GOptionGroup *group,  GTranslateFunc func,  gpointer data,  GDestroyNotify destroy_notify);
240 		g_option_group_set_translate_func(gOptionGroup, func, data, destroyNotify);
241 	}
242 	
243 	/**
244 	 * A convenience function to use gettext() for translating
245 	 * user-visible strings.
246 	 * Since 2.6
247 	 * Params:
248 	 * domain = the domain to use
249 	 */
250 	public void setTranslationDomain(string domain)
251 	{
252 		// void g_option_group_set_translation_domain  (GOptionGroup *group,  const gchar *domain);
253 		g_option_group_set_translation_domain(gOptionGroup, Str.toStringz(domain));
254 	}
255 }