[Gnucash-changes] r13510 - gnucash/trunk/src/register - Minor code factoring, line-wraps, control-flow simplifications, etc.

Chris Shoemaker chris at cvs.gnucash.org
Mon Mar 6 22:41:40 EST 2006


Author: chris
Date: 2006-03-06 22:41:39 -0500 (Mon, 06 Mar 2006)
New Revision: 13510
Trac: http://svn.gnucash.org/trac/changeset/13510

Modified:
   gnucash/trunk/src/register/ledger-core/split-register-load.c
   gnucash/trunk/src/register/register-core/table-allgui.c
   gnucash/trunk/src/register/register-core/table-allgui.h
   gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c
Log:
   Minor code factoring, line-wraps, control-flow simplifications, etc. 
   centered around split-register-load.c.


Modified: gnucash/trunk/src/register/ledger-core/split-register-load.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-load.c	2006-03-07 03:40:02 UTC (rev 13509)
+++ gnucash/trunk/src/register/ledger-core/split-register-load.c	2006-03-07 03:41:39 UTC (rev 13510)
@@ -100,9 +100,7 @@
                        TRUE, start_primary_color, *vcell_loc);
   vcell_loc->virt_row++;
 
-  {
-    for (node = xaccTransGetSplitList (trans); node; node = node->next)
-    {
+  for (node = xaccTransGetSplitList (trans); node; node = node->next) {
       Split *secondary = node->data;
 
       if (!xaccTransStillHasSplit(trans, secondary)) continue;
@@ -113,21 +111,20 @@
                            xaccSplitGetGUID (secondary),
                            visible_splits, TRUE, *vcell_loc);
       vcell_loc->virt_row++;
-    }
   }
 
-  if (!add_blank)
-    return;
-
-  if (find_trans == trans && find_split == NULL &&
-      find_class == CURSOR_CLASS_SPLIT)
-        *new_split_row = vcell_loc->virt_row;
-
-  /* Add blank transaction split */
-  gnc_table_set_vcell (reg->table, split_cursor,
-                       xaccSplitGetGUID (NULL), FALSE, TRUE, *vcell_loc);
-  vcell_loc->virt_row++;
-
+  if (add_blank) {
+      
+      if (find_trans == trans && find_split == NULL &&
+          find_class == CURSOR_CLASS_SPLIT) {
+          *new_split_row = vcell_loc->virt_row;
+      }
+      
+      /* Add blank transaction split */
+      gnc_table_set_vcell(reg->table, split_cursor, xaccSplitGetGUID(NULL), 
+                          FALSE, TRUE, *vcell_loc);
+      vcell_loc->virt_row++;
+  }
 }
 
 static gint
@@ -230,10 +227,11 @@
     new_trans = xaccMallocTransaction (gnc_get_current_book ());
 
     xaccTransBeginEdit (new_trans);
-    xaccTransSetCurrency (new_trans, currency ? currency : gnc_default_currency ());
+    xaccTransSetCurrency (new_trans, 
+                          currency ? currency : gnc_default_currency());
     xaccTransSetDateSecs (new_trans, info->last_date_entered);
     blank_split = xaccMallocSplit (gnc_get_current_book ());
-    xaccTransAppendSplit (new_trans, blank_split);
+    xaccSplitSetParent(blank_split, new_trans);
     xaccTransCommitEdit (new_trans);
 
     info->blank_split_guid = *xaccSplitGetGUID (blank_split);
@@ -262,15 +260,14 @@
     find_trans = xaccSplitGetParent (blank_split);
     find_split = NULL;
     find_trans_split = blank_split;
-    find_class = info->cursor_hint_cursor_class;
   }
   else
   {
     find_trans = info->cursor_hint_trans;
     find_split = info->cursor_hint_split;
     find_trans_split = info->cursor_hint_trans_split;
-    find_class = info->cursor_hint_cursor_class;
   }
+  find_class = info->cursor_hint_cursor_class;
 
   save_loc = table->current_cursor_loc;
 
@@ -293,11 +290,7 @@
   {
     VirtualLocation virt_loc;
 
-    virt_loc.vcell_loc.virt_row = -1;
-    virt_loc.vcell_loc.virt_col = -1;
-    virt_loc.phys_row_offset = -1;
-    virt_loc.phys_col_offset = -1;
-
+    gnc_virtual_location_init(&virt_loc);
     gnc_table_move_cursor_gui (table, virt_loc);
   }
 
@@ -360,19 +353,17 @@
   // list we're about to load.
   if (pending_trans != NULL)
   {
-    SplitList *splits;
-    for (splits = xaccTransGetSplitList(pending_trans); splits; splits = splits->next)
+    for (node = xaccTransGetSplitList(pending_trans); node; node = node->next)
     {
-      Split *pending_split = (Split*)splits->data;
+      Split *pending_split = (Split*)node->data;
       if (!xaccTransStillHasSplit(pending_trans, pending_split)) continue;
       if (g_list_find(slist, pending_split) != NULL)
         continue;
 
-      //printf("pending_split [%s] not found\n", guid_to_string(xaccSplitGetGUID(pending_split)));
-      if (g_list_find_custom(slist, pending_trans, _find_split_with_parent_txn) != NULL)
+      if (g_list_find_custom(slist, pending_trans, 
+                             _find_split_with_parent_txn) != NULL)
         continue;
 
-      //printf("transaction [%s] not found\n", guid_to_string(xaccTransGetGUID(pending_trans)));
       if (!we_own_slist)
       { // lazy-copy
         slist = g_list_copy(slist);
@@ -494,9 +485,9 @@
 
     if (dynamic || multi_line || info->trans_expanded)
     {
-      gnc_table_set_virt_cell_cursor
-        (table, trans_split_loc.vcell_loc,
-         gnc_split_register_get_active_cursor (reg));
+      gnc_table_set_virt_cell_cursor(
+          table, trans_split_loc.vcell_loc,
+          gnc_split_register_get_active_cursor (reg));
       gnc_split_register_set_trans_visible (reg, trans_split_loc.vcell_loc,
                                             TRUE, multi_line);
 

Modified: gnucash/trunk/src/register/register-core/table-allgui.c
===================================================================
--- gnucash/trunk/src/register/register-core/table-allgui.c	2006-03-07 03:40:02 UTC (rev 13509)
+++ gnucash/trunk/src/register/register-core/table-allgui.c	2006-03-07 03:41:39 UTC (rev 13510)
@@ -57,7 +57,6 @@
 static void gnc_table_init (Table * table);
 static void gnc_table_free_data (Table * table);
 static void gnc_virtual_cell_construct (gpointer vcell, gpointer user_data);
-static void gnc_virtual_location_init (VirtualLocation *vloc);
 static void gnc_virtual_cell_destroy (gpointer vcell, gpointer user_data);
 static void gnc_table_resize (Table * table, int virt_rows, int virt_cols);
 
@@ -620,7 +619,7 @@
   g_table_resize (table->virt_cells, 0, 0);
 }
 
-static void
+void
 gnc_virtual_location_init (VirtualLocation *vloc)
 {
   if (vloc == NULL)

Modified: gnucash/trunk/src/register/register-core/table-allgui.h
===================================================================
--- gnucash/trunk/src/register/register-core/table-allgui.h	2006-03-07 03:40:02 UTC (rev 13509)
+++ gnucash/trunk/src/register/register-core/table-allgui.h	2006-03-07 03:41:39 UTC (rev 13510)
@@ -47,7 +47,7 @@
  * -- there is only one cursor for a given virt row.
  * -- there is no overlap; a phys row can only belong to one virt row.
  *
- * Lets say there are three cursors T(rans),S(plit), and B(lank).  
+ * Lets say there are three cursors T(rans), S(plit), and B(lank).  
  * Lets say that these are used to 'print' the following table layout:
  * 
  *       virt row 1   T
@@ -157,6 +157,7 @@
 Table *     gnc_table_new (TableLayout *layout,
                            TableModel *model,
                            TableControl *control);
+void        gnc_virtual_location_init (VirtualLocation *vloc);
 
 void        gnc_table_save_state (Table *table);
 void        gnc_table_destroy (Table *table);

Modified: gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c	2006-03-07 03:40:02 UTC (rev 13509)
+++ gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c	2006-03-07 03:41:39 UTC (rev 13510)
@@ -676,10 +676,7 @@
         item_edit->reset_pos = TRUE;
         item_edit->x_offset = 0;
 
-        item_edit->virt_loc.vcell_loc.virt_row = -1;
-        item_edit->virt_loc.vcell_loc.virt_col = -1;
-        item_edit->virt_loc.phys_row_offset = -1;
-        item_edit->virt_loc.phys_col_offset = -1;
+        gnc_virtual_location_init(&item_edit->virt_loc);
 
 #ifdef USE_XIM
         item_edit->ic = NULL;



More information about the gnucash-changes mailing list