config: add nm_config_setup() to initialize config singleton

Make nm_config_new() usable without accessing static/singleton data.

nm_config_setup() is now used to initialize the singleton.
Still, you must not call nm_config_get() before calling
nm_config_setup() or after freeing the provided singleton
instance.
This commit is contained in:
Thomas Haller
2014-07-09 15:17:01 +02:00
parent 9387e8e8a7
commit 1ff5154369
7 changed files with 199 additions and 118 deletions

View File

@@ -177,7 +177,8 @@ nm_main_utils_early_setup (const char *progname,
char **argv[],
int *argc,
GOptionEntry *options,
GOptionEntry *more_options,
void (*option_context_hook) (gpointer user_data, GOptionContext *opt_ctx),
gpointer option_context_hook_data,
const char *summary)
{
GOptionContext *opt_ctx = NULL;
@@ -220,9 +221,9 @@ nm_main_utils_early_setup (const char *progname,
g_option_context_set_ignore_unknown_options (opt_ctx, FALSE);
g_option_context_set_help_enabled (opt_ctx, TRUE);
g_option_context_add_main_entries (opt_ctx, options, NULL);
if (more_options)
g_option_context_add_main_entries (opt_ctx, more_options, NULL);
g_option_context_set_summary (opt_ctx, summary);
if (option_context_hook)
option_context_hook (option_context_hook_data, opt_ctx);
success = g_option_context_parse (opt_ctx, argc, argv, &error);
if (!success) {