void lance_mailer ( const gchar *uri ) { gchar *chaine; GError *error = NULL; chaine = g_strconcat ( "mailto:", uri, NULL ); if ( gtk_show_uri ( NULL, chaine, GDK_CURRENT_TIME, &error ) == FALSE ) { gchar *tmp_str; tmp_str = g_strdup_printf ( _("Grisbi was unable to execute a mailer to write at <tt>%s</tt>.\n" "The error was: %s."), uri, error -> message ); g_error_free ( error ); dialogue_error_hint ( tmp_str, _("Cannot execute mailer") ); g_free(tmp_str); } g_free ( chaine ); }
/** * Initialization function for the html backend. * * \return TRUE on succes, FALSE otherwise. */ gint html_initialise ( GSList * opes_selectionnees, gchar * filename ) { g_return_val_if_fail ( filename, FALSE ); html_lastline = -1; html_lastcol = 0; html_last_is_hsep = FALSE; html_first_line = TRUE; html_out = utf8_fopen ( filename, "w" ); if ( ! html_out ) { dialogue_error_hint ( _("Make sure file exists and is writable."), g_strdup_printf (_("Cannot open file '%s' for writing"), filename)); return FALSE; } fprintf (html_out, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n\n" "<html>\n" " <head>\n" " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n" " <title>"); if (!gsb_gui_navigation_get_current_report ()) return FALSE; html_safe (etats_titre(gsb_gui_navigation_get_current_report ())); fprintf (html_out, "</title>\n" " </head>\n\n" " <body>\n" " <table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n\n"); return TRUE; }
/** * save the file * * \param origine 0 from gsb_file_save (menu), -1 from gsb_file_close, -2 from gsb_file_save_as * * \return TRUE if ok, FALSE if problem * */ gboolean gsb_file_save_file ( gint origine ) { gint etat_force, result; gchar *nouveau_nom_enregistrement; devel_debug_int (origine); etat_force = 0; if ( ( !gsb_file_get_modified ( ) && origine != -2 ) || !gsb_data_account_get_accounts_amount () ) { notice_debug ( "nothing done in gsb_file_save_file" ); return ( TRUE ); } /* si le fichier de comptes n'a pas de nom ou si on enregistre sous un nouveau nom */ /* c'est ici */ if ( !nom_fichier_comptes || origine == -2 ) nouveau_nom_enregistrement = gsb_file_dialog_ask_name (); else nouveau_nom_enregistrement = nom_fichier_comptes; if ( !nouveau_nom_enregistrement ) return FALSE; /* on vérifie que le fichier n'est pas locké */ if ( etat.fichier_deja_ouvert && !conf.force_enregistrement && origine != -2 ) { gchar* tmpstr1 = g_strdup_printf( _("Grisbi was unable to save this file because it is locked. Please save it with another name or activate the \"%s\" option in preferences."), _("Force saving of locked files" ) ); gchar* tmpstr2 = g_strdup_printf( _("Can not save file \"%s\""), nom_fichier_comptes ); dialogue_error_hint ( tmpstr1, tmpstr2 ); g_free ( tmpstr1 ); g_free ( tmpstr2 ); return ( FALSE ); } /* Si le fichier est un d'une version précédente de grisbi on demande si on l'efface */ if ( copy_old_filename && strlen ( copy_old_filename ) > 0 ) { gsb_file_save_remove_old_file ( copy_old_filename ); g_free ( copy_old_filename ); copy_old_filename = NULL; } /* make backup before saving if asked */ if (conf.make_backup) gsb_file_save_backup(); /* on a maintenant un nom de fichier */ /* et on sait qu'on peut sauvegarder */ gsb_status_message ( _("Saving file") ); result = gsb_file_save_save_file ( nouveau_nom_enregistrement, conf.compress_file, FALSE ); if ( result ) { /* saving was right, so unlock the last name */ gsb_file_util_modify_lock ( FALSE ); nom_fichier_comptes = nouveau_nom_enregistrement; /* and lock the new name */ gsb_file_util_modify_lock ( TRUE ); /* update variables */ etat.fichier_deja_ouvert = 0; gsb_file_set_modified ( FALSE ); gsb_main_set_grisbi_title ( gsb_gui_navigation_get_current_account ( ) ); gsb_file_append_name_to_opened_list ( nom_fichier_comptes ); } gsb_status_message ( _("Done") ); return ( result ); }
/** * 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; }
/** * Manually parse a gnucash file, tidy it, put result in a temporary * file and parse it via libxml. * * \param filename Filename to parse. * * \return A pointer to a xmlDocPtr containing XML representation of file. */ xmlDocPtr parse_gnucash_file ( gchar * filename ) { gchar buffer[1024], *tempname; FILE * filein, * tempfile; xmlDocPtr doc; filein = utils_files_utf8_fopen ( filename, "r" ); if ( ! filein ) { dialogue_error_hint ( g_strdup_printf ( _("Either file \"%s\" does not exist or it is not a regular file."), filename ), g_strdup_printf ( _("Error opening file '%s'." ), filename ) ); return NULL; } tempname = g_strdup_printf ( "gsbgnc%05d", g_random_int_range (0,99999) ); tempfile = utils_files_utf8_fopen ( tempname, "w" ); if ( ! tempfile ) { gchar *tmp_str; gchar *tmp_str_2; tmp_str = g_strdup ( _("Grisbi needs to open a temporary file in order to import Gnucash data " "but file can't be created.\n" "Check that you have permission to do that.") ); tmp_str_2 = g_strdup_printf ( _("Error opening temporary file '%s'." ), tempname ); dialogue_error_hint ( tmp_str, tmp_str_2 ); g_free ( tmp_str ); g_free ( tmp_str_2 ); fclose(filein); return NULL; } /** * We need to create a temporary file because Gnucash writes XML * files that do not respect the XML specification regarding * namespaces. We need to tidy XML file in order to let libxml * handle it gracefully. */ while ( fgets ( buffer, 1024, filein ) ) { gchar * tag; tag = g_strrstr ( buffer, "<gnc-v2>" ); if ( tag ) { const gchar *ns[14] = { "gnc", "cd", "book", "act", "trn", "split", "cmdty", "ts", "slots", "slot", "price", "sx", "fs", NULL }; const gchar **iter; tag += 7; *tag = 0; tag++; fputs ( buffer, tempfile ); for ( iter = ns ; *iter != NULL ; iter++ ) { gchar *header; header = g_strdup_printf ( " xmlns:%s=\"http://www.gnucash.org/lxr/gnucash/source/src/doc/xml/%s-v1.dtd#%s\"\n", *iter, *iter, *iter ); fputs ( header, tempfile ); g_free ( header ); } fputs ( ">\n", tempfile ); } else { fputs ( buffer, tempfile ); } } fclose ( filein ); fclose ( tempfile ); doc = xmlParseFile( g_filename_from_utf8 ( tempname, -1, NULL, NULL, NULL ) ); /** Once parsed, the temporary file is removed as it is useless. */ g_unlink ( tempname ); return doc; }
/** * create a qif export, according to the filename, the account * and eventually, limit the export to the archive if exists * this will export all the transactions of the account (except if we ask for an archive...) * including the archived transactions * * \param filename that file will be checked and ask to overwrite if needed * \param account_nb * \param archive_number if 0, just export in qif the account transactions ; if non 0, export just the transactions for that archive and account * * \return TRUE ok, FALSE pb */ gboolean qif_export ( const gchar *filename, gint account_nb, gint archive_number ) { FILE * fichier_qif; GSList *list_tmp_transactions; gint beginning; gint floating_point; gchar* tmpstr; if (!gsb_file_util_test_overwrite (filename)) return FALSE; if ( !( fichier_qif = utf8_fopen ( filename, "w" ) )) { dialogue_error_hint ( g_strerror(errno), g_strdup_printf ( _("Error opening file '%s'"), filename ) ); return FALSE; } /* get the floating point of the currency of the amount, * ie the number of digits after the . */ floating_point = gsb_data_currency_get_floating_point (gsb_data_account_get_currency (account_nb)); /* kind of account */ if ( gsb_data_account_get_kind (account_nb) == GSB_TYPE_CASH ) fprintf ( fichier_qif, "!Type:Cash\n" ); else if ( gsb_data_account_get_kind (account_nb) == GSB_TYPE_LIABILITIES || gsb_data_account_get_kind (account_nb) == GSB_TYPE_ASSET ) fprintf ( fichier_qif, "!Type:Oth L\n" ); else fprintf ( fichier_qif, "!Type:Bank\n" ); list_tmp_transactions = gsb_data_transaction_get_complete_transactions_list (); beginning = 1; while ( list_tmp_transactions ) { gint transaction_number_tmp; transaction_number_tmp = gsb_data_transaction_get_transaction_number (list_tmp_transactions -> data); if ( gsb_data_transaction_get_account_number (transaction_number_tmp) == account_nb && (!archive_number || gsb_data_transaction_get_archive_number (transaction_number_tmp) == archive_number)) { if ( beginning ) { /* this is the beginning of the qif file, we set some beginnings things */ fprintf ( fichier_qif, "D%d/%d/%d\n", g_date_get_day (gsb_data_transaction_get_date (transaction_number_tmp)), g_date_get_month (gsb_data_transaction_get_date (transaction_number_tmp)), g_date_get_year (gsb_data_transaction_get_date (transaction_number_tmp))); /* met le solde initial */ tmpstr = utils_real_get_string (gsb_data_account_get_init_balance (account_nb, -1)); fprintf ( fichier_qif, "T%s\n", tmpstr); g_free ( tmpstr ); fprintf ( fichier_qif, "CX\nPOpening Balance\n" ); /* met le nom du imported_account */ fprintf ( fichier_qif, "L%s\n^\n", g_strconcat ( "[", gsb_data_account_get_name (account_nb), "]", NULL ) ); beginning = 0; } /* si c'est une opé de ventil, on la saute pas elle sera recherchée quand */ /* son opé ventilée sera exportée */ if ( !gsb_data_transaction_get_mother_transaction_number ( transaction_number_tmp)) { /* met la date */ fprintf ( fichier_qif, "D%d/%d/%d\n", g_date_get_day (gsb_data_transaction_get_date (transaction_number_tmp)), g_date_get_month (gsb_data_transaction_get_date (transaction_number_tmp)), g_date_get_year (gsb_data_transaction_get_date (transaction_number_tmp))); /* met le pointage */ if ( gsb_data_transaction_get_marked_transaction ( transaction_number_tmp)== OPERATION_POINTEE || gsb_data_transaction_get_marked_transaction ( transaction_number_tmp)== OPERATION_TELERAPPROCHEE ) fprintf ( fichier_qif, "C*\n" ); else if ( gsb_data_transaction_get_marked_transaction ( transaction_number_tmp)== OPERATION_RAPPROCHEE ) fprintf ( fichier_qif, "CX\n" ); /* met les notes */ if ( gsb_data_transaction_get_notes ( transaction_number_tmp)) fprintf ( fichier_qif, "M%s\n", gsb_data_transaction_get_notes ( transaction_number_tmp)); /* met le montant, transforme la devise si necessaire */ tmpstr = utils_real_get_string (gsb_data_transaction_get_adjusted_amount ( transaction_number_tmp, floating_point)); fprintf ( fichier_qif, "T%s\n", tmpstr); g_free ( tmpstr ); /* met le chèque si c'est un type à numérotation automatique */ if ( gsb_data_payment_get_automatic_numbering (gsb_data_transaction_get_method_of_payment_number (transaction_number_tmp))) fprintf ( fichier_qif, "N%s\n", gsb_data_transaction_get_method_of_payment_content ( transaction_number_tmp)); /* met le tiers */ fprintf ( fichier_qif, "P%s\n", gsb_data_payee_get_name ( gsb_data_transaction_get_party_number ( transaction_number_tmp), FALSE )); /* on met soit un virement, soit une ventil, soit les catégories */ /* si c'est une imported_splitted, on recherche toutes les opés de cette imported_splitted */ /* et les met à la suite */ /* la catégorie de l'opé sera celle de la première opé de imported_splitted */ if ( gsb_data_transaction_get_split_of_transaction ( transaction_number_tmp)) { /* it's a split of transactions, look for the children and append them */ gint mother_transaction_category_written; GSList *list_tmp_transactions_2; mother_transaction_category_written = 0; list_tmp_transactions_2 = gsb_data_transaction_get_transactions_list (); while ( list_tmp_transactions_2 ) { gint transaction_number_tmp_2; transaction_number_tmp_2 = gsb_data_transaction_get_transaction_number (list_tmp_transactions_2 -> data); if (gsb_data_transaction_get_mother_transaction_number (transaction_number_tmp_2) == transaction_number_tmp) { /* we are on a child, for the first one, we set the mother category */ /* the child can only be a normal category or a transfer */ if ( gsb_data_transaction_get_contra_transaction_number (transaction_number_tmp_2) > 0) { /* the child is a transfer */ if ( !mother_transaction_category_written ) { fprintf ( fichier_qif, "L%s\n", g_strconcat ( "[", gsb_data_account_get_name (gsb_data_transaction_get_contra_transaction_account (transaction_number_tmp_2)), "]", NULL )); mother_transaction_category_written = 1; } fprintf ( fichier_qif, "S%s\n", g_strconcat ( "[", gsb_data_account_get_name (gsb_data_transaction_get_contra_transaction_account ( transaction_number_tmp_2)), "]", NULL )); } else { /* it's a category : sub-category */ if ( !mother_transaction_category_written ) { fprintf ( fichier_qif, "L%s\n", gsb_data_category_get_name (gsb_data_transaction_get_category_number (transaction_number_tmp_2), gsb_data_transaction_get_sub_category_number (transaction_number_tmp_2), _("No category defined"))); mother_transaction_category_written = 1; } fprintf ( fichier_qif, "S%s\n", gsb_data_category_get_name (gsb_data_transaction_get_category_number (transaction_number_tmp_2), gsb_data_transaction_get_sub_category_number (transaction_number_tmp_2), _("No category defined"))); } /* set the notes of the split child */ if ( gsb_data_transaction_get_notes (transaction_number_tmp_2)) fprintf ( fichier_qif, "E%s\n", gsb_data_transaction_get_notes (transaction_number_tmp_2)); /* set the amount of the split child */ tmpstr = utils_real_get_string (gsb_data_transaction_get_adjusted_amount (transaction_number_tmp_2, floating_point)); fprintf ( fichier_qif, "$%s\n", tmpstr); g_free ( tmpstr ); } list_tmp_transactions_2 = list_tmp_transactions_2 -> next; } } else { /* if it's a transfer, the contra-account must exist, else we do * as for a normal category */ if ( gsb_data_transaction_get_contra_transaction_number (transaction_number_tmp) > 0 ) { /* it's a transfer */ fprintf ( fichier_qif, "L%s\n", g_strconcat ( "[", gsb_data_account_get_name (gsb_data_transaction_get_contra_transaction_account ( transaction_number_tmp)), "]", NULL )); } else { /* it's a normal category */ fprintf ( fichier_qif, "L%s\n", gsb_data_category_get_name (gsb_data_transaction_get_category_number (transaction_number_tmp), gsb_data_transaction_get_sub_category_number (transaction_number_tmp), FALSE )); } } fprintf ( fichier_qif, "^\n" ); } } list_tmp_transactions = list_tmp_transactions -> next; } if ( beginning ) { /* there is no transaction in the account, so do the opening of the account, bug no date */ /* met le solde initial */ gchar* tmpstr = utils_real_get_string (gsb_data_account_get_init_balance (account_nb, -1)); fprintf ( fichier_qif, "T%s\n", tmpstr); g_free ( tmpstr ); fprintf ( fichier_qif, "CX\nPOpening Balance\n" ); /* met le nom du imported_account */ fprintf ( fichier_qif, "L%s\n^\n", g_strconcat ( "[", gsb_data_account_get_name (account_nb), "]", NULL ) ); } fclose ( fichier_qif ); 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; }
/** * si la commande du navigateur contient %s, on le remplace par url, * sinon on ajoute l'url à la fin et & * * sous Windows si la commande est vide ou egale a la valeur par defaut * on lance le butineur par defaut (open) */ gboolean lance_navigateur_web ( const gchar *url ) { gchar **split; gchar *chaine = NULL; gchar* tmp_str; #ifdef _WIN32 gboolean use_default_browser = TRUE; if ( conf.browser_command && strlen ( conf.browser_command ) ) { use_default_browser = !strcmp ( conf.browser_command,ETAT_WWW_BROWSER ); } #else /* _WIN32 */ if ( !( conf.browser_command && strlen ( conf.browser_command ) ) ) { tmp_str = g_strdup_printf ( _("Grisbi was unable to execute a web browser to " "browse url:\n<span foreground=\"blue\">%s</span>.\n\n" "Please adjust your settings to a valid executable."), url ); dialogue_error_hint ( tmp_str, _("Cannot execute web browser") ); g_free (tmp_str); return FALSE; } #endif /* _WIN32 */ #ifdef _WIN32 if (!use_default_browser) { #endif /* _WIN32 */ /* search if the sequence `%s' is in the string * and split the string before and after this delimiter */ split = g_strsplit ( conf.browser_command, "%s", 0 ); if ( split[1] ) { /* he has a %s in the command */ /* concat the string before %s, the url and the string after %s */ tmp_str = g_strconcat ( " ", url, " ", NULL ); chaine = g_strjoinv ( tmp_str, split ); g_free( tmp_str ); g_strfreev ( split ); /* add the & character at the end */ tmp_str = g_strconcat ( chaine, "&", NULL ); g_free ( chaine ); chaine = tmp_str; } else chaine = g_strconcat ( conf.browser_command, " ", url, "&", NULL ); if ( system ( chaine ) == -1 ) { tmp_str = g_strdup_printf ( _("Grisbi was unable to execute a web browser to " "browse url <tt>%s</tt>.\nThe command was: %s.\n" "Please adjust your settings to a valid executable."), url, chaine ); dialogue_error_hint ( tmp_str, _("Cannot execute web browser") ); g_free(tmp_str); } #ifdef _WIN32 } else { win32_shell_execute_open ( url ); } #endif /* _WIN32 */ g_free(chaine); return FALSE; }