/** * duplicate the form organization of the account in the param * * \param origin_account * \param target_account * * \return TRUE, FALSE if problem * */ gboolean gsb_data_form_dup_organization ( gint origin_account, gint target_account ) { form_organization *origin_form; form_organization *new_form; origin_form = gsb_data_account_get_form_organization (origin_account); if ( !origin_form ) return FALSE; new_form = g_malloc0 ( sizeof (form_organization)); if ( !new_form ) { dialogue_error_memory (); return FALSE; } memcpy ( new_form, origin_form, sizeof (form_organization)); gsb_data_account_set_form_organization ( target_account, new_form ); return TRUE; }
/** * ajoute une nouvelle icone pour le compte passé en paramètre * * /param la chaine codée de l'icone * return TRUE if OK else FALSE * */ gboolean gsb_select_icon_new_account_icon_from_file ( gint account_number, const gchar *filename ) { struct_account_icon *icon; GdkPixbuf *pixbuf; GError *error = NULL; if ( !filename || !strlen ( filename ) ) return FALSE; else { if ( !g_file_test ( filename, G_FILE_TEST_EXISTS ) ) return FALSE; } icon = g_malloc0 ( sizeof ( struct_account_icon ) ); icon_buffer = icon; if ( !icon ) { dialogue_error_memory (); return FALSE; } icon -> account_number = account_number; pixbuf = gdk_pixbuf_new_from_file_at_size ( filename , 32, 32, &error ); if ( pixbuf ) { icon -> pixbuf = pixbuf; list_accounts_icon = g_slist_prepend ( list_accounts_icon, icon ); return TRUE; } else { gchar* tmp_str; tmp_str = g_strconcat( "Erreur de pixbuf : ", error -> message, " image ", filename, NULL ); devel_debug ( tmp_str ); dialogue_error ( tmp_str ); g_error_free ( error ); g_free ( tmp_str ); g_free ( icon ); return FALSE; } }
/** * create a new form organization * and append it to the account * the form struct is set to 0 and has to be filled * * \param account_number * * \return FALSE * */ gboolean gsb_data_form_new_organization ( gint account_number ) { form_organization *new_form; new_form = g_malloc0 (sizeof (form_organization)); if ( !new_form ) { dialogue_error_memory (); return FALSE; } gsb_data_account_set_form_organization ( account_number, new_form ); return FALSE; }
/** * create a new reconcile, give it a number, append it to the list * and return the number * * \param name the name of the reconcile (can be freed after, it's a copy) or NULL * * \return the number of the new reconcile or 0 if memory problem (a message will be showed) * */ gint gsb_data_reconcile_new ( const gchar *name ) { struct_reconcile *reconcile; reconcile = g_malloc0 ( sizeof ( struct_reconcile )); if (!reconcile) { dialogue_error_memory (); return 0; } reconcile -> reconcile_number = gsb_data_reconcile_max_number () + 1; if (name) reconcile -> reconcile_name = my_strdup (name); reconcile_list = g_list_append ( reconcile_list, reconcile ); return reconcile -> reconcile_number; }
/** * ajoute une nouvelle icone pour le compte passé en paramètre * * * return TRUE if OK else FALSE * */ gboolean gsb_select_icon_new_account_icon ( gint account_number, GdkPixbuf *pixbuf ) { struct_account_icon *icon; icon = g_malloc0 ( sizeof ( struct_account_icon ) ); icon_buffer = icon; if ( !icon ) { dialogue_error_memory (); return FALSE; } icon -> account_number = account_number; icon -> pixbuf = pixbuf; list_accounts_icon = g_slist_prepend ( list_accounts_icon, icon ); return TRUE; }
/** * create a new archive, give him a number, append it to the list * and return the number * * \param name the name of the archive (can be freed after, it's a copy) or NULL * * \return the number of the new archive * */ gint gsb_data_archive_new ( const gchar *name ) { struct_archive *archive; archive = g_malloc0 ( sizeof ( struct_archive )); if (!archive) { dialogue_error_memory (); return 0; } archive -> archive_number = gsb_data_archive_max_number () + 1; if (name) archive -> archive_name = my_strdup (name); else archive -> archive_name = NULL; archive_list = g_slist_append ( archive_list, archive ); archive_buffer = archive; return archive -> archive_number; }
/** * function called when the user come to the automatically association page * fill the label and show the button if possible * * \param assistant * \param new_page * * \return FALSE * */ gboolean gsb_assistant_reconcile_config_update_auto_asso ( GtkWidget *assistant, gint new_page ) { gchar *string; GSList *tmp_list; gint associate_number; /* update the string containing the number of transactions to link */ string = g_strdup_printf (_("Still %d transactions to link with a reconciliation."), transactions_to_link); gtk_label_set_text ( GTK_LABEL (label_transactions_to_link_2), string); g_free (string); gtk_misc_set_alignment ( GTK_MISC (label_transactions_to_link_2), 0, 0.5 ); /* calculate how many transactions can be associated automatically, * to avoid to do that 2 times, we set each transactions in a structure with * the associated number of bank reconciliation */ if (list_association) { g_slist_free (list_association); list_association = NULL; } tmp_list = gsb_data_transaction_get_transactions_list (); while (tmp_list) { gint transaction_number; transaction_number = gsb_data_transaction_get_transaction_number (tmp_list -> data); if (gsb_data_transaction_get_marked_transaction (transaction_number) == OPERATION_RAPPROCHEE && !gsb_data_transaction_get_reconcile_number (transaction_number)) { /* ok we are on a marked R transaction without reconcile number, * we search for that reconcile */ gint reconcile_number; reconcile_number = gsb_data_reconcile_get_number_by_date (gsb_data_transaction_get_date (transaction_number), gsb_data_transaction_get_account_number (transaction_number)); if (reconcile_number) { struct association_transaction_reconcile *association; association = g_malloc0 (sizeof (struct association_transaction_reconcile)); if (!association) { dialogue_error_memory (); return FALSE; } association -> transaction_number = transaction_number; association -> reconcile_number = reconcile_number; list_association = g_slist_append ( list_association, association ); } } tmp_list = tmp_list -> next; } /* set the number of possible links */ associate_number = g_slist_length (list_association); if (associate_number) { string = g_strdup_printf (_("Grisbi can associate %d transactions to a reconciliation.\n" "Please click on the launch button to create the links."), associate_number); gtk_widget_set_sensitive ( button_run_association, TRUE ); } else { string = my_strdup (_("There is no transaction that Grisbi can link.\n" "Check if you created all the necesssary reconciliations.")); gtk_widget_set_sensitive ( button_run_association, FALSE ); } gtk_label_set_text ( GTK_LABEL (label_possible_association), string); g_free (string); return FALSE; }
gboolean gsb_account_new ( kind_account account_type, gint currency_number, gint bank_number, gsb_real init_amount, const gchar *name, gchar *name_icon ) { gint account_number; GtkWidget *notebook_general; /* create the new account */ account_number = gsb_data_account_new (account_type); if ( account_number == -1 ) { dialogue_error_memory (); return FALSE; } /* set the default method of payment */ gsb_data_payment_create_default (account_number); /* set the icon_name */ if ( name_icon ) gsb_data_account_set_name_icon ( account_number, name_icon ); gsb_data_account_set_currency ( account_number, currency_number); gsb_data_account_set_bank (account_number, bank_number); gsb_data_account_set_init_balance (account_number, init_amount); gsb_data_account_set_mini_balance_wanted ( account_number, gsb_real_new ( 0, gsb_data_currency_get_floating_point (currency_number) ) ); gsb_data_account_set_mini_balance_authorized (account_number, gsb_real_new ( 0, gsb_data_currency_get_floating_point (currency_number) ) ); gsb_data_account_set_name (account_number, name); /* update the combofix for categ */ gsb_category_update_combofix ( FALSE ); /* update the name of accounts in form */ gsb_account_update_combo_list ( gsb_form_scheduler_get_element_widget (SCHEDULED_FORM_ACCOUNT), FALSE ); /* update the main page */ mise_a_jour_liste_comptes_accueil = 1; /* update the accounts lists */ gsb_menu_update_accounts_in_menus (); /* do the next part only if the widgets are created * (can come here at the end of the new file assistant...) */ notebook_general = gsb_gui_get_general_notebook ( ); if (notebook_general) { /* Add an entry in navigation pane. */ gsb_gui_navigation_add_account ( account_number, TRUE ); /* Go to accounts properties */ gtk_notebook_set_current_page ( GTK_NOTEBOOK ( notebook_general ), GSB_ACCOUNT_PAGE ); gtk_notebook_set_current_page ( GTK_NOTEBOOK ( account_page ), GSB_PROPERTIES_PAGE ); gsb_account_property_fill_page (); } gsb_file_set_modified ( TRUE ); return TRUE; }