void show_config_list_dialog(GtkWindow *parent) { GHashTable *confs = g_hash_table_new_full( /*hash_func*/ g_str_hash, /*key_equal_func:*/ g_str_equal, /*key_destroy_func:*/ g_free, /*value_destroy_func:*/ NULL); //TODO: free the hashtables somewhere!! GHashTable *events = load_event_config_data(); load_event_config_data_from_user_storage(events); GHashTable *workflows = load_workflow_config_data(WORKFLOWS_DIR); load_workflow_config_data_from_user_storage(workflows); GtkListStore *workflows_store = add_workflows_to_liststore(workflows); g_hash_table_insert(confs, _("Workflows"), workflows_store); GtkListStore *events_store = add_events_to_liststore(events); g_hash_table_insert(confs, _("Events"), events_store); GtkWindow *window = create_config_list_window(confs, parent); gtk_widget_show_all(GTK_WIDGET(window)); }
int main(int argc, char **argv) { int expert_mode = 0; const char *prgname = "abrt"; abrt_init(argv); /* I18n */ setlocale(LC_ALL, ""); #if ENABLE_NLS bindtextdomain(PACKAGE, LOCALEDIR); 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 * * env variable can be used to override the default prgname, so it's the * same as the application which is calling us (trac#303) * * note that g_set_prgname has to be called before gtk_init */ char *env_prgname = getenv("LIBREPORT_PRGNAME"); g_set_prgname(env_prgname ? env_prgname : prgname); gtk_init(&argc, &argv); /* Can't keep these strings/structs static: _() doesn't support that */ const char *program_usage_string = _( "& [-vpdx] [-e EVENT]... [-g GUI_FILE] PROBLEM_DIR\n" "\n" "GUI tool to analyze and report problem saved in specified PROBLEM_DIR" ); enum { OPT_v = 1 << 0, OPT_g = 1 << 1, OPT_p = 1 << 2, OPT_d = 1 << 3, OPT_e = 1 << 4, OPT_x = 1 << 5, }; /* 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")), OPT_BOOL( 'd', "delete", NULL, _("Remove PROBLEM_DIR after reporting")), OPT_LIST( 'e', "event", &g_auto_event_list, "EVENT", _("Run only these events")), OPT_BOOL( 'x', "expert", &expert_mode, _("Expert mode")), 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); /* Allow algorithms to add mallocated strings */ for (GList *elem = g_auto_event_list; elem; elem = g_list_next(elem)) elem->data = xstrdup((const char *)elem->data); export_abrt_envvars(opts & OPT_p); g_dump_dir_name = xstrdup(argv[0]); /* load /etc/abrt/events/foo.{conf,xml} stuff and $XDG_CACHE_HOME/abrt/events/foo.conf */ g_event_config_list = load_event_config_data(); load_event_config_data_from_user_storage(g_event_config_list); load_user_settings("report-gtk"); load_workflow_config_data(WORKFLOWS_DIR); /* list of workflows applicable to the currently processed problem */ GList *possible_names = list_possible_events_glist(g_dump_dir_name, "workflow"); GHashTable *possible_workflows = load_workflow_config_data_from_list(possible_names, WORKFLOWS_DIR); g_list_free_full(possible_names, free); /* if we have only 1 workflow, we can use the events from it as default */ if (!expert_mode && g_auto_event_list == NULL && g_hash_table_size(possible_workflows) == 1) { GHashTableIter iter; gpointer key, value; g_hash_table_iter_init(&iter, possible_workflows); if (g_hash_table_iter_next(&iter, &key, &value)) { log_notice("autoselected workflow: '%s'", (char *)key); g_auto_event_list = wf_get_event_names((workflow_t *)value); } } g_hash_table_destroy(possible_workflows); problem_data_reload_from_dump_dir(); g_custom_logger = &show_error_as_msgbox; GtkApplication *app = gtk_application_new("org.freedesktop.libreport.report", G_APPLICATION_NON_UNIQUE); g_signal_connect(app, "activate", G_CALLBACK(activate_wizard), (gpointer)&expert_mode); g_signal_connect(app, "startup", G_CALLBACK(startup_wizard), NULL); /* Enter main loop */ g_application_run(G_APPLICATION(app), argc, argv); g_object_unref(app); if (opts & OPT_d) delete_dump_dir_possibly_using_abrtd(g_dump_dir_name); save_user_settings(); return 0; }