From d63896c7a6769570832e9956fa3f6b47a023dff7 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Mon, 15 Jun 1998 05:36:37 +0000 Subject: [PATCH] updates from rob browning git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@893 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/register/combocell-gtk.c | 16 +++++++++++----- src/register/table-gtk.c | 22 ++++++++++++++-------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/register/combocell-gtk.c b/src/register/combocell-gtk.c index ce284f9d11..66551aca3c 100644 --- a/src/register/combocell-gtk.c +++ b/src/register/combocell-gtk.c @@ -97,12 +97,18 @@ void xaccInitComboCell (ComboCell *cell) static void destroyCombo (BasicCell *bcell) { - ComboCell *cell; + ComboCell *cell = (ComboCell *) bcell; + PopBox *box = (PopBox *) (cell->cell.gui_private); - cell = (ComboCell *) bcell; - - if (!(cell->cell.realize)) { - PopBox *box = (PopBox *) (cell->cell.gui_private); + /* HACK: I had to put the three extra tests in the guard so that + we don't get a segfault on register window closes. I haven't checked + to be sure this is exactly the right thing to do, but it works. + + Actually, almost all of the combobox (and table-gtk for that + matter) code is an ugly hack that should go away when we have a + real table widget... */ + + if (!(cell->cell.realize) && box && box->table && box->table->entry_frame) { gtk_container_remove(GTK_CONTAINER(box->table->entry_frame), GTK_WIDGET(box->combobox)); gtk_container_add(GTK_CONTAINER(box->table->entry_frame), diff --git a/src/register/table-gtk.c b/src/register/table-gtk.c index c3bc393ca6..373ff2156d 100644 --- a/src/register/table-gtk.c +++ b/src/register/table-gtk.c @@ -614,6 +614,8 @@ xaccCreateTable (Table *table, GtkWidget * parent) } gtk_clist_thaw(GTK_CLIST(reg)); } + gtk_clist_set_policy(GTK_CLIST(reg), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_clist_freeze(GTK_CLIST(reg)); for(i = num_header_rows; i < table->num_phys_rows; i++) { @@ -712,7 +714,7 @@ void xaccRefreshTableGUI (Table * table) { CellBlock *curs; - GtkWidget * reg; + GtkCList * reg; int num_header_rows = 0; int i, j; @@ -722,7 +724,7 @@ xaccRefreshTableGUI (Table * table) /* The 0'th row of the handlers is defined as the header */ curs = table->handlers[0][0]; num_header_rows = curs->numRows; - reg = table->table_widget; + reg = GTK_CLIST(table->table_widget); printf (" refresh numphysrows=%d numphyscols=%d \n", table->num_phys_rows, table->num_phys_cols); @@ -733,20 +735,24 @@ xaccRefreshTableGUI (Table * table) table->entries[i][3]); } - gtk_clist_freeze(GTK_CLIST(reg)); + gtk_clist_freeze(reg); - while(GTK_CLIST(reg)->rows < (table->num_phys_rows - num_header_rows)) { - gtk_clist_append(GTK_CLIST(reg), NULL); + /* Adjust table to have the right number of rows */ + while(reg->rows < (table->num_phys_rows - num_header_rows)) { + gtk_clist_append(reg, NULL); + } + while(reg->rows > (table->num_phys_rows - num_header_rows)) { + gtk_clist_remove(reg, 0); } for(i = num_header_rows; i < table->num_phys_rows; i++) { for(j = 0; j < table->num_phys_cols; j++) { - gtk_clist_set_text(GTK_CLIST(reg), i - num_header_rows, j, - table->entries[i][j]); + gtk_clist_set_text(reg, i - num_header_rows, j, table->entries[i][j]); } } - gtk_clist_thaw(GTK_CLIST(reg)); + + gtk_clist_thaw(reg); } /* ================== end of file ======================= */