Function
Gtkinit
Declaration [src]
void
gtk_init (
int* argc,
char*** argv
)
Description [src]
Call this function before using any other GTK+ functions in your GUI applications. It will initialize everything needed to operate the toolkit and parses some standard command line options.
Although you are expected to pass the argc
, argv
parameters from main()
to
this function, it is possible to pass NULL
if argv
is not available or
commandline handling is not required.
argc
and argv
are adjusted accordingly so your own code will
never see those standard arguments.
Note that there are some alternative ways to initialize GTK+:
if you are calling gtk_parse_args(), gtk_init_check(),
gtk_init_with_args()
or g_option_context_parse()
with
the option group returned by gtk_get_option_group(),
you don’t have to call gtk_init().
And if you are using GtkApplication
, you don’t have to call any of the
initialization functions either; the GtkApplication::startup
handler
does it for you.
This function will terminate your program if it was unable to
initialize the windowing system for some reason. If you want
your program to fall back to a textual interface you want to
call gtk_init_check()
instead.
Since 2.18, GTK+ calls signal (SIGPIPE, SIG_IGN)
during initialization, to ignore SIGPIPE signals, since these are
almost never wanted in graphical applications. If you do need to
handle SIGPIPE for some reason, reset the handler after gtk_init(),
but notice that other libraries (e.g. libdbus or gvfs) might do
similar things.
Parameters
argc
-
Type:
int*
Address of the
argc
parameter of yourmain()
function (or 0 ifargv
isNULL
). This will be changed if any arguments were handled.The argument will be modified by the function. argv
-
Type: An array of
char**
Address of the
argv
parameter of main(), orNULL
. Any options understood by GTK+ are stripped before return.The argument will be modified by the function. The argument can be set to NULL
by the function.The length of the array is specified in the argc
argument.The caller of the function takes ownership of the returned data, and is responsible for freeing it. Each element is a NUL terminated UTF-8 string.