2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
27 * outFile = OptionGroup
28 * strct = GOptionGroup
45 * - glib.OptionContext
48 * - GDataset* -> Dataset
49 * - GOptionContext* -> OptionContext
53 module glib
.OptionGroup
;
55 private import glib
.glibtypes
;
57 private import lib
.glib
;
59 private import glib
.Dataset
;
60 private import glib
.OptionContext
;
61 private import glib
.Str
;
65 * The GOption commandline parser is intended to be a simpler replacement for the
66 * popt library. It supports short and long commandline options, as shown in the
68 * testtreemodel -r 1 --max-size 20 --rand --display=:1.0 -vb -- file1 file2
69 * The example demonstrates a number of features of the GOption commandline parser
70 * Options can be single letters, prefixed by a single dash. Multiple
71 * short options can be grouped behind a single dash.
72 * Long options are prefixed by two consecutive dashes.
73 * Options can have an extra argument, which can be a number, a string or a filename.
74 * For long options, the extra argument can be appended with an equals sign after the
76 * Non-option arguments are returned to the application as rest arguments.
77 * An argument consisting solely of two dashes turns off further parsing, any remaining
78 * arguments (even those starting with a dash) are returned to the application as rest
80 * Another important feature of GOption is that it can automatically generate nicely
81 * formatted help output. Unless it is explicitly turned off with
82 * g_option_context_set_help_enabled(), GOption will recognize the
83 * --help, -?, --help-all
84 * and --help-groupname options
85 * (where groupname is the name of a GOptionGroup)
86 * and write a text similar to the one shown in the following example to stdout.
88 * testtreemodel [OPTION...] - test tree model performance
90 * -?, --help Show help options
91 * --help-all Show all help options
92 * --help-gtk Show GTK+ Options
93 * Application Options:
94 * -r, --repeats=N Average over N repetitions
95 * -m, --max-size=M Test up to 2^M items
96 * --display=DISPLAY X display to use
97 * -v, --verbose Be verbose
98 * -b, --beep Beep when done
99 * --rand Randomize the data
100 * GOption groups options in GOptionGroups, which makes it easy to
101 * incorporate options from multiple sources. The intended use for this is
102 * to let applications collect option groups from the libraries it uses,
103 * add them to their GOptionContext, and parse all options by a single call
104 * to g_option_context_parse(). See gtk_get_option_group() for an example.
105 * If an option is declared to be of type string or filename, GOption takes
106 * care of converting it to the right encoding; strings are returned in UTF-8,
107 * filenames are returned in the GLib filename encoding.
108 * Here is a complete example of setting up GOption to parse the example
109 * commandline above and produce the example help output.
110 * static gint repeats = 2;
111 * static gint max_size = 8;
112 * static gboolean verbose = FALSE;
113 * static gboolean beep = FALSE;
114 * static gboolean rand = FALSE;
115 * static GOptionEntry entries[] =
117 * { "repeats", 'r', 0, G_OPTION_ARG_INT, repeats, "Average over N repetitions", "N" },
118 * { "max-size", 'm', 0, G_OPTION_ARG_INT, max_size, "Test up to 2^M items", "M" },
119 * { "verbose", 'v', 0, G_OPTION_ARG_NONE, verbose, "Be verbose", NULL },
120 * { "beep", 'b', 0, G_OPTION_ARG_NONE, beep, "Beep when done", NULL },
121 * { "rand", 0, 0, G_OPTION_ARG_NONE, rand, "Randomize the data", NULL },
125 * main (int argc, char *argv[])
127 * GError *error = NULL;
128 * GOptionContext *context;
129 * context = g_option_context_new ("- test tree model performance");
130 * g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
131 * g_option_context_add_group (context, gtk_get_option_group (TRUE));
132 * g_option_context_parse (context, argc, argv, error);
136 public class OptionGroup
139 /** the main Gtk struct */
140 protected GOptionGroup
* gOptionGroup
;
143 public GOptionGroup
* getOptionGroupStruct()
149 /** the main Gtk struct as a void* */
150 protected void* getStruct()
152 return cast(void*)gOptionGroup
;
156 * Sets our main struct and passes it to the parent class
158 public this (GOptionGroup
* gOptionGroup
)
160 this.gOptionGroup
= gOptionGroup
;
194 * Creates a new GOptionGroup.
196 * the name for the option group, this is used to provide
197 * help for the options in this group with --help-name
199 * a description for this group to be shown in
200 * --help. This string is translated using the translation
201 * domain or translation function of the group
203 * a description for the --help-name option.
204 * This string is translated using the translation domain or translation function
207 * user data that will be passed to the pre- and post-parse hooks,
208 * the error hook and to callbacks of G_OPTION_ARG_CALLBACK options, or NULL
210 * a function that will be called to free user_data, or NULL
212 * a newly created option group. It should be added
213 * to a GOptionContext or freed with g_option_group_free().
216 public this (char[] name
, char[] description
, char[] helpDescription
, void* userData
, GDestroyNotify destroy
)
218 // GOptionGroup* g_option_group_new (const gchar *name, const gchar *description, const gchar *help_description, gpointer user_data, GDestroyNotify destroy);
219 this(cast(GOptionGroup
*)g_option_group_new(Str
.toStringz(name
), Str
.toStringz(description
), Str
.toStringz(helpDescription
), userData
, destroy
) );
223 * Frees a GOptionGroup. Note that you must not
224 * free groups which have been added to a GOptionContext.
231 // void g_option_group_free (GOptionGroup *group);
232 g_option_group_free(gOptionGroup
);
236 * Adds the options specified in entries to group.
240 * a NULL-terminated array of GOptionEntrys
243 public void addEntries(GOptionEntry
* entries
)
245 // void g_option_group_add_entries (GOptionGroup *group, const GOptionEntry *entries);
246 g_option_group_add_entries(gOptionGroup
, entries
);
251 * Associates two functions with group which will be called
252 * from g_option_context_parse() before the first option is parsed
253 * and after the last option has been parsed, respectively.
254 * Note that the user data to be passed to pre_parse_func and
255 * post_parse_func can be specified when constructing the group
256 * with g_option_group_new().
260 * a function to call before parsing, or NULL
262 * a function to call after parsing, or NULL
265 public void setParseHooks(GOptionParseFunc preParseFunc
, GOptionParseFunc postParseFunc
)
267 // void g_option_group_set_parse_hooks (GOptionGroup *group, GOptionParseFunc pre_parse_func, GOptionParseFunc post_parse_func);
268 g_option_group_set_parse_hooks(gOptionGroup
, preParseFunc
, postParseFunc
);
273 * Associates a function with group which will be called
274 * from g_option_context_parse() when an error occurs.
275 * Note that the user data to be passed to pre_parse_func and
276 * post_parse_func can be specified when constructing the group
277 * with g_option_group_new().
281 * a function to call when an error occurs
284 public void setErrorHook(GOptionErrorFunc errorFunc
)
286 // void g_option_group_set_error_hook (GOptionGroup *group, GOptionErrorFunc error_func);
287 g_option_group_set_error_hook(gOptionGroup
, errorFunc
);
291 * Sets the function which is used to translate user-visible
292 * strings, for --help output. Different
293 * groups can use different GTranslateFuncs. If func
294 * is NULL, strings are not translated.
295 * If you are using gettext(), you only need to set the translation
296 * domain, see g_option_group_set_translation_domain().
300 * the GTranslateFunc, or NULL
302 * user data to pass to func, or NULL
304 * a function which gets called to free data, or NULL
307 public void setTranslateFunc(GTranslateFunc func
, void* data
, GDestroyNotify destroyNotify
)
309 // void g_option_group_set_translate_func (GOptionGroup *group, GTranslateFunc func, gpointer data, GDestroyNotify destroy_notify);
310 g_option_group_set_translate_func(gOptionGroup
, func
, data
, destroyNotify
);
314 * A convenience function to use gettext() for translating
315 * user-visible strings.
322 public void setTranslationDomain(char[] domain
)
324 // void g_option_group_set_translation_domain (GOptionGroup *group, const gchar *domain);
325 g_option_group_set_translation_domain(gOptionGroup
, Str
.toStringz(domain
));