SX "enabled" patch from Peter McAlpine <peter@aoeu.ca>.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15486 57a11ea4-9604-0410-9ed3-97b8803252fd
zzzoldfeatures/module-cleanup
Joshua Sled 20 years ago
parent 594a1f343f
commit 8577897ac7

@ -413,20 +413,34 @@ gnc_sx_get_current_instances(void)
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 @@ _gnc_sx_instance_find_by_sx(GncSxInstances *in_list_instances, SchedXaction *sx_
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)
{

@ -55,6 +55,7 @@ static QofLogModule log_module = GNC_MOD_SX;
* <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 @@ static QofLogModule log_module = GNC_MOD_SX;
#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 @@ gnc_schedXaction_dom_tree_create(SchedXaction *sx)
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,
@ -284,6 +289,18 @@ sx_name_handler( xmlNodePtr node, gpointer sx_pdata )
return TRUE;
}
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 )
{
@ -561,6 +578,7 @@ sx_slots_handler( xmlNodePtr node, gpointer sx_pdata )
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 },

@ -336,6 +336,7 @@ ScheduledTransaction = element gnc:schedxaction {
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 },

@ -60,6 +60,7 @@ xaccSchedXactionInit(SchedXaction *sx, QofBook *book)
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,6 +376,21 @@ xaccSchedXactionSetSlot( SchedXaction *sx,
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,

@ -124,6 +124,9 @@ void gnc_sx_set_instance_count( SchedXaction *sx, gint instanceNum );
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 );

@ -68,6 +68,7 @@ struct gncp_SchedXaction
/* the current instance-count of the SX. */
gint instance_num;
gboolean enabled;
gboolean autoCreateOption;
gboolean autoCreateNotify;
gint advanceCreateDays;

@ -73,6 +73,7 @@ static gint _sx_engine_event_handler_id = -1;
#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 @@ struct _GncSxEditorDialog
GtkLabel *lastOccurLabel;
GtkToggleButton *enabledOpt;
GtkToggleButton *autocreateOpt;
GtkToggleButton *notifyOpt;
GtkToggleButton *advanceOpt;
@ -341,10 +343,18 @@ gnc_sxed_check_changed( GncSxEditorDialog *sxed )
/* 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 @@ gnc_sxed_check_changed( GncSxEditorDialog *sxed )
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 @@ gnc_sxed_save_sx( GncSxEditorDialog *sxed )
}
}
/* Enabled states */
{
gboolean enabledState;
enabledState = gtk_toggle_button_get_active( sxed->enabledOpt );
xaccSchedXactionSetEnabled( sxed->sx, enabledState );
}
/* Auto-create/notification states */
{
gboolean autocreateState, notifyState;
@ -960,6 +983,12 @@ gnc_sxed_save_sx( GncSxEditorDialog *sxed )
}
static void
enabled_toggled( GtkObject *o, GncSxEditorDialog *sxed )
{
return;
}
static void
autocreate_toggled( GtkObject *o, GncSxEditorDialog *sxed )
{
@ -1053,6 +1082,8 @@ gnc_sxed_get_widgets( GncSxEditorDialog *sxed )
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 @@ gnc_ui_scheduled_xaction_editor_dialog_create(SchedXaction *sx,
{ 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 @@ schedXact_editor_populate( GncSxEditorDialog *sxed )
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 @@ schedXact_editor_populate( GncSxEditorDialog *sxed )
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 =

@ -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"

@ -493,9 +493,9 @@ sxftd_compute_sx(SXFromTransInfo *sxfti)
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 =

@ -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>

Loading…
Cancel
Save