void tax_table_delete_entry_cb (GtkButton *button, TaxTableWindow *ttw) { g_return_if_fail (ttw); if (!ttw->current_table || !ttw->current_entry) return; if (g_list_length (gncTaxTableGetEntries (ttw->current_table)) <= 1) { char *message = _("You cannot remove the last entry from the tax table. " "Try deleting the tax table if you want to do that."); gnc_error_dialog (ttw->dialog, "%s", message); return; } if (gnc_verify_dialog (ttw->dialog, FALSE, "%s", _("Are you sure you want to delete this entry?"))) { /* Ok, let's remove it */ gnc_suspend_gui_refresh (); gncTaxTableBeginEdit (ttw->current_table); gncTaxTableRemoveEntry (ttw->current_table, ttw->current_entry); gncTaxTableEntryDestroy (ttw->current_entry); gncTaxTableChanged (ttw->current_table); gncTaxTableCommitEdit (ttw->current_table); ttw->current_entry = NULL; gnc_resume_gui_refresh (); } }
void gncTaxTableAddEntry (GncTaxTable *table, GncTaxTableEntry *entry) { if (!table || !entry) return; if (entry->table == table) return; /* already mine */ gncTaxTableBeginEdit (table); if (entry->table) gncTaxTableRemoveEntry (entry->table, entry); entry->table = table; table->entries = g_list_insert_sorted (table->entries, entry, (GCompareFunc)gncTaxTableEntryCompare); mark_table (table); mod_table (table); gncTaxTableCommitEdit (table); }