Exemplo n.º 1
0
static void
search_new_item_cb (GtkButton *button, GNCSearchWindow *sw)
{
    gpointer res;

    g_return_if_fail (sw->new_item_cb);

    res = (sw->new_item_cb)(sw->user_data);

    if (res)
    {
        const GncGUID *guid = (const GncGUID *) ((sw->get_guid->param_getfcn)(res, sw->get_guid));
        QofQueryOp op = QOF_QUERY_OR;

        if (!sw->q)
        {
            if (!sw->start_q)
            {
                sw->start_q = qof_query_create_for (sw->search_for);
                qof_query_set_book (sw->start_q, gnc_get_current_book ());
            }
            sw->q = qof_query_copy (sw->start_q);
            op = QOF_QUERY_AND;
        }

        qof_query_add_guid_match (sw->q, g_slist_prepend (NULL, QOF_PARAM_GUID),
                                  guid, op);

        /* Watch this entity so we'll refresh once it's actually changed */
        gnc_gui_component_watch_entity (sw->component_id, guid, QOF_EVENT_MODIFY);
    }
}
Exemplo n.º 2
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 ();
}
Exemplo n.º 3
0
DialogQueryList *
gnc_dialog_query_list_new (GList *param_list, Query *q)
{
    GladeXML *xml;
    DialogQueryList *dql;
    GtkWidget *scroller, *close;
    GList *node;

    dql = g_new0 (DialogQueryList, 1);
    xml = gnc_glade_xml_new ("dialog-query-list.glade", "Query List Dialog");

    /* Grab the dialog, save the dialog info */
    dql->dialog = glade_xml_get_widget (xml, "Query List Dialog");
    g_object_set_data (G_OBJECT (dql->dialog), "dialog-info", dql);

    /* grab the widgets */
    dql->label = glade_xml_get_widget (xml, "dialog_label");
    dql->button_box = glade_xml_get_widget (xml, "button_vbox");
    scroller = glade_xml_get_widget (xml, "result_scroller");
    close = glade_xml_get_widget (xml, "close_button");

    /* build the query list */
    dql->qlist = gnc_query_list_new (param_list, q);
    gtk_container_add (GTK_CONTAINER (scroller), dql->qlist);

    /* connect the double-click signal of the qlist */
    g_signal_connect (G_OBJECT (dql->qlist), "double_click_entry",
                      G_CALLBACK(gnc_dialog_query_list_double_click_entry), dql);


    /* connect to the close button */
    g_signal_connect (G_OBJECT (close), "clicked",
                      G_CALLBACK (gnc_dialog_query_list_close), dql);

    /* connect to the cleanup */
    g_signal_connect (G_OBJECT (dql->dialog), "delete_event",
                      G_CALLBACK (gnc_dialog_query_list_delete_cb), dql);


    /* register ourselves */
    dql->component_id =
        gnc_register_gui_component ("GNC Dialog Query List",
                                    gnc_dialog_query_list_refresh_handler,
                                    close_handler, dql);

    /* Build the book list */
    dql_build_booklist (dql, q);

    /* and register the books */
    for (node = dql->books; node; node = node->next)
        gnc_gui_component_watch_entity (dql->component_id, (GncGUID*)node->data,
                                        QOF_EVENT_DESTROY);

    return dql;
}
Exemplo n.º 4
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);
    }
}
Exemplo n.º 5
0
DialogQueryView *
gnc_dialog_query_view_new (GList *param_list, Query *q)
{
    GtkBuilder  *builder;
    DialogQueryView *dqv;
    GtkWidget *result_hbox, *close, *scrollWin, *frame, *but_hbox;
    GList *node;

    dqv = g_new0 (DialogQueryView, 1);
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-query-view.glade", "Query View Dialog");

    /* Grab the dialog, save the dialog info */
    dqv->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Query View Dialog"));
    g_object_set_data (G_OBJECT (dqv->dialog), "dialog-info", dqv);

    /* grab the widgets */
    dqv->label = GTK_WIDGET(gtk_builder_get_object (builder, "dialog_label"));
    result_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "result_hbox"));
    close = GTK_WIDGET(gtk_builder_get_object (builder, "close_button"));

    /* build the query list */
    dqv->qview = gnc_query_view_new (param_list, q);

    frame = gtk_frame_new(NULL);

    scrollWin = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrollWin),
                                   GTK_POLICY_AUTOMATIC,
                                   GTK_POLICY_AUTOMATIC);
    gtk_container_set_border_width(GTK_CONTAINER(scrollWin), 5);

    gtk_container_add(GTK_CONTAINER(scrollWin), dqv->qview);
    gtk_container_add(GTK_CONTAINER(frame), scrollWin);

    gtk_box_pack_start (GTK_BOX (result_hbox), frame, TRUE, TRUE, 3);

    /* Create the button_box */
    dqv->button_box = gtk_vbox_new (FALSE, 2);
    gtk_box_pack_start (GTK_BOX (result_hbox), dqv->button_box, FALSE, FALSE, 3);

    /* connect the double-click signal of the qview */
    g_signal_connect (G_OBJECT (dqv->qview), "double_click_entry",
                      G_CALLBACK(gnc_dialog_query_view_double_click_entry), dqv);

    /* connect to the close button */
    g_signal_connect (G_OBJECT (close), "clicked",
                      G_CALLBACK (gnc_dialog_query_view_close), dqv);

    /* connect to the cleanup */
    g_signal_connect (G_OBJECT (dqv->dialog), "delete_event",
                      G_CALLBACK (gnc_dialog_query_view_delete_cb), dqv);

    /* register ourselves */
    dqv->component_id = gnc_register_gui_component ("GNC Dialog Query View",
                        gnc_dialog_query_view_refresh_handler,
                        close_handler, dqv);

    /* Build the book list */
    dqv_build_booklist (dqv, q);

    /* and register the books */
    for (node = dqv->books; node; node = node->next)
        gnc_gui_component_watch_entity (dqv->component_id, (GncGUID*)node->data,
                                        QOF_EVENT_DESTROY);

    g_object_unref(G_OBJECT(builder));

    return dqv;
}
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 */
}
Exemplo n.º 7
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);
    }
}
Exemplo n.º 8
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++;
    }
}