r22118 - gnucash/trunk/src - Rename internal function names for read-only option of r22107 also to "auto-read-only".

Christian Stimming cstim at code.gnucash.org
Sat Mar 24 18:35:00 EDT 2012


Author: cstim
Date: 2012-03-24 18:34:59 -0400 (Sat, 24 Mar 2012)
New Revision: 22118
Trac: http://svn.gnucash.org/trac/changeset/22118

Modified:
   gnucash/trunk/src/app-utils/app-utils.scm
   gnucash/trunk/src/app-utils/business-prefs.scm
   gnucash/trunk/src/engine/Transaction.c
   gnucash/trunk/src/engine/engine.i
   gnucash/trunk/src/libqof/qof/qofbook.c
   gnucash/trunk/src/libqof/qof/qofbook.h
   gnucash/trunk/src/libqof/qof/qofbookslots.h
   gnucash/trunk/src/libqof/qof/test/test-qofbook.c
   gnucash/trunk/src/register/ledger-core/split-register-load.c
Log:
Rename internal function names for read-only option of r22107 also to "auto-read-only".

(Initially I thought there were a relation to the "freeze" state of a
transaction, but this turned out to be not the case.)

Modified: gnucash/trunk/src/app-utils/app-utils.scm
===================================================================
--- gnucash/trunk/src/app-utils/app-utils.scm	2012-03-24 22:34:44 UTC (rev 22117)
+++ gnucash/trunk/src/app-utils/app-utils.scm	2012-03-24 22:34:59 UTC (rev 22118)
@@ -322,9 +322,9 @@
 
 (define gnc:*option-section-accounts* OPTION-SECTION-ACCOUNTS)
 (define gnc:*option-name-trading-accounts* OPTION-NAME-TRADING-ACCOUNTS)
-(define gnc:*option-name-auto-freeze-days* OPTION-NAME-AUTO-FREEZE-DAYS)
+(define gnc:*option-name-auto-readonly-days* OPTION-NAME-AUTO-READONLY-DAYS)
 
-(export gnc:*option-section-accounts* gnc:*option-name-trading-accounts* gnc:*option-name-auto-freeze-days*)
+(export gnc:*option-section-accounts* gnc:*option-name-trading-accounts* gnc:*option-name-auto-readonly-days*)
 
 (define gnc:*option-section-budgeting* OPTION-SECTION-BUDGETING)
 (define gnc:*option-name-default-budget* OPTION-NAME-DEFAULT-BUDGET)

Modified: gnucash/trunk/src/app-utils/business-prefs.scm
===================================================================
--- gnucash/trunk/src/app-utils/business-prefs.scm	2012-03-24 22:34:44 UTC (rev 22117)
+++ gnucash/trunk/src/app-utils/business-prefs.scm	2012-03-24 22:34:59 UTC (rev 22118)
@@ -133,7 +133,7 @@
 
   (reg-option
    (gnc:make-number-range-option
-	gnc:*option-section-accounts* gnc:*option-name-auto-freeze-days*
+	gnc:*option-section-accounts* gnc:*option-name-auto-readonly-days*
 	"b" (N_ "Choose the number of days after which transactions will be read-only and cannot be edited anymore.  This threshold is marked by a red line in the account register windows.  If zero, all transactions can be edited and none are read-only.")
 	0 ;; default
 	0 ;; lower bound

Modified: gnucash/trunk/src/engine/Transaction.c
===================================================================
--- gnucash/trunk/src/engine/Transaction.c	2012-03-24 22:34:44 UTC (rev 22117)
+++ gnucash/trunk/src/engine/Transaction.c	2012-03-24 22:34:59 UTC (rev 22118)
@@ -1965,12 +1965,12 @@
     gboolean result;
     g_assert(trans);
 
-    if (!qof_book_uses_autofreeze(book))
+    if (!qof_book_uses_autoreadonly(book))
     {
         return FALSE;
     }
 
-    threshold_date = qof_book_get_autofreeze_gdate(book);
+    threshold_date = qof_book_get_autoreadonly_gdate(book);
     trans_date = xaccTransGetDatePostedGDate(trans);
 
 //    g_warning("there is auto-read-only with days=%d, trans_date_day=%d, threshold_date_day=%d",

Modified: gnucash/trunk/src/engine/engine.i
===================================================================
--- gnucash/trunk/src/engine/engine.i	2012-03-24 22:34:44 UTC (rev 22117)
+++ gnucash/trunk/src/engine/engine.i	2012-03-24 22:34:59 UTC (rev 22118)
@@ -295,7 +295,7 @@
 
     SET_ENUM("OPTION-SECTION-ACCOUNTS");
     SET_ENUM("OPTION-NAME-TRADING-ACCOUNTS");
-    SET_ENUM("OPTION-NAME-AUTO-FREEZE-DAYS");
+    SET_ENUM("OPTION-NAME-AUTO-READONLY-DAYS");
 
     SET_ENUM("OPTION-SECTION-BUDGETING");
     SET_ENUM("OPTION-NAME-DEFAULT-BUDGET");

Modified: gnucash/trunk/src/libqof/qof/qofbook.c
===================================================================
--- gnucash/trunk/src/libqof/qof/qofbook.c	2012-03-24 22:34:44 UTC (rev 22117)
+++ gnucash/trunk/src/libqof/qof/qofbook.c	2012-03-24 22:34:59 UTC (rev 22118)
@@ -641,13 +641,13 @@
     return FALSE;
 }
 
-gboolean qof_book_uses_autofreeze (const QofBook *book)
+gboolean qof_book_uses_autoreadonly (const QofBook *book)
 {
     g_assert(book);
-    return (qof_book_get_num_days_autofreeze(book) != 0);
+    return (qof_book_get_num_days_autoreadonly(book) != 0);
 }
 
-gint qof_book_get_num_days_autofreeze (const QofBook *book)
+gint qof_book_get_num_days_autoreadonly (const QofBook *book)
 {
     kvp_value *kvp_val;
     double tmp;
@@ -655,12 +655,12 @@
     kvp_val = kvp_frame_get_slot_path (qof_book_get_slots (book),
                                        KVP_OPTION_PATH,
                                        OPTION_SECTION_ACCOUNTS,
-                                       OPTION_NAME_AUTO_FREEZE_DAYS,
+                                       OPTION_NAME_AUTO_READONLY_DAYS,
                                        NULL);
 
     if (kvp_val == NULL)
     {
-        //g_warning("kvp_val for slot '%s' is NULL", OPTION_NAME_AUTO_FREEZE_DAYS);
+        //g_warning("kvp_val for slot '%s' is NULL", OPTION_NAME_AUTO_READONLY_DAYS);
         return 0;
     }
 
@@ -668,11 +668,18 @@
     return (gint) tmp;
 }
 
-GDate* qof_book_get_autofreeze_gdate (const QofBook *book)
+GDate* qof_book_get_autoreadonly_gdate (const QofBook *book)
 {
-    GDate* result = gnc_g_date_new_today();
+    gint num_days;
+    GDate* result = NULL;
+
     g_assert(book);
-    g_date_subtract_days(result, qof_book_get_num_days_autofreeze(book));
+    num_days = qof_book_get_num_days_autoreadonly(book);
+    if (num_days > 0)
+    {
+        result = gnc_g_date_new_today();
+        g_date_subtract_days(result, num_days);
+    }
     return result;
 }
 

Modified: gnucash/trunk/src/libqof/qof/qofbook.h
===================================================================
--- gnucash/trunk/src/libqof/qof/qofbook.h	2012-03-24 22:34:44 UTC (rev 22117)
+++ gnucash/trunk/src/libqof/qof/qofbook.h	2012-03-24 22:34:59 UTC (rev 22118)
@@ -248,22 +248,24 @@
 /** Returns flag indicating whether this book uses trading accounts */
 gboolean qof_book_use_trading_accounts (const QofBook *book);
 
-/** Returns TRUE if the auto-freeze feature should be used, otherwise
- * FALSE. This is just a wrapper on get_num_days_autofreeze == 0. */
-gboolean qof_book_uses_autofreeze (const QofBook *book);
+/** Returns TRUE if the auto-read-only feature should be used, otherwise
+ * FALSE. This is just a wrapper on qof_book_get_num_days_autoreadonly() == 0. */
+gboolean qof_book_uses_autoreadonly (const QofBook *book);
 
-/** Returns the number of days for auto-freeze transactions. If zero,
- * the auto-freeze feature should be disabled (and uses_autofreeze
+/** Returns the number of days for auto-read-only transactions. If zero,
+ * the auto-read-only feature should be disabled (and qof_book_uses_autoreadonly()
  * returns FALSE). */
-gint qof_book_get_num_days_autofreeze (const QofBook *book);
+gint qof_book_get_num_days_autoreadonly (const QofBook *book);
 
-/** Returns the GDate that is the threshold for autofreeze. Any txn
- * with posted-date lesser or equal to this date should be set to
- * freeze.
+/** Returns the GDate that is the threshold for auto-read-only. Any txn
+ * with posted-date lesser than this date should be considered read-only.
  *
+ * If the auto-read-only feature is not used (qof_book_uses_autoreadonly()
+ * returns FALSE), NULL is returned here.
+ *
  * The returned object was allocated newly; the caller must
  * g_date_free() the object afterwards. */
-GDate* qof_book_get_autofreeze_gdate (const QofBook *book);
+GDate* qof_book_get_autoreadonly_gdate (const QofBook *book);
 
 /** Is the book shutting down? */
 gboolean qof_book_shutting_down (const QofBook *book);

Modified: gnucash/trunk/src/libqof/qof/qofbookslots.h
===================================================================
--- gnucash/trunk/src/libqof/qof/qofbookslots.h	2012-03-24 22:34:44 UTC (rev 22117)
+++ gnucash/trunk/src/libqof/qof/qofbookslots.h	2012-03-24 22:34:59 UTC (rev 22118)
@@ -64,7 +64,7 @@
 
 #define OPTION_SECTION_ACCOUNTS        N_("Accounts")
 #define OPTION_NAME_TRADING_ACCOUNTS   N_("Use Trading Accounts")
-#define OPTION_NAME_AUTO_FREEZE_DAYS   N_("Day Threshold for Read-Only Transactions (red line)")
+#define OPTION_NAME_AUTO_READONLY_DAYS N_("Day Threshold for Read-Only Transactions (red line)")
 
 #define OPTION_SECTION_BUDGETING       N_("Budgeting")
 #define OPTION_NAME_DEFAULT_BUDGET     N_("Default Budget")
@@ -75,7 +75,7 @@
  * KVP-OPTION-PATH
  * OPTION-SECTION-ACCOUNTS
  * OPTION-NAME-TRADING-ACCOUNTS
- * OPTION-NAME-AUTO-FREEZE-DAYS
+ * OPTION-NAME-AUTO-READONLY-DAYS
  * OPTION-SECTION-BUDGETING
  * OPTION-NAME-DEFAULT-BUDGET
  */

Modified: gnucash/trunk/src/libqof/qof/test/test-qofbook.c
===================================================================
--- gnucash/trunk/src/libqof/qof/test/test-qofbook.c	2012-03-24 22:34:44 UTC (rev 22117)
+++ gnucash/trunk/src/libqof/qof/test/test-qofbook.c	2012-03-24 22:34:59 UTC (rev 22118)
@@ -393,32 +393,32 @@
     const char *slot_path;
 
     /* create correct slot path */
-    slot_path = (const char *) g_strconcat( KVP_OPTION_PATH, "/", OPTION_SECTION_ACCOUNTS, "/", OPTION_NAME_AUTO_FREEZE_DAYS, NULL );
+    slot_path = (const char *) g_strconcat( KVP_OPTION_PATH, "/", OPTION_SECTION_ACCOUNTS, "/", OPTION_NAME_AUTO_READONLY_DAYS, NULL );
     g_assert( slot_path != NULL );
 
     g_test_message( "Testing default: No auto-freeze days are set" );
-    g_assert( qof_book_uses_autofreeze( fixture-> book ) == FALSE );
-    g_assert( qof_book_get_num_days_autofreeze( fixture-> book ) == 0 );
+    g_assert( qof_book_uses_autoreadonly( fixture-> book ) == FALSE );
+    g_assert( qof_book_get_num_days_autoreadonly( fixture-> book ) == 0 );
 
     g_test_message( "Testing with incorrect slot path and some correct value - 17" );
-    kvp_frame_set_double(qof_book_get_slots(fixture->book), OPTION_NAME_AUTO_FREEZE_DAYS, 17);
-    g_assert( qof_book_uses_autofreeze( fixture-> book ) == FALSE );
-    g_assert( qof_book_get_num_days_autofreeze( fixture-> book ) == 0 );
+    kvp_frame_set_double(qof_book_get_slots(fixture->book), OPTION_NAME_AUTO_READONLY_DAYS, 17);
+    g_assert( qof_book_uses_autoreadonly( fixture-> book ) == FALSE );
+    g_assert( qof_book_get_num_days_autoreadonly( fixture-> book ) == 0 );
 
     g_test_message( "Testing when setting this correctly with some correct value - 17" );
     kvp_frame_set_double(qof_book_get_slots(fixture->book), slot_path, 17);
-    g_assert( qof_book_uses_autofreeze( fixture-> book ) == TRUE );
-    g_assert( qof_book_get_num_days_autofreeze( fixture-> book ) == 17 );
+    g_assert( qof_book_uses_autoreadonly( fixture-> book ) == TRUE );
+    g_assert( qof_book_get_num_days_autoreadonly( fixture-> book ) == 17 );
 
     g_test_message( "Testing when setting this correctly to zero again" );
     kvp_frame_set_double(qof_book_get_slots(fixture->book), slot_path, 0);
-    g_assert( qof_book_uses_autofreeze( fixture-> book ) == FALSE );
-    g_assert( qof_book_get_num_days_autofreeze( fixture-> book ) == 0 );
+    g_assert( qof_book_uses_autoreadonly( fixture-> book ) == FALSE );
+    g_assert( qof_book_get_num_days_autoreadonly( fixture-> book ) == 0 );
 
     g_test_message( "Testing when setting this correctly with some correct value - 32" );
     kvp_frame_set_double(qof_book_get_slots(fixture->book), slot_path, 32);
-    g_assert( qof_book_uses_autofreeze( fixture-> book ) == TRUE );
-    g_assert( qof_book_get_num_days_autofreeze( fixture-> book ) == 32 );
+    g_assert( qof_book_uses_autoreadonly( fixture-> book ) == TRUE );
+    g_assert( qof_book_get_num_days_autoreadonly( fixture-> book ) == 32 );
 
 }
 

Modified: gnucash/trunk/src/register/ledger-core/split-register-load.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-load.c	2012-03-24 22:34:44 UTC (rev 22117)
+++ gnucash/trunk/src/register/ledger-core/split-register-load.c	2012-03-24 22:34:59 UTC (rev 22118)
@@ -269,7 +269,7 @@
     gboolean multi_line;
     gboolean dynamic;
     gboolean we_own_slist = FALSE;
-    gboolean use_autofreeze = qof_book_uses_autofreeze(gnc_get_current_book());
+    gboolean use_autoreadonly = qof_book_uses_autoreadonly(gnc_get_current_book());
 
     VirtualCellLocation vcell_loc;
     VirtualLocation save_loc;
@@ -277,7 +277,7 @@
     int new_trans_split_row = -1;
     int new_trans_row = -1;
     int new_split_row = -1;
-    time_t present, autofreeze_time;
+    time_t present, autoreadonly_time;
 
     g_return_if_fail(reg);
     table = reg->table;
@@ -435,8 +435,8 @@
     /* get the current time and reset the dividing row */
     present = gnc_timet_get_today_end ();
     {
-        GDate *d = qof_book_get_autofreeze_gdate(gnc_get_current_book());
-        autofreeze_time = timespecToTime_t(gdate_to_timespec(*d));
+        GDate *d = qof_book_get_autoreadonly_gdate(gnc_get_current_book());
+        autoreadonly_time = timespecToTime_t(gdate_to_timespec(*d));
         g_date_free(d);
     }
 
@@ -538,10 +538,10 @@
         }
 
         if (info->show_present_divider &&
-                use_autofreeze &&
+                use_autoreadonly &&
                 !found_divider_upper)
         {
-            if (xaccTransGetDate (trans) >= autofreeze_time)
+            if (xaccTransGetDate (trans) >= autoreadonly_time)
             {
                 table->model->dividing_row_upper = vcell_loc.virt_row;
                 found_divider_upper = TRUE;
@@ -591,7 +591,7 @@
 
     /* No upper divider yet? Store it now */
     if (info->show_present_divider &&
-            use_autofreeze &&
+            use_autoreadonly &&
             !found_divider_upper && need_divider_upper)
     {
         table->model->dividing_row_upper = vcell_loc.virt_row;



More information about the gnucash-changes mailing list