aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2011-06-10 14:51:42 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2011-06-10 14:51:42 +0200
commit5d1c8bbf75a275ddbc1f01b43165ce9411986b6e (patch)
treef14b11e622cff10d1716bfd299743e0d621aa5ff /src
parenta2b898b610c7150a8e1c904afbe0f936b7069e4f (diff)
downloadlogdiag-5d1c8bbf75a275ddbc1f01b43165ce9411986b6e.tar.gz
logdiag-5d1c8bbf75a275ddbc1f01b43165ce9411986b6e.tar.xz
logdiag-5d1c8bbf75a275ddbc1f01b43165ce9411986b6e.zip
Change the way command line arguments are parsed.
Diffstat (limited to 'src')
-rw-r--r--src/logdiag.c41
1 files changed, 16 insertions, 25 deletions
diff --git a/src/logdiag.c b/src/logdiag.c
index c9c6af2..90548d3 100644
--- a/src/logdiag.c
+++ b/src/logdiag.c
@@ -19,6 +19,14 @@
int
main (int argc, char *argv[])
{
+ gchar **files = NULL;
+ GOptionEntry option_entries[] =
+ {
+ {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
+ NULL, N_("[FILE]")},
+ {NULL}
+ };
+
GError *error;
#ifdef _WIN32
gchar *install_dir;
@@ -38,8 +46,8 @@ main (int argc, char *argv[])
textdomain (GETTEXT_DOMAIN);
error = NULL;
- gtk_init_with_args (&argc, &argv,
- N_("[FILE] - Schematic editor"), NULL, GETTEXT_DOMAIN, &error);
+ gtk_init_with_args (&argc, &argv, N_("- Schematic editor"),
+ option_entries, GETTEXT_DOMAIN, &error);
if (error)
{
g_warning ("%s", error->message);
@@ -49,31 +57,14 @@ main (int argc, char *argv[])
gtk_window_set_default_icon_name (PROJECT_NAME);
- /* TODO: Accept multiple files. */
- if (argc < 2)
- ld_window_main_new (NULL);
- else
+ /* TODO: Be able to open multiple files. */
+ if (files)
{
- gchar *arg_utf8, *arg_filename;
-
- arg_utf8 = g_locale_to_utf8 (argv[1], -1, NULL, NULL, &error);
- if (error)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- return 1;
- }
- arg_filename = g_filename_from_utf8 (arg_utf8, -1, NULL, NULL, &error);
- if (error)
- {
- g_warning ("%s", error->message);
- g_error_free (error);
- return 1;
- }
- ld_window_main_new (arg_filename);
- g_free (arg_filename);
- g_free (arg_utf8);
+ ld_window_main_new (files[0]);
+ g_strfreev (files);
}
+ else
+ ld_window_main_new (NULL);
gtk_main ();
return 0;