/** * Update the clickable list of closed accounts and target * accounts to move a transaction, in menu. * * \param * \return FALSE * */ gboolean gsb_menu_update_accounts_in_menus ( void ) { GSList *list_tmp; GtkActionGroup * action_group; if ( move_to_account_merge_id != -1 ) gtk_ui_manager_remove_ui ( ui_manager, move_to_account_merge_id ); move_to_account_merge_id = gtk_ui_manager_new_merge_id ( ui_manager ); action_group = gtk_action_group_new ( "Group3" ); /* create the closed accounts and accounts in the menu to move a transaction */ list_tmp = gsb_data_account_get_list_accounts (); while ( list_tmp ) { gint i; i = gsb_data_account_get_no_account ( list_tmp -> data ); if ( !gsb_data_account_get_closed_account ( i ) ) { gchar *tmp_name; gchar *account_name; GtkAction *action; tmp_name = g_strdup_printf ( "MoveToAccount%d", i ); account_name = gsb_data_account_get_name ( i ); if ( !account_name ) account_name = _("Unnamed account"); action = gtk_action_new ( tmp_name, account_name, "", "" ); if ( gsb_gui_navigation_get_current_account () == i ) gtk_action_set_sensitive ( action, FALSE ); gtk_action_group_add_action ( action_group, action ); g_signal_connect ( action, "activate", G_CALLBACK ( move_selected_operation_to_account_nb ), GINT_TO_POINTER ( i ) ); gtk_ui_manager_add_ui ( ui_manager, move_to_account_merge_id, "/menubar/EditMenu/MoveToAnotherAccount/", tmp_name, tmp_name, GTK_UI_MANAGER_MENUITEM, FALSE ); g_free ( tmp_name ); } list_tmp = list_tmp -> next; } gtk_ui_manager_insert_action_group ( ui_manager, action_group, 2 ); gtk_ui_manager_ensure_update ( ui_manager ); return FALSE; }
/** * create a combobox containing the list of the accounts * * \param func Function to call when a line is selected (type : gboolean func ( GtkWidget *button, gpointer data ) * \param data data to send to the function * \param include_closed If set to TRUE, include the closed accounts * * \return a new GtkCombobox containing the list of the accounts */ GtkWidget *gsb_account_create_combo_list ( GCallback func, gpointer data, gboolean include_closed ) { GSList *list_tmp; GtkListStore *store; GtkCellRenderer *renderer; GtkWidget *combobox; combobox = gtk_combo_box_new (); store = gtk_list_store_new ( 2, G_TYPE_STRING, G_TYPE_INT ); list_tmp = gsb_data_account_get_list_accounts (); while ( list_tmp ) { gint account_number; GtkTreeIter iter; account_number = gsb_data_account_get_no_account ( list_tmp -> data ); if ( account_number >= 0 && ( !gsb_data_account_get_closed_account (account_number) || include_closed ) ) { gtk_list_store_append ( GTK_LIST_STORE (store), &iter ); gtk_list_store_set ( store, &iter, 0, gsb_data_account_get_name (account_number), 1, account_number, -1 ); } list_tmp = list_tmp -> next; } gtk_combo_box_set_model ( GTK_COMBO_BOX (combobox), GTK_TREE_MODEL (store)); /* by default, this is blank, so set the first */ gtk_combo_box_set_active ( GTK_COMBO_BOX (combobox), 0 ); if ( func ) g_signal_connect ( G_OBJECT (combobox), "changed", G_CALLBACK(func), data ); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL); return combobox; }
/** * update all the accounts form organization according * to the given account * * \param account_number the account number model to fill the others * * \return TRUE : ok, FALSE : problem, nothing done * */ gboolean gsb_form_config_update_from_account (gint account_number) { form_organization *form; GSList *tmp_list; if (account_number == -1) return FALSE; form = gsb_data_account_get_form_organization ( account_number ); if ( !form) return FALSE; tmp_list = gsb_data_account_get_list_accounts ( ); while ( tmp_list ) { form_organization *tmp_form; gint col; gint no_account; no_account = gsb_data_account_get_no_account ( tmp_list -> data ); if (no_account == account_number) { tmp_list = tmp_list -> next; continue; } tmp_form = gsb_data_account_get_form_organization (no_account); if ( tmp_form == NULL ) { tmp_list = tmp_list -> next; continue; } for (col = 0 ; col<MAX_WIDTH ; col++) { gint line; for (line=0 ; line <MAX_HEIGHT ; line++) tmp_form -> form_table[line][col] = form -> form_table[line][col]; tmp_form -> width_columns_percent[col] = form -> width_columns_percent[col]; } tmp_form -> columns = form -> columns; tmp_form -> rows = form -> rows; tmp_list = tmp_list -> next; } return TRUE; }
/** * Create a menu with the list of accounts. This list is * clickable and activates func if specified. * used for now to add a submenu item in a main menu * * \param func Function to call when a line is selected * \param activate_currrent If set to TRUE, does not mark as * unsensitive current account * \param include_closed If set to TRUE, include the closed accounts * * \return A newly created menu */ GtkWidget *gsb_account_create_menu_list ( GCallback func, gboolean activate_currrent, gboolean include_closed ) { GtkWidget *menu; GtkWidget *item; GSList *list_tmp; menu = gtk_menu_new (); list_tmp = gsb_data_account_get_list_accounts (); while ( list_tmp ) { gint i; i = gsb_data_account_get_no_account ( list_tmp -> data ); if ( i >= 0 && ( !gsb_data_account_get_closed_account (i) || include_closed ) ) { item = gtk_menu_item_new_with_label ( gsb_data_account_get_name (i)); g_object_set_data ( G_OBJECT ( item ), "account_number", GINT_TO_POINTER (i)); if ( func ) g_signal_connect ( G_OBJECT ( item ), "activate", G_CALLBACK(func), NULL ); gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ), item ); if ( !activate_currrent && gsb_gui_navigation_get_current_account () == i) { gtk_widget_set_sensitive ( item, FALSE ); } gtk_widget_show ( item ); } list_tmp = list_tmp -> next; } return ( menu ); }
/** * update the list of accounts in a combo_box filled * by gsb_account_create_combo_list * * \param combo_box * \param include_closed * * \return FALSE * */ gboolean gsb_account_update_combo_list ( GtkWidget *combo_box, gboolean include_closed ) { GSList *list_tmp; GtkListStore *store; if (!combo_box) return FALSE; store = GTK_LIST_STORE (gtk_combo_box_get_model ( GTK_COMBO_BOX (combo_box))); gtk_list_store_clear (store); list_tmp = gsb_data_account_get_list_accounts (); while ( list_tmp ) { gint account_number; GtkTreeIter iter; account_number = gsb_data_account_get_no_account ( list_tmp -> data ); if ( account_number >= 0 && ( !gsb_data_account_get_closed_account (account_number) || include_closed ) ) { gtk_list_store_append ( GTK_LIST_STORE (store), &iter ); gtk_list_store_set ( store, &iter, 0, gsb_data_account_get_name (account_number), 1, account_number, -1 ); } list_tmp = list_tmp -> next; } return FALSE; }
/** * open a new grisbi file, don't check anything about another opened file that must * have been done before * * \para filename the name of the file * * \return TRUE ok, FALSE problem * */ gboolean gsb_file_open_file ( gchar *filename ) { GSList *list_tmp; devel_debug (filename); if ( !filename || !strlen (filename)) return FALSE; gsb_status_wait ( TRUE ); gsb_status_message ( _("Loading accounts") ); /* try to load the file */ /* FIXME:BUG under Windows: for unknwon reason yet filename is cleared * when returning from gsb_file_load_open_file! * making application crashes! */ if ( gsb_file_load_open_file (filename)) { /* the file has been opened succesfully */ /* we make a backup if necessary */ if ( conf.sauvegarde_demarrage ) { gsb_file_save_backup (); gsb_file_set_modified ( FALSE ); } } else { /* Loading failed. */ gsb_status_message ( _("Failed to load accounts") ); if ( conf.sauvegarde_demarrage || conf.make_backup || conf.make_backup_every_minutes ) { gchar *tmpstr = g_strdup_printf ( _("Error loading file '%s'"), filename); gchar *tmpstr2 = g_strdup_printf ( _("Grisbi was unable to load file. You should find the last " "backups in '%s', they are saved with date and time into " "their name so you should find easily the last backup " "saved.\n" "Please contact the Grisbi's team on [email protected] " "to find what happened to you current file."), gsb_file_get_backup_path ()); dialogue_error_hint ( tmpstr2, tmpstr ); g_free ( tmpstr ); g_free ( tmpstr2 ); gsb_status_stop_wait ( TRUE ); return FALSE; } else { gchar *tmpstr = g_strdup_printf ( _("Error loading file '%s'"), filename); gchar *tmpstr2; if (gsb_file_get_backup_path ()) tmpstr2 = g_strdup_printf ( _("Grisbi was unable to load file and the backups seem not to " "be activated... This is a bad thing.\nYour backup path is '%s', " "try to find if earlier you had some backups in there ?\n" "Please contact the Grisbi's team on [email protected] " "to find what happened to you current file."), gsb_file_get_backup_path ()); else tmpstr2 = my_strdup ( _("Grisbi was unable to load file and the backups seem not " "to be activated... This is a bad thing.\n" "Please contact the Grisbi's team on " "[email protected] to find what happened to you " "current file.")); dialogue_error_hint ( tmpstr2, tmpstr ); g_free ( tmpstr ); g_free ( tmpstr2 ); gsb_status_stop_wait ( TRUE ); return FALSE; } } /* ok, here the file or backup is loaded */ gsb_status_message ( _("Checking schedulers")); /* the the name in the last opened files */ gsb_file_append_name_to_opened_list ( filename ); /* create the archives store data, ie the transaction wich will replace the archive in * the list of transactions */ gsb_data_archive_store_create_list (); /* create all the gui */ gsb_file_new_gui (); /* check the amounts of all the accounts */ gsb_status_message ( _("Checking amounts")); list_tmp = gsb_data_account_get_list_accounts (); while ( list_tmp ) { gint account_number; volatile gint value; account_number = gsb_data_account_get_no_account ( list_tmp -> data ); /* set the minimum balances to be shown or not */ value = gsb_real_cmp ( gsb_data_account_get_current_balance (account_number), gsb_data_account_get_mini_balance_authorized (account_number) ) == -1; gsb_data_account_set_mini_balance_authorized_message ( account_number, value); value = gsb_real_cmp ( gsb_data_account_get_current_balance (account_number), gsb_data_account_get_mini_balance_wanted (account_number) ) == -1; gsb_data_account_set_mini_balance_wanted_message ( account_number, value); list_tmp = list_tmp -> next; } /* set Grisbi title */ gsb_main_set_grisbi_title ( -1 ); /* update the main page */ mise_a_jour_accueil (TRUE); /* for now, the flag for modification of the file is ok, but the menu couldn't be set * as sensitive/unsensitive so do it now */ gsb_file_set_modified ( gsb_file_get_modified ( ) ); gsb_status_message ( _("Done") ); gsb_status_stop_wait ( TRUE ); /* go to the home page */ gsb_gui_navigation_set_selection ( GSB_HOME_PAGE, -1, NULL ); /* set the focus to the selection tree at left */ gtk_widget_grab_focus ( gsb_gui_navigation_get_tree_view ( ) ); return TRUE; }
/** * called by menubar to obfuscate the file * * \param * * \return TRUE * */ gboolean file_obfuscate_run ( void ) { GtkWidget *assistant; gint result; gsb_status_message ( _("Obfuscating file...") ); assistant = gsb_assistant_new ( _("Grisbi file obfuscation"), _("This assistant produces anonymized copies of account files, with " "all personal data replaced with harmless random data, in order to " "attach an anonimized copy of your Grisbi file with any bug report " "you submit." "\n\n" "That said, please check that bugs you submit are still valid with " "anonymized version of your files.\n" "\n" "To avoid any problems in your file, after saving the modified file, " "Grisbi will close without letting you saving anything. " "So if you didn't save your changes, please stop this assistant, " "save your work and restart the obfuscation process.\n\n" "In next page, you will be able to select individual features to " "obfuscate or to keep depending on the level of privacy needed."), "bug.png", NULL ); gsb_assistant_add_page ( assistant, file_obfuscate_page_1 (), 1, 0, 2, NULL ); gsb_assistant_add_page ( assistant, file_obfuscate_page_2 (), 2, 1, -1, NULL ); result = gsb_assistant_run ( assistant ); if (result == GTK_RESPONSE_APPLY) { /* obfuscate the file */ GSList *tmp_list; gchar *filename; /* remove the swp file */ gsb_file_util_modify_lock (FALSE); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_accounts_details))) { /* hide the details of account but not the names */ tmp_list = gsb_data_account_get_list_accounts (); while (tmp_list) { gint account_number = gsb_data_account_get_no_account (tmp_list -> data); gsb_data_account_set_id (account_number, g_strdup_printf ("id account %d", account_number)); gsb_data_account_set_comment (account_number, NULL); gsb_data_account_set_holder_name (account_number, NULL); gsb_data_account_set_holder_address (account_number, NULL); gsb_data_account_set_init_balance (account_number, null_real); gsb_data_account_set_mini_balance_wanted (account_number, null_real); gsb_data_account_set_mini_balance_authorized (account_number, null_real); gsb_data_account_set_bank_branch_code (account_number, NULL); gsb_data_account_set_bank_account_number (account_number, NULL); gsb_data_account_set_bank_account_key (account_number, NULL); tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_amount))) { /* hide the amounts of transactions */ tmp_list = gsb_data_transaction_get_complete_transactions_list (); while (tmp_list) { gint transaction_number = gsb_data_transaction_get_transaction_number (tmp_list -> data); gsb_data_transaction_set_amount (transaction_number, null_real); gsb_data_transaction_set_voucher (transaction_number, NULL); gsb_data_transaction_set_bank_references (transaction_number, NULL); tmp_list = tmp_list -> next; } /* hide the amounts of scheduled transactions */ tmp_list = gsb_data_scheduled_get_scheduled_list (); while (tmp_list) { gint scheduled_number = gsb_data_scheduled_get_scheduled_number (tmp_list -> data); gsb_data_scheduled_set_amount (scheduled_number, null_real); tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_accounts_names))) { /* hide the accounts names */ tmp_list = gsb_data_account_get_list_accounts (); while (tmp_list) { gint account_number = gsb_data_account_get_no_account (tmp_list -> data); gsb_data_account_set_name (account_number, g_strdup_printf ("Account n°%d", account_number)); tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_payee))) { /* hide the payees names */ tmp_list = gsb_data_payee_get_payees_list (); while (tmp_list) { gint payee_number = gsb_data_payee_get_no_payee (tmp_list -> data); gsb_data_payee_set_name (payee_number, g_strdup_printf ( "Payee n°%d", payee_number)); gsb_data_payee_set_description (payee_number, NULL); tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_categories))) { /* hide the categories */ tmp_list = gsb_data_category_get_categories_list (); while (tmp_list) { GSList *list_sub_categ; gint category_number = gsb_data_category_get_no_category (tmp_list -> data); gsb_data_category_set_name (category_number, g_strdup_printf ( "Category n°%d", category_number)); list_sub_categ = gsb_data_category_get_sub_category_list (category_number); while (list_sub_categ) { gint sub_categ_number = gsb_data_category_get_no_sub_category (list_sub_categ -> data); gsb_data_category_set_sub_category_name (category_number, sub_categ_number, g_strdup_printf ("Sub-category n°%d", sub_categ_number)); list_sub_categ = list_sub_categ -> next; } tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_budgets))) { /* hide the budgets */ tmp_list = gsb_data_budget_get_budgets_list (); while (tmp_list) { GSList *list_sub_budget; gint budget_number = gsb_data_budget_get_no_budget (tmp_list -> data); gsb_data_budget_set_name (budget_number, g_strdup_printf ( "Budget n°%d", budget_number)); list_sub_budget = gsb_data_budget_get_sub_budget_list (budget_number); while (list_sub_budget) { gint sub_budget_number = gsb_data_budget_get_no_sub_budget (list_sub_budget -> data); gsb_data_budget_set_sub_budget_name (budget_number, sub_budget_number, g_strdup_printf ("Sub-budget n°%d", sub_budget_number)); list_sub_budget = list_sub_budget -> next; } tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_notes))) { /* hide the notes */ tmp_list = gsb_data_transaction_get_complete_transactions_list (); while (tmp_list) { gint transaction_number = gsb_data_transaction_get_transaction_number (tmp_list -> data); gsb_data_transaction_set_notes (transaction_number, NULL); tmp_list = tmp_list -> next; } /* hide the notes of scheduled transactions */ tmp_list = gsb_data_scheduled_get_scheduled_list (); while (tmp_list) { gint scheduled_number = gsb_data_scheduled_get_scheduled_number (tmp_list -> data); gsb_data_scheduled_set_notes (scheduled_number, NULL); tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_banks))) { /* hide the banks */ tmp_list = gsb_data_bank_get_bank_list (); while (tmp_list) { gint bank_number = gsb_data_bank_get_no_bank (tmp_list -> data); gsb_data_bank_set_name (bank_number, g_strdup_printf ("Bank n°%d", bank_number)); gsb_data_bank_set_code (bank_number, NULL); gsb_data_bank_set_bank_address (bank_number, NULL); gsb_data_bank_set_bank_tel (bank_number, NULL); gsb_data_bank_set_bank_mail (bank_number, NULL); gsb_data_bank_set_bank_web (bank_number, NULL); gsb_data_bank_set_bank_note (bank_number, NULL); gsb_data_bank_set_correspondent_name (bank_number, NULL); gsb_data_bank_set_correspondent_tel (bank_number, NULL); gsb_data_bank_set_correspondent_mail (bank_number, NULL); gsb_data_bank_set_correspondent_fax (bank_number, NULL); tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_reports))) { /* hide the reports names*/ tmp_list = gsb_data_report_get_report_list (); while (tmp_list) { gint report_number = gsb_data_report_get_report_number (tmp_list -> data); gsb_data_report_set_report_name ( report_number, g_strdup_printf ( "Report n°%d", report_number)); tmp_list = tmp_list -> next; } } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_reconcile))) { /* hide the reconciles */ GList *reconcile_list; reconcile_list = gsb_data_reconcile_get_reconcile_list (); while (reconcile_list) { gint reconcile_number = gsb_data_reconcile_get_no_reconcile (reconcile_list -> data); gsb_data_reconcile_set_init_balance (reconcile_number, null_real); gsb_data_reconcile_set_final_balance (reconcile_number, null_real); reconcile_list = reconcile_list -> next; } } if (nom_fichier_comptes) { /* remove the .gsb */ nom_fichier_comptes[strlen(nom_fichier_comptes) -4] = 0; filename = g_strconcat ( nom_fichier_comptes, "-obfuscated.gsb", NULL); } else filename = g_strconcat ( my_get_gsb_file_default_dir (), "No_name-obfuscated.gsb", NULL); if (gsb_file_save_save_file (filename, FALSE, FALSE)) dialogue_hint ( g_strdup_printf ( _("Obfuscated file saved as\n'%s'"), filename ), _("Obfuscation succeeded") ); else dialogue_error_hint (g_strdup_printf (_("Grisbi couldn't save the file\n'%s'"), filename ), _("Obfuscation failed") ); /* bye bye */ exit (0); } gtk_widget_destroy ( assistant ); gsb_status_message ( _("Done.") ); return FALSE; }
/** * Fill the `model' GtkTreeModel with all payment methods known. They * are organized by account and then my method_ptr of payment method: Debit, * Credit, Neutral. * * \param model * * \return */ void gsb_payment_method_config_fill_list ( GtkTreeModel *model) { GSList *list_tmp; gtk_tree_store_clear ( GTK_TREE_STORE (model) ); /* Fill tree, iter over with accounts */ list_tmp = gsb_data_account_get_list_accounts (); while ( list_tmp ) { gint account_number; GSList *payment_list; GtkTreeIter account_iter, debit_iter, credit_iter; account_number = gsb_data_account_get_no_account ( list_tmp -> data ); gtk_tree_store_append (GTK_TREE_STORE (model), &account_iter, NULL); gtk_tree_store_set (GTK_TREE_STORE (model), &account_iter, PAYMENT_METHODS_NAME_COLUMN, gsb_data_account_get_name (account_number), PAYMENT_METHODS_NUMBERING_COLUMN, NULL, PAYMENT_METHODS_TYPE_COLUMN, 0, PAYMENT_METHODS_DEFAULT_COLUMN, FALSE, PAYMENT_METHODS_ACTIVABLE_COLUMN, FALSE, PAYMENT_METHODS_VISIBLE_COLUMN, FALSE, PAYMENT_METHODS_NUMBER_COLUMN, NULL, PAYMENT_METHODS_ACCOUNT_COLUMN, account_number, -1 ); /* Create the "Debit" node */ gtk_tree_store_append (GTK_TREE_STORE (model), &debit_iter, &account_iter); gtk_tree_store_set (GTK_TREE_STORE (model), &debit_iter, PAYMENT_METHODS_NAME_COLUMN, _("Debit"), PAYMENT_METHODS_NUMBERING_COLUMN, NULL, PAYMENT_METHODS_TYPE_COLUMN, 0, PAYMENT_METHODS_DEFAULT_COLUMN, FALSE, PAYMENT_METHODS_ACTIVABLE_COLUMN, FALSE, PAYMENT_METHODS_VISIBLE_COLUMN, FALSE, PAYMENT_METHODS_NUMBER_COLUMN, NULL, PAYMENT_METHODS_ACCOUNT_COLUMN, account_number, -1 ); /* Create the "Credit" node */ gtk_tree_store_append (GTK_TREE_STORE (model), &credit_iter, &account_iter); gtk_tree_store_set (GTK_TREE_STORE (model), &credit_iter, PAYMENT_METHODS_NAME_COLUMN, _("Credit"), PAYMENT_METHODS_NUMBERING_COLUMN, NULL, /* This is a hack: account number is put in Debit/Credit nodes */ PAYMENT_METHODS_TYPE_COLUMN, 0, PAYMENT_METHODS_DEFAULT_COLUMN, FALSE, PAYMENT_METHODS_ACTIVABLE_COLUMN, FALSE, PAYMENT_METHODS_VISIBLE_COLUMN, FALSE, PAYMENT_METHODS_NUMBER_COLUMN, NULL, PAYMENT_METHODS_ACCOUNT_COLUMN, account_number, -1 ); /* Iter over account payment methods */ payment_list = gsb_data_payment_get_payments_list (); while (payment_list) { gint payment_number; GtkTreeIter *parent_iter = NULL; GtkTreeIter method_iter; gboolean isdefault; const gchar *number; payment_number = gsb_data_payment_get_number (payment_list -> data); /* check if we have to show this payment here */ if (gsb_data_payment_get_account_number (payment_number) != account_number) { payment_list = payment_list -> next; continue; } /* set if default value */ if ( payment_number == gsb_data_account_get_default_debit (account_number) || payment_number == gsb_data_account_get_default_credit (account_number) ) isdefault = 1; else isdefault = 0; /* look for the parent iter according to the sign */ switch (gsb_data_payment_get_sign (payment_number)) { case GSB_PAYMENT_NEUTRAL: parent_iter = &account_iter; break; case GSB_PAYMENT_DEBIT: parent_iter = &debit_iter; break; case GSB_PAYMENT_CREDIT: parent_iter = &credit_iter; break; } /* set the last number */ if ( gsb_data_payment_get_automatic_numbering (payment_number)) number = gsb_data_payment_get_last_number ( payment_number ); else number = g_strdup(""); /* Insert a child node */ gtk_tree_store_append (GTK_TREE_STORE (model), &method_iter, parent_iter); gtk_tree_store_set (GTK_TREE_STORE (model), &method_iter, PAYMENT_METHODS_NAME_COLUMN, gsb_data_payment_get_name (payment_number), PAYMENT_METHODS_NUMBERING_COLUMN, number, PAYMENT_METHODS_TYPE_COLUMN, gsb_data_payment_get_sign (payment_number), PAYMENT_METHODS_DEFAULT_COLUMN, isdefault, PAYMENT_METHODS_ACTIVABLE_COLUMN, gsb_data_payment_get_sign (payment_number) != 0, PAYMENT_METHODS_VISIBLE_COLUMN, gsb_data_payment_get_sign (payment_number) != 0, PAYMENT_METHODS_NUMBER_COLUMN, payment_number, PAYMENT_METHODS_ACCOUNT_COLUMN, account_number, -1 ); payment_list = payment_list -> next; } list_tmp = list_tmp -> next; } }
/** * clear and fill the reconciliation tree with the accounts, * and for each account, set the method of payments in the good order * * \param * * \return */ void gsb_reconcile_sort_config_fill ( void ) { GtkTreeIter account_iter, payment_method_iter; GSList *list_tmp; GtkTreeModel *model; model = gtk_tree_view_get_model (GTK_TREE_VIEW (reconcile_treeview)); gtk_tree_store_clear (GTK_TREE_STORE (model)); list_tmp = gsb_data_account_get_list_accounts (); while ( list_tmp ) { gint account_number; GSList *sorted_list; GSList *payment_list; gboolean visible; account_number = gsb_data_account_get_no_account ( list_tmp -> data ); /* when no method of payment, hide the checkbuttons because non sense */ payment_list = gsb_data_payment_get_list_for_account (account_number); if (payment_list) { visible = TRUE; g_slist_free (payment_list); } else visible = FALSE; gtk_tree_store_append (GTK_TREE_STORE (model), &account_iter, NULL); gtk_tree_store_set (GTK_TREE_STORE (model), &account_iter, RECONCILIATION_SORT_NAME_COLUMN, gsb_data_account_get_name (account_number), RECONCILIATION_SORT_VISIBLE_COLUMN, visible, RECONCILIATION_SORT_SORT_COLUMN, gsb_data_account_get_reconcile_sort_type(account_number), RECONCILIATION_SORT_SPLIT_NEUTRAL_COLUMN, gsb_data_account_get_split_neutral_payment (account_number), RECONCILIATION_SORT_ACCOUNT_COLUMN, account_number, RECONCILIATION_SORT_TYPE_COLUMN, 0, RECONCILIATION_SORT_SENSITIVE_COLUMN, visible, -1 ); /* the sorted list is a list of numbers of method of payment, in the good order */ sorted_list = gsb_data_account_get_sort_list (account_number); while ( sorted_list ) { gint payment_number; /* in the sorted list, a number can be negative, when split a neutral into 2 parts * so payment number here can be negative for neutral payments */ payment_number = GPOINTER_TO_INT (sorted_list -> data); if (payment_number) { gchar *name = NULL; gtk_tree_store_append (GTK_TREE_STORE (model), &payment_method_iter, &account_iter); /* if split the neutrals, show here with the name */ switch (gsb_data_payment_get_sign (abs (payment_number))) { case GSB_PAYMENT_DEBIT: case GSB_PAYMENT_CREDIT: name = my_strdup (gsb_data_payment_get_name (payment_number)); break; case GSB_PAYMENT_NEUTRAL: if (gsb_data_account_get_split_neutral_payment (account_number)) { /* the neutrals are splitted */ if (payment_number < 0) name = g_strconcat ( gsb_data_payment_get_name (-payment_number), " ( - )", NULL ); else name = g_strconcat ( gsb_data_payment_get_name (payment_number), " ( + )", NULL ); } else name = my_strdup (gsb_data_payment_get_name (payment_number)); break; } gtk_tree_store_set (GTK_TREE_STORE (model), &payment_method_iter, RECONCILIATION_SORT_NAME_COLUMN, name, RECONCILIATION_SORT_VISIBLE_COLUMN, FALSE, RECONCILIATION_SORT_SORT_COLUMN, FALSE, RECONCILIATION_SORT_SPLIT_NEUTRAL_COLUMN, FALSE, RECONCILIATION_SORT_ACCOUNT_COLUMN, account_number, RECONCILIATION_SORT_TYPE_COLUMN, payment_number, RECONCILIATION_SORT_SENSITIVE_COLUMN, TRUE, -1 ); if (name) g_free (name); } sorted_list = sorted_list -> next; } if ( gtk_tree_model_iter_has_child( GTK_TREE_MODEL(model), &account_iter) && gsb_data_account_get_reconcile_sort_type (account_number) ) { GtkTreePath * treepath; treepath = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &account_iter); if ( treepath ) { gtk_tree_view_expand_row ( GTK_TREE_VIEW(reconcile_treeview), treepath, TRUE ); gtk_tree_path_free ( treepath ); } } list_tmp = list_tmp -> next; } }
/** * fill the reconcile list, * sort each reconcile in its account * * \param * * \return * */ void gsb_reconcile_config_fill ( void ) { GtkTreeModel *model; GSList *tmp_list; GrisbiWinEtat *w_etat; if (!reconcile_treeview) return; w_etat = (GrisbiWinEtat *) grisbi_win_get_w_etat (); model = gtk_tree_view_get_model ( GTK_TREE_VIEW (reconcile_treeview)); gtk_tree_store_clear (GTK_TREE_STORE(model)); /* we make a tree_model containing the accounts, * and for each account, all the reconciles */ tmp_list = gsb_data_account_get_list_accounts (); while (tmp_list) { gint account_number; GtkTreeIter account_iter; GList *reconcile_list; account_number = gsb_data_account_get_no_account (tmp_list -> data); gtk_tree_store_append ( GTK_TREE_STORE (model), &account_iter, NULL ); gtk_tree_store_set ( GTK_TREE_STORE (model), &account_iter, RECONCILIATION_NAME_COLUMN, gsb_data_account_get_name (account_number), RECONCILIATION_WEIGHT_COLUMN, 800, RECONCILIATION_ACCOUNT_COLUMN, account_number, -1 ); /* for each account, get the concerned reconciles */ reconcile_list = gsb_data_reconcile_get_sort_reconcile_list (account_number); if (w_etat->reconcile_sort) reconcile_list = g_list_reverse (reconcile_list); while (reconcile_list) { gint reconcile_number; reconcile_number = GPOINTER_TO_INT (reconcile_list->data); if (gsb_data_reconcile_get_account (reconcile_number) == account_number) { GtkTreeIter reconcile_iter; gchar *init_date, *final_date; gchar *init_balance, *final_balance; init_date = gsb_format_gdate (gsb_data_reconcile_get_init_date (reconcile_number)); final_date = gsb_format_gdate (gsb_data_reconcile_get_final_date (reconcile_number)); init_balance = utils_real_get_string (gsb_data_reconcile_get_init_balance (reconcile_number)); final_balance = utils_real_get_string (gsb_data_reconcile_get_final_balance (reconcile_number)); gtk_tree_store_append ( GTK_TREE_STORE (model), &reconcile_iter, &account_iter ); gtk_tree_store_set ( GTK_TREE_STORE (model), &reconcile_iter, RECONCILIATION_NAME_COLUMN, gsb_data_reconcile_get_name (reconcile_number), RECONCILIATION_WEIGHT_COLUMN, 400, RECONCILIATION_INIT_DATE_COLUMN, init_date, RECONCILIATION_FINAL_DATE_COLUMN, final_date, RECONCILIATION_INIT_BALANCE_COLUMN, init_balance, RECONCILIATION_FINAL_BALANCE_COLUMN, final_balance, RECONCILIATION_RECONCILE_COLUMN, reconcile_number, RECONCILIATION_ACCOUNT_COLUMN, account_number, -1 ); g_free (init_date); g_free (final_date); g_free (init_balance); g_free (final_balance); } reconcile_list = reconcile_list -> next; } tmp_list = tmp_list -> next; } }