forked from AuroraMiddleware/gtk
Drop gtk_init_with_args
We want to simplify our initialization code and remove all commandline argument handling from it. The first stop for this is to reduce the number of gtk_init variants we have.
This commit is contained in:
parent
b39e537e1c
commit
7e8eb3ddcd
@ -902,83 +902,6 @@ gtk_get_option_group (gboolean open_default_display)
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_init_with_args:
|
||||
* @argc: (inout): Address of the `argc` parameter of
|
||||
* your main() function (or 0 if @argv is %NULL). This will be changed if
|
||||
* any arguments were handled.
|
||||
* @argv: (array length=argc) (inout) (allow-none): Address of the
|
||||
* `argv` parameter of main(), or %NULL. Any options
|
||||
* understood by GTK+ are stripped before return.
|
||||
* @parameter_string: (allow-none): a string which is displayed in
|
||||
* the first line of `--help` output, after
|
||||
* `programname [OPTION...]`
|
||||
* @entries: (array zero-terminated=1): a %NULL-terminated array
|
||||
* of #GOptionEntrys describing the options of your program
|
||||
* @translation_domain: (nullable): a translation domain to use for translating
|
||||
* the `--help` output for the options in @entries
|
||||
* and the @parameter_string with gettext(), or %NULL
|
||||
* @error: a return location for errors
|
||||
*
|
||||
* This function does the same work as gtk_init_check().
|
||||
* Additionally, it allows you to add your own commandline options,
|
||||
* and it automatically generates nicely formatted
|
||||
* `--help` output. Note that your program will
|
||||
* be terminated after writing out the help output.
|
||||
*
|
||||
* Returns: %TRUE if the windowing system has been successfully
|
||||
* initialized, %FALSE otherwise
|
||||
*
|
||||
* Since: 2.6
|
||||
*/
|
||||
gboolean
|
||||
gtk_init_with_args (gint *argc,
|
||||
gchar ***argv,
|
||||
const gchar *parameter_string,
|
||||
const GOptionEntry *entries,
|
||||
const gchar *translation_domain,
|
||||
GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
GOptionGroup *gtk_group;
|
||||
gboolean retval;
|
||||
|
||||
if (gtk_initialized)
|
||||
goto done;
|
||||
|
||||
gettext_initialization ();
|
||||
|
||||
if (!check_setugid ())
|
||||
return FALSE;
|
||||
|
||||
gtk_group = gtk_get_option_group (FALSE);
|
||||
|
||||
context = g_option_context_new (parameter_string);
|
||||
g_option_context_add_group (context, gtk_group);
|
||||
g_option_context_set_translation_domain (context, translation_domain);
|
||||
|
||||
if (entries)
|
||||
g_option_context_add_main_entries (context, entries, translation_domain);
|
||||
retval = g_option_context_parse (context, argc, argv, error);
|
||||
|
||||
g_option_context_free (context);
|
||||
|
||||
if (!retval)
|
||||
return FALSE;
|
||||
|
||||
done:
|
||||
if (gdk_display_open_default () != NULL)
|
||||
{
|
||||
if (gtk_get_debug_flags () & GTK_DEBUG_INTERACTIVE)
|
||||
gtk_window_set_interactive_debugging (TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_parse_args:
|
||||
* @argc: (inout): a pointer to the number of command line arguments
|
||||
|
@ -84,14 +84,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_init_check (int *argc,
|
||||
char ***argv);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_init_with_args (gint *argc,
|
||||
gchar ***argv,
|
||||
const gchar *parameter_string,
|
||||
const GOptionEntry *entries,
|
||||
const gchar *translation_domain,
|
||||
GError **error);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GOptionGroup *gtk_get_option_group (gboolean open_default_display);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user