How to get dialog-transfer's created transaction?

Derek Atkins warlord at MIT.EDU
Mon Jun 23 20:02:27 CDT 2003


Excellent!  A non-db question!  Thanks, Christian, we needed the
change of pace ;)

Christian Stimming <stimming at tuhh.de> writes:

> Status: Currently there is no way to get any hold of the Transaction that was 
> created in the gnc_xfer_dialog -- it is created inside the 
> gnc_xfer_dialog_ok_cb inside one particular code block, and there is no 
> pointer at all about the created Transaction anywhere else.
> 
> Question: I'd like to add a "Transaction*" field to the struct _xferDialog, 
> plus an appropriate getter function, where a pointer to that transaction is 
> stored after it got created. Any objections about introducing that data 
> field?

Unfortunately that wont help.  The dialog data is destroyed as soon as
you click "ok", so you don't have any time to actually grab it out.
You're better off creating a callback function that will pass the
transaction back to you.  Eg:

void gnc_dialog_transfer_set_txn_cb(DialogTransfer* dialog,
                void(*handler)(gpointer, Transaction*), gpointer arg)
{
        ....
        dialog->txn_cb_handler = handler;
        dialog->txn_cb_arg = arg;
        ...
}

Then after you create the transaction you can do:

        if (dialog->txn_cb_handler)
                (dialog->txn_cb_handler)(dialog->txb_cb_arg, trans);

The only question here is whether you are guaranteed that the
transaction dialog exits before you do.  If not, you'll have to reset
the handler to NULL.

Another option you have is to create a gtk signal, but that might be a
lot more work considering we don't have a widget to add it to.

> Christian

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list