void handler_export(GtkWidget *widget, gpointer data) { FILE *fp; int i; const char *name, *hours, *usage, *cost, *total; const char *utf8_name, *utf8_hours, *utf8_usage, *utf8_cost, *utf8_total; const char *tusage_str, *tcost_str; if(!(fp = fopen("export.txt", "w"))) { gui_perror(_("Export failed")); return; } utf8_name = _("Name"); utf8_hours = _("Hours"); utf8_usage = _("Usage"); utf8_cost = _("Cost"); name = g_locale_from_utf8(utf8_name, -1, 0, 0, 0); hours = g_locale_from_utf8(utf8_hours, -1, 0, 0, 0); usage = g_locale_from_utf8(utf8_usage, -1, 0, 0, 0); cost = g_locale_from_utf8(utf8_cost, -1, 0, 0, 0); if(!name) name = conv_iso7(utf8_name); if(!hours) hours = conv_iso7(utf8_hours); if(!usage) usage = conv_iso7(utf8_usage); if(!cost) cost = conv_iso7(utf8_cost); fprintf(fp, "%20s %5s %8s %6s\n", name, hours, usage, cost); for(i=0; i<people_count; i++) { const char *usage = gtk_entry_get_text(GTK_ENTRY(en_usage[i])); const char *cost = gtk_entry_get_text(GTK_ENTRY(en_cost[i])); fprintf(fp, "%20s: %5d %8s %6s\n", people[i].name, people[i].hours, usage, cost); } fputs("--------------------------------------------------\n", fp); tusage_str = gtk_entry_get_text(GTK_ENTRY(en_tot_usage)); tcost_str = gtk_entry_get_text(GTK_ENTRY(en_ctot_cost)); utf8_total = _("Total:"); total = g_locale_from_utf8(utf8_total, -1, 0, 0, 0); if(!total) total = conv_iso7(utf8_total); fprintf(fp, "%20s: %8s %6s\n", total, tusage_str, tcost_str); fclose(fp); gui_info(_("Calculation results exported successfully")); }