From 5a3d1833d13234520284302e3617ff757c41e380 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 16 Feb 2011 11:26:01 +0100 Subject: gui-wizard-gtk: added option handling and dump dir loading in main() Signed-off-by: Denys Vlasenko --- src/gui-gtk/main.c | 2 +- src/gui-wizard-gtk/main.c | 30 ++++++++++++++++++++++++++++++ src/gui-wizard-gtk/wizard.c | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/gui-gtk/main.c b/src/gui-gtk/main.c index c223d4c6..4932cbb3 100644 --- a/src/gui-gtk/main.c +++ b/src/gui-gtk/main.c @@ -69,7 +69,7 @@ int main(int argc, char **argv) NULL, NULL, }; - argv++; + argv += optind; if (!argv[0]) { char *home = getenv("HOME"); diff --git a/src/gui-wizard-gtk/main.c b/src/gui-wizard-gtk/main.c index 9b278740..3cd088bd 100644 --- a/src/gui-wizard-gtk/main.c +++ b/src/gui-wizard-gtk/main.c @@ -3,8 +3,38 @@ #include "parse_options.h" #include "wizard.h" +#define PROGNAME "bug-reporting-wizard" + +static crash_data_t *cd; + int main(int argc, char **argv) { + /* Can't keep these strings/structs static: _() doesn't support that */ + const char *program_usage_string = _( + PROGNAME" [-v] [DIR]\n\n" + "GUI tool to run analyze and report ABRT crash in specified DIR\n" + ); + enum { + OPT_v = 1 << 0, + }; + /* Keep enum above and order of options below in sync! */ + struct options program_options[] = { + OPT__VERBOSE(&g_verbose), + OPT_END() + }; + + /*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage_string); + + argv += optind; + if (!argv[0] || argv[1]) /* zero or >1 arguments */ + show_usage_and_die(program_usage_string, program_options); + + struct dump_dir *dd = dd_opendir(argv[0], 0); + if (!dd) + return 1; + cd = create_crash_data_from_dump_dir(dd); + dd_close(dd); + gtk_init(&argc, &argv); GtkWidget *assistant = create_assistant(); diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c index 0a708e4e..be6de7a9 100644 --- a/src/gui-wizard-gtk/wizard.c +++ b/src/gui-wizard-gtk/wizard.c @@ -75,7 +75,7 @@ static void add_pages() for (int i = 0; page_names[i] != NULL; i++) { - GtkWidget *page = GTK_WIDGET(gtk_builder_get_object(builder, page_names[i])); + GtkWidget *page = GTK_WIDGET(gtk_builder_get_object(builder, page_names[i])); if (page == NULL) continue; -- cgit