After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 497159 - add gimp-vectors-export-to-{file,string} () to PDB
add gimp-vectors-export-to-{file,string} () to PDB
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: libgimp
git master
Other All
: Normal enhancement
: 2.6
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks: 101604
 
 
Reported: 2007-11-15 19:24 UTC by Lionel Tarazon
Modified: 2007-11-18 22:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
diff against trunk for tools/pdbgen/pdb/vectors.pdb (2.68 KB, patch)
2007-11-16 19:10 UTC, weskaggs
none Details | Review
diff against trunk for tools/pdbgen/pdb/vectors.pdb (3.48 KB, patch)
2007-11-17 18:47 UTC, weskaggs
committed Details | Review

Description Lionel Tarazon 2007-11-15 19:24:07 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
Comment 1 weskaggs 2007-11-15 21:02:36 UTC
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.
Comment 2 Sven Neumann 2007-11-16 07:21:08 UTC
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.
Comment 3 weskaggs 2007-11-16 19:10:36 UTC
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.
Comment 4 Michael Natterer 2007-11-16 20:33:38 UTC
It is possible, check for use cases of "no_validate => 1" to see how
to disable validation for single parameters.
Comment 5 weskaggs 2007-11-17 18:47:57 UTC
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.
Comment 6 Sven Neumann 2007-11-18 16:58:31 UTC
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.
Comment 7 weskaggs 2007-11-18 18:58:35 UTC
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.
Comment 8 Sven Neumann 2007-11-18 22:39:56 UTC
I have started working on the error reporting revamp. A preliminary patch is at http://sven.gimp.org/misc/pdb-error.diff.