Am Dienstag, 29. Mai 2007 18:57 schrieb Josh Sled: > "Benjamin Sperisen" <[EMAIL PROTECTED]> writes: > > Now that I have code that can load CSV files, I think I can move to > > the next phase: loading the files into GnuCash. I've been looking > > through the code trying to figure out how to write an importer plugin, > > but I'm a bit lost. Is there some documentation you could point me to > > that explains how to write a plugin? All I really need is code that > > adds a menu item for the importer and calls an event handler that I > > can write; then I'll have the "glue" between the code I've got and the > > rest of GnuCash. > > I suggest looking at: > > - src/gnome/gnc-plugin-basic-commands.c, which is similar, being the core > "plugin" for the basic commands/menu items. > > - src/import-export/ofx/gnc-plugin-ofx.c, which is even more similar, as > it's basically the same thing. :)
I suggest even stronger to look at import-export/ofx, as this is pretty much exactly that kind of framework you need: - gncmod-ofx-import.c defines a loadable module. For a csv module, replace all "ofx" by "csv" and there you are. - gnc-plugin-ofx.c defines the gnc-plugin methods and registers this plugin with the gnc_plugin_manager by calling gnc_plugin_manager_add_plugin(); the actual *location* of a menu entry is defined in gnc-plugin-ofx-ui.xml which is loaded at run-time. The mapping of the "OfxImportAction" of the ui.xml file to an actual C callback is done in the gnc_plugin_actions struct in gnc-plugin-ofx.c. - The callback function that is run on clicking a menu item is gnc_plugin_ofx_cmd_import() in gnc-plugin-ofx.c which calls the actual import function. For menu item callbacks that also lookup the account window that was opened, see import-export/hbci/gnc-plugin-hbci.c, although this is considerably more involved. Also, I think you don't need to create a gncmod module (the first point above) but instead you could probably add the CSV importer directly into the src/import-export/ directory and call the registration code from libgncmod_generic_import_gnc_module_init() in gncmod-generic-import.c. But if you prefer a separate CSV module, feel free to take the OFX module as a template which will fit quite well. Regards, Christian _______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel