Exemplo n.º 1
0
gboolean
gncAddressEqual(const GncAddress* a, const GncAddress* b)
{
    if (a == NULL && b == NULL) return TRUE;
    if (a == NULL || b == NULL) return FALSE;

    g_return_val_if_fail(GNC_IS_ADDRESS(a), FALSE);
    g_return_val_if_fail(GNC_IS_ADDRESS(b), FALSE);

    if (g_strcmp0(a->name, b->name) != 0)
    {
        PWARN("names differ: %s vs %s", a->name, b->name);
        return FALSE;
    }
    if (g_strcmp0(a->addr1, b->addr1) != 0)
    {
        PWARN("address lines 1 differ: %s vs %s", a->addr1, b->addr1);
        return FALSE;
    }
    if (g_strcmp0(a->addr2, b->addr2) != 0)
    {
        PWARN("address lines 2 differ: %s vs %s", a->addr2, b->addr1);
        return FALSE;
    }
    if (g_strcmp0(a->addr3, b->addr3) != 0)
    {
        PWARN("address lines 3 differ: %s vs %s", a->addr3, b->addr3);
        return FALSE;
    }
    if (g_strcmp0(a->addr4, b->addr4) != 0)
    {
        PWARN("address lines 4 differ: %s vs %s", a->addr4, b->addr4);
        return FALSE;
    }
    if (g_strcmp0(a->phone, b->phone) != 0)
    {
        PWARN("phone numbers differ: %s vs %s", a->phone, b->phone);
        return FALSE;
    }
    if (g_strcmp0(a->fax, b->fax) != 0)
    {
        PWARN("fax numbers differ: %s vs %s", a->fax, b->fax);
        return FALSE;
    }
    if (g_strcmp0(a->email, b->email) != 0)
    {
        PWARN("email addresses differ: %s vs %s", a->email, b->email);
        return FALSE;
    }

    return TRUE;
}
Exemplo n.º 2
0
static void
gnc_address_set_property (GObject         *object,
                          guint            prop_id,
                          const GValue          *value,
                          GParamSpec      *pspec)
{
    GncAddress *address;

    g_return_if_fail(GNC_IS_ADDRESS(object));

    address = GNC_ADDRESS(object);
    switch (prop_id)
    {
    case PROP_NAME:
        gncAddressSetName(address, g_value_get_string(value));
        break;
    case PROP_ADDR1:
        gncAddressSetAddr1(address, g_value_get_string(value));
        break;
    case PROP_ADDR2:
        gncAddressSetAddr2(address, g_value_get_string(value));
        break;
    case PROP_ADDR3:
        gncAddressSetAddr3(address, g_value_get_string(value));
        break;
    case PROP_ADDR4:
        gncAddressSetAddr4(address, g_value_get_string(value));
        break;
    case PROP_PHONE:
        gncAddressSetPhone(address, g_value_get_string(value));
        break;
    case PROP_FAX:
        gncAddressSetFax(address, g_value_get_string(value));
        break;
    case PROP_EMAIL:
        gncAddressSetEmail(address, g_value_get_string(value));
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
        break;
    }
}
Exemplo n.º 3
0
static void
gnc_address_get_property (GObject         *object,
                          guint            prop_id,
                          GValue          *value,
                          GParamSpec      *pspec)
{
    GncAddress *address;

    g_return_if_fail(GNC_IS_ADDRESS(object));

    address = GNC_ADDRESS(object);
    switch (prop_id)
    {
    case PROP_NAME:
        g_value_set_string(value, address->name);
        break;
    case PROP_ADDR1:
        g_value_set_string(value, address->addr1);
        break;
    case PROP_ADDR2:
        g_value_set_string(value, address->addr2);
        break;
    case PROP_ADDR3:
        g_value_set_string(value, address->addr3);
        break;
    case PROP_ADDR4:
        g_value_set_string(value, address->addr4);
        break;
    case PROP_PHONE:
        g_value_set_string(value, address->phone);
        break;
    case PROP_FAX:
        g_value_set_string(value, address->fax);
        break;
    case PROP_EMAIL:
        g_value_set_string(value, address->email);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
        break;
    }
}
Exemplo n.º 4
0
/**
 * Listens for MODIFY events from addresses.   If the address belongs to an employee,
 * mark the employee as dirty.
 *
 * @param entity Entity for the event
 * @param event_type Event type
 * @param user_data User data registered with the handler
 * @param event_data Event data passed with the event.
 */
static void
listen_for_address_events(QofInstance *entity, QofEventId event_type,
                          gpointer user_data, gpointer event_data)
{
    GncEmployee* empl;

    if ((event_type & QOF_EVENT_MODIFY) == 0)
    {
        return;
    }
    if (!GNC_IS_ADDRESS(entity))
    {
        return;
    }
    if (!GNC_IS_EMPLOYEE(event_data))
    {
        return;
    }
    empl = GNC_EMPLOYEE(event_data);
    gncEmployeeBeginEdit(empl);
    mark_employee(empl);
    gncEmployeeCommitEdit(empl);
}
Exemplo n.º 5
0
static void
listen_for_gncaddress_events(QofInstance *entity,  QofEventId event_type,
                             gpointer user_data, gpointer event_data)
{
    AddressQF *qfb = user_data;
    const char *addr2, *addr3, *addr4;

    /* We only listen for GncAddress events */
    if (!GNC_IS_ADDRESS (entity))
        return;

    /* We listen for MODIFY (if the description was changed into
     * something non-empty, so we add the string to the quickfill) and
     * DESTROY (to remove the description from the quickfill). */
    if (0 == (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_DESTROY)))
        return;

    /*     g_warning("entity %p, entity type %s, event type %s, user data %p, ecent data %p", */
    /*               entity, entity->e_type, qofeventid_to_string(event_type), user_data, event_data); */

    addr2 = gncAddressGetAddr2(GNC_ADDRESS(entity));
    addr3 = gncAddressGetAddr3(GNC_ADDRESS(entity));
    addr4 = gncAddressGetAddr4(GNC_ADDRESS(entity));
    if (event_type & QOF_EVENT_MODIFY)
    {
        /* If the description was changed into something non-empty, so
         * we add the string to the quickfill */
        if (addr2 && strlen(addr2) > 0)
        {
            /* Add the new string to the quickfill */
            gnc_quickfill_insert (qfb->qf_addr2, addr2, QUICKFILL_LIFO);
        }
        if (addr3 && strlen(addr3) > 0)
        {
            /* Add the new string to the quickfill */
            gnc_quickfill_insert (qfb->qf_addr3, addr3, QUICKFILL_LIFO);
        }
        if (addr4 && strlen(addr4) > 0)
        {
            /* Add the new string to the quickfill */
            gnc_quickfill_insert (qfb->qf_addr4, addr4, QUICKFILL_LIFO);
        }
    }
    else if (event_type & QOF_EVENT_DESTROY)
    {
        if (addr2 && strlen(addr2) > 0)
        {
            /* Remove the description from the quickfill */
            gnc_quickfill_insert (qfb->qf_addr2, addr2, QUICKFILL_LIFO);
        }
        if (addr3 && strlen(addr3) > 0)
        {
            /* Remove the description from the quickfill */
            gnc_quickfill_insert (qfb->qf_addr3, addr3, QUICKFILL_LIFO);
        }
        if (addr4 && strlen(addr4) > 0)
        {
            /* Remove the description from the quickfill */
            gnc_quickfill_insert (qfb->qf_addr4, addr4, QUICKFILL_LIFO);
        }
    }
}