Exemplo n.º 1
0
/**
 * get the date in the date entry
 *
 * \param entry
 *
 * \return a newly allocated GDate or NULL if invalid date
 * */
GDate *gsb_calendar_entry_get_date ( GtkWidget *entry )
{
    GDate *date;

    if (!entry
	||
	!GTK_IS_ENTRY (entry)
	||
	!gsb_date_check_entry (entry))
	return NULL;

    date = gsb_date_get_last_entry_date (gtk_entry_get_text (GTK_ENTRY (entry)));
    return date;
}
Exemplo n.º 2
0
/**
 * called when the user click on the button 'create the new reconciliation'
 * check the entries and create the corresponding reconciliation
 *
 * \param button
 * \param label a message label, hidden at the beginning, that will say ok the reconciliation is created
 * 		or if there is a problem...
 *
 * \return FALSE
 * */
static gboolean gsb_assistant_reconcile_config_page_add_new_reconcile ( GtkWidget *button,
                        GtkWidget *label )
{
    gint reconcile_number;
    gchar *string;

    /* first, we check the date are valid */
    if ( !gsb_date_check_entry ( reconcile_init_date_entry ) )
    {
        string = make_red ( _("The initial date is not valid, please check it.") );
        gtk_label_set_markup ( GTK_LABEL ( label) , string );
        gtk_widget_grab_focus (reconcile_init_date_entry);
        g_free ( string );
        return FALSE;
    }

    if ( !gsb_date_check_entry ( reconcile_final_date_entry ) )
    {
        string = make_red ( _("The final date is not valid, please check it.") );
        gtk_label_set_markup ( GTK_LABEL ( label) , string );
        gtk_widget_grab_focus ( reconcile_final_date_entry );
        g_free ( string );
    return FALSE;
    }

    /* check there is a name */
    if ( !strlen (gtk_entry_get_text ( GTK_ENTRY ( reconcile_name_entry ) ) ) )
    {
        string = make_red ( _("Please give a name to the new reconciliation.") );
        gtk_label_set_markup ( GTK_LABEL ( label) , string );
        gtk_widget_grab_focus ( reconcile_name_entry );
        g_free ( string );
        return FALSE;
    }

    /* check if already exist the name */
    if ( gsb_data_reconcile_get_number_by_name (
     gtk_entry_get_text (GTK_ENTRY (reconcile_name_entry) ) ) )
    {
        string = make_red ( _("That name already exists, please find another one.") );
        gtk_label_set_markup ( GTK_LABEL ( label) , string );
        gtk_widget_grab_focus ( reconcile_name_entry );
        g_free ( string );
        return FALSE;
    }

    /* ok, now we can create the reconcile */
    reconcile_number = gsb_data_reconcile_new (
                        gtk_entry_get_text ( GTK_ENTRY ( reconcile_name_entry ) ) );
    if ( !reconcile_number )
    if (gsb_data_reconcile_get_number_by_name ( gtk_entry_get_text (
     GTK_ENTRY ( reconcile_name_entry ) ) ) )
    {
        string = make_red ( _("Cannot allocate memory : Bad things will happen soon.") );
        gtk_label_set_markup ( GTK_LABEL ( label) , string );
        gtk_widget_grab_focus ( reconcile_name_entry );
        g_free ( string );
        return FALSE;
    }

    gsb_data_reconcile_set_init_date ( reconcile_number,
                        gsb_calendar_entry_get_date ( reconcile_init_date_entry ) );
    gsb_data_reconcile_set_final_date ( reconcile_number,
                        gsb_calendar_entry_get_date ( reconcile_final_date_entry ) );
    gsb_data_reconcile_set_init_balance ( reconcile_number,
                        utils_real_get_from_string ( gtk_entry_get_text (
                        GTK_ENTRY (reconcile_init_balance_entry ) ) ) );
    gsb_data_reconcile_set_final_balance ( reconcile_number,
                        utils_real_get_from_string ( gtk_entry_get_text (
                        GTK_ENTRY ( reconcile_final_balance_entry ) ) ) );
    gsb_data_reconcile_set_account ( reconcile_number,
                        gsb_account_get_combo_account_number ( reconcile_account_button ) );

    /* erase the entries but not the account wich can be used again */
    gtk_entry_set_text ( GTK_ENTRY (reconcile_name_entry), "" );
    gtk_entry_set_text ( GTK_ENTRY (reconcile_init_date_entry), "" );
    gtk_entry_set_text ( GTK_ENTRY (reconcile_final_date_entry), "" );
    gtk_entry_set_text ( GTK_ENTRY (reconcile_init_balance_entry), "" );
    gtk_entry_set_text ( GTK_ENTRY (reconcile_final_balance_entry), "" );

    string = make_blue ( g_strdup_printf ( _("Reconciliation %s successfully appended!"),
                        gsb_data_reconcile_get_name ( reconcile_number ) ) );
    gtk_label_set_markup ( GTK_LABEL ( label ), string );
    g_free ( string );

    /* update the list of reconcile in the configuration list */
    gsb_reconcile_config_fill ( );

    gtk_widget_grab_focus ( reconcile_name_entry );

    return FALSE;
}