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 module glib.OptionGroup;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gtkc.glib;
30 public  import gtkc.glibtypes;
31 
32 
33 /**
34  * A `GOptionGroup` struct defines the options in a single
35  * group. The struct has only private fields and should not be directly accessed.
36  * 
37  * All options in a group share the same translation function. Libraries which
38  * need to parse commandline options are expected to provide a function for
39  * getting a `GOptionGroup` holding their options, which
40  * the application can then add to its #GOptionContext.
41  */
42 public class OptionGroup
43 {
44 	/** the main Gtk struct */
45 	protected GOptionGroup* gOptionGroup;
46 
47 	/** Get the main Gtk struct */
48 	public GOptionGroup* getOptionGroupStruct()
49 	{
50 		return gOptionGroup;
51 	}
52 
53 	/** the main Gtk struct as a void* */
54 	protected void* getStruct()
55 	{
56 		return cast(void*)gOptionGroup;
57 	}
58 
59 	/**
60 	 * Sets our main struct and passes it to the parent class.
61 	 */
62 	public this (GOptionGroup* gOptionGroup)
63 	{
64 		this.gOptionGroup = gOptionGroup;
65 	}
66 
67 	/**
68 	 */
69 
70 	/**
71 	 * Adds the options specified in @entries to @group.
72 	 *
73 	 * Params:
74 	 *     entries = a %NULL-terminated array of #GOptionEntrys
75 	 *
76 	 * Since: 2.6
77 	 */
78 	public void addEntries(GOptionEntry* entries)
79 	{
80 		g_option_group_add_entries(gOptionGroup, entries);
81 	}
82 
83 	/**
84 	 * Frees a #GOptionGroup. Note that you must not free groups
85 	 * which have been added to a #GOptionContext.
86 	 *
87 	 * Since: 2.6
88 	 */
89 	public void free()
90 	{
91 		g_option_group_free(gOptionGroup);
92 	}
93 
94 	/**
95 	 * Associates a function with @group which will be called
96 	 * from g_option_context_parse() when an error occurs.
97 	 *
98 	 * Note that the user data to be passed to @error_func can be
99 	 * specified when constructing the group with g_option_group_new().
100 	 *
101 	 * Params:
102 	 *     errorFunc = a function to call when an error occurs
103 	 *
104 	 * Since: 2.6
105 	 */
106 	public void setErrorHook(GOptionErrorFunc errorFunc)
107 	{
108 		g_option_group_set_error_hook(gOptionGroup, errorFunc);
109 	}
110 
111 	/**
112 	 * Associates two functions with @group which will be called
113 	 * from g_option_context_parse() before the first option is parsed
114 	 * and after the last option has been parsed, respectively.
115 	 *
116 	 * Note that the user data to be passed to @pre_parse_func and
117 	 * @post_parse_func can be specified when constructing the group
118 	 * with g_option_group_new().
119 	 *
120 	 * Params:
121 	 *     preParseFunc = a function to call before parsing, or %NULL
122 	 *     postParseFunc = a function to call after parsing, or %NULL
123 	 *
124 	 * Since: 2.6
125 	 */
126 	public void setParseHooks(GOptionParseFunc preParseFunc, GOptionParseFunc postParseFunc)
127 	{
128 		g_option_group_set_parse_hooks(gOptionGroup, preParseFunc, postParseFunc);
129 	}
130 
131 	/**
132 	 * Sets the function which is used to translate user-visible strings,
133 	 * for `--help` output. Different groups can use different
134 	 * #GTranslateFuncs. If @func is %NULL, strings are not translated.
135 	 *
136 	 * If you are using gettext(), you only need to set the translation
137 	 * domain, see g_option_group_set_translation_domain().
138 	 *
139 	 * Params:
140 	 *     func = the #GTranslateFunc, or %NULL
141 	 *     data = user data to pass to @func, or %NULL
142 	 *     destroyNotify = a function which gets called to free @data, or %NULL
143 	 *
144 	 * Since: 2.6
145 	 */
146 	public void setTranslateFunc(GTranslateFunc func, void* data, GDestroyNotify destroyNotify)
147 	{
148 		g_option_group_set_translate_func(gOptionGroup, func, data, destroyNotify);
149 	}
150 
151 	/**
152 	 * A convenience function to use gettext() for translating
153 	 * user-visible strings.
154 	 *
155 	 * Params:
156 	 *     domain = the domain to use
157 	 *
158 	 * Since: 2.6
159 	 */
160 	public void setTranslationDomain(string domain)
161 	{
162 		g_option_group_set_translation_domain(gOptionGroup, Str.toStringz(domain));
163 	}
164 
165 	/**
166 	 * Creates a new #GOptionGroup.
167 	 *
168 	 * Params:
169 	 *     name = the name for the option group, this is used to provide
170 	 *         help for the options in this group with `--help-`@name
171 	 *     description = a description for this group to be shown in
172 	 *         `--help`. This string is translated using the translation
173 	 *         domain or translation function of the group
174 	 *     helpDescription = a description for the `--help-`@name option.
175 	 *         This string is translated using the translation domain or translation function
176 	 *         of the group
177 	 *     userData = user data that will be passed to the pre- and post-parse hooks,
178 	 *         the error hook and to callbacks of %G_OPTION_ARG_CALLBACK options, or %NULL
179 	 *     destroy = a function that will be called to free @user_data, or %NULL
180 	 *
181 	 * Return: a newly created option group. It should be added
182 	 *     to a #GOptionContext or freed with g_option_group_free().
183 	 *
184 	 * Since: 2.6
185 	 *
186 	 * Throws: ConstructionException GTK+ fails to create the object.
187 	 */
188 	public this(string name, string description, string helpDescription, void* userData, GDestroyNotify destroy)
189 	{
190 		auto p = g_option_group_new(Str.toStringz(name), Str.toStringz(description), Str.toStringz(helpDescription), userData, destroy);
191 		
192 		if(p is null)
193 		{
194 			throw new ConstructionException("null returned by new");
195 		}
196 		
197 		this(cast(GOptionGroup*) p);
198 	}
199 }