mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-09-03 20:53:02 -05:00
Refactor gnc_sxed_check_changed() with a bunch of extract-functions.
This commit is contained in:
+210
-232
@@ -160,7 +160,7 @@ static void gnc_sxed_reg_check_close(GncSxEditorDialog *sxed);
|
||||
static gboolean sxed_delete_event( GtkWidget *widget, GdkEvent *event, gpointer ud );
|
||||
static gboolean sxed_confirmed_cancel( GncSxEditorDialog *sxed );
|
||||
static gboolean editor_component_sx_equality( gpointer find_data,
|
||||
gpointer user_data );
|
||||
gpointer user_data );
|
||||
|
||||
static GtkActionEntry gnc_sxed_menu_entries [] =
|
||||
{
|
||||
@@ -261,6 +261,126 @@ editor_ok_button_clicked_cb( GtkButton *b, GncSxEditorDialog *sxed )
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gnc_sxed_check_name_changed (GncSxEditorDialog *sxed)
|
||||
{
|
||||
char *name = gtk_editable_get_chars (GTK_EDITABLE(sxed->nameEntry), 0, -1);
|
||||
|
||||
if (strlen(name) == 0)
|
||||
return TRUE;
|
||||
|
||||
if (xaccSchedXactionGetName(sxed->sx) == NULL ||
|
||||
strcmp(xaccSchedXactionGetName(sxed->sx), name) != 0)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_sxed_check_end_date_changed (GncSxEditorDialog *sxed)
|
||||
{
|
||||
GDate sxEndDate, dlgEndDate;
|
||||
|
||||
if (! xaccSchedXactionHasEndDate (sxed->sx))
|
||||
return TRUE;
|
||||
|
||||
sxEndDate = *xaccSchedXactionGetEndDate (sxed->sx);
|
||||
gnc_gdate_set_time64 (&dlgEndDate,
|
||||
gnc_date_edit_get_date (sxed-> endDateEntry));
|
||||
|
||||
if (g_date_compare (&sxEndDate, &dlgEndDate) != 0)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_sxed_check_num_occurs_changed(GncSxEditorDialog *sxed)
|
||||
{
|
||||
gint sxNumOccur, sxNumRem, dlgNumOccur, dlgNumRem;
|
||||
|
||||
if (! xaccSchedXactionGetNumOccur(sxed->sx))
|
||||
return TRUE;
|
||||
dlgNumOccur =
|
||||
gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(sxed->endCountSpin));
|
||||
dlgNumRem =
|
||||
gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(sxed->endRemainSpin));
|
||||
sxNumOccur = xaccSchedXactionGetNumOccur (sxed->sx);
|
||||
sxNumRem = xaccSchedXactionGetRemOccur (sxed->sx);
|
||||
|
||||
if (dlgNumOccur != sxNumOccur || dlgNumRem != sxNumRem)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_sxed_check_creation_changed (GncSxEditorDialog *sxed)
|
||||
{
|
||||
gboolean sxAutoCreate, sxNotify;
|
||||
gint dlgAdvance = 0;
|
||||
gint dlgRemind = 0;
|
||||
|
||||
gboolean dlgEnabled =
|
||||
gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(sxed->enabledOpt) );
|
||||
gboolean dlgAutoCreate =
|
||||
gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(sxed->autocreateOpt) );
|
||||
gboolean dlgNotify =
|
||||
gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(sxed->notifyOpt) );
|
||||
|
||||
if (dlgEnabled != xaccSchedXactionGetEnabled (sxed->sx))
|
||||
return TRUE;
|
||||
|
||||
xaccSchedXactionGetAutoCreate (sxed->sx, &sxAutoCreate, &sxNotify);
|
||||
if (dlgAutoCreate != sxAutoCreate || dlgNotify != sxNotify)
|
||||
return TRUE;
|
||||
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(sxed->advanceOpt)))
|
||||
dlgAdvance = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(sxed->advanceSpin));
|
||||
if (dlgAdvance != xaccSchedXactionGetAdvanceCreation (sxed->sx))
|
||||
return TRUE;
|
||||
|
||||
if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(sxed->remindOpt)))
|
||||
dlgRemind = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(sxed->remindSpin));
|
||||
if (dlgRemind != xaccSchedXactionGetAdvanceReminder (sxed->sx))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_sxed_check_dates_changed (GncSxEditorDialog *sxed)
|
||||
{
|
||||
GList *dialog_schedule = NULL;
|
||||
GDate dialog_start_date, sx_start_date;
|
||||
gchar *dialog_schedule_str, *sx_schedule_str;
|
||||
gboolean schedules_are_the_same, start_dates_are_the_same;
|
||||
|
||||
g_date_clear(&dialog_start_date, 1);
|
||||
gnc_frequency_save_to_recurrence (sxed->gncfreq, &dialog_schedule,
|
||||
&dialog_start_date);
|
||||
dialog_schedule_str = recurrenceListToString(dialog_schedule);
|
||||
recurrenceListFree(&dialog_schedule);
|
||||
|
||||
sx_start_date = *xaccSchedXactionGetStartDate (sxed->sx);
|
||||
sx_schedule_str = recurrenceListToString (gnc_sx_get_schedule(sxed->sx));
|
||||
|
||||
g_debug ("dialog schedule [%s], sx schedule [%s]",
|
||||
dialog_schedule_str, sx_schedule_str);
|
||||
|
||||
schedules_are_the_same = (strcmp(dialog_schedule_str,
|
||||
sx_schedule_str) == 0);
|
||||
g_free(dialog_schedule_str);
|
||||
g_free(sx_schedule_str);
|
||||
|
||||
start_dates_are_the_same = (g_date_compare(&dialog_start_date,
|
||||
&sx_start_date) == 0);
|
||||
|
||||
if (schedules_are_the_same && start_dates_are_the_same)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Checks to see if the SX has been modified from it's previously-saved
|
||||
* state.
|
||||
@@ -268,185 +388,43 @@ editor_ok_button_clicked_cb( GtkButton *b, GncSxEditorDialog *sxed )
|
||||
* previous configuration.
|
||||
************************************************************************/
|
||||
static gboolean
|
||||
gnc_sxed_check_changed( GncSxEditorDialog *sxed )
|
||||
gnc_sxed_check_changed (GncSxEditorDialog *sxed)
|
||||
{
|
||||
if ( sxed->newsxP )
|
||||
SplitRegister *sr = NULL;
|
||||
if (sxed->newsxP)
|
||||
return TRUE;
|
||||
|
||||
/* name */
|
||||
{
|
||||
char *name;
|
||||
|
||||
name = gtk_editable_get_chars( GTK_EDITABLE(sxed->nameEntry), 0, -1 );
|
||||
if ( strlen(name) == 0 )
|
||||
{
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
if ( (xaccSchedXactionGetName(sxed->sx) == NULL)
|
||||
|| (strcmp( xaccSchedXactionGetName(sxed->sx),
|
||||
name ) != 0) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (gnc_sxed_check_name_changed(sxed))
|
||||
return TRUE;
|
||||
/* end options */
|
||||
{
|
||||
/* dialog says... no end */
|
||||
if ( gtk_toggle_button_get_active( sxed->optEndNone ) )
|
||||
{
|
||||
if ( xaccSchedXactionHasEndDate(sxed->sx)
|
||||
|| xaccSchedXactionHasOccurDef(sxed->sx) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
/* dialog says... no end */
|
||||
if (gtk_toggle_button_get_active (sxed->optEndNone) &&
|
||||
(xaccSchedXactionHasEndDate (sxed->sx) ||
|
||||
xaccSchedXactionHasOccurDef (sxed->sx)))
|
||||
return TRUE;
|
||||
|
||||
/* dialog says... end date */
|
||||
if ( gtk_toggle_button_get_active( sxed->optEndDate ) )
|
||||
{
|
||||
GDate sxEndDate, dlgEndDate;
|
||||
|
||||
if ( ! xaccSchedXactionHasEndDate( sxed->sx ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
sxEndDate = *xaccSchedXactionGetEndDate( sxed->sx );
|
||||
gnc_gdate_set_time64( &dlgEndDate,
|
||||
gnc_date_edit_get_date( sxed->
|
||||
endDateEntry ) );
|
||||
|
||||
if ( g_date_compare( &sxEndDate, &dlgEndDate ) != 0 )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* dialog says... num occur */
|
||||
if ( gtk_toggle_button_get_active( sxed->optEndCount ) )
|
||||
{
|
||||
gint sxNumOccur, sxNumRem, dlgNumOccur, dlgNumRem;
|
||||
|
||||
if ( ! xaccSchedXactionGetNumOccur( sxed->sx ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
dlgNumOccur =
|
||||
gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(sxed->endCountSpin) );
|
||||
|
||||
dlgNumRem =
|
||||
gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(sxed->endRemainSpin) );
|
||||
|
||||
sxNumOccur = xaccSchedXactionGetNumOccur( sxed->sx );
|
||||
sxNumRem = xaccSchedXactionGetRemOccur( sxed->sx );
|
||||
|
||||
if ( (dlgNumOccur != sxNumOccur)
|
||||
|| (dlgNumRem != sxNumRem) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* dialog says... end date */
|
||||
if (gtk_toggle_button_get_active( sxed->optEndDate ) &&
|
||||
gnc_sxed_check_end_date_changed(sxed))
|
||||
return TRUE;
|
||||
|
||||
/* dialog says... num occur */
|
||||
if (gtk_toggle_button_get_active (sxed->optEndCount) &&
|
||||
gnc_sxed_check_num_occurs_changed (sxed))
|
||||
return TRUE;
|
||||
/* SX options [autocreate, notify, reminder, advance] */
|
||||
{
|
||||
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) );
|
||||
dlgNotify =
|
||||
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)) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
dlgAdvance = 0;
|
||||
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(sxed->advanceOpt) ) )
|
||||
{
|
||||
dlgAdvance =
|
||||
gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(sxed->
|
||||
advanceSpin) );
|
||||
}
|
||||
sxAdvance = xaccSchedXactionGetAdvanceCreation( sxed->sx );
|
||||
if ( dlgAdvance != sxAdvance )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
dlgRemind = 0;
|
||||
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(sxed->remindOpt) ) )
|
||||
{
|
||||
dlgRemind =
|
||||
gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(sxed->remindSpin) );
|
||||
}
|
||||
sxRemind = xaccSchedXactionGetAdvanceReminder( sxed->sx );
|
||||
if ( dlgRemind != sxRemind )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
GList *dialog_schedule = NULL;
|
||||
GDate dialog_start_date, sx_start_date;
|
||||
gchar *dialog_schedule_str, *sx_schedule_str;
|
||||
gboolean schedules_are_the_same, start_dates_are_the_same;
|
||||
|
||||
g_date_clear(&dialog_start_date, 1);
|
||||
gnc_frequency_save_to_recurrence(sxed->gncfreq, &dialog_schedule, &dialog_start_date);
|
||||
dialog_schedule_str = recurrenceListToString(dialog_schedule);
|
||||
recurrenceListFree(&dialog_schedule);
|
||||
|
||||
sx_start_date = *xaccSchedXactionGetStartDate(sxed->sx);
|
||||
sx_schedule_str = recurrenceListToString(gnc_sx_get_schedule(sxed->sx));
|
||||
|
||||
g_debug("dialog schedule [%s], sx schedule [%s]",
|
||||
dialog_schedule_str, sx_schedule_str);
|
||||
|
||||
schedules_are_the_same = (strcmp(dialog_schedule_str, sx_schedule_str) == 0);
|
||||
g_free(dialog_schedule_str);
|
||||
g_free(sx_schedule_str);
|
||||
|
||||
start_dates_are_the_same = (g_date_compare(&dialog_start_date, &sx_start_date) == 0);
|
||||
|
||||
if (!schedules_are_the_same || !start_dates_are_the_same)
|
||||
return TRUE;
|
||||
}
|
||||
if (gnc_sxed_check_creation_changed (sxed))
|
||||
return TRUE;
|
||||
/* Dates and Schedules */
|
||||
if (gnc_sxed_check_dates_changed (sxed))
|
||||
return TRUE;
|
||||
|
||||
/* template transactions */
|
||||
{
|
||||
SplitRegister *sr =
|
||||
gnc_ledger_display_get_split_register( sxed->ledger );
|
||||
sr = gnc_ledger_display_get_split_register( sxed->ledger );
|
||||
if ( gnc_split_register_changed( sr ) )
|
||||
return TRUE;
|
||||
|
||||
if ( gnc_split_register_changed( sr ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -483,19 +461,19 @@ check_credit_debit_balance( gpointer key,
|
||||
gboolean *unbalanced = (gboolean*)ud;
|
||||
*unbalanced |= !(gnc_numeric_zero_p(
|
||||
gnc_numeric_sub_fixed( tcds->debitSum,
|
||||
tcds->creditSum ) ));
|
||||
tcds->creditSum ) ));
|
||||
|
||||
if (qof_log_check(G_LOG_DOMAIN, QOF_LOG_DEBUG))
|
||||
{
|
||||
if ( gnc_numeric_zero_p( gnc_numeric_sub_fixed( tcds->debitSum,
|
||||
tcds->creditSum ) ) )
|
||||
tcds->creditSum ) ) )
|
||||
{
|
||||
g_debug( "%p | true [%s - %s = %s]",
|
||||
key,
|
||||
gnc_numeric_to_string( tcds->debitSum ),
|
||||
gnc_numeric_to_string( tcds->creditSum ),
|
||||
gnc_numeric_to_string(gnc_numeric_sub_fixed( tcds->debitSum,
|
||||
tcds->creditSum )) );
|
||||
tcds->creditSum )) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -504,7 +482,7 @@ check_credit_debit_balance( gpointer key,
|
||||
gnc_numeric_to_string( tcds->debitSum ),
|
||||
gnc_numeric_to_string( tcds->creditSum ),
|
||||
gnc_numeric_to_string(gnc_numeric_sub_fixed( tcds->debitSum,
|
||||
tcds->creditSum )) );
|
||||
tcds->creditSum )) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -614,8 +592,8 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed )
|
||||
t = xaccSplitGetParent( s );
|
||||
|
||||
if ( !(tcds =
|
||||
(txnCreditDebitSums*)g_hash_table_lookup( txns,
|
||||
(gpointer)t )) )
|
||||
(txnCreditDebitSums*)g_hash_table_lookup( txns,
|
||||
(gpointer)t )) )
|
||||
{
|
||||
tcds = g_new0( txnCreditDebitSums, 1 );
|
||||
tcds->creditSum = gnc_numeric_zero();
|
||||
@@ -647,8 +625,8 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed )
|
||||
GNC_SX_CREDIT_FORMULA,
|
||||
NULL );
|
||||
if ( v
|
||||
&& (str = kvp_value_get_string(v))
|
||||
&& strlen( str ) != 0 )
|
||||
&& (str = kvp_value_get_string(v))
|
||||
&& strlen( str ) != 0 )
|
||||
{
|
||||
if ( gnc_sx_parse_vars_from_formula( str, vars, &tmp ) < 0 )
|
||||
{
|
||||
@@ -675,8 +653,8 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed )
|
||||
GNC_SX_DEBIT_FORMULA,
|
||||
NULL );
|
||||
if ( v
|
||||
&& (str = kvp_value_get_string(v))
|
||||
&& strlen(str) != 0 )
|
||||
&& (str = kvp_value_get_string(v))
|
||||
&& strlen(str) != 0 )
|
||||
{
|
||||
if ( gnc_sx_parse_vars_from_formula( str, vars, &tmp ) < 0 )
|
||||
{
|
||||
@@ -716,13 +694,13 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed )
|
||||
g_hash_table_destroy(txns);
|
||||
|
||||
if ( unbalanceable
|
||||
&& !gnc_verify_dialog( sxed->dialog, FALSE,
|
||||
"%s",
|
||||
_("The Scheduled Transaction Editor "
|
||||
"cannot automatically balance "
|
||||
"this transaction. "
|
||||
"Should it still be "
|
||||
"entered?") ) )
|
||||
&& !gnc_verify_dialog( sxed->dialog, FALSE,
|
||||
"%s",
|
||||
_("The Scheduled Transaction Editor "
|
||||
"cannot automatically balance "
|
||||
"this transaction. "
|
||||
"Should it still be "
|
||||
"entered?") ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -752,9 +730,9 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed )
|
||||
(xaccSchedXactionGetName(sxed->sx) == NULL)
|
||||
|| (strcmp( xaccSchedXactionGetName(sxed->sx), name ) != 0);
|
||||
for ( sxList =
|
||||
gnc_book_get_schedxactions(gnc_get_current_book())->sx_list;
|
||||
nameHasChanged && !nameExists && sxList;
|
||||
sxList = sxList->next )
|
||||
gnc_book_get_schedxactions(gnc_get_current_book())->sx_list;
|
||||
nameHasChanged && !nameExists && sxList;
|
||||
sxList = sxList->next )
|
||||
{
|
||||
char *existingName, *existingNameKey;
|
||||
existingName =
|
||||
@@ -817,8 +795,8 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed )
|
||||
GDate startDate, endDate, nextDate;
|
||||
|
||||
if ( !gtk_toggle_button_get_active(sxed->optEndDate)
|
||||
&& !gtk_toggle_button_get_active(sxed->optEndCount)
|
||||
&& !gtk_toggle_button_get_active(sxed->optEndNone) )
|
||||
&& !gtk_toggle_button_get_active(sxed->optEndCount)
|
||||
&& !gtk_toggle_button_get_active(sxed->optEndNone) )
|
||||
{
|
||||
const char *sx_end_spec_msg =
|
||||
_( "Please provide a valid end selection." );
|
||||
@@ -863,8 +841,8 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed )
|
||||
if ( gtk_toggle_button_get_active(sxed->optEndDate) )
|
||||
{
|
||||
gnc_gdate_set_time64( &endDate,
|
||||
gnc_date_edit_get_date( sxed->
|
||||
endDateEntry ) );
|
||||
gnc_date_edit_get_date( sxed->
|
||||
endDateEntry ) );
|
||||
}
|
||||
|
||||
g_date_clear(&nextDate, 1);
|
||||
@@ -877,7 +855,7 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed )
|
||||
recurrenceListFree(&schedule);
|
||||
|
||||
if (!g_date_valid(&nextDate)
|
||||
|| (g_date_valid(&endDate) && (g_date_compare(&nextDate, &endDate) > 0)))
|
||||
|| (g_date_valid(&endDate) && (g_date_compare(&nextDate, &endDate) > 0)))
|
||||
{
|
||||
const char *invalid_sx_check_msg =
|
||||
_("You have attempted to create a Scheduled "
|
||||
@@ -918,8 +896,8 @@ gnc_sxed_save_sx( GncSxEditorDialog *sxed )
|
||||
{
|
||||
/* get the end date data */
|
||||
gnc_gdate_set_time64( &gdate,
|
||||
gnc_date_edit_get_date(
|
||||
sxed->endDateEntry ) );
|
||||
gnc_date_edit_get_date(
|
||||
sxed->endDateEntry ) );
|
||||
xaccSchedXactionSetEndDate( sxed->sx, &gdate );
|
||||
/* set the num occurrences data */
|
||||
xaccSchedXactionSetNumOccur( sxed->sx, 0 );
|
||||
@@ -1064,7 +1042,7 @@ scheduledxaction_editor_dialog_destroy(GtkWidget *object, gpointer data)
|
||||
return;
|
||||
|
||||
gnc_unregister_gui_component_by_data
|
||||
(DIALOG_SCHEDXACTION_EDITOR_CM_CLASS, sxed);
|
||||
(DIALOG_SCHEDXACTION_EDITOR_CM_CLASS, sxed);
|
||||
|
||||
gnc_embedded_window_close_page(sxed->embed_window, sxed->plugin_page);
|
||||
gtk_widget_destroy(GTK_WIDGET(sxed->embed_window));
|
||||
@@ -1135,20 +1113,20 @@ gnc_ui_scheduled_xaction_editor_dialog_create (SchedXaction *sx,
|
||||
void (*fn)();
|
||||
gpointer objectData;
|
||||
} widgets[] =
|
||||
{
|
||||
{ "ok_button", "clicked", editor_ok_button_clicked_cb, NULL },
|
||||
{ "cancel_button", "clicked", editor_cancel_button_clicked_cb, NULL },
|
||||
{ "help_button", "clicked", editor_help_button_clicked_cb, NULL },
|
||||
{ "rb_noend", "toggled", endgroup_rb_toggled_cb, GINT_TO_POINTER(END_NEVER_OPTION) },
|
||||
{ "rb_enddate", "toggled", endgroup_rb_toggled_cb, GINT_TO_POINTER(END_DATE_OPTION) },
|
||||
{ "rb_num_occur", "toggled", endgroup_rb_toggled_cb, GINT_TO_POINTER(NUM_OCCUR_OPTION) },
|
||||
{ "remain_spin" , "value-changed", sxed_excal_update_adapt_cb, NULL },
|
||||
{ "enabled_opt", "toggled", enabled_toggled_cb, NULL },
|
||||
{ "autocreate_opt", "toggled", autocreate_toggled_cb, NULL },
|
||||
{ "advance_opt", "toggled", advance_toggled_cb, NULL },
|
||||
{ "remind_opt", "toggled", remind_toggled_cb, NULL },
|
||||
{ NULL, NULL, NULL, NULL }
|
||||
};
|
||||
{
|
||||
{ "ok_button", "clicked", editor_ok_button_clicked_cb, NULL },
|
||||
{ "cancel_button", "clicked", editor_cancel_button_clicked_cb, NULL },
|
||||
{ "help_button", "clicked", editor_help_button_clicked_cb, NULL },
|
||||
{ "rb_noend", "toggled", endgroup_rb_toggled_cb, GINT_TO_POINTER(END_NEVER_OPTION) },
|
||||
{ "rb_enddate", "toggled", endgroup_rb_toggled_cb, GINT_TO_POINTER(END_DATE_OPTION) },
|
||||
{ "rb_num_occur", "toggled", endgroup_rb_toggled_cb, GINT_TO_POINTER(NUM_OCCUR_OPTION) },
|
||||
{ "remain_spin" , "value-changed", sxed_excal_update_adapt_cb, NULL },
|
||||
{ "enabled_opt", "toggled", enabled_toggled_cb, NULL },
|
||||
{ "autocreate_opt", "toggled", autocreate_toggled_cb, NULL },
|
||||
{ "advance_opt", "toggled", advance_toggled_cb, NULL },
|
||||
{ "remind_opt", "toggled", remind_toggled_cb, NULL },
|
||||
{ NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
dlgExists = gnc_find_gui_components( DIALOG_SCHEDXACTION_EDITOR_CM_CLASS,
|
||||
editor_component_sx_equality,
|
||||
@@ -1282,7 +1260,7 @@ schedXact_editor_create_freq_sel( GncSxEditorDialog *sxed )
|
||||
|
||||
sxed->gncfreq =
|
||||
GNC_FREQUENCY(gnc_frequency_new_from_recurrence(gnc_sx_get_schedule(sxed->sx),
|
||||
xaccSchedXactionGetStartDate(sxed->sx)));
|
||||
xaccSchedXactionGetStartDate(sxed->sx)));
|
||||
g_assert(sxed->gncfreq);
|
||||
g_signal_connect( sxed->gncfreq, "changed",
|
||||
G_CALLBACK(gnc_sxed_freq_changed),
|
||||
@@ -1489,7 +1467,7 @@ schedXact_editor_populate( GncSxEditorDialog *sxed )
|
||||
if ( splitList != NULL )
|
||||
{
|
||||
splitReg = gnc_ledger_display_get_split_register
|
||||
( sxed->ledger );
|
||||
( sxed->ledger );
|
||||
gnc_split_register_load(splitReg, splitList, NULL );
|
||||
} /* otherwise, use the existing stuff. */
|
||||
}
|
||||
@@ -1522,18 +1500,18 @@ endgroup_rb_toggled_cb( GtkButton *b, gpointer d )
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case END_NEVER_OPTION:
|
||||
set_endgroup_toggle_states( sxed, END_NEVER );
|
||||
break;
|
||||
case END_DATE_OPTION:
|
||||
set_endgroup_toggle_states( sxed, END_DATE );
|
||||
break;
|
||||
case NUM_OCCUR_OPTION:
|
||||
set_endgroup_toggle_states( sxed, END_OCCUR );
|
||||
break;
|
||||
default:
|
||||
g_critical( "Unknown id %d", id );
|
||||
break;
|
||||
case END_NEVER_OPTION:
|
||||
set_endgroup_toggle_states( sxed, END_NEVER );
|
||||
break;
|
||||
case END_DATE_OPTION:
|
||||
set_endgroup_toggle_states( sxed, END_DATE );
|
||||
break;
|
||||
case NUM_OCCUR_OPTION:
|
||||
set_endgroup_toggle_states( sxed, END_OCCUR );
|
||||
break;
|
||||
default:
|
||||
g_critical( "Unknown id %d", id );
|
||||
break;
|
||||
}
|
||||
gnc_sxed_update_cal(sxed);
|
||||
}
|
||||
@@ -1584,7 +1562,7 @@ editor_component_sx_equality( gpointer find_data,
|
||||
== ((GncSxEditorDialog*)user_data)->sx );
|
||||
}
|
||||
/*
|
||||
typedef enum { NO_END, DATE_END, COUNT_END } END_TYPE;
|
||||
typedef enum { NO_END, DATE_END, COUNT_END } END_TYPE;
|
||||
*/
|
||||
|
||||
static void
|
||||
@@ -1606,8 +1584,8 @@ gnc_sxed_update_cal(GncSxEditorDialog *sxed)
|
||||
|
||||
last_sx_inst = xaccSchedXactionGetLastOccurDate(sxed->sx);
|
||||
if (g_date_valid(last_sx_inst)
|
||||
&& g_date_valid(&first_date)
|
||||
&& g_date_compare(last_sx_inst, &first_date) != 0)
|
||||
&& g_date_valid(&first_date)
|
||||
&& g_date_compare(last_sx_inst, &first_date) != 0)
|
||||
{
|
||||
start_date = *last_sx_inst;
|
||||
recurrenceListNextInstance(recurrences, &start_date, &first_date);
|
||||
@@ -1646,7 +1624,7 @@ gnc_sxed_update_cal(GncSxEditorDialog *sxed)
|
||||
else if (gtk_toggle_button_get_active(sxed->optEndCount))
|
||||
{
|
||||
gint num_remain
|
||||
= gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(sxed->endRemainSpin));
|
||||
= gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(sxed->endRemainSpin));
|
||||
gnc_dense_cal_store_update_recurrences_count_end(sxed->dense_cal_model, &first_date, recurrences, num_remain);
|
||||
}
|
||||
else
|
||||
@@ -1726,7 +1704,7 @@ _open_editors(GtkDialog *dialog, gint response_code, gpointer data)
|
||||
for (sx_iter = adhd->affected_sxes; sx_iter; sx_iter = sx_iter->next)
|
||||
{
|
||||
gnc_ui_scheduled_xaction_editor_dialog_create((SchedXaction*)sx_iter->data,
|
||||
FALSE);
|
||||
FALSE);
|
||||
}
|
||||
}
|
||||
g_list_free(adhd->affected_sxes);
|
||||
@@ -1790,8 +1768,8 @@ _sx_engine_event_handler(QofInstance *ent, QofEventId event_type, gpointer user_
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
name_column = gtk_tree_view_column_new_with_attributes(_("Name"),
|
||||
renderer,
|
||||
"text", 0, NULL);
|
||||
renderer,
|
||||
"text", 0, NULL);
|
||||
gtk_tree_view_append_column(list, name_column);
|
||||
|
||||
g_signal_connect(G_OBJECT(dialog), "response",
|
||||
|
||||
Reference in New Issue
Block a user