static void col_ref_cb (QofInstance* ref_ent, gpointer user_data) { QofInstanceReference *ref; QofInstanceCopyData *qecd; QofInstance *ent; const GncGUID *cm_guid; char cm_sa[GUID_ENCODING_LENGTH + 1]; gchar *cm_string; g_return_if_fail(user_data); qecd = (QofInstanceCopyData*)user_data; ent = qecd->from; g_return_if_fail(ent); ref = g_new0(QofInstanceReference, 1); ref->type = ent->e_type; ref->ref_guid = g_new(GncGUID, 1); ref->ent_guid = qof_instance_get_guid(ent); ref->param = qof_class_get_parameter(ent->e_type, qecd->param->param_name); cm_guid = qof_entity_get_guid(ref_ent); guid_to_string_buff(cm_guid, cm_sa); cm_string = g_strdup(cm_sa); if (TRUE == string_to_guid(cm_string, ref->ref_guid)) { g_free(cm_string); qof_session_update_reference_list(qecd->new_session, ref); } }
/** * gnc_general_search_new: * * Creates a new GNCGeneralSearch widget which can be used to provide * an easy way to choose selections. * * @param type The type of object that this widget will be used for. * This parameter is a QofIdTypeConst. * @param label The label for the GtkButton child widget. * @param text_editable switch to enable or disable direct text entry * @param search_cb The callback function to use when an object has been * selected in the search dialog. This dialog is created when clicking on * the GtkButton child widget. * @param user_data Generic pointer to context relevant data that can be * used by callback functions later on. At present, depending on the context * this can be a QofBook, a GncISI structure or a InvoiceWindow structure. * @param book Pointer to the QofBook for this search widget. This is used for * the autocompletion in the text entry widget. * * @return a GNCGeneralSearch widget. */ GtkWidget * gnc_general_search_new (QofIdTypeConst type, const char *label, gboolean text_editable, GNCSearchCB search_cb, gpointer user_data, QofBook *book) { GNCGeneralSearch *gsl; GNCGeneralSearchPrivate *priv; const QofParam *get_guid; g_return_val_if_fail (type && label && search_cb, NULL); get_guid = qof_class_get_parameter (type, QOF_PARAM_GUID); g_return_val_if_fail (get_guid, NULL); gsl = g_object_new (GNC_TYPE_GENERAL_SEARCH, NULL); create_children (gsl, label, text_editable, type, book); priv = _PRIVATE(gsl); priv->type = type; priv->search_cb = search_cb; priv->user_data = user_data; priv->get_guid = get_guid; priv->component_id = gnc_register_gui_component (GNCGENERALSEARCH_CLASS, refresh_handler, NULL, gsl); return GTK_WIDGET (gsl); }
/********************************************************************\ * gnc_query_list_new * * creates the query list * * * * Args: param_list - the list of params * * query - the query to use to find entries * * Returns: the query list widget, or NULL if there was a problem. * \********************************************************************/ void gnc_query_list_construct (GNCQueryList *list, GList *param_list, Query *query) { GNCQueryListPriv *priv; g_return_if_fail(list); g_return_if_fail(param_list); g_return_if_fail(query); g_return_if_fail(IS_GNC_QUERY_LIST(list)); /* more configuration */ list->query = qof_query_copy(query); list->column_params = param_list; /* cache the function to get the guid of this query type */ priv = GNC_QUERY_LIST_GET_PRIVATE(list); priv->get_guid = qof_class_get_parameter (qof_query_get_search_for(query), QOF_PARAM_GUID); /* Initialize the CList */ gnc_query_list_init_clist(list); /* Set initial sort order */ gnc_query_list_set_query_sort(list, TRUE); }
static void check_cb (QofInstance *ent, gpointer data) { QofInstance *parent, *child; QofCollection *coll; struct tally *c; const QofParam *param; mygrand *testg; myparent *testp; mychild *testc; c = (struct tally*)data; /* check the same number and type of entities exist in the copied book */ testg = (mygrand*)ent; /* we always have a grandparent */ do_test((testg != NULL), "grandparent not found"); c->total++; param = qof_class_get_parameter(GRAND_MODULE_NAME, OBJ_LIST); coll = (QofCollection*)param->param_getfcn(ent, param); c->collect = qof_collection_count(coll); if (c->book) { qof_book_set_references(c->book); } param = qof_class_get_parameter(GRAND_MODULE_NAME, OBJ_RELATIVE); parent = QOF_INSTANCE(param->param_getfcn(ent, param)); testp = grand_getChild((mygrand*)ent); /* not all grandparents have family so just keep count. */ if (!parent) { c->nulls++; return; } do_test((0 == safe_strcmp(parent_getName(testp), parent_getName((myparent*)parent))), "parent copy test"); param = qof_class_get_parameter(PARENT_MODULE_NAME, OBJ_RELATIVE); child = param->param_getfcn(parent, param); testc = parent_getChild((myparent*)parent); if (!child) { c->nulls++; return; } do_test((0 == safe_strcmp(child_getName(testc), child_getName((mychild*)child))), "child copy test"); }