r15739 - gnucash/trunk - Use a single key for check position names instead of a series of

David Hampton hampton at cvs.gnucash.org
Mon Mar 19 21:08:14 EDT 2007


Author: hampton
Date: 2007-03-19 21:08:12 -0400 (Mon, 19 Mar 2007)
New Revision: 15739
Trac: http://svn.gnucash.org/trac/changeset/15739

Modified:
   gnucash/trunk/checks/gnomeprint/quicken.chk
   gnucash/trunk/checks/gnomeprint/quicken_wallet.chk
   gnucash/trunk/checks/quicken.chk
   gnucash/trunk/checks/quicken_wallet.chk
   gnucash/trunk/src/gnome/dialog-print-check.c
Log:
Use a single key for check position names instead of a series of
manufactured key names, one key per name.


Modified: gnucash/trunk/checks/gnomeprint/quicken.chk
===================================================================
--- gnucash/trunk/checks/gnomeprint/quicken.chk	2007-03-18 22:45:08 UTC (rev 15738)
+++ gnucash/trunk/checks/gnomeprint/quicken.chk	2007-03-20 01:08:12 UTC (rev 15739)
@@ -8,9 +8,7 @@
 
 [Check Positions]
 Height = 252.0
-Name_1 = Top
-Name_2 = Middle
-Name_3 = Bottom
+Names = Top;Middle;Bottom
 
 [Check Items]
 Type_1 = PAYEE

Modified: gnucash/trunk/checks/gnomeprint/quicken_wallet.chk
===================================================================
--- gnucash/trunk/checks/gnomeprint/quicken_wallet.chk	2007-03-18 22:45:08 UTC (rev 15738)
+++ gnucash/trunk/checks/gnomeprint/quicken_wallet.chk	2007-03-20 01:08:12 UTC (rev 15739)
@@ -8,9 +8,7 @@
 
 [Check Positions]
 Height = 204.0
-Name_1 = Top
-Name_2 = Middle
-Name_3 = Bottom
+Names = Top;Middle;Bottom
 
 [Check Items]
 Type_1 = PAYEE

Modified: gnucash/trunk/checks/quicken.chk
===================================================================
--- gnucash/trunk/checks/quicken.chk	2007-03-18 22:45:08 UTC (rev 15738)
+++ gnucash/trunk/checks/quicken.chk	2007-03-20 01:08:12 UTC (rev 15739)
@@ -8,9 +8,7 @@
 
 [Check Positions]
 Height = 252.0
-Name_1 = Top
-Name_2 = Middle
-Name_3 = Bottom
+Names = Top;Middle;Bottom
 
 [Check Items]
 Type_1 = PAYEE

Modified: gnucash/trunk/checks/quicken_wallet.chk
===================================================================
--- gnucash/trunk/checks/quicken_wallet.chk	2007-03-18 22:45:08 UTC (rev 15738)
+++ gnucash/trunk/checks/quicken_wallet.chk	2007-03-20 01:08:12 UTC (rev 15739)
@@ -8,9 +8,7 @@
 
 [Check Positions]
 Height = 204.0
-Name_1 = Top
-Name_2 = Middle
-Name_3 = Bottom
+Names = Top;Middle;Bottom
 
 [Check Items]
 Type_1 = PAYEE

Modified: gnucash/trunk/src/gnome/dialog-print-check.c
===================================================================
--- gnucash/trunk/src/gnome/dialog-print-check.c	2007-03-18 22:45:08 UTC (rev 15738)
+++ gnucash/trunk/src/gnome/dialog-print-check.c	2007-03-20 01:08:12 UTC (rev 15739)
@@ -87,7 +87,7 @@
 #define KF_KEY_ALIGN       "Align"
 #define KF_KEY_SHOW_GRID   "Show_Grid"
 #define KF_KEY_SHOW_BOXES  "Show_Boxes"
-#define KF_KEY_NAME        "Name"
+#define KF_KEY_NAMES       "Names"
 #define KF_KEY_HEIGHT      "Height"
 #define KF_KEY_TYPE        "Type"
 #define KF_KEY_COORDS      "Coords"
@@ -798,8 +798,9 @@
 {
     GError *error = NULL;
     GSList *list = NULL;
-    gchar *key, *name;
-    int i;
+    gchar *key, **names;
+    gsize length;
+    gint i;
 
     key = g_strdup_printf("%s", KF_KEY_HEIGHT);
     format->height = g_key_file_get_double(key_file, KF_GROUP_POS, key, &error);
@@ -813,32 +814,30 @@
             g_warning("Check file %s, error reading group %s, key %s: %s",
                       file, KF_GROUP_POS, key, error->message);
             g_free(key);
-            return list;
+            return NULL;
         }
     }
 
-    for (i = 1;; i++) {
-        key = g_strdup_printf("%s_%d", KF_KEY_NAME, i);
-        name = g_key_file_get_string(key_file, KF_GROUP_POS, key, &error);
-        if (error) {
-            if ((error->domain == G_KEY_FILE_ERROR)
-                && ((error->code == G_KEY_FILE_ERROR_GROUP_NOT_FOUND)
-                    || (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND))) {
-                /* This is the expected exit from this function. */
-                g_free(key);
-                return list;
-            }
-            g_warning("Check file %s, error reading group %s, key %s: %s",
-                      file, KF_GROUP_POS, key, error->message);
-            g_free(key);
-            return list;
+    names = g_key_file_get_string_list(key_file, KF_GROUP_POS, KF_KEY_NAMES,
+                                       &length, &error);
+    if (error) {
+        if ((error->domain == G_KEY_FILE_ERROR)
+            && ((error->code == G_KEY_FILE_ERROR_GROUP_NOT_FOUND)
+                || (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND))) {
+          /* This is the expected exit from this function. */
+          g_free(key);
+          return NULL;
         }
+        g_warning("Check file %s, error reading group %s, key %s: %s",
+                  file, KF_GROUP_POS, key, error->message);
         g_free(key);
-
-        list = g_slist_append(list, name);
+        return list;
     }
 
-    /* Should never be reached. */
+    for (i = 0; i < length; i++)
+      list = g_slist_append(list, g_strdup(names[i]));
+
+    g_strfreev(names);
     return list;
 }
 



More information about the gnucash-changes mailing list