Merge Bob Fewell's 'bug798475' into master.

This commit is contained in:
John Ralls 2023-01-24 13:36:50 -08:00
commit 4739e8ce04
8 changed files with 773 additions and 268 deletions

View File

@ -351,7 +351,6 @@ void gnc_ui_close_book (QofBook* book, GtkWindow *parent)
equity_list = g_list_prepend(equity_list, GINT_TO_POINTER(ACCT_TYPE_EQUITY)); equity_list = g_list_prepend(equity_list, GINT_TO_POINTER(ACCT_TYPE_EQUITY));
box = GTK_WIDGET(gtk_builder_get_object (builder, "income_acct_box")); box = GTK_WIDGET(gtk_builder_get_object (builder, "income_acct_box"));
cbw->income_acct_widget = gnc_account_sel_new(); cbw->income_acct_widget = gnc_account_sel_new();
gnc_account_sel_set_hexpand (GNC_ACCOUNT_SEL(cbw->income_acct_widget), TRUE);
gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(cbw->income_acct_widget), gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(cbw->income_acct_widget),
equity_list, NULL); equity_list, NULL);
gnc_account_sel_set_new_account_ability(GNC_ACCOUNT_SEL(cbw->income_acct_widget), TRUE); gnc_account_sel_set_new_account_ability(GNC_ACCOUNT_SEL(cbw->income_acct_widget), TRUE);
@ -360,7 +359,6 @@ void gnc_ui_close_book (QofBook* book, GtkWindow *parent)
/* expense acct */ /* expense acct */
box = GTK_WIDGET(gtk_builder_get_object (builder, "expense_acct_box")); box = GTK_WIDGET(gtk_builder_get_object (builder, "expense_acct_box"));
cbw->expense_acct_widget = gnc_account_sel_new(); cbw->expense_acct_widget = gnc_account_sel_new();
gnc_account_sel_set_hexpand (GNC_ACCOUNT_SEL(cbw->expense_acct_widget), TRUE);
gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(cbw->expense_acct_widget), gnc_account_sel_set_acct_filters(GNC_ACCOUNT_SEL(cbw->expense_acct_widget),
equity_list, NULL); equity_list, NULL);
gnc_account_sel_set_new_account_ability(GNC_ACCOUNT_SEL(cbw->expense_acct_widget), TRUE); gnc_account_sel_set_new_account_ability(GNC_ACCOUNT_SEL(cbw->expense_acct_widget), TRUE);

File diff suppressed because it is too large Load Diff

View File

@ -42,25 +42,7 @@ extern "C" {
#define GNC_ACCOUNT_SEL_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, GNC_TYPE_ACCOUNT_SEL, GNCAccountSelClass) #define GNC_ACCOUNT_SEL_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, GNC_TYPE_ACCOUNT_SEL, GNCAccountSelClass)
#define GNC_IS_ACCOUNT_SEL(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, GNC_TYPE_ACCOUNT_SEL) #define GNC_IS_ACCOUNT_SEL(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, GNC_TYPE_ACCOUNT_SEL)
typedef struct typedef struct _GNCAccountSel GNCAccountSel;
{
GtkBox hbox;
gboolean initDone;
gboolean isModal;
GtkListStore *store;
GtkComboBox *combo;
GList *acctTypeFilters;
GList *acctCommodityFilters;
gint eventHandlerId;
/* The state of this pointer also serves as a flag about what state
* the widget is in WRT the new-account-button ability. */
GtkWidget *newAccountButton;
gint currentSelection;
#if 0 /* completion not implemented. */
GCompletion *completion;
#endif /* 0 - completion not implemented */
} GNCAccountSel;
typedef struct typedef struct
{ {
@ -70,7 +52,7 @@ typedef struct
void (*account_sel_changed) (GNCAccountSel *gas); void (*account_sel_changed) (GNCAccountSel *gas);
} GNCAccountSelClass; } GNCAccountSelClass;
GType gnc_account_sel_get_type (void); GType gnc_account_sel_get_type (void) G_GNUC_CONST;
GtkWidget* gnc_account_sel_new (void); GtkWidget* gnc_account_sel_new (void);
/** /**
@ -78,13 +60,14 @@ GtkWidget* gnc_account_sel_new (void);
* list, then it doesn't change the state of the GAS. If the account is * list, then it doesn't change the state of the GAS. If the account is
* NULL, then the first list selection is made if set_default_acct is TRUE. * NULL, then the first list selection is made if set_default_acct is TRUE.
**/ **/
void gnc_account_sel_set_account (GNCAccountSel *gas, Account *acct, void gnc_account_sel_set_account (GNCAccountSel *gas, Account *acct,
gboolean set_default_acct); gboolean set_default_acct);
/** /**
* Returns the currently-selected Account. If, for some reason the selection * Returns the currently-selected Account. If, for some reason the selection
* is in a bad state, NULL will be returned. * is in a bad state, NULL will be returned.
**/ **/
Account* gnc_account_sel_get_account (GNCAccountSel *gas); Account* gnc_account_sel_get_account (GNCAccountSel *gas);
/** /**
* The GNCAccountSel can be setup to filter the accounts displayed. * The GNCAccountSel can be setup to filter the accounts displayed.
@ -92,9 +75,19 @@ Account* gnc_account_sel_get_account (GNCAccountSel *gas);
* @param commodityFilters A GList of gnc_commodity types which are allowed. * @param commodityFilters A GList of gnc_commodity types which are allowed.
* The list is copied, of course. * The list is copied, of course.
**/ **/
void gnc_account_sel_set_acct_filters (GNCAccountSel *gas, GList *typeFilters, void gnc_account_sel_set_acct_filters (GNCAccountSel *gas,
GList *typeFilters,
GList *commodityFilters); GList *commodityFilters);
/**
* The GNCAccountSel can be setup to filter the accounts displayed.
* @param gas The GNCAccountSel widget.
* @param excludeFilter A GList of accounts to be excluded.
* The list is copied, of course.
**/
void gnc_account_sel_set_acct_exclude_filter (GNCAccountSel *gas,
GList *excludeFilter);
/** /**
* Conditional inclusion of a new-account button to the right of the * Conditional inclusion of a new-account button to the right of the
* combobox. * combobox.
@ -108,9 +101,13 @@ void gnc_account_sel_set_new_account_ability (GNCAccountSel *gas, gboolean state
**/ **/
void gnc_account_sel_set_new_account_modal (GNCAccountSel *gas, gboolean state); void gnc_account_sel_set_new_account_modal (GNCAccountSel *gas, gboolean state);
gint gnc_account_sel_get_num_account (GNCAccountSel *gas); /**
void gnc_account_sel_purge_account (GNCAccountSel *gas, Account *acc, gboolean recursive); * Get the number of accounts visible.
void gnc_account_sel_set_hexpand (GNCAccountSel *gas, gboolean expand); *
* @param gas The GNCAccountSel widget.
* @return The number of visible accounts from the filter model.
**/
gint gnc_account_sel_get_visible_account_num (GNCAccountSel *gas);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -638,7 +638,6 @@ gnc_loan_assistant_create( LoanAssistantData *ldd )
gas_data[i].height); gas_data[i].height);
gtk_widget_set_halign (GTK_WIDGET(gas), GTK_ALIGN_FILL); gtk_widget_set_halign (GTK_WIDGET(gas), GTK_ALIGN_FILL);
gnc_account_sel_set_hexpand (GNC_ACCOUNT_SEL(gas), true);
gnc_account_sel_set_new_account_modal (GNC_ACCOUNT_SEL(gas), true); gnc_account_sel_set_new_account_modal (GNC_ACCOUNT_SEL(gas), true);
g_object_set (GTK_WIDGET(gas), "margin", 2, nullptr); g_object_set (GTK_WIDGET(gas), "margin", 2, nullptr);
*(gas_data[i].loc) = gas; *(gas_data[i].loc) = gas;
@ -732,7 +731,7 @@ gnc_loan_assistant_create( LoanAssistantData *ldd )
G_CALLBACK(loan_opt_escrow_toggle_cb), ldd ); G_CALLBACK(loan_opt_escrow_toggle_cb), ldd );
gtk_widget_set_sensitive( GTK_WIDGET(ldd->optEscrowHBox), FALSE ); gtk_widget_set_sensitive( GTK_WIDGET(ldd->optEscrowHBox), FALSE );
ldd->optEscrowGAS = GNC_ACCOUNT_SEL(gnc_account_sel_new()); ldd->optEscrowGAS = GNC_ACCOUNT_SEL(gnc_account_sel_new());
gnc_account_sel_set_hexpand (GNC_ACCOUNT_SEL(ldd->optEscrowGAS), true); g_object_set (ldd->optEscrowGAS, "entry-width", 50, NULL);
gnc_account_sel_set_new_account_modal (GNC_ACCOUNT_SEL(ldd->optEscrowGAS), true); gnc_account_sel_set_new_account_modal (GNC_ACCOUNT_SEL(ldd->optEscrowGAS), true);
gnc_account_sel_set_new_account_ability( ldd->optEscrowGAS, TRUE ); gnc_account_sel_set_new_account_ability( ldd->optEscrowGAS, TRUE );
gtk_container_add( GTK_CONTAINER(ldd->optEscrowHBox), gtk_container_add( GTK_CONTAINER(ldd->optEscrowHBox),

View File

@ -239,7 +239,6 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message,
acct_box = GTK_WIDGET(gtk_builder_get_object (builder, "acct_hbox")); acct_box = GTK_WIDGET(gtk_builder_get_object (builder, "acct_hbox"));
ddc->acct_combo = gnc_account_sel_new(); ddc->acct_combo = gnc_account_sel_new();
gnc_account_sel_set_hexpand (GNC_ACCOUNT_SEL(ddc->acct_combo), TRUE);
gtk_box_pack_start (GTK_BOX(acct_box), ddc->acct_combo, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX(acct_box), ddc->acct_combo, TRUE, TRUE, 0);
date_box = GTK_WIDGET(gtk_builder_get_object (builder, "date_hbox")); date_box = GTK_WIDGET(gtk_builder_get_object (builder, "date_hbox"));
@ -360,7 +359,6 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message,
ddc->acct_combo = gnc_account_sel_new(); ddc->acct_combo = gnc_account_sel_new();
if (*acct) if (*acct)
gnc_account_sel_set_account (GNC_ACCOUNT_SEL(ddc->acct_combo), *acct, FALSE); gnc_account_sel_set_account (GNC_ACCOUNT_SEL(ddc->acct_combo), *acct, FALSE);
gnc_account_sel_set_hexpand (GNC_ACCOUNT_SEL(ddc->acct_combo), TRUE);
gtk_box_pack_start (GTK_BOX(acct_box), ddc->acct_combo, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX(acct_box), ddc->acct_combo, TRUE, TRUE, 0);
date_box = GTK_WIDGET(gtk_builder_get_object (builder, "date_hbox")); date_box = GTK_WIDGET(gtk_builder_get_object (builder, "date_hbox"));

View File

@ -479,7 +479,6 @@ gnc_employee_new_window (GtkWindow *parent,
edit = gnc_account_sel_new(); edit = gnc_account_sel_new();
acct_types = g_list_prepend(NULL, (gpointer)ACCT_TYPE_CREDIT); acct_types = g_list_prepend(NULL, (gpointer)ACCT_TYPE_CREDIT);
gnc_account_sel_set_acct_filters (GNC_ACCOUNT_SEL(edit), acct_types, NULL); gnc_account_sel_set_acct_filters (GNC_ACCOUNT_SEL(edit), acct_types, NULL);
gnc_account_sel_set_hexpand (GNC_ACCOUNT_SEL(edit), TRUE);
g_list_free (acct_types); g_list_free (acct_types);
ew->ccard_acct_sel = edit; ew->ccard_acct_sel = edit;

View File

@ -1178,8 +1178,8 @@ set_ok_sensitivity(GtkWidget *dialog)
sa_mas = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_SA_MAS); sa_mas = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_SA_MAS);
trans_mas = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_TRANS_MAS); trans_mas = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_TRANS_MAS);
sa_mas_cnt = gnc_account_sel_get_num_account(GNC_ACCOUNT_SEL(sa_mas)); sa_mas_cnt = gnc_account_sel_get_visible_account_num(GNC_ACCOUNT_SEL(sa_mas));
trans_mas_cnt = gnc_account_sel_get_num_account(GNC_ACCOUNT_SEL(trans_mas)); trans_mas_cnt = gnc_account_sel_get_visible_account_num(GNC_ACCOUNT_SEL(trans_mas));
sensitive = (((NULL == sa_mas) || sensitive = (((NULL == sa_mas) ||
(!gtk_widget_is_sensitive(sa_mas) || sa_mas_cnt)) && (!gtk_widget_is_sensitive(sa_mas) || sa_mas_cnt)) &&
@ -1190,6 +1190,19 @@ set_ok_sensitivity(GtkWidget *dialog)
gtk_widget_set_sensitive(button, sensitive); gtk_widget_set_sensitive(button, sensitive);
} }
static GList *
gppat_get_exclude_list (Account *acc, gboolean exclude_subaccounts)
{
GList *acct_list = NULL;
if (exclude_subaccounts)
acct_list = gnc_account_get_descendants (acc);
acct_list = g_list_prepend (acct_list, acc);
return acct_list;
}
static void static void
gppat_populate_gas_list(GtkWidget *dialog, gppat_populate_gas_list(GtkWidget *dialog,
GNCAccountSel *gas, GNCAccountSel *gas,
@ -1197,6 +1210,7 @@ gppat_populate_gas_list(GtkWidget *dialog,
{ {
Account *account; Account *account;
GList *filter; GList *filter;
GList *exclude;
g_return_if_fail(GTK_IS_DIALOG(dialog)); g_return_if_fail(GTK_IS_DIALOG(dialog));
if (gas == NULL) if (gas == NULL)
@ -1207,8 +1221,12 @@ gppat_populate_gas_list(GtkWidget *dialog,
/* Setting the account type filter triggers GNCAccountSel population. */ /* Setting the account type filter triggers GNCAccountSel population. */
gnc_account_sel_set_acct_filters (gas, filter, NULL); gnc_account_sel_set_acct_filters (gas, filter, NULL);
/* Accounts to be deleted must be removed. */ /* Accounts to be deleted must be excluded from GAS. */
gnc_account_sel_purge_account( gas, account, exclude_subaccounts); exclude = gppat_get_exclude_list (account, exclude_subaccounts);
gnc_account_sel_set_acct_exclude_filter (gas, exclude);
g_list_free (exclude);
gnc_account_sel_set_account (gas, NULL, TRUE);
/* The sensitivity of the OK button needs to be reevaluated. */ /* The sensitivity of the OK button needs to be reevaluated. */
set_ok_sensitivity(dialog); set_ok_sensitivity(dialog);
@ -1259,7 +1277,11 @@ gppat_setup_account_selector (GtkBuilder *builder, GtkWidget *dialog,
GtkWidget *box = GTK_WIDGET(gtk_builder_get_object (builder, hbox)); GtkWidget *box = GTK_WIDGET(gtk_builder_get_object (builder, hbox));
gtk_box_pack_start (GTK_BOX(box), selector, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX(box), selector, TRUE, TRUE, 0);
gnc_account_sel_set_hexpand (GNC_ACCOUNT_SEL(selector), TRUE);
// placeholder accounts are OK for this GAS
if (g_strcmp0 (sel_name, DELETE_DIALOG_SA_MAS) == 0)
g_object_set (selector, "hide-placeholder", FALSE, NULL);
g_object_set_data(G_OBJECT(dialog), sel_name, selector); g_object_set_data(G_OBJECT(dialog), sel_name, selector);
gppat_populate_gas_list(dialog, GNC_ACCOUNT_SEL(selector), TRUE); gppat_populate_gas_list(dialog, GNC_ACCOUNT_SEL(selector), TRUE);

View File

@ -569,7 +569,6 @@ CsvImpTransAssist::CsvImpTransAssist ()
acct_selector = gnc_account_sel_new(); acct_selector = gnc_account_sel_new();
auto account_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "account_hbox")); auto account_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "account_hbox"));
gtk_box_pack_start (GTK_BOX(account_hbox), acct_selector, TRUE, TRUE, 6); gtk_box_pack_start (GTK_BOX(account_hbox), acct_selector, TRUE, TRUE, 6);
gnc_account_sel_set_hexpand (GNC_ACCOUNT_SEL(acct_selector), true);
gtk_widget_show (acct_selector); gtk_widget_show (acct_selector);
g_signal_connect(G_OBJECT(acct_selector), "account_sel_changed", g_signal_connect(G_OBJECT(acct_selector), "account_sel_changed",