r15486 - gnucash/trunk/src - SX "enabled" patch from Peter McAlpine <peter at aoeu.ca>.
Josh Sled
jsled at cvs.gnucash.org
Wed Jan 31 22:30:23 EST 2007
Author: jsled
Date: 2007-01-31 22:30:21 -0500 (Wed, 31 Jan 2007)
New Revision: 15486
Trac: http://svn.gnucash.org/trac/changeset/15486
Modified:
gnucash/trunk/src/app-utils/gnc-sx-instance-model.c
gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c
gnucash/trunk/src/doc/xml/gnucash-v2.rnc
gnucash/trunk/src/engine/SchedXaction.c
gnucash/trunk/src/engine/SchedXaction.h
gnucash/trunk/src/engine/SchedXactionP.h
gnucash/trunk/src/gnome/dialog-sx-editor.c
gnucash/trunk/src/gnome/dialog-sx-editor.h
gnucash/trunk/src/gnome/dialog-sx-from-trans.c
gnucash/trunk/src/gnome/glade/sched-xact.glade
Log:
SX "enabled" patch from Peter McAlpine <peter at aoeu.ca>.
Modified: gnucash/trunk/src/app-utils/gnc-sx-instance-model.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-sx-instance-model.c 2007-02-01 02:25:52 UTC (rev 15485)
+++ gnucash/trunk/src/app-utils/gnc-sx-instance-model.c 2007-02-01 03:30:21 UTC (rev 15486)
@@ -413,20 +413,34 @@
GncSxInstanceModel*
gnc_sx_get_instances(GDate *range_end)
{
+ GList *enabled_sxes = NULL;
GncSxInstanceModel *instances;
- GList *sxes;
g_assert(range_end != NULL);
g_assert(g_date_valid(range_end));
+ {
+ GList *all_sxes = gnc_book_get_schedxactions(gnc_get_current_book())->sx_list;
+ GList *sx_iter = g_list_first(all_sxes);
+
+ for (; sx_iter != NULL; sx_iter = sx_iter->next)
+ {
+ SchedXaction *sx = (SchedXaction*)sx_iter->data;
+ if (xaccSchedXactionGetEnabled(sx))
+ {
+ enabled_sxes = g_list_append(enabled_sxes, sx);
+ }
+ }
+ }
+
instances = gnc_sx_instance_model_new();
instances->range_end = *range_end;
- sxes = gnc_book_get_schedxactions(gnc_get_current_book())->sx_list;
- instances->sx_instance_list = gnc_g_list_map(sxes, (GncGMapFunc)_gnc_sx_gen_instances, range_end);
+ instances->sx_instance_list = gnc_g_list_map(enabled_sxes, (GncGMapFunc)_gnc_sx_gen_instances, range_end);
+ g_list_free(enabled_sxes);
+
return instances;
}
-
static GncSxInstanceModel*
gnc_sx_instance_model_new(void)
{
@@ -585,6 +599,7 @@
return -1;
}
+// @fixme: this needs to ignore non-enabled SXes
static void
_gnc_sx_instance_event_handler(QofEntity *ent, QofEventId event_type, gpointer user_data, gpointer evt_data)
{
Modified: gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c 2007-02-01 02:25:52 UTC (rev 15485)
+++ gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c 2007-02-01 03:30:21 UTC (rev 15486)
@@ -55,6 +55,7 @@
* <gnc:schedxaction version="1.0.0">
* <sx:id type="guid">...</sx:id>
* <sx:name>Rent</sx:name>
+ * <sx:enabled>y</sx:enabled>
* <sx:autoCreate>y</sx:autoCreate>
* <sx:autoCreateNotify>n</sx:autoCreateNotify>
* <sx:advanceCreateDays>0</sx:advanceCreateDays>
@@ -117,6 +118,7 @@
#define SX_ID "sx:id"
#define SX_NAME "sx:name"
+#define SX_ENABLED "sx:enabled"
#define SX_AUTOCREATE "sx:autoCreate"
#define SX_AUTOCREATE_NOTIFY "sx:autoCreateNotify"
#define SX_ADVANCE_CREATE_DAYS "sx:advanceCreateDays"
@@ -164,6 +166,9 @@
xmlNewTextChild( ret, NULL, BAD_CAST SX_NAME, BAD_CAST xaccSchedXactionGetName(sx) );
+ xmlNewTextChild( ret, NULL, BAD_CAST SX_ENABLED,
+ BAD_CAST ( sx->enabled ? "y" : "n" ) );
+
xmlNewTextChild( ret, NULL, BAD_CAST SX_AUTOCREATE,
BAD_CAST ( sx->autoCreateOption ? "y" : "n" ) );
xmlNewTextChild( ret, NULL, BAD_CAST SX_AUTOCREATE_NOTIFY,
@@ -285,6 +290,18 @@
}
static gboolean
+sx_enabled_handler( xmlNodePtr node, gpointer sx_pdata )
+{
+ struct sx_pdata *pdata = sx_pdata;
+ SchedXaction *sx = pdata->sx;
+ gchar *tmp = dom_tree_to_text( node );
+
+ sx->enabled = (safe_strcmp( tmp, "y" ) == 0 ? TRUE : FALSE );
+
+ return TRUE;
+}
+
+static gboolean
sx_autoCreate_handler( xmlNodePtr node, gpointer sx_pdata )
{
struct sx_pdata *pdata = sx_pdata;
@@ -561,6 +578,7 @@
struct dom_tree_handler sx_dom_handlers[] = {
{ SX_ID, sx_id_handler, 1, 0 },
{ SX_NAME, sx_name_handler, 1, 0 },
+ { SX_ENABLED, sx_enabled_handler, 0, 0 },
{ SX_AUTOCREATE, sx_autoCreate_handler, 1, 0 },
{ SX_AUTOCREATE_NOTIFY, sx_notify_handler, 1, 0 },
{ SX_ADVANCE_CREATE_DAYS, sx_advCreate_handler, 1, 0 },
Modified: gnucash/trunk/src/doc/xml/gnucash-v2.rnc
===================================================================
--- gnucash/trunk/src/doc/xml/gnucash-v2.rnc 2007-02-01 02:25:52 UTC (rev 15485)
+++ gnucash/trunk/src/doc/xml/gnucash-v2.rnc 2007-02-01 03:30:21 UTC (rev 15486)
@@ -336,6 +336,7 @@
attribute version { "1.0.0" },
element sx:id { attribute type { "guid" }, xsd:string { pattern = "[0-9a-f]{32}" }},
element sx:name { text },
+ element sx:enabled { "y" | "n" },
element sx:autoCreate { "y" | "n" },
element sx:autoCreateNotify { "y" | "n" },
element sx:advanceCreateDays { xsd:int },
Modified: gnucash/trunk/src/engine/SchedXaction.c
===================================================================
--- gnucash/trunk/src/engine/SchedXaction.c 2007-02-01 02:25:52 UTC (rev 15485)
+++ gnucash/trunk/src/engine/SchedXaction.c 2007-02-01 03:30:21 UTC (rev 15486)
@@ -60,6 +60,7 @@
g_date_clear( &sx->start_date, 1 );
g_date_clear( &sx->end_date, 1 );
+ sx->enabled = 1;
sx->num_occurances_total = 0;
sx->autoCreateOption = FALSE;
sx->autoCreateNotify = FALSE;
@@ -375,7 +376,22 @@
gnc_sx_commit_edit(sx);
}
+gboolean
+xaccSchedXactionGetEnabled( SchedXaction *sx )
+{
+ return sx->enabled;
+}
+
void
+xaccSchedXactionSetEnabled( SchedXaction *sx, gboolean newEnabled)
+{
+ gnc_sx_begin_edit(sx);
+ sx->enabled = newEnabled;
+ qof_instance_set_dirty(&sx->inst);
+ gnc_sx_commit_edit(sx);
+}
+
+void
xaccSchedXactionGetAutoCreate( SchedXaction *sx,
gboolean *outAutoCreate,
gboolean *outNotify )
Modified: gnucash/trunk/src/engine/SchedXaction.h
===================================================================
--- gnucash/trunk/src/engine/SchedXaction.h 2007-02-01 02:25:52 UTC (rev 15485)
+++ gnucash/trunk/src/engine/SchedXaction.h 2007-02-01 03:30:21 UTC (rev 15486)
@@ -124,6 +124,9 @@
GList *xaccSchedXactionGetSplits( SchedXaction *sx );
void xaccSchedXactionSetSplits( SchedXaction *sx, GList *newSplits );
+gboolean xaccSchedXactionGetEnabled( SchedXaction *sx );
+void xaccSchedXactionSetEnabled( SchedXaction *sx, gboolean newEnabled );
+
void xaccSchedXactionGetAutoCreate( SchedXaction *sx,
gboolean *outAutoCreate,
gboolean *outNotify );
Modified: gnucash/trunk/src/engine/SchedXactionP.h
===================================================================
--- gnucash/trunk/src/engine/SchedXactionP.h 2007-02-01 02:25:52 UTC (rev 15485)
+++ gnucash/trunk/src/engine/SchedXactionP.h 2007-02-01 03:30:21 UTC (rev 15486)
@@ -68,6 +68,7 @@
/* the current instance-count of the SX. */
gint instance_num;
+ gboolean enabled;
gboolean autoCreateOption;
gboolean autoCreateNotify;
gint advanceCreateDays;
Modified: gnucash/trunk/src/gnome/dialog-sx-editor.c
===================================================================
--- gnucash/trunk/src/gnome/dialog-sx-editor.c 2007-02-01 02:25:52 UTC (rev 15485)
+++ gnucash/trunk/src/gnome/dialog-sx-editor.c 2007-02-01 03:30:21 UTC (rev 15486)
@@ -73,6 +73,7 @@
#define SXED_WIN_PREFIX "sx_editor_win"
#define SXED_NAME_ENTRY "sxe_name"
#define SXED_LAST_OCCUR_LABEL "last_occur_label"
+#define ENABLED_OPT "enabled_opt"
#define AUTOCREATE_OPT "autocreate_opt"
#define NOTIFY_OPT "notify_opt"
#define ADVANCE_OPT "advance_opt"
@@ -124,6 +125,7 @@
GtkLabel *lastOccurLabel;
+ GtkToggleButton *enabledOpt;
GtkToggleButton *autocreateOpt;
GtkToggleButton *notifyOpt;
GtkToggleButton *advanceOpt;
@@ -341,10 +343,18 @@
/* SX options [autocreate, notify, reminder, advance] */
{
- gboolean dlgAutoCreate, dlgNotify, sxAutoCreate, sxNotify;
+ gboolean dlgEnabled,
+ dlgAutoCreate,
+ dlgNotify,
+ sxEnabled,
+ sxAutoCreate,
+ sxNotify;
gint dlgAdvance, sxAdvance;
gint dlgRemind, sxRemind;
+ dlgEnabled =
+ gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(sxed->
+ enabledOpt) );
dlgAutoCreate =
gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(sxed->
autocreateOpt) );
@@ -352,6 +362,11 @@
gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(sxed->
notifyOpt) );
+ sxEnabled = xaccSchedXactionGetEnabled( sxed->sx );
+ if ( ! ((dlgEnabled == sxEnabled)) ) {
+ return TRUE;
+ }
+
xaccSchedXactionGetAutoCreate( sxed->sx, &sxAutoCreate, &sxNotify );
if ( ! ((dlgAutoCreate == sxAutoCreate)
&& (dlgNotify == sxNotify)) ) {
@@ -909,6 +924,14 @@
}
}
+ /* Enabled states */
+ {
+ gboolean enabledState;
+
+ enabledState = gtk_toggle_button_get_active( sxed->enabledOpt );
+ xaccSchedXactionSetEnabled( sxed->sx, enabledState );
+ }
+
/* Auto-create/notification states */
{
gboolean autocreateState, notifyState;
@@ -961,6 +984,12 @@
}
static void
+enabled_toggled( GtkObject *o, GncSxEditorDialog *sxed )
+{
+ return;
+}
+
+static void
autocreate_toggled( GtkObject *o, GncSxEditorDialog *sxed )
{
if ( !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(o)) ) {
@@ -1053,6 +1082,8 @@
sxed->nameEntry = GTK_EDITABLE(w);
w = glade_xml_get_widget( sxed->gxml, SXED_LAST_OCCUR_LABEL );
sxed->lastOccurLabel = GTK_LABEL(w);
+ w = glade_xml_get_widget( sxed->gxml, ENABLED_OPT );
+ sxed->enabledOpt = GTK_TOGGLE_BUTTON(w);
w = glade_xml_get_widget( sxed->gxml, AUTOCREATE_OPT );
sxed->autocreateOpt = GTK_TOGGLE_BUTTON(w);
w = glade_xml_get_widget( sxed->gxml, NOTIFY_OPT );
@@ -1108,6 +1139,7 @@
{ REMAIN_SPIN , "value-changed", sxed_excal_update_adapt, NULL },
+ { ENABLED_OPT, "toggled", enabled_toggled, NULL },
{ AUTOCREATE_OPT, "toggled", autocreate_toggled, NULL },
{ ADVANCE_OPT, "toggled", advance_toggle, (gpointer)ADVANCE_DAYS_SPIN },
{ REMIND_OPT, "toggled", advance_toggle, (gpointer)REMIND_DAYS_SPIN },
@@ -1300,7 +1332,7 @@
struct tm *tmpTm;
GDate *gd;
gint daysInAdvance;
- gboolean autoCreateState, notifyState;
+ gboolean enabledState, autoCreateState, notifyState;
name = xaccSchedXactionGetName(sxed->sx);
if ( name != NULL ) {
@@ -1344,6 +1376,9 @@
set_endgroup_toggle_states( sxed, END_NEVER );
}
+ enabledState = xaccSchedXactionGetEnabled( sxed->sx );
+ gtk_toggle_button_set_active( sxed->enabledOpt, enabledState );
+
/* Do auto-create/notify setup */
if ( sxed->newsxP ) {
autoCreateState =
Modified: gnucash/trunk/src/gnome/dialog-sx-editor.h
===================================================================
--- gnucash/trunk/src/gnome/dialog-sx-editor.h 2007-02-01 02:25:52 UTC (rev 15485)
+++ gnucash/trunk/src/gnome/dialog-sx-editor.h 2007-02-01 03:30:21 UTC (rev 15486)
@@ -28,8 +28,8 @@
#define DIALOG_SCHEDXACTION_EDITOR_CM_CLASS "dialog-scheduledtransaction-editor"
#define SXED_GCONF_SECTION "dialogs/scheduled_trans/transaction_editor"
-#define KEY_CREATE_AUTO "create_auto"
-#define KEY_NOTIFY "notify"
+#define KEY_CREATE_AUTO "create_auto"
+#define KEY_NOTIFY "notify"
#define KEY_CREATE_DAYS "create_days"
#define KEY_REMIND_DAYS "remind_days"
Modified: gnucash/trunk/src/gnome/dialog-sx-from-trans.c
===================================================================
--- gnucash/trunk/src/gnome/dialog-sx-from-trans.c 2007-02-01 02:25:52 UTC (rev 15485)
+++ gnucash/trunk/src/gnome/dialog-sx-from-trans.c 2007-02-01 03:30:21 UTC (rev 15486)
@@ -493,9 +493,9 @@
gnc_sx_set_instance_count( sx, 1 );
/* Set the autocreate, days-in-advance and remind-in-advance values from
- options. */
- {
- gboolean autoCreateState, notifyState;
+ * options. */
+ {
+ gboolean autoCreateState, notifyState;
gint daysInAdvance;
autoCreateState =
Modified: gnucash/trunk/src/gnome/glade/sched-xact.glade
===================================================================
--- gnucash/trunk/src/gnome/glade/sched-xact.glade 2007-02-01 02:25:52 UTC (rev 15485)
+++ gnucash/trunk/src/gnome/glade/sched-xact.glade 2007-02-01 03:30:21 UTC (rev 15486)
@@ -236,7 +236,7 @@
<child>
<widget class="GtkTable" id="table2">
<property name="visible">True</property>
- <property name="n_rows">4</property>
+ <property name="n_rows">5</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
@@ -257,8 +257,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@@ -279,8 +279,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@@ -339,8 +339,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
@@ -362,8 +362,8 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@@ -422,8 +422,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
@@ -459,13 +459,35 @@
<packing>
<property name="left_attach">0</property>
<property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="x_padding">24</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkCheckButton" id="enabled_opt">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Enabled</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
</widget>
</child>
</widget>
More information about the gnucash-changes
mailing list