/**
 * create the scheduled part : that widgets are created at the beginning
 * and normally never destroyed, they are showed only for
 * scheduled transactions 
 * Cela ne fonctionne pas : tous les widgets sont détruits par la
 * fonction gsb_form_create_widgets ( )
 *
 * \param table a GtkTable with the dimension SCHEDULED_HEIGHT*SCHEDULED_WIDTH to be filled
 *
 * \return FALSE
 * */
gboolean gsb_form_scheduler_create ( GtkWidget *table )
{
    gint row, column;
    struct_element *element;
    devel_debug (NULL);
    if (!table)
        return FALSE;

    /* just in case... be sure that not created */
    if (scheduled_element_list)
        gsb_form_scheduler_free_list ( );

    /* check the dimensions, 
     * if problem give a warning message but continue the program with changing the values */
    g_object_get ( G_OBJECT (table),
		   "n-columns", &column,
		   "n-rows", &row,
		   NULL );
    if ( column != SCHEDULED_WIDTH
	 ||
	 row != SCHEDULED_HEIGHT )
    {
        warning_debug ( _("gsb_form_scheduler_create is called with a bad table,\n"
                          "the number of rows or columns is not good.\n"
                          "The function will resize the table to the correct values but "
                          "should check that warning."));
        gtk_table_resize ( GTK_TABLE (table), SCHEDULED_HEIGHT, SCHEDULED_WIDTH );
    }

    /* ok, now fill the form 
     * we play with height and width, but for now it's fix : 6 columns and 1 line */
    for ( row=0 ; row < SCHEDULED_HEIGHT ; row++ )
	for ( column=0 ; column < SCHEDULED_WIDTH ; column++ )
	{
	    gint element_number;
	    GtkWidget *widget = NULL;
	    const gchar *tooltip_text = NULL;
	    gchar *text_auto [] = { _("Manual"), _("Automatic"), NULL };
	    gchar *text_frequency [] = { _("Once"), _("Weekly"), _("Monthly"), _("Bimonthly"),
                        _("Quarterly"), _("Yearly"), _("Custom"), NULL };
	    gchar *text_frequency_user [] = { _("Days"), _("Weeks"), _("Months"), _("Years"), NULL };

	    element_number = row*SCHEDULED_WIDTH + column;

	    switch ( element_number )
	    {
		case SCHEDULED_FORM_ACCOUNT:
		    widget = gsb_account_create_combo_list ( G_CALLBACK ( gsb_form_scheduler_change_account ),
                        NULL, FALSE);
		    gtk_combo_box_set_active ( GTK_COMBO_BOX (widget), 0 );
		    tooltip_text = _("Choose the account");
		    break;

		case SCHEDULED_FORM_AUTO:
		    widget = gsb_combo_box_new_with_index ( text_auto, NULL, NULL );
		    tooltip_text = _("Automatic/manual scheduled transaction");
		    break;

		case SCHEDULED_FORM_FREQUENCY_BUTTON:
		    widget = gsb_combo_box_new_with_index ( text_frequency,
                        G_CALLBACK (gsb_form_scheduler_frequency_button_changed), NULL );
		    tooltip_text = _("Frequency");
		    break;

        case SCHEDULED_FORM_LIMIT_DATE:
            widget = gsb_calendar_entry_new (FALSE);
            g_signal_connect ( G_OBJECT (widget),
                        "button-press-event",
                        G_CALLBACK (gsb_form_scheduler_button_press_event),
                        GINT_TO_POINTER (element_number));
            g_signal_connect ( G_OBJECT (widget),
                        "focus-in-event",
                        G_CALLBACK (gsb_form_entry_get_focus),
                        GINT_TO_POINTER (element_number));
            g_signal_connect_after ( G_OBJECT (widget),
                        "focus-out-event",
                        G_CALLBACK (gsb_form_scheduler_entry_lose_focus),
                        GINT_TO_POINTER (element_number));
            tooltip_text = _("Limit date");
            break;

		case SCHEDULED_FORM_FREQUENCY_USER_ENTRY:
		    widget = gtk_entry_new ();
            g_signal_connect ( G_OBJECT (widget),
                        "focus-in-event",
                        G_CALLBACK (gsb_form_entry_get_focus),
                        GINT_TO_POINTER (element_number));
            g_signal_connect_after ( G_OBJECT (widget),
                        "focus-out-event",
                        G_CALLBACK (gsb_form_scheduler_entry_lose_focus),
                        GINT_TO_POINTER (element_number));
		    tooltip_text = _("Own frequency");
		    break;

		case SCHEDULED_FORM_FREQUENCY_USER_BUTTON:
		    widget = gsb_combo_box_new_with_index ( text_frequency_user,
							    NULL, NULL );
		    tooltip_text = _("Custom frequency");
		    break;
	    }

	    if (!widget)
            continue;

	    if (tooltip_text)
            gtk_widget_set_tooltip_text ( GTK_WIDGET (widget),
                        tooltip_text);

	    /* save the element */
	    element = g_malloc0 (sizeof (struct_element));
	    element -> element_number = element_number;
	    element -> element_widget = widget;
	    scheduled_element_list = g_slist_append ( scheduled_element_list,
                        element );

	    /* set in the form */
	    gtk_table_attach ( GTK_TABLE (table),
                        widget,
                        column, column+1,
                        row, row+1,
                        GTK_EXPAND | GTK_FILL,
                        GTK_EXPAND | GTK_FILL,
                        0, 0);
	}
    gsb_form_scheduler_clean ( );
    return FALSE;
}
Esempio n. 2
0
/**
 * initialisation of all the variables of grisbi
 * if some are not empty, free them before set it to NULL
 *
 * \param
 *
 * \return
 * */
void init_variables ( void )
{
    gint bet_array_col_width_init[BET_ARRAY_COLUMNS] = {15, 40, 15, 15, 15 };
    gint transaction_col_align_init[CUSTOM_MODEL_VISIBLE_COLUMNS] = { 1, 1, 0, 1, 2, 2, 2 };
    gint i;

/* xxx on devrait séparer ça en 2 : les variables liées au fichier de compte, qui doivent être remises  à 0,
 * et les variables liées à grisbi (ex sauvegarde auto...) qui doivent rester */
    devel_debug (NULL);

    /* init the new crypted file */
    run.new_crypted_file = FALSE;

    /* init the format date */
    initialise_format_date ( );

    /* init the decimal point and the thousands separator. */
    initialise_number_separators ( );

    /* initialise l'ordre des pages du panneau de gauche */
    gsb_gui_navigation_init_pages_list ( );

    /* if ever there is still something from the previous list,
     * erase now */
    transaction_model_initialize();

    gsb_data_account_init_variables ();
    gsb_data_transaction_init_variables ();
    gsb_data_payee_init_variables ();
    payees_init_variables_list ();
    gsb_data_category_init_variables ();
    categories_init_variables_list ();
    gsb_data_budget_init_variables ();
    budgetary_lines_init_variables_list ();
    gsb_data_report_init_variables ();
    gsb_data_report_amount_comparison_init_variables ();
    gsb_data_report_text_comparison_init_variables ();
    gsb_data_scheduled_init_variables ();
    gsb_scheduler_list_init_variables ();
    gsb_data_currency_init_variables ();
    gsb_data_currency_link_init_variables ();
    gsb_data_fyear_init_variables ();
    gsb_data_bank_init_variables ();
    gsb_data_reconcile_init_variables ();
    gsb_data_payment_init_variables ();
    gsb_data_archive_init_variables ();
    gsb_data_archive_store_init_variables ();
    gsb_data_import_rule_init_variables ();
    gsb_import_associations_init_variables ( );
    gsb_data_partial_balance_init_variables ( );

    gsb_currency_init_variables ();
    gsb_fyear_init_variables ();
    gsb_report_init_variables ();
    gsb_regex_init_variables ();

    gsb_data_print_config_init ();

    /* no bank in memory for now */
    bank_list_model = NULL;

    run.mise_a_jour_liste_comptes_accueil = FALSE;
    run.mise_a_jour_liste_echeances_manuelles_accueil = FALSE;
    run.mise_a_jour_liste_echeances_auto_accueil = FALSE;
    run.mise_a_jour_soldes_minimaux = FALSE;
    run.mise_a_jour_fin_comptes_passifs = FALSE;

    orphan_child_transactions = NULL;

    /* the main notebook is set to NULL,
     * important because it's the checked variable in a new file
     * to know if the widgets are created or not */
    gsb_gui_init_general_notebook ( );

    if ( nom_fichier_comptes )
        g_free ( nom_fichier_comptes );
    nom_fichier_comptes = NULL;

    affichage_echeances = SCHEDULER_PERIODICITY_ONCE_VIEW;
    affichage_echeances_perso_nb_libre = 0;
    affichage_echeances_perso_j_m_a = PERIODICITY_DAYS;

    /* initialization of titles and logo part */
    if ( titre_fichier && strlen ( titre_fichier ) )
        g_free ( titre_fichier );
    titre_fichier = g_strdup( _("My accounts") );

    etat.is_pixmaps_dir = TRUE;
    if ( etat.name_logo && strlen ( etat.name_logo ) )
        g_free ( etat.name_logo );
    etat.name_logo = NULL;
    etat.utilise_logo = 1;
    gsb_select_icon_init_logo_variables ();

    etat.retient_affichage_par_compte = 0;

    /* reconcile (etat) */
    run.reconcile_account_number = -1;
    g_free ( run.reconcile_final_balance );
    if ( run.reconcile_new_date )
        g_date_free ( run.reconcile_new_date );
    run.reconcile_final_balance = NULL;
    run.reconcile_new_date = NULL;

    adresse_commune = NULL;
    adresse_secondaire = NULL;

    current_tree_view_width = 0;
    scheduler_current_tree_view_width = 0;

    initialise_tab_affichage_ope();

    valeur_echelle_recherche_date_import = 2;
    etat.get_fyear_by_value_date = FALSE;

    /* init default combofix values */
    etat.combofix_mixed_sort = FALSE;
    etat.combofix_max_item = 0;
    etat.combofix_case_sensitive = FALSE;
    etat.combofix_enter_select_completion = FALSE;
    etat.combofix_force_payee = FALSE;
    etat.combofix_force_category = FALSE;

    /* mis à NULL prévient un plantage aléatoire dans
     * gsb_currency_update_combobox_currency_list */
    detail_devise_compte = NULL;

    /* defaut value for width and align of columns */
    initialise_largeur_colonnes_tab_affichage_ope ( GSB_ACCOUNT_PAGE, transaction_col_width_init );
    initialise_largeur_colonnes_tab_affichage_ope ( GSB_SCHEDULER_PAGE, scheduler_col_width_init );
    for ( i = 0 ; i < CUSTOM_MODEL_VISIBLE_COLUMNS ; i++ )
        transaction_col_align[i] = transaction_col_align_init[i];

    if ( etat.transaction_column_width && strlen ( etat.transaction_column_width ) )
    {
        g_free ( etat.transaction_column_width );
        etat.transaction_column_width = NULL;
    }
    if ( etat.scheduler_column_width && strlen ( etat.scheduler_column_width ) )
    {
        g_free ( etat.scheduler_column_width );
        etat.scheduler_column_width = NULL;
    }

    gsb_gui_navigation_init_tree_view ( );

    /* free the form */
    gsb_form_widget_free_list ();
    gsb_form_scheduler_free_list ();

    /* set colors to default */
    gsb_color_set_colors_to_default ( );

    /* divers */
    etat.add_archive_in_total_balance = TRUE;   /* add the archived transactions by default */
    etat.get_fyear_by_value_date = 0;           /* By default use transaction-date */

    /* remove the timeout if necessary */
    if (id_timeout)
    {
    g_source_remove (id_timeout);
    id_timeout = 0;
    }

    /* initializes the variables for the estimate balance module */
    /* création de la liste des données à utiliser dans le tableau de résultats */
    bet_data_init_variables ( );
    /* initialisation des boites de dialogue */
    bet_future_initialise_dialog ( );
    etat.bet_deb_period = 1;
    /* defaut value for width of columns */
    for ( i = 0 ; i < BET_ARRAY_COLUMNS ; i++ )
        bet_array_col_width[i] = bet_array_col_width_init[i];

    bet_data_finance_data_simulator_init ( );

    bet_graph_set_configuration_variables ( NULL );

}
Esempio n. 3
0
/**
 * initialisation of all the variables of grisbi
 * if some are not empty, free them before set it to NULL
 *
 * \param
 *
 * \return
 * */
void init_variables ( void )
{
    gint transaction_col_align_init[CUSTOM_MODEL_VISIBLE_COLUMNS] = { 1, 1, 0, 1, 2, 2, 2 };
    gint i;
	GrisbiWinRun *w_run;

    devel_debug (NULL);

	/* raz some variables of structure w_run */
	w_run = grisbi_win_get_w_run ();
	w_run->account_number_is_0 = FALSE;
	w_run->prefs_expand_tree = TRUE;
	if (w_run->prefs_selected_row)
		g_free (w_run->prefs_selected_row);
	w_run->prefs_selected_row = g_strdup ("0:0");

	/* initialise l'ordre des pages du panneau de gauche */
    gsb_gui_navigation_init_pages_list ( );

    /* if ever there is still something from the previous list,
     * erase now */
    transaction_model_set_model ( NULL );

    gsb_data_account_init_variables ();
    gsb_data_transaction_init_variables ();
    gsb_data_payee_init_variables ();
    payees_init_variables_list ();
    gsb_data_category_init_variables ();
    categories_init_variables_list ();
    gsb_data_budget_init_variables ();
    budgetary_lines_init_variables_list ();
    gsb_data_report_init_variables ();
    gsb_data_report_amount_comparison_init_variables ();
    gsb_data_report_text_comparison_init_variables ();
    gsb_data_scheduled_init_variables ();
    gsb_scheduler_list_init_variables ();
    gsb_data_currency_init_variables ();
    gsb_data_currency_link_init_variables ();
    gsb_data_fyear_init_variables ();
    gsb_data_bank_init_variables ();
    gsb_data_reconcile_init_variables ();
    gsb_data_payment_init_variables ();
    gsb_data_archive_init_variables ();
    gsb_data_archive_store_init_variables ();
    gsb_data_import_rule_init_variables ();
    gsb_import_associations_init_variables ( );
    gsb_data_partial_balance_init_variables ( );

    gsb_currency_init_variables ();
    gsb_fyear_init_variables ();
    gsb_report_init_variables ();
    gsb_regex_init_variables ();

    gsb_data_print_config_init ();

    /* no bank in memory for now */
    bank_list_model = NULL;

    run.mise_a_jour_liste_comptes_accueil = FALSE;
    run.mise_a_jour_liste_echeances_manuelles_accueil = FALSE;
    run.mise_a_jour_liste_echeances_auto_accueil = FALSE;
    run.mise_a_jour_soldes_minimaux = FALSE;
    run.mise_a_jour_fin_comptes_passifs = FALSE;

    orphan_child_transactions = NULL;

    etat.affichage_echeances = SCHEDULER_PERIODICITY_ONCE_VIEW;
    etat.affichage_echeances_perso_nb_libre = 0;
    etat.affichage_echeances_perso_j_m_a = PERIODICITY_DAYS;

    if ( etat.name_logo && strlen ( etat.name_logo ) )
        g_free ( etat.name_logo );
    etat.name_logo = NULL;
    etat.utilise_logo = 1;
    gsb_select_icon_init_logo_variables ();

    etat.retient_affichage_par_compte = 0;

    /* reconcile (etat) */
    run.reconcile_account_number = -1;
    g_free ( run.reconcile_final_balance );
    if ( run.reconcile_new_date )
        g_date_free ( run.reconcile_new_date );
    run.reconcile_final_balance = NULL;
    run.reconcile_new_date = NULL;

    current_tree_view_width = 0;
    scheduler_current_tree_view_width = 0;

    initialise_tab_affichage_ope();

    etat.import_files_nb_days = 2;
    etat.get_fyear_by_value_date = FALSE;

    /* init default combofix values */
    etat.combofix_mixed_sort = FALSE;
    etat.combofix_case_sensitive = FALSE;
    etat.combofix_force_payee = FALSE;
    etat.combofix_force_category = FALSE;

    /* mis à NULL prévient un plantage aléatoire dans
     * gsb_currency_update_combobox_currency_list */
    detail_devise_compte = NULL;

    /* the main notebook is set to NULL,
     * important because it's the checked variable in a new file
     * to know if the widgets are created or not */
    grisbi_win_free_general_notebook ();

    /* defaut value for width and align of columns */
    initialise_largeur_colonnes_tab_affichage_ope ( GSB_ACCOUNT_PAGE, transaction_col_width_init );
    initialise_largeur_colonnes_tab_affichage_ope ( GSB_SCHEDULER_PAGE, scheduler_col_width_init );
    for ( i = 0 ; i < CUSTOM_MODEL_VISIBLE_COLUMNS ; i++ )
        transaction_col_align[i] = transaction_col_align_init[i];

    if ( etat.transaction_column_width && strlen ( etat.transaction_column_width ) )
    {
        g_free ( etat.transaction_column_width );
        etat.transaction_column_width = NULL;
    }
    if ( etat.scheduler_column_width && strlen ( etat.scheduler_column_width ) )
    {
        g_free ( etat.scheduler_column_width );
        etat.scheduler_column_width = NULL;
    }

    gsb_gui_navigation_init_tree_view ( );

    /* free the form */
    gsb_form_widget_free_list ();
    gsb_form_scheduler_free_list ();

    /* set colors to default */
    gsb_rgba_set_colors_to_default ();

    /* divers */
    etat.get_fyear_by_value_date = 0;           /* By default use transaction-date */

    /* remove the timeout if necessary */
    if (id_timeout)
    {
    g_source_remove (id_timeout);
    id_timeout = 0;
    }

    /* initializes the variables for the estimate balance module */
    /* création de la liste des données à utiliser dans le tableau de résultats */
    bet_data_init_variables ( );
    /* initialisation des boites de dialogue */
    bet_future_initialise_dialog ( );
    etat.bet_deb_period = 1;
    /* defaut value for width of columns */
    for ( i = 0 ; i < BET_ARRAY_COLUMNS ; i++ )
        bet_array_col_width[i] = bet_array_col_width_init[i];

    bet_data_finance_data_simulator_init ( );
	bet_data_loan_delete_all_loans ();

#ifdef HAVE_GOFFICE
    bet_graph_set_configuration_variables ( NULL );
#endif /* HAVE_GOFFICE */

}