move scheduled transaction book anchors to own file

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8539 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2003-06-10 15:07:52 +00:00
parent cc556f3e89
commit 664b865f8b
5 changed files with 194 additions and 52 deletions

View File

@ -20,6 +20,7 @@ libgncmod_engine_la_SOURCES = \
QueryCore.c \
QueryObject.c \
SchedXaction.c \
SX-book.c \
SX-ttinfo.c \
Scrub.c \
Scrub2.c \
@ -57,6 +58,7 @@ gncinclude_HEADERS = \
Group.h \
Period.h \
SchedXaction.h \
SX-book.h \
SX-ttinfo.h \
Query.h \
QueryNew.h \
@ -100,6 +102,7 @@ noinst_HEADERS = \
QueryCoreP.h \
SchedXactionP.h \
ScrubP.h \
SX-book.h \
SX-ttinfo.h \
TransactionP.h \
gnc-book-p.h \

47
src/engine/SX-book-p.h Normal file
View File

@ -0,0 +1,47 @@
/********************************************************************\
* SX-book-p.h -- private scheduled transaction dataset access *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
\********************************************************************/
/*
* FILE:
* SX-book-p.h
*
* FUNCTION:
* Private members of SX-in-book utils.
* See src/doc/books.txt for design overview.
*
* HISTORY:
* Copyright (c) 2003 Linas Vepstas <linas@linas.org>
*/
#ifndef GNC_SX_BOOK_P_H
#define GNC_SX_BOOK_P_H
/* ====================================================================== */
struct xaccSchedXactionsDef {
GNCBook *book;
GList *sx_list;
gboolean sx_notsaved;
};
void gnc_book_set_schedxactions( GNCBook *book, GList *newList );
#endif /* GNC_SX_BOOK_P_H */

93
src/engine/SX-book.c Normal file
View File

@ -0,0 +1,93 @@
/********************************************************************\
* SX-book.c -- scheduled transaction dataset access *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
\********************************************************************/
/*
* FILE:
* SX-book.c
*
* FUNCTION:
* Anchor Scheduled Transaction Info into the book.
* See src/doc/books.txt for design overview.
*
* HISTORY:
* Copyright (c) 2003 Linas Vepstas <linas@linas.org>
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "gnc-book.h"
#include "gnc-book-p.h"
#include "gnc-engine.h"
// #include "gnc-engine-util.h"
#include "SchedXaction.h"
// #include "SchedXactionP.h"
#include "SX-book.h"
#include "SX-book-p.h"
/* static short module = MOD_SX; */
/* ====================================================================== */
#define GNC_SCHEDXACTIONS "gnc_schedxactions"
SchedXactions *
gnc_book_get_schedxaction_list( GNCBook *book )
{
if ( book == NULL ) return NULL;
return gnc_book_get_data (book, GNC_SCHEDXACTIONS);
}
GList *
gnc_book_get_schedxactions( GNCBook *book )
{
SchedXactions *list;
if ( book == NULL ) return NULL;
list = gnc_book_get_data (book, GNC_SCHEDXACTIONS);
if (list) return list->sx_list;
return NULL;
}
void
gnc_book_set_schedxactions( GNCBook *book, GList *newList )
{
SchedXactions *old_list, *new_list;
if ( book == NULL ) return;
old_list = gnc_book_get_data (book, GNC_SCHEDXACTIONS);
if (old_list && old_list->sx_list == newList) return;
new_list = g_new (SchedXactions, 1);
new_list->book = book;
new_list->sx_list = newList;
new_list->sx_notsaved = TRUE;
if (NULL == newList) new_list->sx_notsaved = FALSE;
gnc_book_set_data (book, GNC_SCHEDXACTIONS, new_list);
g_free (old_list);
}
/* ========================== END OF FILE =============================== */

47
src/engine/SX-book.h Normal file
View File

@ -0,0 +1,47 @@
/********************************************************************\
* SX-book.h -- scheduled transaction dataset access *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
\********************************************************************/
/*
* FILE:
* SX-book.h
*
* FUNCTION:
* Anchor Scheduled Transaction info in a book.
* See src/doc/books.txt for design overview.
*
* HISTORY:
* Copyright (c) 2003 Linas Vepstas <linas@linas.org>
*/
#ifndef GNC_SX_BOOK_H
#define GNC_SX_BOOK_H
#include <glib.h>
#include "gnc-book.h"
typedef struct xaccSchedXactionsDef SchedXactions;
SchedXactions * gnc_book_get_schedxaction_list( GNCBook *book );
GList * gnc_book_get_schedxactions( GNCBook *book );
#endif /* GNC_SX_BOOK_H */
/* ========================== END OF FILE =============================== */

View File

@ -35,12 +35,8 @@
#include "config.h"
#include <dlfcn.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <glib.h>
@ -61,55 +57,11 @@
#include "gnc-pricedb-p.h"
#include "SchedXaction.h"
#include "SchedXactionP.h"
#include "SX-book.h"
#include "SX-book-p.h"
static short module = MOD_ENGINE;
/* ====================================================================== */
typedef struct xaccSchedXactionListDef {
GNCBook *book;
GList *sx_list;
gboolean sx_notsaved;
} SchedXactionList;
#define GNC_SCHEDXACTIONS "gnc_schedxactions"
static SchedXactionList *
gnc_book_get_schedxaction_list( GNCBook *book )
{
if ( book == NULL ) return NULL;
return gnc_book_get_data (book, GNC_SCHEDXACTIONS);
}
GList *
gnc_book_get_schedxactions( GNCBook *book )
{
SchedXactionList *list;
if ( book == NULL ) return NULL;
list = gnc_book_get_data (book, GNC_SCHEDXACTIONS);
if (list) return list->sx_list;
return NULL;
}
void
gnc_book_set_schedxactions( GNCBook *book, GList *newList )
{
SchedXactionList *old_list, *new_list;
if ( book == NULL ) return;
old_list = gnc_book_get_data (book, GNC_SCHEDXACTIONS);
if (old_list && old_list->sx_list == newList) return;
new_list = g_new (SchedXactionList, 1);
new_list->book = book;
new_list->sx_list = newList;
new_list->sx_notsaved = TRUE;
if (NULL == newList) new_list->sx_notsaved = FALSE;
gnc_book_set_data (book, GNC_SCHEDXACTIONS, new_list);
g_free (old_list);
}
/* ====================================================================== */
/* dirty flag stuff */
@ -124,7 +76,7 @@ mark_sx_clean(gpointer data, gpointer user_data)
static void
book_sxns_mark_saved(GNCBook *book)
{
SchedXactionList *sxl;
SchedXactions *sxl;
sxl = gnc_book_get_schedxaction_list (book);
if (sxl) sxl->sx_notsaved = FALSE;
@ -139,7 +91,7 @@ book_sxlist_notsaved(GNCBook *book)
{
GList *sxlist;
SchedXaction *sx;
SchedXactionList *sxl;
SchedXactions *sxl;
sxl = gnc_book_get_schedxaction_list (book);
if((sxl && sxl->sx_notsaved)