/grisbi-0.8.8/src/gsb_file_load.c
C | 9049 lines | 7053 code | 1317 blank | 679 comment | 1181 complexity | e349fee8c1f640345d425cb15981f5fd MD5 | raw file
Possible License(s): GPL-2.0
Large files files are truncated, but you can click here to view the full file
- /* ************************************************************************** */
- /* */
- /* Copyright (C) 2000-2008 Cédric Auger (cedric@grisbi.org) */
- /* 2003-2009 Benjamin Drieu (bdrieu@april.org) */
- /* 2008-2010 Pierre Biava (grisbi@pierre.biava.name) */
- /* http://www.grisbi.org */
- /* */
- /* This program is free software; you can redistribute it and/or modify */
- /* it under the terms of the GNU General Public License as published by */
- /* the Free Software Foundation; either version 2 of the License, or */
- /* (at your option) any later version. */
- /* */
- /* This program is distributed in the hope that it will be useful, */
- /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
- /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
- /* GNU General Public License for more details. */
- /* */
- /* You should have received a copy of the GNU General Public License */
- /* along with this program; if not, write to the Free Software */
- /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
- /* */
- /* ************************************************************************** */
- #ifdef HAVE_CONFIG_H
- #include <config.h>
- #endif
- #include "include.h"
- #include <glib/gstdio.h>
- #include <gio/gio.h>
- /*START_INCLUDE*/
- #include "gsb_file_load.h"
- #include "bet_data.h"
- #include "custom_list.h"
- #include "dialog.h"
- #include "fenetre_principale.h"
- #include "gsb_assistant_archive.h"
- #include "gsb_assistant_first.h"
- #include "gsb_calendar.h"
- #include "gsb_currency_config.h"
- #include "gsb_data_account.h"
- #include "gsb_data_archive.h"
- #include "gsb_data_bank.h"
- #include "gsb_data_budget.h"
- #include "gsb_data_category.h"
- #include "gsb_data_currency.h"
- #include "gsb_data_currency_link.h"
- #include "gsb_data_form.h"
- #include "gsb_data_fyear.h"
- #include "gsb_data_import_rule.h"
- #include "gsb_data_partial_balance.h"
- #include "gsb_data_payee.h"
- #include "gsb_data_payment.h"
- #include "gsb_data_print_config.h"
- #include "gsb_data_reconcile.h"
- #include "gsb_data_report.h"
- #include "gsb_data_report_amout_comparison.h"
- #include "gsb_data_report_text_comparison.h"
- #include "gsb_data_scheduled.h"
- #include "gsb_data_transaction.h"
- #include "gsb_file.h"
- #include "gsb_file_util.h"
- #include "gsb_plugins.h"
- #include "gsb_real.h"
- #include "gsb_select_icon.h"
- #include "gsb_scheduler_list.h"
- #include "import.h"
- #include "structures.h"
- #include "traitement_variables.h"
- #include "utils.h"
- #include "utils_dates.h"
- #include "utils_files.h"
- #include "utils_str.h"
- #include "erreur.h"
- /*END_INCLUDE*/
- /*START_STATIC*/
- static void gsb_file_load_account_icon_part ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_account_part ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_account_part_before_0_6 ( GMarkupParseContext *context,
- const gchar *text );
- static void gsb_file_load_archive ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_bank ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_bet_future_data ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_bet_historical ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_bet_part ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_bet_transfert_part ( const gchar **attribute_names,
- const gchar **attribute_values );
- static gboolean gsb_file_load_check_new_structure ( gchar *file_content );
- static void gsb_file_load_color_part ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_copy_old_file ( gchar *filename, gchar *file_content);
- static void gsb_file_load_currency ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_currency_link ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_end_element_before_0_6 ( GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data,
- GError **error);
- static void gsb_file_load_financial_year ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_general_part ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_general_part_before_0_6 ( GMarkupParseContext *context,
- const gchar *text );
- static gint gsb_file_load_get_new_payment_number ( gint account_number,
- gint payment_number );
- static void gsb_file_load_import_rule ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_logo_accueil ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_partial_balance ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_party ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_payment_part ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_print_part ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_reconcile ( const gchar **attribute_names,
- const gchar **attribute_values );
- static void gsb_file_load_report_part_before_0_6 ( GMarkupParseContext *context,
- const gchar *text );
- static void gsb_file_load_scheduled_transactions ( const gchar **attribute_names,
- const gchar **attribute_values );
- static gboolean gsb_file_load_set_last_reconcile_data ( gint account_number,
- GDate *final_date,
- gsb_real final_balance );
- static void gsb_file_load_start_element ( GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- GError **error);
- static void gsb_file_load_start_element_before_0_6 ( GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- GError **error);
- static void gsb_file_load_text_element_before_0_6 ( GMarkupParseContext *context,
- const gchar *text,
- gsize text_len,
- gpointer user_data,
- GError **error);
- static void gsb_file_load_transactions ( const gchar **attribute_names,
- const gchar **attribute_values );
- static gboolean gsb_file_load_update_previous_version ( void );
- /*END_STATIC*/
- /*START_EXTERN*/
- extern gchar *adresse_commune;
- extern gchar *adresse_secondaire;
- extern gint affichage_echeances;
- extern gint affichage_echeances_perso_nb_libre;
- extern GdkColor archive_background_color;
- extern gint bet_array_col_width[BET_ARRAY_COLUMNS];
- extern GdkColor calendar_entry_color;
- extern GdkColor couleur_bet_division;
- extern GdkColor couleur_bet_future;
- extern GdkColor couleur_bet_solde;
- extern GdkColor couleur_bet_transfert;
- extern GdkColor couleur_fond[2];
- extern GdkColor couleur_grise;
- extern GdkColor couleur_jour;
- extern GdkColor couleur_selection;
- extern gint display_one_line;
- extern gint display_three_lines;
- extern gint display_two_lines;
- extern gsb_real error_real;
- extern struct iso_4217_currency iso_4217_currencies[];
- extern GtkWidget *logo_accueil;
- extern gint no_devise_totaux_categ;
- extern gint no_devise_totaux_ib;
- extern gint no_devise_totaux_tiers;
- extern gsb_real null_real;
- extern gint scheduler_col_width[SCHEDULER_COL_VISIBLE_COLUMNS];
- extern GdkColor split_background;
- extern gint tab_affichage_ope[TRANSACTION_LIST_ROWS_NB][CUSTOM_MODEL_VISIBLE_COLUMNS];
- extern GdkColor text_color[2];
- extern gchar *titre_fichier;
- extern gint transaction_col_align[CUSTOM_MODEL_N_VISIBLES_COLUMN];
- extern gint transaction_col_width[CUSTOM_MODEL_N_VISIBLES_COLUMN];
- extern gint valeur_echelle_recherche_date_import;
- /*END_EXTERN*/
- static struct
- {
- gboolean download_ok;
- gchar *file_version;
- gchar *grisbi_version;
- /* there is always only one to TRUE, used to split the retrieves functions */
- gboolean general_part;
- gboolean account_part;
- gboolean report_part;
- } download_tmp_values = { FALSE, NULL, NULL, FALSE, FALSE, FALSE};
- static gint account_number;
- /* to import older file than 0.6, makes the link between category and sub-category */
- static gint last_category = 0;
- static gint last_sub_category_number = 0;
- /* to import older file than 0.6, makes the link between budget and sub-budget */
- static gint last_budget = 0;
- static gint last_sub_budget_number = 0;
- /* to import older file than 0.6, makes the link between report and comparison structures */
- static gint last_report_number;
- /* filled only when loading a version before 0.6, contains the order of the accounts
- * in the 0.6, the accounts are saved directly in the good order
- * this is a list of the accounts number, in the good order */
- static GSList *sort_accounts = NULL;
- /* temporary structure used to go from the 0.5.x versions to 0.6.x versions
- * because before, method of payment were saved in each account, and now
- * there is a general list of method of payment */
- struct payment_conversion_struct
- {
- gint account_number;
- gint last_payment_number;
- gint new_payment_number;
- };
- static GSList *payment_conversion_list = NULL;
- /* temporary structure to set the final date and the final balance of a reconcile
- * in the reconcile itself, and not in the account as before 0.6.0 */
- struct reconcile_conversion_struct
- {
- gint reconcile_number;
- gint account_number;
- GDate *final_date;
- gsb_real final_balance;
- };
- gboolean result_reconcile = FALSE;
- static GSList *reconcile_conversion_list = NULL;
- static struct reconcile_conversion_struct *buffer_reconcile_conversion;
- /* structure temporaire utilisée pour faire un lien entre ancien et nouveau numéro
- * de rapprochement et chaque compte parce que dans les versions précédentes de Grisbi
- * on pouvait utiliser un męme rapprochement dans les opérations car celles-ci étaient
- * organisées par comptes */
- struct old_new_rec_conversion_struct
- {
- gint account_number;
- gint old_rec_number;
- gint new_rec_number;
- };
- static GSList *old_new_rec_list = NULL;
- static struct old_new_rec_conversion_struct *buffer_old_new_rec_conversion;
- /* variable utilisée pour indiquer le chemin de la copie d'un fichier de compte
- * d'une version antérieure de grisbi */
- gchar *copy_old_filename = NULL;
- /* structure temporaire pour le chargement d'un tiers/catégorie/imputation et sous-catégorie
- * sous-imputation */
- struct new_div_sous_div_struct
- {
- gint no_div;
- gint new_no_div;
- gint no_sub_div;
- gchar *name;
- gint type;
- };
- static struct new_div_sous_div_struct *buffer_new_div_sous_div;
- /**
- * called to open the grisbi file given in param
- *
- * \filename the filename to load with full path
- *
- * \return TRUE if ok
- * */
- gboolean gsb_file_load_open_file ( gchar *filename )
- {
- struct stat buffer_stat;
- gint return_value;
- gchar *file_content;
- gulong length;
- devel_debug ( filename );
- /* general check */
-
- if ( !g_file_test (filename, G_FILE_TEST_EXISTS) )
- {
- gchar* tmpstr1 = g_strdup_printf ( _("Cannot open file '%s': %s"),
- filename,
- _("File does not exist") );
- gchar* tmpstr2 = g_strdup_printf ( _("Error loading file '%s'"), filename);
- dialogue_error_hint ( tmpstr1, tmpstr2 );
- g_free ( tmpstr1 );
- g_free ( tmpstr2 );
- gsb_file_remove_name_from_opened_list (filename);
- return FALSE;
- }
- /* check here if it's not a regular file */
- if ( !g_file_test ( filename, G_FILE_TEST_IS_REGULAR ))
- {
- gchar* tmpstr1 = g_strdup_printf (
- _("%s doesn't seem to be a regular file,\nplease check it and try again."),
- filename );
- gchar* tmpstr2 = g_strdup_printf ( _("Error loading file '%s'"), filename);
- dialogue_error_hint ( tmpstr1 , tmpstr2);
- g_free ( tmpstr1 );
- g_free ( tmpstr2 );
- gsb_file_remove_name_from_opened_list (filename);
- return ( FALSE );
- }
- /* fill the buffer stat to check the permission */
- return_value = g_stat (filename, &buffer_stat);
- /* check the access to the file and display a message */
- #ifndef _WIN32
- if ( buffer_stat.st_mode != 33152 )
- gsb_file_util_display_warning_permissions ( );
- #endif /* _WIN32 */
- /* load the file */
- if (gsb_file_util_get_contents (filename, &file_content, &length))
- {
- GMarkupParser *markup_parser = g_malloc0 (sizeof (GMarkupParser));
- GMarkupParseContext *context;
- gsb_plugin *plugin;
- /* first, we check if the file is crypted, if it is, we decrypt it */
- if ( !strncmp ( file_content, "Grisbi encrypted file ", 22 ) ||
- !strncmp ( file_content, "Grisbi encryption v2: ", 22 ) )
- {
- plugin = gsb_plugin_find ( "openssl" );
- if ( plugin )
- {
- gint (*crypt_function) ( gchar *, gchar **, gboolean, gulong );
-
- crypt_function = (gpointer) plugin -> plugin_run;
- length = crypt_function ( filename, &file_content, FALSE, length );
-
- if ( ! length )
- return FALSE;
- }
- else
- {
- dialogue_error_hint ( _("Grisbi was unable to load required plugin to "
- "handle that file.\n\n"
- "Please make sure if is installed (i.e. check "
- "that 'grisbi-ssl' package is installed) and "
- "try again."),
- _("Encryption plugin not found." ) );
- return FALSE;
- }
- }
- /* we begin to check if we are in a version under 0.6 or 0.6 and above,
- * because the xml structure changes after 0.6 */
- if ( gsb_file_load_check_new_structure (file_content))
- {
- /* fill the GMarkupParser for a new xml structure */
- markup_parser -> start_element = (void *) gsb_file_load_start_element;
- markup_parser -> error = (void *) gsb_file_load_error;
- }
- else
- {
- /* copy of an old file grisbi */
- gsb_file_load_copy_old_file ( filename, file_content );
- /* fill the GMarkupParser for the last xml structure */
- markup_parser -> start_element = (void *) gsb_file_load_start_element_before_0_6;
- markup_parser -> end_element = (void *) gsb_file_load_end_element_before_0_6;
- markup_parser -> text = (void *) gsb_file_load_text_element_before_0_6;
- /* we will have to convert the method of payments numbers */
- payment_conversion_list = NULL;
- /* we will have to set the final date and balance in the last reconcile */
- reconcile_conversion_list = NULL;
- }
- context = g_markup_parse_context_new ( markup_parser,
- 0,
- NULL,
- NULL );
- download_tmp_values.download_ok = FALSE;
- g_markup_parse_context_parse ( context,
- file_content,
- strlen (file_content),
- NULL );
- if ( !download_tmp_values.download_ok )
- {
- g_markup_parse_context_free (context);
- g_free (markup_parser);
- g_free (file_content);
- return FALSE;
- }
- g_markup_parse_context_free (context);
- g_free (markup_parser);
- g_free (file_content);
- }
- else
- {
- gchar* tmpstr1 = g_strdup_printf (_("Cannot open file '%s': %s"),
- filename,
- g_strerror(errno));
- gchar* tmpstr2 = g_strdup_printf ( _("Error loading file '%s'"), filename);
- dialogue_error_hint (tmpstr1, tmpstr2);
- g_free ( tmpstr1 );
- g_free ( tmpstr2 );
- gsb_file_remove_name_from_opened_list (filename);
- return FALSE;
- }
- return gsb_file_load_update_previous_version();
- }
- /**
- * check if the xml file is the last structure (before 0.6) or
- * the new structure (after 0.6)
- *
- * \param file_content the grisbi file
- *
- * \return TRUE if the version is after 0.6
- * */
- gboolean gsb_file_load_check_new_structure ( gchar *file_content )
- {
- if ( strstr ( file_content, "Generalites" ) )
- return FALSE;
- return TRUE;
- }
- void gsb_file_load_start_element ( GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- GError **error)
- {
- /* the first time we come here, we check if it's a grisbi file */
- if ( !download_tmp_values.download_ok )
- {
- if ( strcmp ( element_name,
- "Grisbi" ))
- {
- dialogue_error ( _("This is not a Grisbi file... Loading aborted.") );
- g_markup_parse_context_end_parse (context,
- NULL);
- return;
- }
- download_tmp_values.download_ok = TRUE;
- return;
- }
- if ( !strcmp ( element_name,
- "General" ))
- {
- gsb_file_load_general_part ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Color" ))
- {
- gsb_file_load_color_part ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Print" ))
- {
- gsb_file_load_print_part ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Account" ))
- {
- gsb_file_load_account_part ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Payment" ))
- {
- gsb_file_load_payment_part ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Transaction" ))
- {
- gsb_file_load_transactions ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Scheduled" ))
- {
- gsb_file_load_scheduled_transactions ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Party" ))
- {
- gsb_file_load_party ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Category" ))
- {
- gsb_file_load_category ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Sub_category" ))
- {
- gsb_file_load_sub_category ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Budgetary" ))
- {
- gsb_file_load_budgetary ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Sub_budgetary" ))
- {
- gsb_file_load_sub_budgetary ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Currency" ))
- {
- gsb_file_load_currency ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Currency_link" ))
- {
- gsb_file_load_currency_link ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Bank" ))
- {
- gsb_file_load_bank ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Financial_year" ))
- {
- gsb_file_load_financial_year ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Archive" ))
- {
- gsb_file_load_archive ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Reconcile" ))
- {
- gsb_file_load_reconcile ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Import_rule" ))
- {
- gsb_file_load_import_rule ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Partial_balance" ))
- {
- gsb_file_load_partial_balance ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name, "Bet" ) )
- {
- gsb_file_load_bet_part ( attribute_names, attribute_values );
- return;
- }
- if ( !strcmp ( element_name, "Bet_historical" ) )
- {
- gsb_file_load_bet_historical ( attribute_names, attribute_values );
- return;
- }
- if ( !strcmp ( element_name, "Bet_future" ) )
- {
- gsb_file_load_bet_future_data ( attribute_names, attribute_values );
- return;
- }
- if ( !strcmp ( element_name, "Bet_transfert" ) )
- {
- gsb_file_load_bet_transfert_part ( attribute_names, attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Report" ))
- {
- gsb_file_load_report ( attribute_names,
- attribute_values );
- return;
- }
- if ( !strcmp ( element_name,
- "Text_comparison" ))
- {
- gsb_file_load_text_comparison ( attribute_names,
- attribute_values);
- return;
- }
- if ( !strcmp ( element_name,
- "Amount_comparison" ))
- {
- gsb_file_load_amount_comparison ( attribute_names,
- attribute_values);
- return;
- }
- if ( !strcmp ( element_name, "Logo" ) )
- {
- if ( etat.utilise_logo )
- gsb_file_load_logo_accueil ( attribute_names, attribute_values );
- return;
- }
- if ( !strcmp ( element_name, "Account_icon" ) )
- {
- gsb_file_load_account_icon_part ( attribute_names, attribute_values );
- return;
- }
- /* the first time we come here, we check if it's a grisbi file */
- }
- void gsb_file_load_error ( GMarkupParseContext *context,
- GError *error,
- gpointer user_data )
- {
- /* the first time we come here, we check if it's a grisbi file */
- gchar* tmpstr = g_strdup_printf (
- _("An error occured while parsing the file :\nError number : %d\n%s"),
- error -> code,
- error -> message );
- dialogue_error ( tmpstr );
- g_free ( tmpstr );
- }
- /**
- * load the general part in the grisbi file
- *
- * \param attribute_names
- * \param attribute_values
- *
- * */
- void gsb_file_load_general_part ( const gchar **attribute_names,
- const gchar **attribute_values )
- {
- gint i=0;
- if ( !attribute_names[i] )
- return;
- do
- {
- /* we test at the beginning if the attribute_value is NULL, if yes, */
- /* go to the next */
- if ( !strcmp (attribute_values[i],
- "(null)"))
- {
- /* Nothing */
- }
- else if ( !strcmp ( attribute_names[i],
- "File_version" ))
- {
- if ( download_tmp_values.file_version )
- g_free ( download_tmp_values.file_version );
- download_tmp_values.file_version = my_strdup (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Grisbi_version" ))
- {
- if ( download_tmp_values.grisbi_version )
- g_free ( download_tmp_values.grisbi_version );
- download_tmp_values.grisbi_version = my_strdup (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Crypt_file" ))
- {
- etat.crypt_file = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Archive_file" ))
- {
- etat.is_archive = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "File_title" ) && strlen (attribute_values[i]))
- {
- titre_fichier = my_strdup (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "General_address" ))
- {
- if ( adresse_commune )
- g_free ( adresse_commune );
- adresse_commune = my_strdup (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Second_general_address" ))
- {
- if ( adresse_secondaire )
- g_free ( adresse_secondaire );
- adresse_secondaire = my_strdup (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i], "Date_format" ) )
- {
- gsb_date_set_format_date ( attribute_values[i] );
- }
- else if ( !strcmp ( attribute_names[i], "Decimal_point" ) )
- {
- gsb_real_set_decimal_point ( attribute_values[i] );
- }
- else if ( !strcmp ( attribute_names[i], "Thousands_separator" ) )
- {
- if ( !strcmp ( attribute_values[i], "empty" ) )
- gsb_real_set_thousands_sep ( NULL );
- else
- gsb_real_set_thousands_sep ( attribute_values[i] );
- }
- else if ( !strcmp ( attribute_names[i],
- "Party_list_currency_number" ))
- {
- no_devise_totaux_tiers = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Category_list_currency_number" ))
- {
- no_devise_totaux_categ = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Budget_list_currency_number" ))
- {
- no_devise_totaux_ib = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Scheduler_view" ))
- {
- affichage_echeances = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Scheduler_custom_number" ))
- {
- affichage_echeances_perso_nb_libre = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Scheduler_custom_menu" ))
- {
- affichage_echeances_perso_j_m_a = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Import_interval_search" ))
- {
- valeur_echelle_recherche_date_import = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Import_extract_number_for_check" ))
- {
- etat.get_extract_number_for_check = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Import_fusion_transactions" ))
- {
- etat.get_fusion_import_transactions = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Import_categorie_for_payee" ))
- {
- etat.get_categorie_for_payee = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Import_fyear_by_value_date" ))
- {
- etat.get_fyear_by_value_date = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i], "Reconcile_end_date" ) )
- {
- etat.reconcile_end_date = utils_str_atoi ( attribute_values[i] );
- }
- else if ( !strcmp ( attribute_names[i],
- "Use_logo" ))
- {
- etat.utilise_logo = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i], "Name_logo" ) )
- {
- GdkPixbuf *pixbuf = NULL;
- etat.name_logo = my_strdup ( attribute_values[i] );
- if ( etat.is_pixmaps_dir )
- {
- gchar *chemin_logo = NULL;
- if ( etat.name_logo )
- chemin_logo = g_build_filename ( GRISBI_PIXMAPS_DIR, etat.name_logo, NULL );
- else
- chemin_logo = g_build_filename ( GRISBI_PIXMAPS_DIR, "grisbi-logo.png", NULL );
- if ( chemin_logo )
- pixbuf = gdk_pixbuf_new_from_file ( chemin_logo, NULL );
- if ( chemin_logo && strlen ( chemin_logo ) > 0 )
- g_free ( chemin_logo );
- }
- if ( pixbuf )
- {
- gtk_window_set_default_icon ( pixbuf );
- gsb_select_icon_set_logo_pixbuf ( pixbuf );
- }
- }
- else if ( !strcmp ( attribute_names[i], "Is_pixmaps_dir" ) )
- {
- etat.is_pixmaps_dir = utils_str_atoi ( attribute_values[i] );
- if ( etat.is_pixmaps_dir && etat.name_logo == NULL )
- {
- GdkPixbuf *pixbuf = NULL;
- gchar *chemin_logo = NULL;
- chemin_logo = g_build_filename ( GRISBI_PIXMAPS_DIR, "grisbi-logo.png", NULL );
- pixbuf = gdk_pixbuf_new_from_file ( chemin_logo, NULL );
- gtk_window_set_default_icon ( pixbuf );
- gsb_select_icon_set_logo_pixbuf ( pixbuf );
- g_free ( chemin_logo );
- }
- }
- else if ( !strcmp ( attribute_names[i],
- "Remind_display_per_account" ))
- {
- etat.retient_affichage_par_compte = utils_str_atoi( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Transactions_view" ))
- {
- gchar **pointeur_char;
- gint j, k;
- pointeur_char = g_strsplit ( attribute_values[i],
- "-",
- 0 );
- for ( j = 0 ; j<TRANSACTION_LIST_ROWS_NB ; j++ )
- for ( k = 0 ; k<CUSTOM_MODEL_VISIBLE_COLUMNS ; k++ )
- tab_affichage_ope[j][k] = utils_str_atoi (
- pointeur_char[k + j*CUSTOM_MODEL_VISIBLE_COLUMNS]);
- g_strfreev ( pointeur_char );
- }
- else if ( !strcmp ( attribute_names[i],
- "One_line_showed" ))
- {
- display_one_line = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Two_lines_showed" ))
- {
- display_two_lines = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Three_lines_showed" ))
- {
- display_three_lines = utils_str_atoi ( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i], "Transaction_column_width" ) )
- {
- /* initialise la réinitialisation des colonnes */
- run.transaction_column_width = my_strdup ( attribute_values[i] );
- initialise_largeur_colonnes_tab_affichage_ope ( GSB_ACCOUNT_PAGE,
- run.transaction_column_width );
- }
- else if ( !strcmp ( attribute_names[i], "Transaction_column_align" ) )
- {
- gchar **pointeur_char;
- gint j;
- /* the transactions columns are xx-xx-xx-xx and we want to set in transaction_col_width[1-2-3...] */
- pointeur_char = g_strsplit ( attribute_values[i], "-", 0 );
- for ( j = 0 ; j < CUSTOM_MODEL_VISIBLE_COLUMNS ; j++ )
- transaction_col_align[j] = utils_str_atoi ( pointeur_char[j] );
- g_strfreev ( pointeur_char );
- }
- else if ( !strcmp ( attribute_names[i], "Scheduler_column_width" ) )
- {
- /* initialise la réinitialisation des colonnes */
- run.scheduler_column_width = my_strdup ( attribute_values[i] );
- initialise_largeur_colonnes_tab_affichage_ope ( GSB_SCHEDULER_PAGE,
- run.scheduler_column_width );
- }
- else if ( !strcmp ( attribute_names[i],
- "Combofix_mixed_sort" ))
- {
- etat.combofix_mixed_sort = utils_str_atoi( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Combofix_max_item" ))
- {
- etat.combofix_max_item = utils_str_atoi( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Combofix_case_sensitive" ))
- {
- etat.combofix_case_sensitive = utils_str_atoi( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Combofix_force_payee" ))
- {
- etat.combofix_force_payee = utils_str_atoi( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Combofix_force_category" ))
- {
- etat.combofix_force_category = utils_str_atoi( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Automatic_amount_separator" ))
- {
- etat.automatic_separator = utils_str_atoi( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "CSV_separator" ))
- {
- if ( etat.csv_separator )
- g_free ( etat.csv_separator );
- etat.csv_separator = my_strdup ( attribute_values[i] );
- }
- else if ( !strcmp ( attribute_names[i],
- "CSV_skipped_lines" ))
- {
- if ( attribute_values[i] && strlen ( attribute_values[i] ) )
- {
- gchar ** pointeur_char = g_strsplit ( attribute_values[i], "-", 0 );
- gint line = 0;
- while ( pointeur_char[line] )
- {
- etat.csv_skipped_lines[line] = utils_str_atoi ( pointeur_char[line] );
- line ++;
- }
- g_strfreev ( pointeur_char );
- }
- }
- else if ( !strcmp ( attribute_names[i],
- "Metatree_sort_transactions" ))
- {
- etat.metatree_sort_transactions = utils_str_atoi( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Add_archive_in_total_balance" ))
- {
- etat.add_archive_in_total_balance = utils_str_atoi( attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i], "Bet_array_column_width" ))
- {
- gchar **pointeur_char;
- gint j;
- /* the bet_array columns are xx-xx-xx-xx-xx and we want to set in bet_array_col_width[1-2-3...] */
- pointeur_char = g_strsplit ( attribute_values[i], "-", 0 );
- for ( j = 0; j < BET_ARRAY_COLUMNS; j++ )
- bet_array_col_width[j] = utils_str_atoi ( pointeur_char[j] );
- g_strfreev ( pointeur_char );
- }
- else if ( !strcmp ( attribute_names[i], "Bet_capital" ) )
- {
- etat.bet_capital = utils_str_safe_strtod ( attribute_values[i], NULL );
- }
- else if ( !strcmp ( attribute_names[i], "Bet_currency" ) )
- {
- etat.bet_currency = utils_str_atoi ( attribute_values[i] );
- }
- else if ( !strcmp ( attribute_names[i], "Bet_taux_annuel" ) )
- {
- etat.bet_taux_annuel = utils_str_safe_strtod ( attribute_values[i], NULL );
- }
- else if ( !strcmp ( attribute_names[i], "Bet_index_duree" ) )
- {
- etat.bet_index_duree = utils_str_atoi ( attribute_values[i] );
- }
- else if ( !strcmp ( attribute_names[i], "Bet_frais" ) )
- {
- etat.bet_frais = utils_str_safe_strtod ( attribute_values[i], NULL );
- }
- else if ( !strcmp ( attribute_names[i], "Bet_type_taux" ) )
- {
- etat.bet_type_taux = utils_str_atoi ( attribute_values[i] );
- }
- i++;
- }
- while ( attribute_names[i] );
- }
- /**
- * load the color part in the grisbi file
- *
- * \param attribute_names
- * \param attribute_values
- *
- * */
- void gsb_file_load_color_part ( const gchar **attribute_names,
- const gchar **attribute_values )
- {
- gint i=0;
- if ( !attribute_names[i] )
- return;
- do
- {
- /* we test at the beginning if the attribute_value is NULL, if yes, */
- /* go to the next */
- if ( !strcmp (attribute_values[i],
- "(null)"))
- {
- /* Nothing */
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_color_0_red" ))
- {
- couleur_fond[0].red = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_color_0_green" ))
- {
- couleur_fond[0].green = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_color_0_blue" ))
- {
- couleur_fond[0].blue = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_color_1_red" ))
- {
- couleur_fond[1].red = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_color_1_green" ))
- {
- couleur_fond[1].green = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_color_1_blue" ))
- {
- couleur_fond[1].blue = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_jour_red" ))
- {
- couleur_jour.red = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_jour_green" ))
- {
- couleur_jour.green = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_jour_blue" ))
- {
- couleur_jour.blue = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_scheduled_red" ))
- {
- couleur_grise.red = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_scheduled_green" ))
- {
- couleur_grise.green = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_scheduled_blue" ))
- {
- couleur_grise.blue = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_archive_red" ))
- {
- archive_background_color.red = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_archive_green" ))
- {
- archive_background_color.green = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_archive_blue" ))
- {
- archive_background_color.blue = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Selection_red" ))
- {
- couleur_selection.red = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Selection_green" ))
- {
- couleur_selection.green = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Selection_blue" ))
- {
- couleur_selection.blue = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_split_red" ))
- {
- split_background.red = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_split_green" ))
- {
- split_background.green = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Background_split_blue" ))
- {
- split_background.blue = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Text_color_0_red" ))
- {
- text_color[0].red = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Text_color_0_green" ))
- {
- text_color[0].green = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Text_color_0_blue" ))
- {
- text_color[0].blue = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Text_color_1_red" ))
- {
- text_color[1].red = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Text_color_1_green" ))
- {
- text_color[1].green = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Text_color_1_blue" ))
- {
- text_color[1].blue = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Calendar_entry_red" ))
- {
- calendar_entry_color.red = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Calendar_entry_green" ))
- {
- calendar_entry_color.green = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Calendar_entry_blue" ))
- {
- calendar_entry_color.blue = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_bet_division_red" ))
- {
- couleur_bet_division.red = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_bet_division_green" ))
- {
- couleur_bet_division.green = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_bet_division_blue" ))
- {
- couleur_bet_division.blue = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_bet_future_red" ))
- {
- couleur_bet_future.red = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_bet_future_green" ))
- {
- couleur_bet_future.green = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_bet_future_blue" ))
- {
- couleur_bet_future.blue = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_bet_solde_red" ))
- {
- couleur_bet_solde.red = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_bet_solde_green" ))
- {
- couleur_bet_solde.green = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_bet_solde_blue" ))
- {
- couleur_bet_solde.blue = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_bet_transfert_red" ))
- {
- couleur_bet_transfert.red = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_bet_transfert_green" ))
- {
- couleur_bet_transfert.green = utils_str_atoi (attribute_values[i]);
- }
- else if ( !strcmp ( attribute_names[i],
- "Couleur_bet_transfert_blue" ))
- {
- couleur_bet_transfert.blue = utils_str_atoi (attribute_values[i]);
- }
- i++;
- }
- while ( attribute_names[i] );
- }
- /**
- * load the print part in the grisbi file
- *
- * \param attribute_names
- * \param attribute_values
- *
- * */
- void gsb_file_load_print_part ( const gchar **attribute_names,
- const gchar **attribute_values )
- {
- gint i=0;
- if ( !attribute_names[i] )
- return;
- do
- {
- /* we test at the beginning if the attribute_value is NULL, if yes, */
- /* go to the next */
- if ( !strcmp (attribute_values[i],
- "(null)"))
- {
- /* Nothing */
- }
- else if ( !strcmp ( attribute_names[i],
- "Draw_lines" ))
- {
- gsb_data_print_config_set_draw_lines (0, utils_str_atoi (attribute_values[i]));
- }
- else if ( !strcmp ( attribute_names[i],
- "Draw_column" ))
- {
- gsb_data_print_config_set_draw_column (0, utils_str_atoi (attribute_values[i]));
- }
- else if ( !strcmp ( attribute_names[i],
- "Draw_background" ))
- {
- gsb_data_print_config_set_draw_background (0, utils_str_atoi (attribute_values[i]));
- }
- else if ( !strcmp ( attribute_names[i],
- "Draw_archives" ))
- {
- gsb_data_print_config_set_draw_archives (0, utils_str_atoi (attribute_values[i]));
- }
- else if ( !strcmp ( attribute_names[i],
- "Draw_columns_name" ))
- {
- gsb_data_print_config_set_draw_columns_name (0, utils_str_atoi (attribute_values[i]));
- }
- else if ( !strcmp ( attribute_names[i],
- "Draw_title" ))
- {
- gsb_data_print_config_set_draw_title (0, utils_str_atoi (attribute_values[i]));
- }
- else if ( !strcmp ( attribute_names[i],
- "Draw_interval_dates" ))
- {
- gsb_data_print_config_set_draw_interval_dates (
- 0, utils_str_atoi (attribute_values[i]) );
- }
- else if ( !strcmp ( attribute_names[i],
- "Draw_dates_are_value_dates" ))
- {
- gsb_data_print_config_set_draw_dates_are_value_dates (
- 0, utils_str_atoi (attribute_values[i]) );
- }
- else if ( !strcmp ( attribute_names[i],
- "Font_transactions" ))
- {
- gsb_data_print_config_set_font_transaction (
- pango_font_description_from_string (attribute_values[i]) );
- }
- else if ( !strcmp ( attribute_names[i],
- "Font_title" ))
- {
- gsb_data_print_config_set_font_title (
- pango_font_description_from_string (attribute_values[i]) );
- }
- else if ( !strcmp ( attribute_names[i],
- "Report_font_transactions" ) )
- {
- gsb_data_print_config_set_report_font_transaction (
- pango_font_description_from_string (attribute_values[i]) );
- }
- else if ( !strcmp ( attribute_names[i],
- "Report_font_title" ) )
- {
- gsb_data_print_config_set_report_font_title (
- pango_font_description_from_string ( attribute_values[i]) );
- }
- i++;
- }
- while ( attribute_names[i] );
- }
- /**
- * load the account part in the grisbi file
- *
- * \param attribute_names
- * \param attribute_values
- *
- * */
- void gsb_file_load_account_part ( const gchar **attribute_names,
- const gchar **attribute_values )
- {
- gint i=0;
- gint account_number = 0;
- if ( !attribute_names[i] )
- return;
- do
- {
- /* we test at the beginning if the attribute_value is NULL, if yes, */
- /* go to the next */
- if ( !strcmp (attribute_values[i],
- "(null)"))
- {
- i++;
- continue;
- }
- if ( !strcmp ( attribute_names[i],
- "Name" ))
- {
- account_number = gsb_data_account_new ( GSB_TYPE_BANK );
- gsb_data_account_set_name ( account_number,
- attribute_values[i]);
- i++;
- continue;
- }
- if ( !strcmp ( attribute_names[i],
- "Id" ))
- {
- if ( strlen (attribute_values[i]))
- gsb_data_account_set_id (account_number,
- attribute_values[i]);
- i++;
- continue;
- }
- if ( !strcmp ( attribute_names[i],
- "Number" ))
- {
- account_number = gsb_data_account_set_account_number ( account_number,
- utils_str_atoi ( attribute_values[i]));
- i++;
- continue;
- }
- if ( !strcm…
Large files files are truncated, but you can click here to view the full file