~ubuntu-branches/ubuntu/oneiric/gpe-expenses/oneiric

« back to all changes in this revision

Viewing changes to src/expenses-gtk.c

  • Committer: Bazaar Package Importer
  • Author(s): Neil Williams
  • Date: 2007-12-07 00:08:39 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20071207000839-sh6utdxr23ymhd8d
Tags: 0.1.4-1
* New upstream release
* use machine operable debian/copyright, migrate to standards 3.7.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <glib/gprintf.h>
28
28
#include <qof.h>
29
29
#include <math.h>
 
30
#include <locale.h>
30
31
 /* GTK and GPE includes */
31
32
#include <gtk/gtkmain.h>
32
33
#include <gpe/pixmaps.h>
486
487
        param = qof_class_get_parameter(GPE_QOF_EXPENSES, EXP_DATE);
487
488
        qt = (QofTime*)param->param_getfcn (ent, param);
488
489
        qd = qof_date_from_qtime (qt);
489
 
        /** \todo Use a locale-sensitive format? */
490
 
        date_string = qof_date_print (qd, QOF_DATE_FORMAT_UK);
 
490
        date_string = qof_date_print (qd, QOF_DATE_FORMAT_LOCALE);
491
491
        qof_date_free (qd);
492
492
        param = qof_class_get_parameter(GPE_QOF_EXPENSES, EXP_TYPE);
493
493
        dis_string = param->param_getfcn(ent, param);
619
619
        gchar *numeric_char;
620
620
        gdouble d_amount;
621
621
        gint precision;
 
622
        /* detect local currency */
 
623
        GpeCurrency * c;
 
624
        struct lconv lc;
 
625
        gchar * sy;
 
626
        guint def_pq_code;
622
627
 
623
628
        context = (GpeExpenseData*)data;
624
629
        g_return_if_fail(context);
625
630
        ENTER (" ");
 
631
        def_pq_code = -1;
626
632
        qe = (Expense_t*)context->entity;
627
633
        param = qof_class_get_parameter(GPE_QOF_EXPENSES, EXP_CURRENCY);
628
634
        i32_setter = (void(*)(QofEntity*, gint32))param->param_setfcn;
629
 
        /** \todo don't use 22 as a default */
630
 
        if(i32_setter != NULL) { i32_setter(context->entity, 22); }
 
635
        /* use locale currency */
 
636
        lc = *localeconv();
 
637
        DEBUG (" sym=%s", lc.currency_symbol);
 
638
        sy = g_strdup (lc.int_curr_symbol);
 
639
        sy = g_strstrip (sy);
 
640
        c = gpe_currency_lookup_name ((QofInstance*)context->entity, sy);
 
641
        if (c)
 
642
                def_pq_code = c->pq_code;
 
643
        g_free (sy);
 
644
        if(i32_setter != NULL) { i32_setter(context->entity, def_pq_code); }
631
645
        param = qof_class_get_parameter(GPE_QOF_EXPENSES, EXP_AMOUNT);
632
646
        numeric_setter = (void(*)(QofEntity*, QofNumeric))param->param_setfcn;
633
647
        d_amount = 0.00;
819
833
        QofBook      *book;
820
834
        const QofParam *param;
821
835
        void (*i32_setter)       (QofEntity*, gint32);
 
836
        /* detect local currency */
 
837
        GpeCurrency * c;
 
838
        struct lconv lc;
 
839
        gchar * sy;
 
840
        guint def_pq_code;
822
841
 
823
842
        g_return_if_fail(context);
 
843
        def_pq_code = -1;
824
844
        book = qof_session_get_book(context->qof.input_session);
825
845
        inst = (QofInstance*)qof_object_new_instance(GPE_QOF_EXPENSES, book);
826
846
        context->entity = &inst->entity;
827
 
        /** \todo implement preferred currency */
 
847
        /* use locale currency */
 
848
        lc = *localeconv();
 
849
        DEBUG (" sym=%s", lc.currency_symbol);
 
850
        sy = g_strdup (lc.int_curr_symbol);
 
851
        sy = g_strstrip (sy);
 
852
        c = gpe_currency_lookup_name (inst, sy);
 
853
        if (c)
 
854
                def_pq_code = c->pq_code;
 
855
        g_free (sy);
828
856
        param = qof_class_get_parameter (GPE_QOF_EXPENSES, EXP_CURRENCY);
829
857
        i32_setter = (void(*)(QofEntity*, gint32))param->param_setfcn;
830
858
        qof_util_param_edit ((QofInstance*)context->entity, param);
831
 
        i32_setter(context->entity, 22);
 
859
        i32_setter(context->entity, def_pq_code);
832
860
        qof_util_param_commit ((QofInstance*)context->entity, param);
833
861
        gtk_list_store_append(context->list_store, &ent_data);
834
862
        exp_refresh_list(context);