Example #1
0
/* Create/Destroy Functions */
GncCustomer *gncCustomerCreate (QofBook *book)
{
    GncCustomer *cust;

    if (!book) return NULL;

    cust = g_object_new (GNC_TYPE_CUSTOMER, NULL);
    qof_instance_init_data (&cust->inst, _GNC_MOD_NAME, book);

    cust->id = CACHE_INSERT ("");
    cust->name = CACHE_INSERT ("");
    cust->notes = CACHE_INSERT ("");
    cust->addr = gncAddressCreate (book, &cust->inst);
    cust->taxincluded = GNC_TAXINCLUDED_USEGLOBAL;
    cust->active = TRUE;
    cust->jobs = NULL;

    cust->discount = gnc_numeric_zero();
    cust->credit = gnc_numeric_zero();
    cust->shipaddr = gncAddressCreate (book, &cust->inst);

    if (gs_address_event_handler_id == 0)
    {
        gs_address_event_handler_id = qof_event_register_handler(listen_for_address_events, NULL);
    }

    qof_event_gen (&cust->inst, QOF_EVENT_CREATE, NULL);

    return cust;
}
GtkTreeModel *
gnc_tree_model_commodity_new (QofBook *book, gnc_commodity_table *ct)
{
    GncTreeModelCommodity *model;
    GncTreeModelCommodityPrivate *priv;
    const GList *item;

    ENTER("");

    item = gnc_gobject_tracking_get_list(GNC_TREE_MODEL_COMMODITY_NAME);
    for ( ; item; item = g_list_next(item))
    {
        model = (GncTreeModelCommodity *)item->data;
        priv = GNC_TREE_MODEL_COMMODITY_GET_PRIVATE(model);
        if (priv->commodity_table == ct)
        {
            g_object_ref(G_OBJECT(model));
            LEAVE("returning existing model %p", model);
            return GTK_TREE_MODEL(model);
        }
    }

    model = g_object_new (GNC_TYPE_TREE_MODEL_COMMODITY, NULL);
    priv = GNC_TREE_MODEL_COMMODITY_GET_PRIVATE(model);
    priv->book = book;
    priv->commodity_table = ct;

    priv->event_handler_id =
        qof_event_register_handler (gnc_tree_model_commodity_event_handler, model);

    LEAVE("");
    return GTK_TREE_MODEL (model);
}
static AddressQF* build_shared_quickfill (QofBook *book, const char * key)
{
    AddressQF *result;
    QofQuery *query = new_query_for_addresss(book);
    GList *entries = qof_query_run(query);

    /*     g_warning("Found %d GncAddress items", g_list_length (entries)); */

    result = g_new0(AddressQF, 1);

    result->qf_addr2 = gnc_quickfill_new();
    result->qf_addr3 = gnc_quickfill_new();
    result->qf_addr4 = gnc_quickfill_new();
    result->qf_sort = QUICKFILL_ALPHA;
    result->book = book;

    g_list_foreach (entries, address_cb, result);

    qof_query_destroy(query);

    result->listener =
        qof_event_register_handler (listen_for_gncaddress_events,
                                    result);

    qof_book_set_data_fin (book, key, result, shared_quickfill_destroy);

    return result;
}
Example #4
0
/* Create/Destroy Functions */
GncEmployee *gncEmployeeCreate (QofBook *book)
{
    GncEmployee *employee;

    if (!book) return NULL;

    employee = g_object_new (GNC_TYPE_EMPLOYEE, NULL);
    qof_instance_init_data (&employee->inst, _GNC_MOD_NAME, book);

    employee->id = CACHE_INSERT ("");
    employee->username = CACHE_INSERT ("");
    employee->language = CACHE_INSERT ("");
    employee->acl = CACHE_INSERT ("");
    employee->addr = gncAddressCreate (book, &employee->inst);
    employee->workday = gnc_numeric_zero();
    employee->rate = gnc_numeric_zero();
    employee->active = TRUE;

    if (gs_address_event_handler_id == 0)
    {
        gs_address_event_handler_id = qof_event_register_handler(listen_for_address_events, NULL);
    }

    qof_event_gen (&employee->inst, QOF_EVENT_CREATE, NULL);

    return employee;
}
static EntryQF* build_shared_quickfill (QofBook *book, const char * key, gboolean use_invoices)
{
    EntryQF *result;
//    GList *entries = qof_query_run(query);
    // TODO: list GncEntry sorted by DATE_ENTERED, increasing, 
    //  and returning one single item??

    /*     g_warning("Found %d GncEntry items", g_list_length (entries)); */

    result = g_new0(EntryQF, 1);

    result->using_invoices = use_invoices;
    result->qf = gnc_quickfill_new();
    result->qf_sort = QUICKFILL_LIFO;
    result->book = book;

//    g_list_foreach (entries, entry_cb, result);
//
//    qof_query_destroy(query);

    result->listener =
        qof_event_register_handler (listen_for_gncentry_events,
                                    result);

    qof_book_set_data_fin (book, key, result, shared_quickfill_destroy);

    return result;
}
Example #6
0
GtkTreeModel *
gnc_tree_model_owner_new (GncOwnerType owner_type)
{
    GncTreeModelOwner *model;
    GncTreeModelOwnerPrivate *priv;
    const GList *item;

    ENTER("owner_type %d", owner_type);
    item = gnc_gobject_tracking_get_list(GNC_TREE_MODEL_OWNER_NAME);
    for ( ; item; item = g_list_next(item))
    {
        model = (GncTreeModelOwner *)item->data;
        priv = GNC_TREE_MODEL_OWNER_GET_PRIVATE(model);
        if (priv->owner_type == owner_type)
        {
            g_object_ref(G_OBJECT(model));
            LEAVE("returning existing model %p", model);
            return GTK_TREE_MODEL(model);
        }
    }

    model = g_object_new (GNC_TYPE_TREE_MODEL_OWNER,
                          NULL);

    priv = GNC_TREE_MODEL_OWNER_GET_PRIVATE(model);
    priv->book = gnc_get_current_book();
    priv->owner_type = owner_type;
    priv->owner_list = gncBusinessGetOwnerList (priv->book, gncOwnerTypeToQofIdType(owner_type), TRUE);

    priv->event_handler_id = qof_event_register_handler
                             ((QofEventHandler)gnc_tree_model_owner_event_handler, model);

    LEAVE("model %p", model);
    return GTK_TREE_MODEL (model);
}
static void
gnc_sx_instance_model_init(GTypeInstance *instance, gpointer klass)
{
    GncSxInstanceModel *inst = (GncSxInstanceModel*)instance;

    g_date_clear(&inst->range_end, 1);
    inst->sx_instance_list = NULL;
    inst->qof_event_handler_id = qof_event_register_handler(_gnc_sx_instance_event_handler, inst);
}
TestSignal
test_signal_new (QofInstance *entity, QofEventId event_type,
                 gpointer event_data)
{
    _TestSignal *sig = g_slice_new (_TestSignal);
    sig->entity = entity;
    sig->event_type = event_type;
    sig->event_data = event_data;
    sig->hits = 0;
    sig->hdlr = qof_event_register_handler (mock_signal_handler, (gpointer)sig);
    return (TestSignal)sig;
}
Example #9
0
void
gnc_component_manager_init (void)
{
    if (changes.entity_events)
    {
        PERR ("component manager already initialized");
        return;
    }

    changes.event_masks = g_hash_table_new (g_str_hash, g_str_equal);
    changes.entity_events = guid_hash_table_new ();

    changes_backup.event_masks = g_hash_table_new (g_str_hash, g_str_equal);
    changes_backup.entity_events = guid_hash_table_new ();

    handler_id = qof_event_register_handler (gnc_cm_event_handler, NULL);
}