Пример #1
0
/**
 * gnc_general_search_set_selected:
 * @gsl: the general selection widget
 * @selection: the selection to point to
 *
 * Sets the selection value of the widget to a particular pointer.
 *
 * Returns nothing.
 */
void
gnc_general_search_set_selected (GNCGeneralSearch *gsl, gpointer selection)
{
    GNCGeneralSearchPrivate *priv;

    g_return_if_fail(gsl != NULL);
    g_return_if_fail(GNC_IS_GENERAL_SEARCH(gsl));

    priv = _PRIVATE(gsl);
    if (selection != gsl->selected_item)
    {
        gsl->selected_item = selection;
        g_signal_emit(gsl,
                      general_search_signals[SELECTION_CHANGED], 0);
    }
    reset_selection_text (gsl);

    gnc_gui_component_clear_watches (priv->component_id);

    if (selection)
    {
        const QofParam *get_guid = priv->get_guid;
        priv->guid = * ((GncGUID *)(get_guid->param_getfcn
                                    (gsl->selected_item, get_guid)));
        gnc_gui_component_watch_entity
        (priv->component_id, &(priv->guid),
         QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
    }
    else
        priv->guid = *guid_null ();
}
Пример #2
0
static void
gnc_ledger_display_set_watches (GNCLedgerDisplay *ld, GList *splits)
{
    GList *node;

    gnc_gui_component_clear_watches (ld->component_id);

    gnc_gui_component_watch_entity_type (ld->component_id,
                                         GNC_ID_ACCOUNT,
                                         QOF_EVENT_MODIFY | QOF_EVENT_DESTROY
                                         | GNC_EVENT_ITEM_CHANGED);

    for (node = splits; node; node = node->next)
    {
        Split *split = node->data;
        Transaction *trans = xaccSplitGetParent (split);

        gnc_gui_component_watch_entity (ld->component_id,
                                        xaccTransGetGUID (trans),
                                        QOF_EVENT_MODIFY);
    }
}
Пример #3
0
void
gnc_unregister_gui_component (gint component_id)
{
    ComponentInfo *ci;

    ci = find_component (component_id);
    if (!ci)
    {
        PERR ("component %d not found", component_id);
        return;
    }

#if CM_DEBUG
    fprintf (stderr, "Unregister component %d in class %s\n",
             ci->component_id,
             ci->component_class ? ci->component_class : "(null)");
#endif

    gnc_gui_component_clear_watches (component_id);

    components = g_list_remove (components, ci);

    destroy_mask_hash (ci->watch_info.event_masks);
    ci->watch_info.event_masks = NULL;

    destroy_event_hash (ci->watch_info.entity_events);
    ci->watch_info.entity_events = NULL;

    g_free (ci->component_class);
    ci->component_class = NULL;

    g_free (ci);

#if CM_DEBUG
    dump_components ();
#endif
}
static void
tax_table_window_refresh (TaxTableWindow *ttw)
{
    GList *list, *node;
    GtkTreeView *view;
    GtkListStore *store;
    GtkTreeIter iter;
    GtkTreePath *path;
    GtkTreeSelection *selection;
    GtkTreeRowReference *reference = NULL;

    g_return_if_fail (ttw);
    view = GTK_TREE_VIEW (ttw->names_view);
    store = GTK_LIST_STORE(gtk_tree_view_get_model(view));

    /* Clear the list */
    gtk_list_store_clear(store);

    gnc_gui_component_clear_watches (ttw->component_id);

    /* Add the items to the list */
    list = gncTaxTableGetTables (ttw->book);
    if (list)
        list = g_list_reverse (g_list_copy (list));

    for (node = list; node; node = node->next)
    {
        GncTaxTable *table = node->data;

        gnc_gui_component_watch_entity (ttw->component_id,
                                        gncTaxTableGetGUID (table),
                                        QOF_EVENT_MODIFY);

        gtk_list_store_prepend(store, &iter);
        gtk_list_store_set(store, &iter,
                           TAX_TABLE_COL_NAME, gncTaxTableGetName (table),
                           TAX_TABLE_COL_POINTER, table,
                           -1);
        if (table == ttw->current_table)
        {
            path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
            reference = gtk_tree_row_reference_new(GTK_TREE_MODEL(store), path);
            gtk_tree_path_free(path);
        }
    }

    if (list)
        g_list_free (list);

    gnc_gui_component_watch_entity_type (ttw->component_id,
                                         GNC_TAXTABLE_MODULE_NAME,
                                         QOF_EVENT_CREATE | QOF_EVENT_DESTROY);

    if (reference)
    {
        path = gtk_tree_row_reference_get_path(reference);
        gtk_tree_row_reference_free(reference);
        if (path)
        {
            selection = gtk_tree_view_get_selection(view);
            gtk_tree_selection_select_path(selection, path);
            gtk_tree_view_scroll_to_cell(view, path, NULL, TRUE, 0.5, 0.0);
            gtk_tree_path_free(path);
        }
    }
    ;;
    tax_table_entries_refresh (ttw);
    /* select_row() above will refresh the entries window */
}
Пример #5
0
static void
gnc_entry_ledger_set_watches (GncEntryLedger *ledger, GList *entries)
{
    GList *node;
    QofIdType type = NULL;

    gnc_gui_component_clear_watches (ledger->component_id);

    switch (ledger->type)
    {
    case GNCENTRY_ORDER_ENTRY:
    case GNCENTRY_ORDER_VIEWER:
        type = GNC_ORDER_MODULE_NAME;
        break;

    case GNCENTRY_INVOICE_ENTRY:
    case GNCENTRY_CUST_CREDIT_NOTE_ENTRY:
        /* Watch the invoice owner to see when items get added via orders */
        gnc_gui_component_watch_entity (ledger->component_id,
                                        gncOwnerGetGUID
                                        (gncInvoiceGetOwner (ledger->invoice)),
                                        QOF_EVENT_MODIFY);
    case GNCENTRY_INVOICE_VIEWER:
    case GNCENTRY_CUST_CREDIT_NOTE_VIEWER:
    case GNCENTRY_BILL_ENTRY:
    case GNCENTRY_BILL_VIEWER:
    case GNCENTRY_EXPVOUCHER_ENTRY:
    case GNCENTRY_EXPVOUCHER_VIEWER:
    case GNCENTRY_VEND_CREDIT_NOTE_ENTRY:
    case GNCENTRY_VEND_CREDIT_NOTE_VIEWER:
    case GNCENTRY_EMPL_CREDIT_NOTE_ENTRY:
    case GNCENTRY_EMPL_CREDIT_NOTE_VIEWER:
        type = GNC_INVOICE_MODULE_NAME;
        break;

    default:
        g_warning ("Invalid ledger type");
        break;
    }

    gnc_gui_component_watch_entity_type (ledger->component_id,
                                         type,
                                         QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);

    /* To make sure the xfer cell is up to date */
    gnc_gui_component_watch_entity_type (ledger->component_id,
                                         GNC_ID_ACCOUNT,
                                         QOF_EVENT_MODIFY | QOF_EVENT_DESTROY
                                         | GNC_EVENT_ITEM_CHANGED);

    /* To make sure the taxtable cell is up to date */
    gnc_gui_component_watch_entity_type (ledger->component_id,
                                         GNC_TAXTABLE_MODULE_NAME,
                                         QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);

    /* For expense vouchers, watch the employee and refresh if it's changed */
    if (ledger->type == GNCENTRY_EXPVOUCHER_ENTRY)
    {
        const GncOwner *owner = gncOwnerGetEndOwner (gncInvoiceGetOwner (ledger->invoice));
        GncEmployee *employee = gncOwnerGetEmployee (owner);

        if (employee)
            gnc_gui_component_watch_entity (ledger->component_id,
                                            gncEmployeeGetGUID (employee),
                                            QOF_EVENT_MODIFY);
    }

    for (node = entries; node; node = node->next)
    {
        GncEntry *entry = node->data;
        gnc_gui_component_watch_entity (ledger->component_id,
                                        gncEntryGetGUID (entry),
                                        QOF_EVENT_MODIFY);
    }
}
Пример #6
0
static void
gnc_query_list_fill(GNCQueryList *list)
{
    GNCQueryListPriv *priv;
    gchar *strings[list->num_columns + 1];
    GList *entries, *item;
    const GncGUID *guid;
    gint i;

    /* Clear all watches */
    priv = GNC_QUERY_LIST_GET_PRIVATE(list);
    gnc_gui_component_clear_watches (priv->component_id);

    /* Reverse the list now because 'append()' takes too long */
    entries = qof_query_run(list->query);

    for (item = entries; item; item = item->next)
    {
        GList *node;
        gint row;
        const QofParam *gup;
        QofParam *qp = NULL;

        for (i = 0, node = list->column_params; node; node = node->next)
        {
            GNCSearchParam *param = node->data;
            GSList *converters = gnc_search_param_get_converters (param);
            const char *type = gnc_search_param_get_param_type (param);
            gpointer res = item->data;

            /* if this is a boolean, ignore it now -- we'll use a checkmark later */
            if (!safe_strcmp (type, QOF_TYPE_BOOLEAN))
            {
                strings[i++] = g_strdup("");
                continue;
            }

            /* Do all the object conversions */
            for (; converters; converters = converters->next)
            {
                qp = converters->data;
                if (converters->next)
                {
                    res = (qp->param_getfcn)(res, qp);
                }
            }

            /* Now convert this to a text value for the row */
            if (!safe_strcmp(type, QOF_TYPE_DEBCRED) ||
                    !safe_strcmp(type, QOF_TYPE_NUMERIC))
            {
                gnc_numeric (*nfcn)(gpointer, QofParam *) =
                    (gnc_numeric(*)(gpointer, QofParam *))(qp->param_getfcn);
                gnc_numeric value = nfcn(res, qp);
                if (list->numeric_abs)
                    value = gnc_numeric_abs (value);
                strings[i++] = g_strdup(xaccPrintAmount(value, gnc_default_print_info(FALSE)));
            }
            else
                strings[i++] = qof_query_core_to_string (type, res, qp);
        }

        row = gtk_clist_append (GTK_CLIST(list), (gchar **) strings);
        gtk_clist_set_row_data (GTK_CLIST(list), row, item->data);

        /* Free up our strings */
        for (i = 0; i < list->num_columns; i++)
        {
            if (strings[i])
                g_free (strings[i]);
        }

        /* Now update any checkmarks */
        update_booleans (list, row);

        /* and set a watcher on this item */
        gup = priv->get_guid;
        guid = (const GncGUID*)((gup->param_getfcn)(item->data, gup));
        gnc_gui_component_watch_entity (priv->component_id, guid,
                                        QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);

        list->num_entries++;
    }
}