Bill Gribble's query and finder patch. Build system fixes.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2405 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas
2000-06-04 21:27:48 +00:00
parent 7c9f8a47de
commit 6bf7915b89
22 changed files with 642 additions and 916 deletions
+6
View File
@@ -1,3 +1,9 @@
2000-06-04 Dave Peticolas <dave@krondo.com>
* src/register/quickfillcell.c (quick_modify): before updating the
original copy, make sure it's still the same as the old value,
modulo case.
2000-06-03 Dave Peticolas <dave@krondo.com>
* src/engine/FileIO.c: John Goerzen's patch for 64-bit
+2 -2
View File
@@ -76,7 +76,7 @@
</li>
<li>
<b><a href="xacc-quicken.html#QIF">Quicken File
<b><a href="xacc-qif-import.html#QIF">Quicken File
Import</a>.</b>
<p>Imports Quicken-style QIF files.</p>
@@ -332,7 +332,7 @@
<dt><a href="mailto:grib@billgribble.com">Bill
Gribble</a></dt>
<dd>qif importation code</dd>
<dd>QIF import code, check printing, transaction find dialog</dd>
<dt><a href="mailto:otto@bug.redhat.com">Otto
Hammersmith</a></dt>
+1 -1
View File
@@ -39,7 +39,7 @@
<li><a href="bofa-mym.html">Importing MYM (Managing Your
Money) Files</a></li>
<li><a href="xacc-quicken.html">A Guide for Former Users of
<li><a href="xacc-qif-import.html">A Guide for Former Users of
Quicken(TM)</a></li>
<li>
+119 -95
View File
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-06-02 12:12-0700\n"
"POT-Creation-Date: 2000-06-04 13:37-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -1176,7 +1176,7 @@ msgid "About"
msgstr ""
#: messages-i18n.c:276 po/guile_strings.txt:64
#: src/gnome/glade-gnc-dialogs.c:1777
#: src/gnome/glade-gnc-dialogs.c:1784
msgid "Account"
msgstr ""
@@ -1193,7 +1193,7 @@ msgstr ""
msgid "AutoDep"
msgstr ""
#: messages-i18n.c:280 src/gnome/glade-gnc-dialogs.c:2391
#: messages-i18n.c:280 src/gnome/glade-gnc-dialogs.c:2398
msgid "Action"
msgstr ""
@@ -1206,7 +1206,7 @@ msgid "Ago"
msgstr ""
#: messages-i18n.c:283 po/guile_strings.txt:57
#: src/gnome/glade-gnc-dialogs.c:2131
#: src/gnome/glade-gnc-dialogs.c:2138
msgid "Amount"
msgstr ""
@@ -1281,7 +1281,7 @@ msgstr ""
msgid "Checking"
msgstr ""
#: messages-i18n.c:302
#: messages-i18n.c:302 src/gnome/glade-gnc-dialogs.c:2449
msgid "Cleared"
msgstr ""
@@ -1298,7 +1298,7 @@ msgid "Create"
msgstr ""
#: messages-i18n.c:306 po/guile_strings.txt:254
#: src/gnome/glade-gnc-dialogs.c:570 src/gnome/glade-gnc-dialogs.c:2075
#: src/gnome/glade-gnc-dialogs.c:570 src/gnome/glade-gnc-dialogs.c:2082
msgid "Credit"
msgstr ""
@@ -1312,7 +1312,7 @@ msgid "Currency"
msgstr ""
#: messages-i18n.c:309 po/guile_strings.txt:6
#: src/gnome/glade-gnc-dialogs.c:1913
#: src/gnome/glade-gnc-dialogs.c:1920
msgid "Date"
msgstr ""
@@ -1321,7 +1321,7 @@ msgid "Days"
msgstr ""
#: messages-i18n.c:311 po/guile_strings.txt:38
#: src/gnome/glade-gnc-dialogs.c:2078
#: src/gnome/glade-gnc-dialogs.c:2085
msgid "Debit"
msgstr ""
@@ -1337,7 +1337,7 @@ msgstr ""
msgid "Deficit"
msgstr ""
#: messages-i18n.c:315 src/gnome/glade-gnc-dialogs.c:2810
#: messages-i18n.c:315 src/gnome/glade-gnc-dialogs.c:2868
msgid "Delete"
msgstr ""
@@ -1350,7 +1350,7 @@ msgid "Depreciation"
msgstr ""
#: messages-i18n.c:318 po/guile_strings.txt:152
#: src/gnome/glade-gnc-dialogs.c:1971
#: src/gnome/glade-gnc-dialogs.c:1978
msgid "Description"
msgstr ""
@@ -1412,7 +1412,7 @@ msgstr ""
msgid "File"
msgstr ""
#: messages-i18n.c:333 src/gnome/glade-gnc-dialogs.c:2465
#: messages-i18n.c:333 src/gnome/glade-gnc-dialogs.c:2523
msgid "Find"
msgstr ""
@@ -1475,7 +1475,7 @@ msgid "LTCG"
msgstr ""
#: messages-i18n.c:348 po/guile_strings.txt:32
#: src/gnome/glade-gnc-dialogs.c:2189
#: src/gnome/glade-gnc-dialogs.c:2196
msgid "Memo"
msgstr ""
@@ -1540,7 +1540,7 @@ msgstr ""
msgid "Preferences"
msgstr ""
#: messages-i18n.c:364 src/gnome/glade-gnc-dialogs.c:2333
#: messages-i18n.c:364 src/gnome/glade-gnc-dialogs.c:2340
msgid "Price"
msgstr ""
@@ -1653,7 +1653,7 @@ msgstr ""
msgid "To"
msgstr ""
#: messages-i18n.c:392 src/gnome/glade-gnc-dialogs.c:2557
#: messages-i18n.c:392 src/gnome/glade-gnc-dialogs.c:2615
msgid "Today"
msgstr ""
@@ -2395,7 +2395,7 @@ msgstr ""
msgid "Help for first option"
msgstr ""
#: po/guile_strings.txt:203 src/gnome/glade-gnc-dialogs.c:2029
#: po/guile_strings.txt:203 src/gnome/glade-gnc-dialogs.c:2036
msgid "Number"
msgstr ""
@@ -2654,8 +2654,8 @@ msgstr ""
msgid "Plot Type"
msgstr ""
#: po/guile_strings.txt:275 src/gnome/glade-gnc-dialogs.c:2666
#: src/gnome/glade-gnc-dialogs.c:2674
#: po/guile_strings.txt:275 src/gnome/glade-gnc-dialogs.c:2724
#: src/gnome/glade-gnc-dialogs.c:2732
msgid "Budget"
msgstr ""
@@ -2723,7 +2723,7 @@ msgstr ""
msgid "Report end date"
msgstr ""
#: po/guile_strings.txt:292 src/gnome/glade-gnc-dialogs.c:1756
#: po/guile_strings.txt:292 src/gnome/glade-gnc-dialogs.c:1763
msgid "None"
msgstr ""
@@ -2813,7 +2813,7 @@ msgstr ""
msgid "Profit/Loss"
msgstr ""
#: po/guile_strings.txt:318 src/gnome/glade-gnc-dialogs.c:2261
#: po/guile_strings.txt:318 src/gnome/glade-gnc-dialogs.c:2268
msgid "Shares"
msgstr ""
@@ -2917,7 +2917,7 @@ msgstr ""
msgid "Display"
msgstr ""
#: po/guile_strings.txt:345 src/gnome/glade-gnc-dialogs.c:3056
#: po/guile_strings.txt:345 src/gnome/glade-gnc-dialogs.c:3114
msgid "Nominal"
msgstr ""
@@ -2983,8 +2983,8 @@ msgstr ""
msgid "You must specify a currency."
msgstr ""
#: src/gnome/dialog-qif-import.c:270 src/gnome/dialog-qif-import.c:638
#: src/gnome/dialog-qif-import.c:701 src/gnome/dialog-qif-import.c:799
#: src/gnome/dialog-qif-import.c:270 src/gnome/dialog-qif-import.c:619
#: src/gnome/dialog-qif-import.c:676 src/gnome/dialog-qif-import.c:774
msgid "QIF File scheme code not loaded properly."
msgstr ""
@@ -2992,7 +2992,7 @@ msgstr ""
msgid "QIF File already loaded. Reload with current settings?"
msgstr ""
#: src/gnome/dialog-qif-import.c:729 src/gnome/dialog-qif-import.c:827
#: src/gnome/dialog-qif-import.c:704 src/gnome/dialog-qif-import.c:802
msgid "Something is very wrong with QIF Importing."
msgstr ""
@@ -3020,8 +3020,8 @@ msgstr ""
msgid "Currency:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:198 src/gnome/glade-gnc-dialogs.c:1854
#: src/gnome/glade-gnc-dialogs.c:1906
#: src/gnome/glade-gnc-dialogs.c:198 src/gnome/glade-gnc-dialogs.c:1861
#: src/gnome/glade-gnc-dialogs.c:1913
msgid "Select ..."
msgstr ""
@@ -3065,8 +3065,8 @@ msgstr ""
msgid "Selected account:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:514 src/gnome/glade-gnc-dialogs.c:2873
#: src/gnome/glade-gnc-dialogs.c:2960
#: src/gnome/glade-gnc-dialogs.c:514 src/gnome/glade-gnc-dialogs.c:2931
#: src/gnome/glade-gnc-dialogs.c:3018
msgid "Description:"
msgstr ""
@@ -3106,7 +3106,7 @@ msgstr ""
msgid "Pages to print:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:835 src/gnome/glade-gnc-dialogs.c:1750
#: src/gnome/glade-gnc-dialogs.c:835 src/gnome/glade-gnc-dialogs.c:1757
msgid "All"
msgstr ""
@@ -3263,247 +3263,271 @@ msgstr ""
msgid " "
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:1700
#: src/gnome/glade-gnc-dialogs.c:1707
msgid "Find Transactions"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:1715
#: src/gnome/glade-gnc-dialogs.c:1722
msgid "Match Accounts"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:1736
#: src/gnome/glade-gnc-dialogs.c:1743
msgid "Find transactions affecting"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:1753
#: src/gnome/glade-gnc-dialogs.c:1760
msgid "Any"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:1762
#: src/gnome/glade-gnc-dialogs.c:1769
msgid "selected accounts:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:1784
#: src/gnome/glade-gnc-dialogs.c:1791
msgid "Match Date"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:1799
#: src/gnome/glade-gnc-dialogs.c:1806
msgid "Find transactions occurring between the dates:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:1823 src/gnome/glade-gnc-dialogs.c:1839
#: src/gnome/glade-gnc-dialogs.c:1876 src/gnome/glade-gnc-dialogs.c:1891
#: src/gnome/glade-gnc-dialogs.c:1830 src/gnome/glade-gnc-dialogs.c:1846
#: src/gnome/glade-gnc-dialogs.c:1883 src/gnome/glade-gnc-dialogs.c:1898
msgid "/"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:1920 src/gnome/glade-gnc-dialogs.c:1978
#: src/gnome/glade-gnc-dialogs.c:1927 src/gnome/glade-gnc-dialogs.c:1985
msgid "Match Description"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:1935
#: src/gnome/glade-gnc-dialogs.c:1942
msgid "Find transactions whose Description matches:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:1957 src/gnome/glade-gnc-dialogs.c:2015
#: src/gnome/glade-gnc-dialogs.c:2175 src/gnome/glade-gnc-dialogs.c:2377
msgid "Case sensitive"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:1964 src/gnome/glade-gnc-dialogs.c:2022
#: src/gnome/glade-gnc-dialogs.c:2182 src/gnome/glade-gnc-dialogs.c:2384
msgid "Case sensitive"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:1971 src/gnome/glade-gnc-dialogs.c:2029
#: src/gnome/glade-gnc-dialogs.c:2189 src/gnome/glade-gnc-dialogs.c:2391
msgid "Regular expression"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:1993
#: src/gnome/glade-gnc-dialogs.c:2000
msgid "Find transactions whose Number matches:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2036
#: src/gnome/glade-gnc-dialogs.c:2043
msgid "Match Amount"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2058
#: src/gnome/glade-gnc-dialogs.c:2065
msgid "Find "
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2072
#: src/gnome/glade-gnc-dialogs.c:2079
msgid "Credit or Debit"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2083
#: src/gnome/glade-gnc-dialogs.c:2090
msgid "splits having amounts of:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2104 src/gnome/glade-gnc-dialogs.c:2233
#: src/gnome/glade-gnc-dialogs.c:2305
#: src/gnome/glade-gnc-dialogs.c:2111 src/gnome/glade-gnc-dialogs.c:2240
#: src/gnome/glade-gnc-dialogs.c:2312
msgid "At least"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2107
#: src/gnome/glade-gnc-dialogs.c:2114
msgid "At most "
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2110 src/gnome/glade-gnc-dialogs.c:2239
#: src/gnome/glade-gnc-dialogs.c:2311
#: src/gnome/glade-gnc-dialogs.c:2117 src/gnome/glade-gnc-dialogs.c:2246
#: src/gnome/glade-gnc-dialogs.c:2318
msgid "Exactly"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2138
#: src/gnome/glade-gnc-dialogs.c:2145
msgid "Match Memo"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2153
#: src/gnome/glade-gnc-dialogs.c:2160
msgid "Find splits whose Memo matches:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2196
#: src/gnome/glade-gnc-dialogs.c:2203
msgid "Match number of shares"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2211
#: src/gnome/glade-gnc-dialogs.c:2218
msgid "Find securities transactions of:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2236 src/gnome/glade-gnc-dialogs.c:2308
#: src/gnome/glade-gnc-dialogs.c:2243 src/gnome/glade-gnc-dialogs.c:2315
msgid "At most"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2253
#: src/gnome/glade-gnc-dialogs.c:2260
msgid "shares"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2268
#: src/gnome/glade-gnc-dialogs.c:2275
msgid "Match share price"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2283
#: src/gnome/glade-gnc-dialogs.c:2290
msgid "Find securities transactions with share price of:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2340
#: src/gnome/glade-gnc-dialogs.c:2347
msgid "Match Action"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2355
#: src/gnome/glade-gnc-dialogs.c:2362
msgid "Find transactions whose Action matches:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2412
msgid "Type of search"
#: src/gnome/glade-gnc-dialogs.c:2405
msgid "Match Cleared state"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2426
msgid "New search"
#: src/gnome/glade-gnc-dialogs.c:2420
msgid "Find transactions whose Cleared status is:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2434
msgid "Refine current search"
#: src/gnome/glade-gnc-dialogs.c:2428
msgid "Not cleared (n)"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2435
msgid "Cleared (c)"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2442
msgid "Reconciled (y)"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2470
msgid "Type of search"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2484
msgid "New search"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2492
msgid "Refine current search"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2500
msgid "Add results to current search"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2450
#: src/gnome/glade-gnc-dialogs.c:2508
msgid "Delete results from current search"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2532
#: src/gnome/glade-gnc-dialogs.c:2590
msgid "Select Date"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2698
#: src/gnome/glade-gnc-dialogs.c:2756
msgid "Name:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2720
#: src/gnome/glade-gnc-dialogs.c:2778
msgid "The name of this budget"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2729
#: src/gnome/glade-gnc-dialogs.c:2787
msgid "Budget Entries"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2777
#: src/gnome/glade-gnc-dialogs.c:2835
msgid "label773"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2801
#: src/gnome/glade-gnc-dialogs.c:2859
msgid "Add"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2808
#: src/gnome/glade-gnc-dialogs.c:2866
msgid "Add a new entry or subentry"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2817
#: src/gnome/glade-gnc-dialogs.c:2875
msgid "Delete the selected entry or subentry"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2832
#: src/gnome/glade-gnc-dialogs.c:2890
msgid "Move the selected item up"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2840
#: src/gnome/glade-gnc-dialogs.c:2898
msgid "Move the selected item down"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2849
#: src/gnome/glade-gnc-dialogs.c:2907
msgid "Entry"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2882
#: src/gnome/glade-gnc-dialogs.c:2940
msgid "Type:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2921
#: src/gnome/glade-gnc-dialogs.c:2979
msgid "Normal"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2924
#: src/gnome/glade-gnc-dialogs.c:2982
msgid "No Total"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2929
#: src/gnome/glade-gnc-dialogs.c:2987
msgid "Matching Transactions..."
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2936
#: src/gnome/glade-gnc-dialogs.c:2994
msgid "Subentry"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2969
#: src/gnome/glade-gnc-dialogs.c:3027
msgid "Amount:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2978
#: src/gnome/glade-gnc-dialogs.c:3036
msgid "Period:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2987
#: src/gnome/glade-gnc-dialogs.c:3045
msgid "Mechanism:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:2996
#: src/gnome/glade-gnc-dialogs.c:3054
msgid "Bill Day:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:3005
#: src/gnome/glade-gnc-dialogs.c:3063
msgid "Grace Period:"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:3059
#: src/gnome/glade-gnc-dialogs.c:3117
msgid "Bill"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:3062
#: src/gnome/glade-gnc-dialogs.c:3120
msgid "Recurring"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:3065
#: src/gnome/glade-gnc-dialogs.c:3123
msgid "Contingency"
msgstr ""
#: src/gnome/glade-gnc-dialogs.c:3199
msgid "window1"
msgstr ""
#: src/gnome/print-session.c:233
msgid "You must select a printer first."
msgstr ""
+2 -1
View File
@@ -18,7 +18,8 @@ LDADD = \
engine/libgncengine.la \
@GNOME_LIBS@ \
@G_WRAP_LINK_ARGS@ \
@GUILE_LINK_ARGS@
@GUILE_LINK_ARGS@ \
@INTLLIBS@
gnucash_SOURCES = \
MultiLedger.c \
+1 -1
View File
@@ -126,7 +126,7 @@ bin_PROGRAMS = gnucash
# dependencies need to go away. The libgwrap one in particular is a
# problem with the current version of gwrap, and will go away when
# that's fixed.
LDADD = gnome/libgncgnome.a register/libgncregister.a register/gnome/libgncregistergnome.a guile/libgncguile.a gnome/libgncgnome.a engine/libgncengine.la @GNOME_LIBS@ @G_WRAP_LINK_ARGS@ @GUILE_LINK_ARGS@
LDADD = gnome/libgncgnome.a register/libgncregister.a register/gnome/libgncregistergnome.a guile/libgncguile.a gnome/libgncgnome.a engine/libgncengine.la @GNOME_LIBS@ @G_WRAP_LINK_ARGS@ @GUILE_LINK_ARGS@ @INTLLIBS@
gnucash_SOURCES = MultiLedger.c SplitLedger.c Destroy.c EuroUtils.c FileDialog.c Refresh.c
+168 -138
View File
@@ -40,9 +40,51 @@
static short module = MOD_QUERY;
/* the Query makes a subset of all splits based on 3 things:
* - an AND-OR tree of predicates which combine to make a
* split filter
* - a sorting order for the matched splits
* - a chop limit which gives the maximum number of sorted
* splits to return. */
struct _querystruct {
/* terms is a list of the OR-terms in a sum-of-products
* logical expression. */
GList * terms;
/* sorting and chopping is independent of the search filter */
sort_type_t primary_sort;
sort_type_t secondary_sort;
sort_type_t tertiary_sort;
gncBoolean sort_increasing;
int max_splits;
/* cache the results so we don't have to run the whole search
* again until it's really necessary */
int changed;
AccountGroup * acct_group;
Split ** split_list;
};
/*******************************************************************
* predicates for standard match types
*******************************************************************/
static int xaccAccountMatchPredicate(Split * s, PredicateData * pd);
static int xaccDescriptionMatchPredicate(Split * s, PredicateData * pd);
static int xaccActionMatchPredicate(Split * s, PredicateData * pd);
static int xaccNumberMatchPredicate(Split * s, PredicateData * pd);
static int xaccAmountMatchPredicate(Split * s, PredicateData * pd);
static int xaccDateMatchPredicate(Split * s, PredicateData * pd);
static int xaccMemoMatchPredicate(Split * s, PredicateData * pd);
static int xaccSharePriceMatchPredicate(Split * s, PredicateData * pd);
static int xaccSharesMatchPredicate(Split * s, PredicateData * pd);
static int xaccClearedMatchPredicate(Split * s, PredicateData * pd);
/********************************************************************
********************************************************************/
#if 0
static void
print_query(Query * q) {
GList * aterms;
@@ -65,6 +107,8 @@ print_query(Query * q) {
}
printf("\n");
}
#endif
/********************************************************************
* xaccMallocQuery
@@ -94,6 +138,10 @@ xaccInitQuery(Query * q, QueryTerm * initial_term) {
or->data = and;
}
if(q->terms) {
xaccQueryClear(q);
}
q->terms = or;
q->split_list = NULL;
q->changed = 1;
@@ -114,7 +162,7 @@ xaccInitQuery(Query * q, QueryTerm * initial_term) {
* allow quick pass-off of results.
********************************************************************/
void
static void
xaccQuerySwapTerms(Query * q1, Query * q2) {
GList * g;
g = q1->terms;
@@ -126,24 +174,6 @@ xaccQuerySwapTerms(Query * q1, Query * q2) {
}
/********************************************************************
* xaccQuerySingleTerm
* initialize the query with 1 term
********************************************************************/
void
xaccQuerySingleTerm(Query * q, QueryTerm * qt) {
GList * or = NULL;
GList * and = NULL;
or = g_list_alloc();
and = g_list_alloc();
and->data = qt;
or->data = and;
q->terms = or;
}
/********************************************************************
* xaccQueryHasTerms
* returns the number of terms in the query, which is generally
@@ -213,9 +243,6 @@ xaccQueryInvert(Query * q) {
num_or_terms = g_list_length(q->terms);
DEBUG("inverting query: ");
DEBUGCMD (print_query(q));
switch(num_or_terms) {
case 0:
retval = xaccMallocQuery();
@@ -289,8 +316,9 @@ xaccQueryMerge(Query * q1, Query * q2, QueryOp op) {
Query * t1, * t2;
GList * i, * j;
DEBUG("merging queries: op=%d\n", op);
DEBUGCMD(print_query(q1); print_query(q2);)
if(!q1 || !q2 || !(q1->acct_group == q2->acct_group)) {
return NULL;
}
switch(op) {
case QUERY_OR:
@@ -827,69 +855,10 @@ xaccQueryAddAccountMatch(Query * q, Account ** acclist, acct_match_t how,
qt->data.type = PD_ACCOUNT;
qt->data.acct.how = how;
qt->data.acct.accounts = acclist;
xaccQuerySingleTerm(qs, qt);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
else {
qr = xaccQueryMerge(q, qs, QUERY_OR);
}
xaccQuerySwapTerms(q, qr);
xaccFreeQuery(qs);
xaccFreeQuery(qr);
}
/********************************************************************
* xaccQueryAddTransMatch
* match splits in the given transaction
********************************************************************/
void
xaccQueryAddTransMatch(Query * q, Transaction * trans, int how,
QueryOp op) {
Query * qs = xaccMallocQuery();
QueryTerm * qt = g_new0(QueryTerm, 1);
Query * qr;
qt->p = & xaccTransMatchPredicate;
qt->sense = how;
qt->data.type = PD_TRANS;
qt->data.trans.trans = trans;
xaccQuerySingleTerm(qs, qt);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
else {
qr = xaccQueryMerge(q, qs, QUERY_OR);
}
xaccQuerySwapTerms(q, qr);
xaccFreeQuery(qs);
xaccFreeQuery(qr);
}
/********************************************************************
* xaccQueryAddSplitMatch
* match exactly the given split
********************************************************************/
void
xaccQueryAddSplitMatch(Query * q, Split * split, int how,
QueryOp op) {
Query * qs = xaccMallocQuery();
QueryTerm * qt = g_new0(QueryTerm, 1);
Query * qr;
qt->p = & xaccSplitMatchPredicate;
qt->sense = how;
qt->data.type = PD_SPLIT;
qt->data.split.split = split;
xaccQuerySingleTerm(qs, qt);
xaccInitQuery(qs, qt);
xaccQuerySetGroup(qs, q->acct_group);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
@@ -925,7 +894,9 @@ xaccQueryAddSingleAccountMatch(Query * q, Account * acct,
qt->data.acct.how = ACCT_MATCH_ANY;
qt->data.acct.accounts = acctlist;
xaccQuerySingleTerm(qs, qt);
xaccInitQuery(qs, qt);
xaccQuerySetGroup(qs, q->acct_group);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
@@ -979,7 +950,9 @@ xaccQueryAddDescriptionMatch(Query * q, char * matchstring,
qt->data.str.matchstring = teststr;
}
xaccQuerySingleTerm(qs, qt);
xaccInitQuery(qs, qt);
xaccQuerySetGroup(qs, q->acct_group);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
@@ -1033,7 +1006,9 @@ xaccQueryAddMemoMatch(Query * q, char * matchstring,
qt->data.str.matchstring = teststr;
}
xaccQuerySingleTerm(qs, qt);
xaccInitQuery(qs, qt);
xaccQuerySetGroup(qs, q->acct_group);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
@@ -1066,7 +1041,9 @@ xaccQueryAddDateMatch(Query * q,
qt->data.date.start = gnc_dmy2timespec(sday, smonth, syear);
qt->data.date.end = gnc_dmy2timespec(eday, emonth, eyear);
xaccQuerySingleTerm(qs, qt);
xaccInitQuery(qs, qt);
xaccQuerySetGroup(qs, q->acct_group);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
@@ -1098,7 +1075,9 @@ xaccQueryAddDateMatchTS(Query * q,
qt->data.date.start = sts;
qt->data.date.end = ets;
xaccQuerySingleTerm(qs, qt);
xaccInitQuery(qs, qt);
xaccQuerySetGroup(qs, q->acct_group);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
@@ -1138,7 +1117,9 @@ xaccQueryAddDateMatchTT(Query * q,
qt->data.date.start = sts;
qt->data.date.end = ets;
xaccQuerySingleTerm(qs, qt);
xaccInitQuery(qs, qt);
xaccQuerySetGroup(qs, q->acct_group);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
@@ -1190,7 +1171,9 @@ xaccQueryAddNumberMatch(Query * q, char * matchstring, int case_sens,
qt->data.str.matchstring = teststr;
}
xaccQuerySingleTerm(qs, qt);
xaccInitQuery(qs, qt);
xaccQuerySetGroup(qs, q->acct_group);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
@@ -1243,7 +1226,9 @@ xaccQueryAddActionMatch(Query * q, char * matchstring, int case_sens,
qt->data.str.matchstring = teststr;
}
xaccQuerySingleTerm(qs, qt);
xaccInitQuery(qs, qt);
xaccQuerySetGroup(qs, q->acct_group);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
@@ -1277,7 +1262,9 @@ xaccQueryAddAmountMatch(Query * q, double amt,
qt->data.amount.amt_sgn = amt_sgn;
qt->data.amount.amount = amt;
xaccQuerySingleTerm(qs, qt);
xaccInitQuery(qs, qt);
xaccQuerySetGroup(qs, q->acct_group);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
@@ -1310,7 +1297,9 @@ xaccQueryAddSharePriceMatch(Query * q, double amt,
qt->data.amount.amt_sgn = 0;
qt->data.amount.amount = amt;
xaccQuerySingleTerm(qs, qt);
xaccInitQuery(qs, qt);
xaccQuerySetGroup(qs, q->acct_group);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
@@ -1342,7 +1331,9 @@ xaccQueryAddSharesMatch(Query * q, double amt,
qt->data.amount.amt_sgn = 0;
qt->data.amount.amount = amt;
xaccQuerySingleTerm(qs, qt);
xaccInitQuery(qs, qt);
xaccQuerySetGroup(qs, q->acct_group);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
@@ -1374,7 +1365,9 @@ xaccQueryAddMiscMatch(Query * q, Predicate p, int how, int data,
qt->data.misc.how = how;
qt->data.misc.data = data;
xaccQuerySingleTerm(qs, qt);
xaccInitQuery(qs, qt);
xaccQuerySetGroup(qs, q->acct_group);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
@@ -1387,6 +1380,37 @@ xaccQueryAddMiscMatch(Query * q, Predicate p, int how, int data,
xaccFreeQuery(qr);
}
/********************************************************************
* xaccQueryAddClearedMatch
* Add a 'cleared' filter to an existing query.
********************************************************************/
void
xaccQueryAddClearedMatch(Query * q, int how,
QueryOp op) {
Query * qs = xaccMallocQuery();
QueryTerm * qt = g_new0(QueryTerm, 1);
Query * qr;
qt->p = & xaccClearedMatchPredicate;
qt->sense = 1;
qt->data.type = PD_CLEARED;
qt->data.cleared.how = how;
xaccInitQuery(qs, qt);
xaccQuerySetGroup(qs, q->acct_group);
if(xaccQueryHasTerms(q)) {
qr = xaccQueryMerge(q, qs, op);
}
else {
qr = xaccQueryMerge(q, qs, QUERY_OR);
}
xaccQuerySwapTerms(q, qr);
xaccFreeQuery(qs);
xaccFreeQuery(qr);
}
/*******************************************************************
* xaccQueryPurgeTerms
@@ -1399,6 +1423,8 @@ xaccQueryPurgeTerms(Query * q, pd_type_t type) {
GList * or;
GList * and;
assert(q != NULL);
for(or = q->terms; or; or = or->next) {
for(and = or->data; and; and = and->next) {
qt = and->data;
@@ -1475,7 +1501,7 @@ string_match_predicate(const char * s, PredicateData * pd)
/*******************************************************************
* value_match_predicate
*******************************************************************/
int
static int
value_match_predicate(double splitamt, PredicateData * pd) {
switch(pd->amount.how) {
case AMT_MATCH_ATLEAST:
@@ -1496,7 +1522,7 @@ value_match_predicate(double splitamt, PredicateData * pd) {
/*******************************************************************
* xaccAccountMatchPredicate
*******************************************************************/
int
static int
xaccAccountMatchPredicate(Split * s, PredicateData * pd) {
Transaction * parent;
Split * split;
@@ -1568,7 +1594,7 @@ xaccAccountMatchPredicate(Split * s, PredicateData * pd) {
/*******************************************************************
* xaccDescriptionMatchPredicate
*******************************************************************/
int
static int
xaccDescriptionMatchPredicate(Split * s, PredicateData * pd) {
Transaction * parent;
const char * descript;
@@ -1586,7 +1612,7 @@ xaccDescriptionMatchPredicate(Split * s, PredicateData * pd) {
/*******************************************************************
* xaccNumberMatchPredicate
*******************************************************************/
int
static int
xaccNumberMatchPredicate(Split * s, PredicateData * pd) {
Transaction * parent;
const char * number;
@@ -1602,38 +1628,10 @@ xaccNumberMatchPredicate(Split * s, PredicateData * pd) {
}
/*******************************************************************
* xaccTransMatchPredicate
*******************************************************************/
int
xaccTransMatchPredicate(Split * s, PredicateData * pd) {
Transaction * parent;
assert(s && pd);
assert(pd->type == PD_TRANS);
parent = xaccSplitGetParent(s);
assert(parent);
return (parent == pd->trans.trans);
}
/*******************************************************************
* xaccSplitMatchPredicate
*******************************************************************/
int
xaccSplitMatchPredicate(Split * s, PredicateData * pd) {
assert(s && pd);
assert(pd->type == PD_SPLIT);
return (s == pd->split.split);
}
/*******************************************************************
* xaccActionMatchPredicate
*******************************************************************/
int
static int
xaccActionMatchPredicate(Split * s, PredicateData * pd) {
const char * action;
@@ -1648,7 +1646,7 @@ xaccActionMatchPredicate(Split * s, PredicateData * pd) {
/*******************************************************************
* xaccMemoMatchPredicate
*******************************************************************/
int
static int
xaccMemoMatchPredicate(Split * s, PredicateData * pd) {
const char * memo;
@@ -1663,15 +1661,18 @@ xaccMemoMatchPredicate(Split * s, PredicateData * pd) {
* xaccMiscMatchPredicate
* *** Bill, please complete! ***
*******************************************************************/
int xaccMiscMatchPredicate(Split * s, PredicateData * pd) {
#if 0
static int
xaccMiscMatchPredicate(Split * s, PredicateData * pd) {
return 0;
}
#endif
/*******************************************************************
* xaccAmountMatchPredicate
*******************************************************************/
int
static int
xaccAmountMatchPredicate(Split * s, PredicateData * pd) {
double splitamt;
@@ -1697,7 +1698,7 @@ xaccAmountMatchPredicate(Split * s, PredicateData * pd) {
/*******************************************************************
* xaccSharePriceMatchPredicate
*******************************************************************/
int
static int
xaccSharePriceMatchPredicate(Split * s, PredicateData * pd) {
double splitamt;
Account * acct;
@@ -1721,7 +1722,7 @@ xaccSharePriceMatchPredicate(Split * s, PredicateData * pd) {
/*******************************************************************
* xaccSharesMatchPredicate
*******************************************************************/
int
static int
xaccSharesMatchPredicate(Split * s, PredicateData * pd) {
double splitamt;
Account * acct;
@@ -1746,7 +1747,7 @@ xaccSharesMatchPredicate(Split * s, PredicateData * pd) {
/*******************************************************************
* xaccDateMatchPredicate
*******************************************************************/
int
static int
xaccDateMatchPredicate(Split * s, PredicateData * pd) {
Timespec transtime;
@@ -1759,6 +1760,35 @@ xaccDateMatchPredicate(Split * s, PredicateData * pd) {
(transtime.tv_sec <= pd->date.end.tv_sec));
}
/*******************************************************************
* xaccClearedMatchPredicate
*******************************************************************/
static int
xaccClearedMatchPredicate(Split * s, PredicateData * pd) {
int cstate;
assert(s && pd);
assert(pd->type == PD_CLEARED);
cstate = xaccSplitGetReconcile(s);
switch(cstate) {
case CREC:
return ((pd->cleared.how & CLEARED_CLEARED) ? 1 : 0);
break;
case YREC:
return ((pd->cleared.how & CLEARED_RECONCILED) ? 1 : 0);
break;
case FREC:
return ((pd->cleared.how & CLEARED_FROZEN) ? 1 : 0);
break;
case NREC:
return ((pd->cleared.how & CLEARED_NO) ? 1 : 0);
break;
}
return 0;
}
/*******************************************************************
* xaccQuerySetSortOrder
+24 -66
View File
@@ -54,7 +54,7 @@ typedef enum {
} sort_type_t;
typedef enum { PD_DATE, PD_AMOUNT, PD_ACCOUNT,
PD_TRANS, PD_SPLIT, PD_STRING, PD_MISC } pd_type_t;
PD_STRING, PD_CLEARED, PD_MISC } pd_type_t;
typedef enum { ACCT_MATCH_ALL, ACCT_MATCH_ANY, ACCT_MATCH_NONE } acct_match_t;
typedef enum { AMT_MATCH_ATLEAST, AMT_MATCH_ATMOST,
@@ -62,33 +62,12 @@ typedef enum { AMT_MATCH_ATLEAST, AMT_MATCH_ATMOST,
typedef enum { AMT_SGN_MATCH_EITHER, AMT_SGN_MATCH_CREDIT,
AMT_SGN_MATCH_DEBIT } amt_match_sgn_t;
enum { CLEARED_NO=1, CLEARED_CLEARED=2, CLEARED_RECONCILED=4,
CLEARED_FROZEN=8 };
enum { STRING_MATCH_CASE=1, STRING_MATCH_REGEXP=2};
/* the Query makes a subset of all splits based on 3 things:
* - an AND-OR tree of predicates which combine to make a
* split filter
* - a sorting order for the matched splits
* - a chop limit which gives the maximum number of sorted
* splits to return. */
typedef struct {
/* terms is a list of the OR-terms in a sum-of-products
* logical expression. */
GList * terms;
/* sorting and chopping is independent of the search filter */
sort_type_t primary_sort;
sort_type_t secondary_sort;
sort_type_t tertiary_sort;
gncBoolean sort_increasing;
int max_splits;
/* cache the results so we don't have to run the whole search
* again until it's really necessary */
int changed;
AccountGroup * acct_group;
Split ** split_list;
} Query;
typedef struct _querystruct Query;
typedef struct {
pd_type_t type;
@@ -124,27 +103,22 @@ typedef struct {
} MiscPredicateData;
typedef struct {
pd_type_t type;
Transaction * trans;
} TransPredicateData;
pd_type_t type;
int how;
} ClearedPredicateData;
typedef struct {
pd_type_t type;
Split * split;
} SplitPredicateData;
typedef union {
pd_type_t type;
DatePredicateData date;
AmountPredicateData amount;
AccountPredicateData acct;
TransPredicateData trans;
SplitPredicateData split;
StringPredicateData str;
ClearedPredicateData cleared;
MiscPredicateData misc;
} PredicateData;
typedef int (* Predicate)(Split * foo, PredicateData * bar);
typedef int (* Predicate)(Split * to_test, PredicateData * test_data);
typedef struct {
Predicate p;
@@ -153,21 +127,22 @@ typedef struct {
} QueryTerm;
/*******************************************************************
* basic Query API
*******************************************************************/
Query * xaccMallocQuery(void);
void xaccInitQuery(Query * q, QueryTerm * initial_term);
void xaccInitQuery(Query * q, QueryTerm * qt);
void xaccFreeQuery(Query *);
void xaccQuerySetGroup(Query * q, AccountGroup * group);
Query * xaccQueryInvert(Query * q1);
Query * xaccQueryMerge(Query * q1, Query * q2, QueryOp op);
void xaccQueryClear(Query * q);
void xaccQueryPurgeTerms(Query * q, pd_type_t type);
Query * xaccQueryInvert(Query * q1);
Query * xaccQueryMerge(Query * q1, Query * q2, QueryOp op);
void xaccQuerySetGroup(Query * q, AccountGroup * group);
void xaccQuerySwapTerms(Query * q1, Query * q2);
void xaccQuerySingleTerm(Query * q, QueryTerm * qt);
void xaccQueryClear(Query * q);
void xaccQueryPurgeTerms(Query * q, pd_type_t type);
int xaccQueryHasTerms(Query * q);
int xaccQueryHasTerms(Query * q);
Split ** xaccQueryGetSplits(Query * q);
Split ** xaccQueryGetSplits(Query * q);
/*******************************************************************
* match-adding API
@@ -178,9 +153,6 @@ void xaccQueryAddAccountMatch(Query * q, Account ** acclist,
void xaccQueryAddSingleAccountMatch(Query * q, Account * acct,
QueryOp op);
void xaccQueryAddTransMatch(Query * q, Transaction * t, int how, QueryOp op);
void xaccQueryAddSplitMatch(Query * q, Split * t, int how, QueryOp op);
void xaccQueryAddDescriptionMatch(Query * q, char * matchstring,
int case_sens, int use_regexp, QueryOp op);
void xaccQueryAddNumberMatch(Query * q, char * matchstring,
@@ -208,24 +180,10 @@ void xaccQueryAddMemoMatch(Query * q, char * matchstring,
int case_sens, int use_regexp, QueryOp op);
void xaccQueryAddMiscMatch(Query * q, Predicate p, int how, int data,
QueryOp op);
void xaccQueryAddClearedMatch(Query * q, int how,
QueryOp op);
/*******************************************************************
* predicates for standard match types
*******************************************************************/
int xaccAccountMatchPredicate(Split * s, PredicateData * pd);
int xaccTransMatchPredicate(Split * s, PredicateData * pd);
int xaccSplitMatchPredicate(Split * s, PredicateData * pd);
int xaccDescriptionMatchPredicate(Split * s, PredicateData * pd);
int xaccActionMatchPredicate(Split * s, PredicateData * pd);
int xaccNumberMatchPredicate(Split * s, PredicateData * pd);
int xaccAmountMatchPredicate(Split * s, PredicateData * pd);
int xaccDateMatchPredicate(Split * s, PredicateData * pd);
int xaccMemoMatchPredicate(Split * s, PredicateData * pd);
int xaccSharePriceMatchPredicate(Split * s, PredicateData * pd);
int xaccSharesMatchPredicate(Split * s, PredicateData * pd);
/*******************************************************************
* sort-related functions
*******************************************************************/
+24 -2
View File
@@ -41,6 +41,7 @@
#include "splitreg.h"
#include "dialog-find-transactions.h"
#include "window-help.h"
#include "Query.h"
/********************************************************************\
@@ -140,6 +141,12 @@ gnc_ui_find_transactions_dialog_create(xaccLedgerDisplay * orig_ledg) {
ftd->action_regexp_toggle =
gtk_object_get_data(GTK_OBJECT(ftd->dialog), "action_regexp_toggle");
ftd->cleared_cleared_toggle =
gtk_object_get_data(GTK_OBJECT(ftd->dialog), "cleared_cleared_toggle");
ftd->cleared_reconciled_toggle =
gtk_object_get_data(GTK_OBJECT(ftd->dialog), "cleared_reconciled_toggle");
ftd->cleared_not_cleared_toggle =
gtk_object_get_data(GTK_OBJECT(ftd->dialog), "cleared_not_cleared_toggle");
/* add an account picker to the first tab */
ftd->account_tree = gnc_account_tree_new();
@@ -208,8 +215,6 @@ gnc_ui_find_transactions_dialog_create(xaccLedgerDisplay * orig_ledg) {
ftd);
/* if there's no original query, make the narrow, add, delete
* buttons inaccessible */
if(!ftd->q) {
@@ -358,6 +363,8 @@ gnc_ui_find_transactions_dialog_ok_cb(GtkButton * button,
int start_year, start_month, start_day;
int end_year, end_month, end_day;
int c_cleared, c_notcleared, c_reconciled;
if(search_type == 0) {
if(ftd->q) xaccFreeQuery(ftd->q);
ftd->q = xaccMallocQuery();
@@ -561,6 +568,21 @@ gnc_ui_find_transactions_dialog_ok_cb(GtkButton * button,
QUERY_AND);
}
c_cleared = gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON(ftd->cleared_cleared_toggle));
c_notcleared = gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON(ftd->cleared_not_cleared_toggle));
c_reconciled = gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON(ftd->cleared_reconciled_toggle));
if(c_cleared || c_notcleared || c_reconciled) {
int how = 0;
if(c_cleared) how = how | CLEARED_CLEARED;
if(c_notcleared) how = how | CLEARED_NO;
if(c_reconciled) how = how | CLEARED_RECONCILED;
xaccQueryAddClearedMatch(q, how, QUERY_AND);
}
if(!ftd->ledger) {
new_ledger = TRUE;
ftd->ledger = xaccLedgerDisplayGeneral(NULL, NULL, SEARCH_LEDGER);
+4
View File
@@ -96,6 +96,10 @@ typedef struct {
GtkWidget * action_case_toggle;
GtkWidget * action_regexp_toggle;
GtkWidget * cleared_not_cleared_toggle;
GtkWidget * cleared_cleared_toggle;
GtkWidget * cleared_reconciled_toggle;
} FindTransactionsDialog;
FindTransactionsDialog *
+60 -85
View File
@@ -396,17 +396,15 @@ gnc_ui_qif_import_select_loaded_file_cb(GtkList * list,
gpointer user_data) {
GtkWidget * dialog = GTK_WIDGET(user_data);
QIFImportWindow * wind =
gtk_object_get_data(GTK_OBJECT(dialog), "qif_window_struct");
gtk_object_get_data(GTK_OBJECT(dialog), "qif_window_struct");
int file_index =
GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(widget), "file_index"));
SCM scm_qiffile;
wind->selected_file = gh_list_ref(wind->imported_files,
gh_int2scm(file_index));
scm_qiffile = GPOINTER_TO_INT
(gtk_object_get_data(GTK_OBJECT(widget), "scm-object"));
wind->selected_file = scm_qiffile;
scm_protect_object(wind->selected_file);
update_file_info(wind, scm_qiffile);
update_file_info(wind, wind->selected_file);
}
@@ -418,54 +416,24 @@ gnc_ui_qif_import_select_loaded_file_cb(GtkList * list,
void
gnc_ui_qif_import_ok_cb(GtkButton * button, gpointer user_data) {
SCM save_map_prefs;
SCM qif_to_gnc;
SCM hash_set;
SCM hash_data;
char * qif_acct_name;
char * qif_cat_name;
int row;
SCM save_map_prefs = gh_eval_str("qif-import:save-map-prefs");
SCM qif_to_gnc = gh_eval_str("qif-import:qif-to-gnc");
GtkWidget * dialog = GTK_WIDGET(user_data);
QIFImportWindow * wind =
gtk_object_get_data(GTK_OBJECT(dialog), "qif_window_struct");
gtk_object_get_data(GTK_OBJECT(user_data), "qif_window_struct");
save_map_prefs = gh_eval_str("qif-import:save-map-prefs");
qif_to_gnc = gh_eval_str("qif-import:qif-to-gnc");
hash_set = gh_eval_str("hash-set!");
/* busy cursor */
gnc_set_busy_cursor(NULL);
/* transfer the info from the account / category pickers to
* the mapping info hash tables */
for(row=0; row < GTK_CLIST(wind->acct_list)->rows; row++) {
gtk_clist_get_text(GTK_CLIST(wind->acct_list), row, 0, &qif_acct_name);
hash_data = (SCM)gtk_clist_get_row_data(GTK_CLIST(wind->acct_list), row);
gh_call3(hash_set, gh_cadr(wind->mapping_info),
gh_str02scm(qif_acct_name),
hash_data);
}
for(row=0; row < GTK_CLIST(wind->cat_list)->rows; row++) {
gtk_clist_get_text(GTK_CLIST(wind->cat_list), row, 0, &qif_cat_name);
hash_data = (SCM)gtk_clist_get_row_data(GTK_CLIST(wind->cat_list), row);
gh_call3(hash_set, gh_caddr(wind->mapping_info),
gh_str02scm(qif_cat_name),
hash_data);
}
/* call a scheme function to do the work */
gh_call2(qif_to_gnc, wind->imported_files,
wind->mapping_info);
/* write out mapping info before destroying the window */
gh_call1(save_map_prefs, wind->mapping_info);
gnc_unset_busy_cursor(NULL);
gnc_ui_qif_import_dialog_destroy(wind);
wind = NULL;
}
@@ -492,24 +460,30 @@ void
gnc_ui_qif_import_account_line_select_cb(GtkCList * clist, gint row,
gint column, GdkEvent * event,
gpointer user_data) {
char * initial_string;
int initial_type;
QIFImportWindow * wind =
gtk_object_get_data(GTK_OBJECT(user_data), "qif_window_struct");
char * gnc_acct_text = NULL;
char * qif_acct_text = NULL;
int initial_type;
SCM scm_acct;
SCM mapping_info;
SCM scm_hash_ref = gh_eval_str("hash-ref");
SCM scm_acct;
SCM old_info;
SCM munge_func = gh_eval_str("qif-dialog:munge-account-mapping");
gtk_clist_get_text(GTK_CLIST(clist), row, 0, &qif_acct_text);
gtk_clist_get_text(GTK_CLIST(clist), row, 2, &gnc_acct_text);
old_info = (SCM)gtk_clist_get_row_data(GTK_CLIST(clist), row);
gtk_clist_get_text(GTK_CLIST(clist), row, 2, &initial_string);
initial_type = gh_scm2int(gh_list_ref(old_info, gh_int2scm(2)));
scm_acct = accountPickerBox(initial_string, initial_type);
mapping_info = gh_call2(scm_hash_ref, gh_cadr(wind->mapping_info),
gh_str02scm(qif_acct_text));
initial_type = gh_scm2int(gh_list_ref(mapping_info, gh_int2scm(2)));
scm_acct = accountPickerBox(gnc_acct_text, initial_type);
if(gh_list_p(scm_acct)) {
gh_call2(munge_func, old_info, scm_acct);
scm_list_set_x(mapping_info, gh_int2scm(1), gh_car(scm_acct));
scm_list_set_x(mapping_info, gh_int2scm(2), gh_cadr(scm_acct));
scm_list_set_x(mapping_info, gh_int2scm(5), gh_caddr(scm_acct));
gtk_clist_set_text(GTK_CLIST(clist), row, 2,
gh_scm2newstr(gh_car(scm_acct), NULL));
gtk_clist_set_text(GTK_CLIST(clist), row, 3,
@@ -522,23 +496,30 @@ void
gnc_ui_qif_import_category_line_select_cb(GtkCList * clist, gint row,
gint column, GdkEvent * event,
gpointer user_data) {
char * initial_string;
int initial_type;
SCM scm_acct;
SCM old_info;
SCM munge_func = gh_eval_str("qif-dialog:munge-account-mapping");
old_info = (SCM)gtk_clist_get_row_data(GTK_CLIST(clist), row);
gtk_clist_get_text(GTK_CLIST(clist), row, 2, &initial_string);
initial_type = gh_scm2int(gh_list_ref(old_info, gh_int2scm(2)));
scm_acct = accountPickerBox(initial_string, initial_type);
QIFImportWindow * wind =
gtk_object_get_data(GTK_OBJECT(user_data), "qif_window_struct");
char * gnc_acct_text = NULL;
char * qif_acct_text = NULL;
int initial_type;
SCM scm_acct;
SCM mapping_info;
SCM scm_hash_ref = gh_eval_str("hash-ref");
gtk_clist_get_text(GTK_CLIST(clist), row, 0, &qif_acct_text);
gtk_clist_get_text(GTK_CLIST(clist), row, 2, &gnc_acct_text);
mapping_info = gh_call2(scm_hash_ref, gh_caddr(wind->mapping_info),
gh_str02scm(qif_acct_text));
initial_type = gh_scm2int(gh_list_ref(mapping_info, gh_int2scm(2)));
scm_acct = accountPickerBox(gnc_acct_text, initial_type);
if(gh_list_p(scm_acct)) {
gh_call2(munge_func, old_info, scm_acct);
scm_list_set_x(mapping_info, gh_int2scm(1), gh_car(scm_acct));
scm_list_set_x(mapping_info, gh_int2scm(2), gh_cadr(scm_acct));
scm_list_set_x(mapping_info, gh_int2scm(5), gh_caddr(scm_acct));
gtk_clist_set_text(GTK_CLIST(clist), row, 2,
gh_scm2newstr(gh_car(scm_acct), NULL));
gtk_clist_set_text(GTK_CLIST(clist), row, 3,
@@ -548,7 +529,6 @@ gnc_ui_qif_import_category_line_select_cb(GtkCList * clist, gint row,
}
/********************************************************************\
* update_file_page
* update the left-side list and the right-side info.
@@ -563,6 +543,7 @@ update_file_page(QIFImportWindow * wind) {
SCM scm_qiffile;
SCM qif_file_path;
int path_strlen;
int scm_file_index = 0;
/* clear the list */
gtk_list_remove_items(GTK_LIST(wind->selected_file_list),
@@ -578,11 +559,11 @@ update_file_page(QIFImportWindow * wind) {
new_list_item =
gtk_list_item_new_with_label(gh_scm2newstr(gh_call1(qif_file_path,
scm_qiffile),
&path_strlen));
&path_strlen));
gtk_object_set_data(GTK_OBJECT(new_list_item),
"scm-object", GINT_TO_POINTER(scm_qiffile));
scm_protect_object(scm_qiffile);
"file_index", GINT_TO_POINTER(scm_file_index));
scm_file_index++;
/* tack it on to the displayed list */
new_loaded_file = g_list_alloc();
new_loaded_file->next = NULL;
@@ -593,7 +574,7 @@ update_file_page(QIFImportWindow * wind) {
/* now add the file to the loaded-files list */
gtk_list_append_items(GTK_LIST(wind->selected_file_list),
new_loaded_file);
/* select_child will update the file info */
if(scm_qiffile == wind->selected_file) {
gtk_list_select_child(GTK_LIST(wind->selected_file_list), new_list_item);
@@ -639,12 +620,6 @@ update_file_info(QIFImportWindow * wind, SCM qif_file) {
return;
}
else {
/* stick the currently-selected qiffile scm in the window data */
gtk_object_set_data(GTK_OBJECT(wind->dialog),
"current_qif_file", GINT_TO_POINTER(qif_file));
scm_protect_object(qif_file);
/* get the currency etc from the Scheme side */
scm_currency = gh_call1(qif_file_currency,
qif_file);
+16
View File
@@ -144,3 +144,19 @@ gnc_ui_select_date_dialog_ok_cb (GtkButton *button,
void
gnc_ui_select_date_dialog_cancel_cb (GtkButton *button,
gpointer user_data);
void
gnc_ui_qif_import_account_line_select_cb
(GtkCList *clist,
gint row,
gint column,
GdkEvent *event,
gpointer user_data);
void
gnc_ui_qif_import_category_line_select_cb
(GtkCList *clist,
gint row,
gint column,
GdkEvent *event,
gpointer user_data);
+72 -2
View File
@@ -401,10 +401,10 @@ create_QIF_File_Import_Dialog (void)
QIF_File_Import_Dialog);
gtk_signal_connect (GTK_OBJECT (account_page_list), "select_row",
GTK_SIGNAL_FUNC (gnc_ui_qif_import_account_line_select_cb),
NULL);
QIF_File_Import_Dialog);
gtk_signal_connect (GTK_OBJECT (category_page_list), "select_row",
GTK_SIGNAL_FUNC (gnc_ui_qif_import_category_line_select_cb),
NULL);
QIF_File_Import_Dialog);
gtk_signal_connect (GTK_OBJECT (button2), "clicked",
GTK_SIGNAL_FUNC (gnc_ui_qif_import_ok_cb),
QIF_File_Import_Dialog);
@@ -1683,6 +1683,13 @@ create_Find_Transactions (void)
GtkWidget *action_case_toggle;
GtkWidget *action_regexp_toggle;
GtkWidget *label720;
GtkWidget *frame25;
GtkWidget *vbox61;
GtkWidget *label787;
GtkWidget *cleared_not_cleared_toggle;
GtkWidget *cleared_cleared_toggle;
GtkWidget *cleared_reconciled_toggle;
GtkWidget *label786;
GtkWidget *hbox20;
GtkWidget *hbox23;
GtkWidget *frame12;
@@ -2395,6 +2402,57 @@ create_Find_Transactions (void)
gtk_widget_show (label720);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 8), label720);
frame25 = gtk_frame_new (_("Match Cleared state"));
gtk_widget_ref (frame25);
gtk_object_set_data_full (GTK_OBJECT (Find_Transactions), "frame25", frame25,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (frame25);
gtk_container_add (GTK_CONTAINER (notebook2), frame25);
vbox61 = gtk_vbox_new (FALSE, 5);
gtk_widget_ref (vbox61);
gtk_object_set_data_full (GTK_OBJECT (Find_Transactions), "vbox61", vbox61,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (vbox61);
gtk_container_add (GTK_CONTAINER (frame25), vbox61);
gtk_container_set_border_width (GTK_CONTAINER (vbox61), 5);
label787 = gtk_label_new (_("Find transactions whose Cleared status is:"));
gtk_widget_ref (label787);
gtk_object_set_data_full (GTK_OBJECT (Find_Transactions), "label787", label787,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (label787);
gtk_box_pack_start (GTK_BOX (vbox61), label787, FALSE, FALSE, 0);
gtk_misc_set_alignment (GTK_MISC (label787), 7.45058e-09, 0.5);
cleared_not_cleared_toggle = gtk_check_button_new_with_label (_("Not cleared (n)"));
gtk_widget_ref (cleared_not_cleared_toggle);
gtk_object_set_data_full (GTK_OBJECT (Find_Transactions), "cleared_not_cleared_toggle", cleared_not_cleared_toggle,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (cleared_not_cleared_toggle);
gtk_box_pack_start (GTK_BOX (vbox61), cleared_not_cleared_toggle, FALSE, FALSE, 0);
cleared_cleared_toggle = gtk_check_button_new_with_label (_("Cleared (c)"));
gtk_widget_ref (cleared_cleared_toggle);
gtk_object_set_data_full (GTK_OBJECT (Find_Transactions), "cleared_cleared_toggle", cleared_cleared_toggle,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (cleared_cleared_toggle);
gtk_box_pack_start (GTK_BOX (vbox61), cleared_cleared_toggle, FALSE, FALSE, 0);
cleared_reconciled_toggle = gtk_check_button_new_with_label (_("Reconciled (y)"));
gtk_widget_ref (cleared_reconciled_toggle);
gtk_object_set_data_full (GTK_OBJECT (Find_Transactions), "cleared_reconciled_toggle", cleared_reconciled_toggle,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (cleared_reconciled_toggle);
gtk_box_pack_start (GTK_BOX (vbox61), cleared_reconciled_toggle, FALSE, FALSE, 0);
label786 = gtk_label_new (_("Cleared"));
gtk_widget_ref (label786);
gtk_object_set_data_full (GTK_OBJECT (Find_Transactions), "label786", label786,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (label786);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 9), label786);
hbox20 = gtk_hbox_new (FALSE, 0);
gtk_widget_ref (hbox20);
gtk_object_set_data_full (GTK_OBJECT (Find_Transactions), "hbox20", hbox20,
@@ -3131,3 +3189,15 @@ create_Budget_Dialog (void)
return Budget_Dialog;
}
GtkWidget*
create_window1 (void)
{
GtkWidget *window1;
window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_object_set_data (GTK_OBJECT (window1), "window1", window1);
gtk_window_set_title (GTK_WINDOW (window1), _("window1"));
return window1;
}
+1
View File
@@ -11,3 +11,4 @@ GtkWidget* create_Print_Check_Dialog (void);
GtkWidget* create_Find_Transactions (void);
GtkWidget* create_Select_Date (void);
GtkWidget* create_Budget_Dialog (void);
GtkWidget* create_window1 (void);
+108 -2
View File
@@ -383,7 +383,8 @@
<signal>
<name>select_row</name>
<handler>gnc_ui_qif_import_account_line_select_cb</handler>
<last_modification_time>Tue, 14 Mar 2000 14:58:13 GMT</last_modification_time>
<data>QIF_File_Import_Dialog</data>
<last_modification_time>Sun, 04 Jun 2000 17:56:41 GMT</last_modification_time>
</signal>
<columns>4</columns>
<column_widths>116,80,204,80</column_widths>
@@ -473,7 +474,8 @@
<signal>
<name>select_row</name>
<handler>gnc_ui_qif_import_category_line_select_cb</handler>
<last_modification_time>Tue, 14 Mar 2000 14:59:18 GMT</last_modification_time>
<data>QIF_File_Import_Dialog</data>
<last_modification_time>Sun, 04 Jun 2000 17:56:55 GMT</last_modification_time>
</signal>
<columns>4</columns>
<column_widths>117,80,204,80</column_widths>
@@ -3628,6 +3630,94 @@ Exactly
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame25</name>
<label>Match Cleared state</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<widget>
<class>GtkVBox</class>
<name>vbox61</name>
<border_width>5</border_width>
<homogeneous>False</homogeneous>
<spacing>5</spacing>
<widget>
<class>GtkLabel</class>
<name>label787</name>
<label>Find transactions whose Cleared status is:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>7.45058e-09</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>cleared_not_cleared_toggle</name>
<can_focus>True</can_focus>
<label>Not cleared (n)</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>cleared_cleared_toggle</name>
<can_focus>True</can_focus>
<label>Cleared (c)</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>cleared_reconciled_toggle</name>
<can_focus>True</can_focus>
<label>Reconciled (y)</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label786</name>
<label>Cleared</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
<widget>
@@ -4690,4 +4780,20 @@ Contingency
</widget>
</widget>
<widget>
<class>GtkWindow</class>
<name>window1</name>
<title>window1</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink>
<widget>
<class>Placeholder</class>
</widget>
</widget>
</GTK-Interface>
View File
-98
View File
@@ -1,98 +0,0 @@
#include <colors.h>
/* Is this approach OK for multi-headed displays, etc.? i.e. where
different windows in the app might have different visuals?
Probably not. */
static GdkColorContext *color_context = NULL;
static int
colors_init(static GtkWidget *main_window) {
if(!color_context) {
gint n;
color_context =
gdk_color_context_new(gtk_widget_get_visual(main_window),
gtk_widget_get_colormap(main_window));
assert(color_context);
color_split_row.pixel = 0; /* this is important! */
color_split_row.red = 44730;
color_split_row.green = 53052;
color_split_row.blue = 65535;
n = 0; /* this is important! */
gdk_color_context_get_pixels (color_context,
&color_split_row.red,
&color_split_row.green,
&color_split_row.blue,
1, &color_split_row.pixel, &n);
assert(n == 1);
assert(gdk_color_parse("black", &color_black) != 0);
color_black.pixel = 0; /* this is important! */
n = 0; /* this is important! */
gdk_color_context_get_pixels (color_context,
&color_black.red,
&color_black.green,
&color_black.blue,
1, &color_black.pixel, &n);
assert(n == 1);
assert(gdk_color_parse("red", &color_red) != 0);
color_red.pixel = 0; /* this is important! */
n = 0; /* this is important! */
gdk_color_context_get_pixels (color_context,
&color_red.red,
&color_red.green,
&color_red.blue,
1, &color_red.pixel, &n);
assert(n == 1);
/*assert(gdk_color_parse("#", &color_split_row) != 0);*/
/*main_row_color.red = 65000;
main_row_color.green = 65000;
main_row_color.blue = 65000;*/
/*main_row_color.pixel = gdk_color_context_get_pixel(color_context,
main_row_color.red,
main_row_color.green,
main_row_color.blue,
&failure);
assert(!failure); */
/*
color_context =
gdk_color_context_new(gtk_widget_get_visual(main_window),
gtk_widget_get_colormap(main_window));
color_split_row.red = 44730 >> 8;
color_split_row.green = 53052 >> 8;
color_split_row.blue = 65535 >> 8;
color_split_row.red = 44730;
color_split_row.green = 53052;
color_split_row.blue = 65535;
color_split_row.pixel = gdk_color_context_get_pixel(color_context,
color_split_row.red,
color_split_row.green,
color_split_row.blue,
&failure);
*/
}
return(0);
}
-43
View File
@@ -1,43 +0,0 @@
* From: Rob Browning <rlb@cs.utexas.edu>
For those of you interested, below is an extremely simple example of a
tiny standalone program that can read an .xac file (specified as the
first argument and then let you select accounts to plot from a Gtk
window. The plot is just a per-transaction running balance, but it's
a start. You need Gtk and plotutils 2.0 installed for this to work.
try
ftp://ftp.digex.net/pub/gnu/plotutils-2.0.tar.gz
ftp://prep.ai.mit.edu/pub/gnu/plotutils-2.0.tar.gz
ftp://ftp.gnu.org/pub/gnu/plotutils-2.0.tar.gz
Issues:
This program is trivial, and it only works via a Gtk GUI. In the end
I think we should support both interactive and non-interactive
operation of our graphing and reporting tools. Whether this happens
via special arguments to xacc, or by providing separate standalone
programs that link to a common library (libxaccplot?) I don't know,
but either way, I think we need both.
This little program generates the graph by launching a child "graph"
process (graph is part of the plotutils package). I don't set any
axis labels or anything. This could obviously be improved, but there
are limits to how flexible the graph program is. It can't, for
example, do pie or bar charts at the moment.
The lower level library (libplot) that graph is based on will allow us
to do whatever we want, although we'll have to do all the scaling,
drawing, etc, that graph normally handles. Right now, graph's
functionality is only availble in the executable, but after talking to
the upstream author, he's decided to turn most of graph into a
library. As a result it doesn't make sense to spend a lot of time
right now re-implementing graph's functionality in libplot. We should
just wait, executing graph as a separate process to handle normal XY
plots for now. Our current efforts should be directed at implementing
graph types plotutils doesn't handle (like pie and bar), and into work
on the general graphing infrastructure.
--
Rob Browning <rlb@cs.utexas.edu>
PGP fingerprint = E8 0E 0D 04 F5 21 A0 94 53 2B 97 F5 D6 4E 39 30
-355
View File
@@ -1,355 +0,0 @@
/* File: plot-test.c */
/* Eventually the graphs should draw to a pixmap and refresh from
there. This is *easy* to do in GTK. */
#include <stdio.h>
#include <assert.h>
#include <getopt.h>
#include <gtk/gtk.h>
#include <gdk/gdkprivate.h>
#include <plot.h>
#include <Account.h>
#include <LedgerUtils.h>
#include <FileIO.h>
#include <plot.h>
static char *filename = NULL;
void
destroy() {
gtk_main_quit ();
}
typedef struct {
char *label;
double value;
} PieChartItem;
static const PieChartItem item1 = {"horses", 121.32};
static const PieChartItem item2 = {"throbbing expanse", 350.19};
static const PieChartItem item3 = {"tangibles", 23.32};
static const PieChartItem item4 = {"intangibles", 45.44};
static const PieChartItem item5 = {"giant fungi", 241.87};
static const PieChartItem *pie_data[] = {
&item1,
&item2,
&item3,
&item4,
&item5,
0
};
static double
pie_chart_slice(GtkWidget *w,
GdkColor *color,
const int width,
const int height,
const int center_x,
const int center_y,
const double total,
const double start_angle,
const PieChartItem *item) {
GdkGC *gc = NULL;
const int pie_width = (2 * width) / 3;
const int pie_height = (2 * width) / 3;
const double full_circle = 360 * 64;
const double arc_sweep = (item->value / total) * full_circle;
gc = gdk_gc_new(GTK_WIDGET(w)->window);
gdk_gc_copy(gc, GTK_WIDGET(w)->style->black_gc);
gdk_gc_set_foreground(gc, color);
gdk_draw_arc(w->window, gc, TRUE,
center_x - pie_width / 2,
center_y - pie_width / 2,
pie_width, pie_height,
rint(start_angle), rint(arc_sweep));
gdk_gc_unref(gc);
return arc_sweep;
}
static void
pie_chart(GtkWidget *w, const PieChartItem *pie_chart_items[]) {
if(pie_chart_items) {
const PieChartItem **item = pie_chart_items;
double total = 0;
double current_angle = 0;
int current_color = 0;
/* this is going to be handled through guile eventually */
const char *pie_color_strings[] = {
"DarkGreen",
"FireBrick",
"DarkBlue",
"DarkOliveGreen",
"DarkOrange",
"MediumSeaGreen",
"peru",
"DarkOrchid",
"LimeGreen"
};
GdkColorContext *color_context =
gdk_color_context_new(gtk_widget_get_visual(w),
gtk_widget_get_colormap(w));
assert(color_context);
/* get total */
while(*item) {
fprintf(stderr, "%s\n", (*item)->label);
total += (*item)->value;
item++;
}
item = pie_chart_items;
while(*item) {
/* This is a *really* inefficient way to handle the colors, but
it's guaranteed safe. We can do something smarter later, but
it may not be worth worrying about. */
GdkColor color;
int n;
const int width = 400;
const int height = 400;
const int center_x = 200;
const int center_y = 200;
assert(gdk_color_parse(pie_color_strings[current_color], &color) != 0);
color.pixel = 0; /* this is important! */
n = 0; /* this is important! */
gdk_color_context_get_pixels (color_context,
&color.red,
&color.green,
&color.blue,
1, &color.pixel, &n);
assert(n == 1);
current_angle +=
pie_chart_slice(w, &color, width, height, center_x, center_y,
total, current_angle, *item);
current_color++;
if(current_color == sizeof(pie_color_strings) / sizeof(char *))
current_color = 0;
item++;
}
gdk_color_context_free(color_context);
}
}
static double
pie_chart_slice_plotutils(const char color[],
const int width,
const int height,
const int center_x,
const int center_y,
const double total,
const double start_angle,
const PieChartItem *item) {
const int pie_radius = width / 3;
const double full_circle = 2 * M_PI;
const double arc_sweep = (item->value / total) * full_circle;
savestate();
filltype(1);
colorname(color);
move(0,0);
savestate();
frotate(start_angle * 180 / M_PI);
cont(pie_radius, 0);
arc(0, 0,
pie_radius, 0,
pie_radius * cos(arc_sweep),
pie_radius * sin(arc_sweep));
cont(0,0);
endpath();
restorestate();
move(0.90 * width / 2 * cos(start_angle + arc_sweep / 2),
0.90 * width / 2 * sin(start_angle + arc_sweep / 2));
alabel('c', 'c', item->label);
restorestate();
fprintf(stderr, "start: %f sweep: %f\n", start_angle, arc_sweep);
return arc_sweep;
}
static void
pie_plotutils(const PieChartItem *pie_chart_items[]) {
if(pie_chart_items) {
const PieChartItem **item = pie_chart_items;
double total = 0;
double current_angle = 0;
int current_color = 0;
/* this is going to be handled through guile eventually */
const char *pie_color_strings[] = {
"DarkGreen",
"FireBrick",
"DarkBlue",
"DarkOliveGreen",
"DarkOrange",
"MediumSeaGreen",
"peru",
"DarkOrchid",
"LimeGreen",
0
};
/* get total */
while(*item) {
fprintf(stderr, "%s\n", (*item)->label);
total += (*item)->value;
item++;
}
item = pie_chart_items;
while(*item) {
/* This is a *really* inefficient way to handle the colors, but
it's guaranteed safe. We can do something smarter later, but
it may not be worth worrying about. */
const int width = 400;
const int height = 400;
const int center_x = 200;
const int center_y = 200;
current_angle +=
pie_chart_slice_plotutils(pie_color_strings[current_color],
width, height, center_x, center_y,
total, current_angle, *item);
current_color++;
if(!pie_color_strings[current_color]) current_color = 0;
item++;
}
}
}
static void
pie_window_expose(GtkDrawingArea *da, GdkEventExpose *event, gpointer data) {
//fprintf(stderr, "%p\n", data);
//pie_chart(GTK_WIDGET(da), data);
{
int handle;
GdkWindowPrivate *priv = (GdkWindowPrivate *)(GTK_WIDGET(da)->window);
assert(parampl("XDRAWABLE_DISPLAY", priv->xdisplay) == 0);
assert(parampl("XDRAWABLE_DRAWABLE1", &(priv->xwindow)) == 0);
//assert(parampl("XDRAWABLE_DRAWABLE2", &(priv->xwindow)) == 0);
assert(parampl("XDRAWABLE_DRAWABLE2", NULL) == 0);
handle = newpl("Xdrawable", stdin, stdout, stderr);
assert(handle);
selectpl(handle);
assert(openpl() == 0);
space(-200, -200, 200, 200);
colorname("grey83");
box(-200, -200, 200, 200);
pie_plotutils(pie_data);
assert(closepl() == 0);
selectpl(0);
deletepl(handle);
}
}
static GtkWidget *
pie_window() {
GtkWidget *window;
GtkWidget *vbox;
GtkWidget *quit_button;
GtkWidget *da;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC (destroy), NULL);
gtk_container_border_width (GTK_CONTAINER (window), 3);
quit_button = gtk_button_new_with_label ("Quit");
gtk_signal_connect_object (GTK_OBJECT (quit_button), "clicked",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
GTK_OBJECT (window));
vbox = gtk_vbox_new(FALSE, 0);
da = gtk_drawing_area_new();
gtk_drawing_area_size(GTK_DRAWING_AREA(da), 400,400);
gtk_box_pack_start(GTK_BOX(vbox), da, FALSE, FALSE, 0);
gtk_widget_show(da);
gtk_signal_connect(GTK_OBJECT (da),
"expose_event",
GTK_SIGNAL_FUNC (pie_window_expose),
pie_data);
gtk_widget_set_events (da, GDK_EXPOSURE_MASK);
gtk_container_add (GTK_CONTAINER(window), vbox);
gtk_box_pack_end(GTK_BOX(vbox), quit_button, FALSE, FALSE, 0);
gtk_widget_show (quit_button);
gtk_widget_show(vbox);
gtk_widget_show (window);
return(window);
}
static void
usage() {
static char usage_string[] =
"usage: plot-test [ --pie ] filename\n"
"--pie generate pie chart.\n";
fputs(usage_string, stderr);
}
int
main(int argc, char *argv[]) {
int opt_pie = 0;
struct option cmd_line_opts[] = {
{"pie", 0, &opt_pie, 1},
{0, 0, 0, 0},
};
int result = 0;
int handle;
GtkWidget *main_win;
GtkWidget *display_area;
GtkWidget *list = NULL;
char c;
while((c = getopt_long(argc, argv, "", cmd_line_opts, NULL)) != EOF) {
if(c == ':') {
usage();
exit(1);
}
if(c == '?') {
usage();
exit(1);
}
}
if(optind != (argc - 1)) {
usage();
exit(1);
}
filename = argv[optind];
gtk_init(&argc, &argv);
//main_win = make_main_window(&list);
//add_accounts_to_list(list, filename);
if(opt_pie) pie_window();
gtk_main();
return result;
}
+20 -6
View File
@@ -18,12 +18,26 @@ INCLUDES = \
-I@PERLINCL@/CORE \
-I${top_srcdir}/src/engine
# -I.. \
# -I../engine \
# -I../guile
LDADD = \
${top_srcdir}/src/engine/libgncengine.a
libgncswig_la_LIBADD = \
@GLIB_LIBS@ \
${top_srcdir}/src/engine/AccInfo.lo \
${top_srcdir}/src/engine/Account.lo \
${top_srcdir}/src/engine/DateUtils.lo \
${top_srcdir}/src/engine/FileIO.lo \
${top_srcdir}/src/engine/GNCId.lo \
${top_srcdir}/src/engine/Group.lo \
${top_srcdir}/src/engine/LedgerUtils.lo \
${top_srcdir}/src/engine/Query.lo \
${top_srcdir}/src/engine/Queue.lo \
${top_srcdir}/src/engine/Scrub.lo \
${top_srcdir}/src/engine/Session.lo \
${top_srcdir}/src/engine/TransLog.lo \
${top_srcdir}/src/engine/Transaction.lo \
${top_srcdir}/src/engine/Backend.lo \
${top_srcdir}/src/engine/date.lo \
${top_srcdir}/src/engine/util.lo \
${top_srcdir}/src/engine/guid.lo \
${top_srcdir}/src/engine/md5.lo
SWIG_INPUT_HDRS := \
${top_srcdir}/src/engine/AccInfo.h \
+14 -6
View File
@@ -133,11 +133,7 @@ CFLAGS = ${GNOME_CFLAGS} -Dbool=char
INCLUDES = -I@PERLINCL@/CORE -I${top_srcdir}/src/engine
# -I.. \
# -I../engine \
# -I../guile
LDADD = ${top_srcdir}/src/engine/libgncengine.a
libgncswig_la_LIBADD = @GLIB_LIBS@ ${top_srcdir}/src/engine/AccInfo.lo ${top_srcdir}/src/engine/Account.lo ${top_srcdir}/src/engine/DateUtils.lo ${top_srcdir}/src/engine/FileIO.lo ${top_srcdir}/src/engine/GNCId.lo ${top_srcdir}/src/engine/Group.lo ${top_srcdir}/src/engine/LedgerUtils.lo ${top_srcdir}/src/engine/Query.lo ${top_srcdir}/src/engine/Queue.lo ${top_srcdir}/src/engine/Scrub.lo ${top_srcdir}/src/engine/Session.lo ${top_srcdir}/src/engine/TransLog.lo ${top_srcdir}/src/engine/Transaction.lo ${top_srcdir}/src/engine/Backend.lo ${top_srcdir}/src/engine/date.lo ${top_srcdir}/src/engine/util.lo ${top_srcdir}/src/engine/guid.lo ${top_srcdir}/src/engine/md5.lo
SWIG_INPUT_HDRS := ${top_srcdir}/src/engine/AccInfo.h ${top_srcdir}/src/engine/Account.h ${top_srcdir}/src/engine/DateUtils.h ${top_srcdir}/src/engine/FileIO.h ${top_srcdir}/src/engine/GNCId.h ${top_srcdir}/src/engine/Group.h ${top_srcdir}/src/engine/LedgerUtils.h ${top_srcdir}/src/engine/Query.h ${top_srcdir}/src/engine/Queue.h ${top_srcdir}/src/engine/Scrub.h ${top_srcdir}/src/engine/Session.h ${top_srcdir}/src/engine/TransLog.h ${top_srcdir}/src/engine/Transaction.h ${top_srcdir}/src/engine/date.h
@@ -157,7 +153,19 @@ X_CFLAGS = @X_CFLAGS@
X_LIBS = @X_LIBS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
libgncswig_la_LIBADD =
libgncswig_la_DEPENDENCIES = ${top_srcdir}/src/engine/AccInfo.lo \
${top_srcdir}/src/engine/Account.lo \
${top_srcdir}/src/engine/DateUtils.lo \
${top_srcdir}/src/engine/FileIO.lo ${top_srcdir}/src/engine/GNCId.lo \
${top_srcdir}/src/engine/Group.lo \
${top_srcdir}/src/engine/LedgerUtils.lo \
${top_srcdir}/src/engine/Query.lo ${top_srcdir}/src/engine/Queue.lo \
${top_srcdir}/src/engine/Scrub.lo ${top_srcdir}/src/engine/Session.lo \
${top_srcdir}/src/engine/TransLog.lo \
${top_srcdir}/src/engine/Transaction.lo \
${top_srcdir}/src/engine/Backend.lo ${top_srcdir}/src/engine/date.lo \
${top_srcdir}/src/engine/util.lo ${top_srcdir}/src/engine/guid.lo \
${top_srcdir}/src/engine/md5.lo
libgncswig_la_OBJECTS = helperfuncs.lo gnucash-engine-perl5_wrap.lo
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-13
View File
@@ -9,19 +9,6 @@
(gnc:support "qif-import/qif-dialog-utils.scm")
(define (qif-dialog:munge-account-mapping old-map new-info)
(let ((new-name (car new-info))
(new-type (cadr new-info))
(new-descript (caddr new-info)))
(list-set! old-map 1 new-name)
(list-set! old-map 2 new-type)
(cond ((qif-cat? (list-ref old-map 5))
(qif-cat:set-description! (list-ref old-map 5) new-descript))
((qif-acct? (list-ref old-map 5))
(qif-acct:set-description! (list-ref old-map 5) new-descript))
(#t
(list-set! old-map 5 new-descript)))))
(define (default-dividend-acct security)
(string-append "Dividends:" security))