diff options
author | Jiri Moskovcak <jmoskovc@redhat.com> | 2011-05-09 22:01:32 +0200 |
---|---|---|
committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2011-05-09 22:01:32 +0200 |
commit | 752b264ed8b08a59e60894b310bad522585674e9 (patch) | |
tree | a88bcafa8b3e8114d15c6778ad25d89ae9b8a10e | |
parent | 99f9b12507a84dbb1a4b4cb3affed4a794b1bd26 (diff) | |
download | abrt-752b264ed8b08a59e60894b310bad522585674e9.tar.gz abrt-752b264ed8b08a59e60894b310bad522585674e9.tar.xz abrt-752b264ed8b08a59e60894b310bad522585674e9.zip |
wizard: added report-only option
- for use from 3rd party apps to show just a reporter selector
-rw-r--r-- | src/gui-wizard-gtk/main.c | 24 | ||||
-rw-r--r-- | src/gui-wizard-gtk/wizard.c | 43 | ||||
-rw-r--r-- | src/gui-wizard-gtk/wizard.glade | 18 | ||||
-rw-r--r-- | src/gui-wizard-gtk/wizard.h | 1 |
4 files changed, 58 insertions, 28 deletions
diff --git a/src/gui-wizard-gtk/main.c b/src/gui-wizard-gtk/main.c index cdcf9e43..d2041cb9 100644 --- a/src/gui-wizard-gtk/main.c +++ b/src/gui-wizard-gtk/main.c @@ -30,6 +30,7 @@ char *g_dump_dir_name = NULL; char *g_analyze_events = NULL; char *g_reanalyze_events = NULL; char *g_report_events = NULL; +int g_report_only = false; problem_data_t *g_cd; @@ -60,6 +61,7 @@ void reload_problem_data_from_dump_dir(void) int main(int argc, char **argv) { + const char *prgname = "abrt"; abrt_init(argv); /* I18n */ @@ -69,17 +71,11 @@ int main(int argc, char **argv) textdomain(PACKAGE); #endif - /* without this the name is set to argv[0] which confuses - * desktops which uses the name to find the corresponding .desktop file - * trac#180 - */ - g_set_prgname("abrt"); - gtk_init(&argc, &argv); /* Can't keep these strings/structs static: _() doesn't support that */ const char *program_usage_string = _( - "\b [-vp] [-g GUI_FILE] DIR\n" + "\b [-vp] [-g GUI_FILE] [-o|--report-only] [-n|--prgname] DIR\n" "\n" "GUI tool to analyze and report problem saved in specified DIR" ); @@ -87,12 +83,20 @@ int main(int argc, char **argv) OPT_v = 1 << 0, OPT_g = 1 << 1, OPT_p = 1 << 2, + OPT_o = 1 << 3, // report only + OPT_n = 1 << 4, // prgname }; /* Keep enum above and order of options below in sync! */ struct options program_options[] = { OPT__VERBOSE(&g_verbose), OPT_STRING('g', NULL, &g_glade_file, "FILE" , _("Alternate GUI file")), OPT_BOOL( 'p', NULL, NULL , _("Add program names to log")), + /* for use from 3rd party apps to show just a reporter selector */ + OPT_BOOL( 'o', "report-only", &g_report_only , _("Use wizard to report pre-filled problem data")), + /* override the default prgname, so it's the same as the application + which is calling us + */ + OPT_STRING( 'n', "prgname", &prgname, "NAME" , _("Override the default prgname")), OPT_END() }; unsigned opts = parse_opts(argc, argv, program_options, program_usage_string); @@ -100,6 +104,12 @@ int main(int argc, char **argv) if (!argv[0] || argv[1]) /* zero or >1 arguments */ show_usage_and_die(program_usage_string, program_options); + /* without this the name is set to argv[0] which confuses + * desktops which uses the name to find the corresponding .desktop file + * trac#180 + */ + g_set_prgname(prgname); + export_abrt_envvars(opts & OPT_p); g_dump_dir_name = xstrdup(argv[0]); diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c index f9d89111..2dc87018 100644 --- a/src/gui-wizard-gtk/wizard.c +++ b/src/gui-wizard-gtk/wizard.c @@ -110,10 +110,10 @@ static const gchar PAGE_SUMMARY[] = "page_0"; static const gchar PAGE_COMMENT[] = "page_1"; static const gchar PAGE_ANALYZE_SELECTOR[] = "page_2"; static const gchar PAGE_ANALYZE_PROGRESS[] = "page_3"; -static const gchar PAGE_REPORTER_SELECTOR[] = "page_4"; +static const gchar PAGE_REPORTER_SELECTOR[] = "page_4_report"; static const gchar PAGE_BACKTRACE_APPROVAL[] = "page_5"; -static const gchar PAGE_REPORT[] = "page_6"; -static const gchar PAGE_REPORT_PROGRESS[] = "page_7"; +static const gchar PAGE_REPORT[] = "page_6_report"; +static const gchar PAGE_REPORT_PROGRESS[] = "page_7_report"; static const gchar *const page_names[] = { @@ -161,6 +161,8 @@ static page_obj_t pages[] = { NULL } }; +/* hardcoded 10 pages limit */ +page_obj_t *added_pages[10]; /* Utility functions */ @@ -1071,7 +1073,7 @@ static void next_page(GtkAssistant *assistant, gpointer user_data) int page_no = gtk_assistant_get_current_page(assistant); VERB2 log("page_no:%d", page_no); - if (page_no == PAGENO_ANALYZE_SELECTOR + if (added_pages[page_no]->name == PAGE_ANALYZE_SELECTOR && g_analyze_event_selected != NULL ) { start_event_run(g_analyze_event_selected, @@ -1084,7 +1086,7 @@ static void next_page(GtkAssistant *assistant, gpointer user_data) ); } - if (page_no == PAGENO_REPORT) + if (added_pages[page_no]->name == PAGE_REPORT) { GList *reporters = NULL; GList *li = g_list_reporters; @@ -1146,6 +1148,10 @@ static gint next_page_no(gint current_page_no, gpointer data) { again: current_page_no++; + /* we don't need any magic here if we're in only-report mode */ + if (g_report_only) + return current_page_no; + switch (current_page_no) { #if 0 @@ -1253,7 +1259,7 @@ static void create_details_treeview() /* wizard.glade file as a string WIZARD_GLADE_CONTENTS: */ #include "wizard_glade.c" -static void add_pages(void) +static void add_pages() { GError *error = NULL; if (!g_glade_file) @@ -1275,13 +1281,24 @@ static void add_pages(void) } int i; + int page_no = 0; for (i = 0; page_names[i] != NULL; i++) { + char *delim = strrchr(page_names[i], '_'); + if(delim != NULL) + { + if (g_report_only && (strncmp(delim+1, "report", strlen("report"))) != 0) + { + pages[i].page_widget = NULL; + continue; + } + } GtkWidget *page = GTK_WIDGET(gtk_builder_get_object(builder, page_names[i])); if (page == NULL) continue; pages[i].page_widget = page; + added_pages[page_no++] = &pages[i]; gtk_assistant_append_page(g_assistant, page); /* If we set all pages to complete the wizard thinks there is nothing @@ -1327,8 +1344,9 @@ static void add_pages(void) //gtk_widget_hide(g_widget_warnings_area); //gtk_assistant_set_page_complete(g_assistant, pages[PAGENO_REPORTER_SELECTOR].page_widget, false); - gtk_assistant_set_page_complete(g_assistant, pages[PAGENO_BACKTRACE_APPROVAL].page_widget, - gtk_toggle_button_get_active(g_tb_approve_bt)); + if (pages[PAGENO_BACKTRACE_APPROVAL].page_widget != NULL) + gtk_assistant_set_page_complete(g_assistant, pages[PAGENO_BACKTRACE_APPROVAL].page_widget, + gtk_toggle_button_get_active(g_tb_approve_bt)); /* configure btn on select analyzers page */ GtkWidget *config_btn = GTK_WIDGET(gtk_builder_get_object(builder, "button_cfg1")); @@ -1341,7 +1359,7 @@ static void add_pages(void) g_signal_connect(G_OBJECT(config_btn), "clicked", G_CALLBACK(on_show_event_list_cb), NULL); } -void create_assistant() +void create_assistant(void) { monospace_font = pango_font_description_from_string("monospace"); @@ -1385,8 +1403,9 @@ void create_assistant() gtk_text_buffer_create_tag(backtrace_buf, "search_result_bg", "background", "red", NULL); g_signal_connect(g_search_entry_bt, "changed", G_CALLBACK(search_timeout), NULL); - gtk_assistant_set_page_complete(g_assistant, - pages[PAGENO_BACKTRACE_APPROVAL].page_widget, - gtk_toggle_button_get_active(g_tb_approve_bt) + if (pages[PAGENO_BACKTRACE_APPROVAL].page_widget != NULL) + gtk_assistant_set_page_complete(g_assistant, + pages[PAGENO_BACKTRACE_APPROVAL].page_widget, + gtk_toggle_button_get_active(g_tb_approve_bt) ); } diff --git a/src/gui-wizard-gtk/wizard.glade b/src/gui-wizard-gtk/wizard.glade index 7a0f3d0b..14aabdaf 100644 --- a/src/gui-wizard-gtk/wizard.glade +++ b/src/gui-wizard-gtk/wizard.glade @@ -51,7 +51,7 @@ <object class="GtkScrolledWindow" id="container_details1"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="shadow_type">GTK_SHADOW_OUT</property> + <property name="shadow_type">out</property> <child> <object class="GtkTreeView" id="tv_details"> <property name="visible">True</property> @@ -104,7 +104,7 @@ <object class="GtkScrolledWindow" id="scrolledwindow4"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="shadow_type">GTK_SHADOW_OUT</property> + <property name="shadow_type">out</property> <child> <object class="GtkTextView" id="tv_comment"> <property name="visible">True</property> @@ -245,7 +245,7 @@ <object class="GtkScrolledWindow" id="scrolledwindow1"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="shadow_type">GTK_SHADOW_OUT</property> + <property name="shadow_type">out</property> <child> <object class="GtkTextView" id="tv_analyze_log"> <property name="visible">True</property> @@ -267,7 +267,7 @@ <object class="GtkWindow" id="window4"> <property name="can_focus">False</property> <child> - <object class="GtkVBox" id="page_4"> + <object class="GtkVBox" id="page_4_report"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">10</property> @@ -374,7 +374,7 @@ <object class="GtkScrolledWindow" id="scrolledwindow2"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="shadow_type">GTK_SHADOW_OUT</property> + <property name="shadow_type">out</property> <child> <object class="GtkTextView" id="tv_backtrace"> <property name="visible">True</property> @@ -548,7 +548,7 @@ <object class="GtkWindow" id="window6"> <property name="can_focus">False</property> <child> - <object class="GtkVBox" id="page_6"> + <object class="GtkVBox" id="page_6_report"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">10</property> @@ -644,7 +644,7 @@ <object class="GtkScrolledWindow" id="container_details2"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="shadow_type">GTK_SHADOW_OUT</property> + <property name="shadow_type">out</property> <child> <placeholder/> </child> @@ -661,7 +661,7 @@ <object class="GtkWindow" id="window7"> <property name="can_focus">False</property> <child> - <object class="GtkVBox" id="page_7"> + <object class="GtkVBox" id="page_7_report"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">10</property> @@ -685,7 +685,7 @@ <object class="GtkScrolledWindow" id="scrolledwindow6"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="shadow_type">GTK_SHADOW_OUT</property> + <property name="shadow_type">out</property> <child> <object class="GtkTextView" id="tv_report_log"> <property name="visible">True</property> diff --git a/src/gui-wizard-gtk/wizard.h b/src/gui-wizard-gtk/wizard.h index 5e341e34..bfc6d915 100644 --- a/src/gui-wizard-gtk/wizard.h +++ b/src/gui-wizard-gtk/wizard.h @@ -27,4 +27,5 @@ extern char *g_analyze_events; extern char *g_reanalyze_events; extern char *g_report_events; extern problem_data_t *g_cd; +extern int g_report_only; void reload_problem_data_from_dump_dir(void); |