4848#include " gnc-engine.h"
4949#include " gnc-gtk-utils.h"
5050#include " import-settings.h"
51- #include "import-match-picker.h"
5251#include " import-backend.h"
5352#include " import-account-matcher.h"
5453#include " import-pending-matches.h"
@@ -131,11 +130,13 @@ static QofLogModule log_module = G_MOD_IMPORT_MATCHER;
131130
132131static const gpointer one = GINT_TO_POINTER (1 );
133132
133+ extern " C" {
134134void on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info);
135135void on_matcher_cancel_clicked (GtkButton *button, gpointer user_data);
136136bool on_matcher_delete_event (GtkWidget *widget, GdkEvent *event, gpointer data);
137137void on_matcher_help_clicked (GtkButton *button, gpointer user_data);
138138void on_matcher_help_close_clicked (GtkButton *button, gpointer user_data);
139+ }
139140
140141static void gnc_gen_trans_list_create_matches (GNCImportMainMatcher *gui);
141142
@@ -171,8 +172,9 @@ update_all_balances (GNCImportMainMatcher *info)
171172{
172173 for (GSList* iter = info->edited_accounts ; iter; iter=iter->next )
173174 {
174- gnc_account_set_defer_bal_computation (iter -> data ,false);
175- xaccAccountRecomputeBalance (iter -> data );
175+ auto acct = static_cast <Account*>(iter->data );
176+ gnc_account_set_defer_bal_computation (acct, false );
177+ xaccAccountRecomputeBalance (acct);
176178 }
177179 g_slist_free (info->edited_accounts );
178180 info->edited_accounts = NULL ;
@@ -307,7 +309,7 @@ static const GncGUID*
307309get_top_trans_match_id (GList* match_list)
308310{
309311 if (!match_list || !match_list->data ) return NULL ;
310- GNCImportMatchInfo * match_info = match_list -> data ;
312+ auto match_info = static_cast <GNCImportMatchInfo *>( match_list->data ) ;
311313 Transaction *trans = match_info->trans ;
312314 return xaccTransGetGUID (trans);
313315}
@@ -317,7 +319,7 @@ static gint
317319get_top_trans_match_score (GList* match_list)
318320{
319321 if (!match_list || !match_list->data ) return 0 ;
320- GNCImportMatchInfo * match_info = match_list -> data ;
322+ auto match_info = static_cast <GNCImportMatchInfo *>( match_list->data ) ;
321323 return match_info->probability ;
322324}
323325
@@ -388,7 +390,7 @@ static void
388390remove_top_matches (GList* conflicts)
389391{
390392 for (GList* iter = conflicts; iter && iter->data ; iter=iter->next )
391- gnc_import_TransInfo_remove_top_match (iter -> data );
393+ gnc_import_TransInfo_remove_top_match (static_cast <GNCImportTransInfo*>( iter->data ) );
392394}
393395
394396static void
@@ -461,9 +463,9 @@ load_hash_tables (GNCImportMainMatcher *info)
461463 }
462464 for (GList *m = accounts_list; m; m = m->next )
463465 {
464- for (GList * n = xaccAccountGetSplitList (m -> data ); n ; n = n -> next )
466+ for (GList *n = xaccAccountGetSplitList (static_cast <Account*>( m->data ) ); n; n = n->next )
465467 {
466- const Split * s = n -> data ;
468+ auto s = static_cast < const Split*>( n->data ) ;
467469 const Transaction *t = xaccSplitGetParent (s);
468470
469471 const gchar *key = xaccTransGetDescription (t);
@@ -492,10 +494,10 @@ gnc_gen_trans_list_show_all (GNCImportMainMatcher *info)
492494 GSList *temp_trans_list = info->temp_trans_list ;
493495 if (!temp_trans_list)
494496 {
495- gnc_info_dialog (GTK_WINDOW (info -> main_widget ), _ ("No new transactions were found in this import." ));
497+ gnc_info_dialog (GTK_WINDOW (info->main_widget ), " %s " , _ (" No new transactions were found in this import." ));
496498 return ;
497499 }
498- GNCImportTransInfo * trans_info = temp_trans_list -> data ;
500+ auto trans_info = static_cast <GNCImportTransInfo *>( temp_trans_list->data ) ;
499501 Split *first_split = gnc_import_TransInfo_get_fsplit (trans_info);
500502 Account *account = xaccSplitGetAccount (first_split);
501503 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (info->append_text ),
@@ -550,7 +552,7 @@ on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info)
550552 Transaction *trans = xaccSplitGetParent (first_split);
551553
552554 for (GList *n = xaccTransGetSplitList (trans); n; n = g_list_next (n))
553- acc_begin_edit (& accounts_modified , xaccSplitGetAccount (n -> data ));
555+ acc_begin_edit (&accounts_modified, xaccSplitGetAccount (static_cast <Split*>( n->data ) ));
554556
555557 // Allow the backend to know if the Append checkbox is ticked or unticked
556558 // by propagating info->append_text to every trans_info->append_text
@@ -592,30 +594,30 @@ on_matcher_ok_clicked (GtkButton *button, GNCImportMainMatcher *info)
592594void
593595on_matcher_cancel_clicked (GtkButton *button, gpointer user_data)
594596{
595- GNCImportMainMatcher * info = user_data ;
597+ auto info = static_cast <GNCImportMainMatcher *>( user_data) ;
596598 gnc_gen_trans_list_delete (info);
597599}
598600
599601bool
600602on_matcher_delete_event (GtkWidget *widget, GdkEvent *event, gpointer data)
601603{
602- GNCImportMainMatcher * info = data ;
604+ auto info = static_cast <GNCImportMainMatcher *>( data) ;
603605 gnc_gen_trans_list_delete (info);
604606 return false ;
605607}
606608
607609void
608610on_matcher_help_close_clicked (GtkButton *button, gpointer user_data)
609611{
610- GtkWidget * help_dialog = user_data ;
612+ auto help_dialog = static_cast <GtkWidget *>( user_data) ;
611613
612614 gtk_widget_destroy (help_dialog);
613615}
614616
615617void
616618on_matcher_help_clicked (GtkButton *button, gpointer user_data)
617619{
618- GNCImportMainMatcher * info = user_data ;
620+ auto info = static_cast <GNCImportMainMatcher*>( user_data) ;
619621
620622 GtkBuilder *builder = gtk_builder_new ();
621623 gnc_builder_add_from_file (builder, " dialog-import.glade" , " textbuffer2" );
@@ -837,15 +839,16 @@ gnc_gen_trans_assign_transfer_account_to_selection_cb (GtkMenuItem *menuitem,
837839 GList *refs = NULL ;
838840 for (GList *l = selected_rows; l; l = l->next )
839841 {
840- gchar * path_str = gtk_tree_path_to_string (l -> data );
841- GtkTreeRowReference * ref = gtk_tree_row_reference_new (model , l -> data );
842+ auto path = static_cast <GtkTreePath*>(l->data );
843+ gchar *path_str = gtk_tree_path_to_string (path);
844+ GtkTreeRowReference *ref = gtk_tree_row_reference_new (model, path);
842845 DEBUG (" passing first = %s" , first ? " true" : " false" );
843846 DEBUG (" passing is_selection = %s" , is_selection ? " true" : " false" );
844847 DEBUG (" passing path = %s" , path_str);
845848 g_free (path_str);
846849 refs = g_list_prepend (refs, ref);
847850 gnc_gen_trans_assign_transfer_account (treeview,
848- & first , is_selection , l -> data ,
851+ &first, is_selection, path ,
849852 &assigned_account, info);
850853 gchar *fullname = gnc_account_get_full_name (assigned_account);
851854 DEBUG (" returned value of account = %s" , fullname);
@@ -859,10 +862,11 @@ gnc_gen_trans_assign_transfer_account_to_selection_cb (GtkMenuItem *menuitem,
859862 // now reselect the transaction rows. This is very slow if there are lots of transactions.
860863 for (GList *l = refs; l; l = l->next )
861864 {
862- GtkTreePath * path = gtk_tree_row_reference_get_path (l -> data );
865+ auto ref = static_cast <GtkTreeRowReference*>(l->data );
866+ GtkTreePath *path = gtk_tree_row_reference_get_path (ref);
863867 gtk_tree_selection_select_path (selection, path);
864868 gtk_tree_path_free (path);
865- gtk_tree_row_reference_free (l -> data );
869+ gtk_tree_row_reference_free (ref );
866870 }
867871 g_list_free (refs);
868872
@@ -888,7 +892,7 @@ static RowInfo * row_get_info (gpointer row, GNCImportMainMatcher *info)
888892{
889893 GtkTreeModel *model = gtk_tree_view_get_model (info->view );
890894 RowInfo *retval = g_new (RowInfo, 1 );
891- gtk_tree_model_get_iter (model , & retval -> iter , row );
895+ gtk_tree_model_get_iter (model, &retval->iter , static_cast <GtkTreePath*>( row) );
892896 gtk_tree_model_get (model, &retval->iter ,
893897 DOWNLOADED_COL_DATA, &retval->trans_info ,
894898 DOWNLOADED_COL_DESCRIPTION_ORIGINAL, &retval->orig_desc ,
908912static void populate_list (gpointer key, gpointer value, GtkListStore *list)
909913{
910914 GtkTreeIter iter;
911- const char * original = key ;
915+ auto original = static_cast < const char *>( key) ;
912916 char *normalized = g_utf8_normalize (original, -1 , G_NORMALIZE_NFC);
913917 char *normalized_folded = normalized ? g_utf8_casefold (normalized, -1 ) : NULL ;
914918 gtk_list_store_append (list, &iter);
@@ -924,7 +928,7 @@ static bool
924928match_func (GtkEntryCompletion *completion, const char *entry_str,
925929 GtkTreeIter *iter, gpointer user_data)
926930{
927- GtkTreeModel * model = user_data ;
931+ auto model = static_cast <GtkTreeModel*>( user_data) ;
928932 gchar *existing_str = NULL ;
929933 bool ret = false ;
930934 gtk_tree_model_get (model, iter,
@@ -1084,7 +1088,7 @@ gnc_gen_trans_set_price_to_selection_cb (GtkMenuItem *menuitem,
10841088 GList *row_info_list = gnc_g_list_map (selected_rows, (GncGMapFunc) row_get_info, info);
10851089 for (GList *n = row_info_list; n; n = g_list_next (n))
10861090 {
1087- RowInfo * row = n -> data ;
1091+ auto row = static_cast <RowInfo*>( n->data ) ;
10881092 Transaction *trans = gnc_import_TransInfo_get_trans (row->trans_info );
10891093 time64 post_date = xaccTransGetDate (trans);
10901094 Split *split = gnc_import_TransInfo_get_fsplit (row->trans_info );
@@ -1137,12 +1141,12 @@ gnc_gen_trans_edit_fields (GtkMenuItem *menuitem, GNCImportMainMatcher *info)
11371141
11381142 char *new_desc = NULL , *new_notes = NULL , *new_memo = NULL ;
11391143 GList *row_info_list = gnc_g_list_map (selected_rows, (GncGMapFunc) row_get_info, info);
1140- if (input_new_fields (info , row_info_list -> data ,
1144+ if (input_new_fields (info, static_cast <RowInfo*>( row_info_list->data ) ,
11411145 &new_desc, &new_notes, &new_memo))
11421146 {
11431147 for (GList *n = row_info_list; n; n = g_list_next (n))
11441148 {
1145- RowInfo * row = n -> data ;
1149+ auto row = static_cast <RowInfo*>( n->data ) ;
11461150 Transaction *trans = gnc_import_TransInfo_get_trans (row->trans_info );
11471151 Split *split = gnc_import_TransInfo_get_fsplit (row->trans_info );
11481152 if (info->can_edit_desc )
@@ -1273,8 +1277,9 @@ gnc_gen_trans_row_changed_cb (GtkTreeSelection *selection,
12731277 GList* list = gtk_tree_selection_get_selected_rows (selection, &model);
12741278 for (GList *n = list; n; n = n->next )
12751279 {
1276- if (get_action_for_path (n -> data , model ) != GNCImport_ADD )
1277- gtk_tree_selection_unselect_path (selection , n -> data );
1280+ auto path = static_cast <GtkTreePath*>(n->data );
1281+ if (get_action_for_path (path, model) != GNCImport_ADD)
1282+ gtk_tree_selection_unselect_path (selection, path);
12781283 }
12791284 g_list_free_full (list, (GDestroyNotify)gtk_tree_path_free);
12801285 }
@@ -1317,7 +1322,7 @@ gnc_gen_trans_view_popup_menu (GtkTreeView *treeview,
13171322 const char *desc = NULL , *memo = NULL , *notes = NULL ;
13181323 if (row_info_list) /* should never be NULL. collect from first row. */
13191324 {
1320- RowInfo * first_rowinfo = row_info_list -> data ;
1325+ auto first_rowinfo = static_cast <RowInfo*>( row_info_list->data ) ;
13211326 Transaction *trans = gnc_import_TransInfo_get_trans (first_rowinfo->trans_info );
13221327 Split *split = gnc_import_TransInfo_get_fsplit (first_rowinfo->trans_info );
13231328 desc = xaccTransGetDescription (trans);
@@ -1334,7 +1339,7 @@ gnc_gen_trans_view_popup_menu (GtkTreeView *treeview,
13341339 bool can_assign_acct = true ;
13351340 for (GList *n = row_info_list; n; n = g_list_next (n))
13361341 {
1337- RowInfo * rowinfo = n -> data ;
1342+ auto rowinfo = static_cast <RowInfo*>( n->data ) ;
13381343
13391344 /* Only allow assigning a destination account for unbalanced transactions */
13401345 if (can_assign_acct)
@@ -1448,7 +1453,7 @@ gnc_gen_trans_onButtonPressed_cb (GtkTreeView *treeview,
14481453 GList* selected;
14491454 GtkTreeModel *model;
14501455 selected = gtk_tree_selection_get_selected_rows (selection, &model);
1451- if (get_action_for_path (selected -> data , model ) == GNCImport_ADD )
1456+ if (get_action_for_path (static_cast <GtkTreePath*>( selected->data ) , model) == GNCImport_ADD)
14521457 gnc_gen_trans_view_popup_menu (treeview, event, info);
14531458 g_list_free_full (selected, (GDestroyNotify)gtk_tree_path_free);
14541459 }
@@ -1893,7 +1898,7 @@ get_peer_acct_names (Split *split)
18931898 GList *names = NULL , *accounts_seen = NULL ;
18941899 for (GList *n = xaccTransGetSplitList (xaccSplitGetParent (split)); n; n = n->next )
18951900 {
1896- Account * account = xaccSplitGetAccount (n -> data );
1901+ Account *account = xaccSplitGetAccount (static_cast <Split*>( n->data ) );
18971902 if ((n->data == split) ||
18981903 (xaccAccountGetType (account) == ACCT_TYPE_TRADING) ||
18991904 (g_list_find (accounts_seen, account)))
@@ -2277,7 +2282,7 @@ filter_existing_splits_on_account_and_date (GNCImportMainMatcher *gui)
22772282 for (GSList* txn = gui->temp_trans_list ; txn != NULL ;
22782283 txn = g_slist_next (txn))
22792284 {
2280- GNCImportTransInfo * txn_info = txn -> data ;
2285+ auto txn_info = static_cast <GNCImportTransInfo*>( txn->data ) ;
22812286 Account *txn_account =
22822287 xaccSplitGetAccount (gnc_import_TransInfo_get_fsplit (txn_info));
22832288 time64 txn_time =
@@ -2314,19 +2319,20 @@ create_hash_of_potential_matches (GList *candidate_splits,
23142319 for (GList* candidate = candidate_splits; candidate != NULL ;
23152320 candidate = g_list_next (candidate))
23162321 {
2317- if (gnc_import_split_has_online_id (candidate -> data ))
2322+ auto split = static_cast <Split*>(candidate->data );
2323+ if (gnc_import_split_has_online_id (split))
23182324 continue ;
23192325 /* In this context an open transaction represents a freshly
23202326 * downloaded one. That can't possibly be a match yet */
2321- if (xaccTransIsOpen (xaccSplitGetParent (candidate -> data )))
2327+ if (xaccTransIsOpen (xaccSplitGetParent (split )))
23222328 continue ;
2323- Account * split_account = xaccSplitGetAccount (candidate -> data );
2329+ Account *split_account = xaccSplitGetAccount (split );
23242330 /* g_hash_table_steal_extended would do the two calls in one shot but is
23252331 * not available until GLib 2.58.
23262332 */
2327- GSList * split_list = g_hash_table_lookup (account_hash , split_account );
2333+ auto split_list = static_cast <GSList*>( g_hash_table_lookup (account_hash, split_account) );
23282334 g_hash_table_steal (account_hash, split_account);
2329- split_list = g_slist_prepend (split_list , candidate -> data );
2335+ split_list = g_slist_prepend (split_list, split );
23302336 g_hash_table_insert (account_hash, split_account, split_list);
23312337 }
23322338 return account_hash;
@@ -2372,11 +2378,11 @@ perform_matching (GNCImportMainMatcher *gui, GHashTable *account_hash)
23722378 for (GSList *imported_txn = gui->temp_trans_list ; imported_txn !=NULL ;
23732379 imported_txn = g_slist_next (imported_txn))
23742380 {
2375- GNCImportTransInfo * txn_info = imported_txn -> data ;
2381+ auto txn_info = static_cast <GNCImportTransInfo*>( imported_txn->data ) ;
23762382 Account *importaccount = xaccSplitGetAccount (gnc_import_TransInfo_get_fsplit (txn_info));
23772383 match_struct s = {txn_info, display_threshold, date_threshold, date_not_threshold, fuzzy_amount};
23782384
2379- g_slist_foreach (g_hash_table_lookup (account_hash , importaccount ),
2385+ g_slist_foreach (static_cast <GSList*>( g_hash_table_lookup (account_hash, importaccount) ),
23802386 (GFunc) match_helper, &s);
23812387
23822388 // Sort the matches, select the best match, and set the action.
0 commit comments