GNOME Bugzilla – Bug 497159
add gimp-vectors-export-to-{file,string} () to PDB
Last modified: 2007-11-18 22:39:56 UTC
At the GIMP GUI both Export/Import paths to SVG exist, but at the plug-in development API, only the Import one is available: gimp_vectors_import_from_{file,string} () It would be really usefull to be able to use an Export one (both file and string ways): gimp_vectors_export_to_{file,string} () Having such a powerfull "import from SVG" function but not the export one makes the first one less useful. Suggestion: Calling parameters could be the same as in the import functions, the only difference would be that "num_vectors" and "vectors_ids" will be input instead of output parameters. This way, you could controll precisely which vectors you want to export. thanks in advance ----------------- Lionel Tarazón PRHLT, UPV, Spain
Note that the related functions in the core are gboolean gimp_vectors_export_file (const GimpImage *image, const GimpVectors *vectors, const gchar *filename, GError **error); and gchar* gimp_vectors_export_string (const GimpImage *image, const GimpVectors *vectors); I see two questions about how to add these to the pdb: (1) should _to_ be inserted into the function names? (2) The file version in the core takes a GError argument. The pdb doesn't provide a GError argument type, but it might be very useful to give the user access to this error information. That would require either adding a new argument type, or using existing argument types to return the domain, code, and/or message components of the GError separately.
Yes, it should be gimp-vectors-export-to-file and gimp-vectors-export-to-string to match the gimp-vectors-import functions. Error reporting from PDB functions is a different aspect and handled in bug #344818.
Created attachment 99223 [details] [review] diff against trunk for tools/pdbgen/pdb/vectors.pdb Here is an implementation. I have tested it by writing a simple plug-in that saves the active path -- I was able to import the result into GIMP and open it using Inkscape. A couple of notes: (1) The code deals with file-writing errors by generating a message within the GIMP app and returning "failure". (2) The core functionality supports exporting the full list of paths in an image, but passing NULL as the "vectors" argument. The natural way to access that from the pdb would be by passing 0 as the vectors id, but that doesn't work due to argument checking. Therefore, this functionality is not supported by the attached code: changes would have to be made in the core to make it possible.
It is possible, check for use cases of "no_validate => 1" to see how to disable validation for single parameters.
Created attachment 99258 [details] [review] diff against trunk for tools/pdbgen/pdb/vectors.pdb Thanks, Mitch. Here is a revised version, which now does allow 0 as the vectors argument, and saves all paths in the image when it is given. It worked when I tested it -- I should note, though, that I haven't traced through the pdb code to make certain that a 0 argument will always be converted to a NULL object. If for some reason that doesn't happen, the code will fail. If something goes wrong, the code attempts to generate a meaningful error message in the gimp app.
Please commit this. The way your code deals with errors is somewhat unusual but we will want to clean up error handling in the PDB anyway.
Now committed. (Re error handling, I thought that because of the file-writing action, there could be errors almost impossible for the code-writer to anticipate, so it was essential to have *some* meaningful error report.) 2007-11-18 Bill Skaggs <weskaggs@primate.ucdavis.edu> * tools/pdbgen/pdb/vectors.pdb: add code for vectors-export-to-file and vectors-export-to-string, as requested in bug #497159. * app/pdb/vectors_cmds.c * app/pdb/internal_procs.c * libgimp/gimpvectors_pdb.c * libgimp/gimpvectors_pdb.h: rebuilt accordingly. Resolving as FIXED. Can be re-opened if there are problems.
I have started working on the error reporting revamp. A preliminary patch is at http://sven.gimp.org/misc/pdb-error.diff.