r22426 - gnucash/trunk/src/bin - Move option parsing back into its own function
Geert Janssens
gjanssens at code.gnucash.org
Mon Sep 24 15:07:23 EDT 2012
Author: gjanssens
Date: 2012-09-24 15:07:22 -0400 (Mon, 24 Sep 2012)
New Revision: 22426
Trac: http://svn.gnucash.org/trac/changeset/22426
Modified:
gnucash/trunk/src/bin/gnucash-bin.c
Log:
Move option parsing back into its own function
Since we can't use gtk_init_with_args, it makes more sense to keep the
command line processing in one spot, more or less as it was before.
Modified: gnucash/trunk/src/bin/gnucash-bin.c
===================================================================
--- gnucash/trunk/src/bin/gnucash-bin.c 2012-09-24 17:06:03 UTC (rev 22425)
+++ gnucash/trunk/src/bin/gnucash-bin.c 2012-09-24 19:07:22 UTC (rev 22426)
@@ -496,14 +496,28 @@
try_load_config_array(stylesheet_files);
}
-/* Parse command line options, using GOption interface */
-
+/* Parse command line options, using GOption interface.
+ * We can't let gtk_init_with_args do it because it fails
+ * before parsing any arguments if the GUI can't be initialized.
+ */
static void
-gnucash_command_line()
+gnc_parse_command_line(int *argc, char ***argv)
{
- if (args_remaining)
- file_to_load = args_remaining[0];
+ GError *error = NULL;
+ GOptionContext *context = g_option_context_new (_("- GnuCash personal and small business finance management"));
+
+ g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
+ g_option_context_add_group (context, gtk_get_option_group(FALSE));
+ if (!g_option_context_parse (context, argc, argv, &error))
+ {
+ g_printerr (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
+ error->message, *argv[0]);
+ g_error_free (error);
+ exit (1);
+ }
+ g_option_context_free (context);
+
if (gnucash_show_version)
{
if (is_development_version)
@@ -535,11 +549,13 @@
else
gconf_path = GCONF_PATH;
}
-
gnc_set_gconf_path(g_strdup(gconf_path));
if (namespace_regexp)
gnc_main_set_namespace_regexp(namespace_regexp);
+
+ if (args_remaining)
+ file_to_load = args_remaining[0];
}
static void
@@ -794,9 +810,6 @@
int
main(int argc, char ** argv)
{
- GError *error = NULL;
- GOptionContext *context;
-
#if !defined(G_THREADS_ENABLED) || defined(G_THREADS_IMPL_NONE)
# error "No GLib thread implementation available!"
#endif
@@ -832,22 +845,7 @@
}
#endif
- /* Parse the arguments. We can't let gtk_init_with_args do it since
- * it fails before parsing any arguments if the GUI can't be initialized.
- */
- context = g_option_context_new (_("- GnuCash personal and small business finance management"));
- g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
- g_option_context_add_group (context, gtk_get_option_group(FALSE));
- if (!g_option_context_parse (context, &argc, &argv, &error))
- {
- g_printerr (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
- error->message, argv[0]);
- g_error_free (error);
- return 1;
- }
- g_option_context_free (context);
-
- gnucash_command_line();
+ gnc_parse_command_line(&argc, &argv);
gnc_print_unstable_message();
gnc_log_init();
More information about the gnucash-changes
mailing list