Commit Graph

85 Commits

Author SHA1 Message Date
Jehan ecf4cfb3c5 app, libgimp, pdb, plug-ins: getting rid of some GimpRGB usage.
This is a first commit to really getting rid of GimpRGB within core and
PDB/plug-in code. This will make color conversion reliability a lot better as
GeglColor will handle conversions for us. The goal is that we should keep origin
color space (for instance when picking colors in a GimpPickable, or when storing
in the FG/BG colors or in paletters) until the last second and convert at use
only.
It's still very much work-in-progress.
2024-02-11 23:28:02 +01:00
Jehan d931098d36 app, libgimp, pdb: new gimp_image_get_palette().
This is meant to replace gimp_image_get_colormap() (see also #9477).

We likely won't need a gimp_image_set_palette() because we can simply edit the
image's colormap/palette with GimpPalette API now and it is directly updated.

For instance, the following code changes the first entry in the image palette to
red, immediately:

```python
i = Gimp.list_images()[0]
p = i.get_palette()
c = Gimp.RGB()
c.r = 1.0
p.entry_set_color(0, c)
```

For this to work fine, I added a new concept to GimpData, which is that they can
be tied to a GimpImage (instead of a GFile). Image palettes are not considered
internals, they are just tied to their image, therefore they can be edited by
scripts/plug-ins.

Additionally with this commit, editing an image's colormap from libgimp API also
generates undo steps now.
2023-10-06 22:04:34 +02:00
Niels De Graef 89c359ce47 Remove GimpUint8Array in favor of GBytes
GLib has a specific type for byte arrays: `GBytes` (and it's underlying
GType `G_TYPE_BYTES`).

By using this type, we can avoid having a `GimpUint8Array` which is a
bit cumbersome to use for both the C API, as well as bindings. By using
`GBytes`, we allow other languages to pass on byte arrays as they are
used to, while the bindings will make sure to do the right thing.

In the end, it makes the API a little bit simpler for everyone, and
reduces confusion for people who are used to working with byte arrays
in other C/GLib based code (and not having 2 different types to denote
the same thing).

Related: https://gitlab.gnome.org/GNOME/gimp/-/issues/5919
2023-05-23 23:37:50 +02:00
Jehan b73278f1a8 app, libgimp, pdb: add missing functions for selected items.
Missing functions were:
* gimp_image_get_selected_channels()
* gimp_image_get_selected_vectors()
* gimp_image_list_selected_channels()
* gimp_image_list_selected_vectors()
* gimp_image_set_selected_channels()
* gimp_image_set_selected_vectors()
* gimp_image_take_selected_channels()
* gimp_image_take_selected_vectors()

There are discussions of renaming GimpVectors to GimpPath, which would
also be consistent with the GUI and make the always-plural less akward
in API. We'll see. For now keeping named like this.
2022-10-20 18:25:43 +02:00
Jehan a6aba929dc app, libgimp, pdb: removing gimp_image_(g|s)et_active_*() functions.
We now have a concept of multiple drawables selectable in GIMP.
Therefore let's get rid of the old single active concept.
2022-07-19 22:52:06 +02:00
Jehan bd199fa0c2 libgimp, pdb, app: new gimp_image_get_selected_drawables() function. 2022-07-19 22:52:06 +02:00
Niels De Graef 1e34a95db7 app, libgimp: pdbgen for previous commit. 2022-02-12 00:07:53 +00:00
Jehan fa16152757 app, libgimp, pdb, plug-ins: update some more functions to get|set().
s/gimp_image_base_type/gimp_image_get_base_type/
s/gimp_image_width/gimp_image_get_width/
s/gimp_image_height/gimp_image_get_height/

Sorry plug-in developers, more porting work! But really this seems like
the right thing to do in order not to get stuck with inconsistent naming
for many more years to come.
2021-04-06 00:49:07 +02:00
Jehan c800b262b0 app, pdb, libgimp: new PDB call gimp-image-set-selected-layers. 2021-02-22 00:00:55 +01:00
Jehan 5a8d69629a libgimp, pdb: new functions gimp_image_policy_rotate() and…
… gimp_image_policy_color_profile().
These functions allow a plug-in to explicitly execute the Rotation and
Profile conversion policies on an image (which may be any of
Rotating/Discarding/Ask or Converting/Keeping/Ask respectively). These
policies are automatically executed when loading an image from GIMP
interfaces, but they won't be when loading an image from the PDB. Then
it is up to the calling code to decide what to do (which can be either
some arbitrary code or following the user policy).
2020-09-24 12:49:57 +02:00
Jehan 5498adf50a app, libgimp, pdb: color picker multi-layer aware.
Color picking on a single layer still works as it used to. On multiple
layer, it will now pick on the composited color, similarly to sample
merged if only selected layers were made visible.

The PDB/libgimp function gimp_image_pick_color() is also updated to work
on multiple drawables too, giving the same ability to plug-ins (the only
call to this function in core plug-ins have been updated).
2020-05-17 18:57:32 +02:00
Jehan ac56b1ed14 app, libgimp, pdb: add PDB function gimp_image_get_selected_layers().
Also add gimp_image_list_selected_layers() which is the GList version.
2020-05-17 18:32:16 +02:00
Michael Natterer 6bca8c4f89 pdb, app, libgimp, plug-ins: replace most PDB filenames/URIs by GFile
and in an attack of madness, changes almost all file plug-in
code to use GFile instead of filenames, which means passing
the GFile down to the bottom and get its filename at the very
end where it's actually needed.
2019-09-11 21:48:34 +02:00
Ell 62a6023b27 pdb: add gimp-image-merge-layer-group procedure
Oddly, we didn't have this one yet :P
2019-09-07 10:33:43 +03:00
Michael Natterer f764fd0f82 pdb, libgimp: change all generated ID array return values to object arrays
and remove the manual libgimp wrappers which now have the same
signature as the generated functions.
2019-09-05 13:01:00 +02:00
Jehan 71ccaa21ee pdb, libgimp: remove double API generation from PDB.
All plug-ins got ported. Let's remove support for the old API with IDs
instead of objects.
2019-09-03 13:31:27 +02:00
Michael Natterer 392f00baf5 app, libgimp: get rid of all ID GTypes and ID param specs
Turn all ID param specs into object param specs (e.g. GimpParamImageID
becomes GimpParamImage) and convert between IDs and objects in
gimpgpparams.c directly above the the wire protocol, so all of app/,
libgimp/ and plug-ins/ can deal directly with objects down to the
lowest level and not care about IDs.

Use the actual object param specs for procedure arguments and return
values again instead of a plain g_param_spec_object() and bring back
the none_ok parameter.

This implies changing the PDB type checking functions to work on pure
integers instead of IDs (one can't check whether object creation is
possible if performing that check requires the object to already
exist).

For example gimp_foo_is_valid() becomes gimp_foo_id_is_valid() and is
not involved in automatic object creation magic at the protocol
level. Added wrappers which still say gimp_foo_is_valid() and take the
respective objects.

Adapted all code, and it all becomes nicer and less convoluted, even
the generated PDB wrappers in app/ and libgimp/.
2019-08-29 11:39:34 +02:00
Jehan 75f8a3804d libgimp: nicer API for functions returning a list.
I.e.: gimp_image_get_(layers|channels|vectors)(), gimp_image_list() and
gimp_item_get_children().
Instead of returning an array of IDs, these will now return a GList with
the right objects ready to use.
2019-08-22 15:54:36 +02:00
Jehan c409829be5 libgimp, pdb: no need to create deprecated versions for private API. 2019-08-22 15:54:36 +02:00
Jehan 8c95499e14 pdb, libgimp: now make all ID types classes of their own.
No need of is_id_arg() anymore in pdb/lib.pl. Let's reuse the {id}
value. Also I had to add an additional trick for GimpDisplay which we
will now generate as such in libgimp PDB files, but still need to show
as GimpObject on app/pdb/.

As previously, only the new classes and the PDB generation for a first
step.
2019-08-22 15:54:36 +02:00
Jehan 79b319cf9d libgimp, pdb: add GimpItem > GimpDrawable > GimpLayer classes.
Only class and subclasses creation and PDB generation for this first
step.
I'll later do other types of items.
2019-08-22 15:54:36 +02:00
Jehan fec6034c7a pdb: keep both the old and new API alive.
By default the new API will be used. But if we build with
GIMP_DEPRECATED_REPLACE_NEW_API macro, then the same function names will
call the old API with ids.

This way, we don't have to update all our plug-ins at once (which I
tried and is very tedious work).

Note that bindings won't have access to the deprecated API at all.
2019-08-22 15:54:36 +02:00
Jehan 17a40b049f libgimp: generate functions both for old and new GimpImage APIs.
This way, it would still be possible to use the old API. WIP.
2019-08-22 15:54:36 +02:00
Jehan 4db8cda24e app, pdb, libgimp: add a new GimpImage class for plug-ins.
This means that all functions which were returning or taking as
parameter an image id (as gint32) are now taking a GimpImage object
instead.
The PDB is still passing around an id only over the wire. But we create
an object for plug-ins to work on.

This is quite a huge API break, but is probably the best bet for the
future quality. It will make nicer API instrospection (and nicer API in
binding), will fix the issues with pspec on GimpImageID in Python
bindings (which makes the current Python API unusable as soon as we need
to work on images, which is most of our plug-ins!), etc.
Also it will allow to use signals on images, which will be a great asset
when we will finally have bi-directionnal communications (i.e. plug-ins
would be able to connect to image changes, destructions, and whatnot).
2019-08-22 15:54:36 +02:00
Michael Natterer 449e84c108 pdb: use guint for tatoo, guide, sample point, which they are
and initialize GimpUnit with PIXEL instead of just 0.
2019-08-15 16:41:39 +02:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Michael Natterer f180a171cd pdb: remove all deprecated procedures 2018-05-20 21:06:29 +02:00
Ell 40e3406b91 pdb: add gimp-image-{freeze,thaw}-{layers,channels,vectors}
These procedures freeze/thaw the corresponding containers of the
image, allowing plug-ins that perform many changes affecting any of
these containers to suppress updates to the corresponding dialogs,
significantly improving performance.
2018-05-07 02:56:10 -04:00
Michael Natterer e16c8a2352 Move the new "default_new_layer_mode" APIs to the image...
...in both the core and libgimp.

Images now know what the default mode for new layers is:

- NORMAL for empty images
- NORMAL for images with any non-legacy layer
- NORMAL_LEGAVY for images with only legacy layers

This changes behavior when layers are created from the UI, but *also*
when created by plug-ins (yes there is a compat issue here):

- Most (all?) single-layer file importers now create NORMAL layers
- Screenshot, Webpage etc also create NORMAL layers

Scripts that create images from scratch (logos etc) should not be
affected because they usually have NORMAL_LEGACY hardcoded.

3rd party plug-ins and scripts will also behave old-style unless they
get ported to gimp_image_get_default_new_layer_mode().
2017-08-21 20:18:00 +02:00
Michael Natterer 4ef3c918a0 pdb, app, libgimp: move the image transform procedures to their own PDB group
because image.pdb is way too large.
2015-05-30 23:55:58 +02:00
Hartmut Kuhse 21bed1e2fb Completely rewrite metadata handling using gexiv2
Based on original patches from Hartmut Kuhse and modified
by Michael Natterer. Changes include:

- remove libexif dependency and add a hard dependency on gexiv2
- typedef GExiv2Metadata to GimpMetadata to avoid having to
  include gexiv2 globally
- add basic GimpMetadata handling functions to libgimpbase
- add image and image file specific metadata functions to libgimp,
  including the exif orientation image rotate dialog
- port plug-ins to use the new APIs
- port file-tiff-save's UI to GtkBuilder
- add new plug-in "metadata" to view the image's metadata
- keep metadata around as GimpImage member in the core
- update the image's metadata on image size, resolution and precision
  changes
- obsolete the old metadata parasites
- migrate the old parasites to new GimpMetadata object on XCF load
2013-10-27 01:02:17 +02:00
Michael Natterer 86f53a3ceb libgimp: make pdbgen generate GIMP_DEPRECATED stuff
instead of GIMP_DISABLE_DEPRECATED.
2012-05-03 01:12:25 +02:00
Michael Natterer 92b4c66777 pdb: export gimp-image-get-precision 2012-05-02 17:51:17 +02:00
Michael Natterer 8918fd338b pdb/libgimp: export gimp-image-new-with-precision
And switch on precision awareness of a plug-in in the core when
possible, instead of in the libgimp wrappers.
2012-05-02 17:51:17 +02:00
Michael Natterer e071bfa3b6 Bug 656716 - Have a procedure to get a layer from its name
Add gimp_image_get_[layer|channel|vectors]_by_name().
2011-09-24 16:35:59 +02:00
Eric Grivel da37e9ff3e Bug 596410 - gimp-image-get-filename returns NULL for imported files
Make gimp_image_get_uri() and gimp_image_get_filename() behave as in
the GIMP 2.6 days. Add new functions gimp_image_get_xcf_uri(),
gimp_image_get_exported_uri() and gimp_image_get_imported_uri().
2011-08-12 21:15:16 +02:00
Michael Natterer 856c89a845 libgimp: add guards that #error out if individual files are included 2011-04-28 19:59:52 +02:00
Michael Natterer 87646e9ace libgimp: deprecate and rename the image parasite functions
in exactly the way the drawable functios were turned into item ones.
2011-03-08 13:19:21 +01:00
Michael Natterer 92b6d70448 libgimp: remove the layer/channel/vectors raise/lower/position procedures
and add them to the list of compat_procs instead.
2011-02-13 18:29:08 +01:00
Michael Natterer 54001221d7 pdb: deprecate gimp_layer_scale_full() and gimp_image_scale_full()
Make gimp_layer_scale() and gimp_image_scale() honor GimpPDBContext's
interpolation property and update the documentation accordingly.
2010-09-16 20:33:56 +02:00
Michael Natterer d0e55640ec pdb: deprecate gimp_image_add_layer,channel,vectors() 2010-09-06 00:15:40 +02:00
Michael Natterer a547c5d200 pdb: add gimp_image_insert_layer,channel,vectors()
which all take "parent" parameters and allow to insert items in a
tree. We don't have channel or vectors trees (yet) but API symmetry is
more important here than a currently useless parameter.
2010-09-05 23:56:35 +02:00
Michael Natterer b24de26791 libgimp: add gimp_image_reorder_item() for arbitrary reordering in a tree 2010-08-31 11:16:41 +02:00
Michael Natterer 0d35e8de6d libgimp: add item based API for positions (raise, lower etc.)
and deprecate the resp. functions for layers, channels and vectors.
2010-08-27 16:11:06 +02:00
Sven Neumann 849a18b08c Bug 574149 – Can't get name/filename of files loaded from URI
2009-03-04  Sven Neumann  <sven@gimp.org>

	Bug 574149 – Can't get name/filename of files loaded from URI

	* tools/pdbgen/pdb/image.pdb: added new procedure 
gimp-image-get-uri.

	* app/pdb/image-cmds.c
	* libgimp/gimpimage_pdb.c: regenerated.

	* plug-ins/pygimp/pygimp-image.c: wrap the new procedure into an
	Image attribute.


svn path=/trunk/; revision=28103
2009-03-04 19:35:18 +00:00
Michael Natterer d9b5207aa2 Change licence to GPLv3 (and to LGPLv3 for libgimp).
2009-01-17  Michael Natterer  <mitch@gimp.org>

	* all files with a GPL header and all COPYING files:

	Change licence to GPLv3 (and to LGPLv3 for libgimp).

	Cleaned up some copyright headers and regenerated the parsers in
	the ImageMap plugin.


svn path=/trunk/; revision=27913
2009-01-17 22:28:01 +00:00
Sven Neumann c286952086 tools/pdbgen/pdb/layer.pdb added new scale procedures that allow to
2008-09-24  Sven Neumann  <sven@gimp.org>

	* tools/pdbgen/pdb/layer.pdb
	* tools/pdbgen/pdb/image.pdb: added new scale procedures that
	allow to specify the interpolation explicitly. Fixes bug 
#486977.
	Also pass the progress parameter to the scale and rotate 
functions.

	* app/pdb/image-cmds.c
	* app/pdb/internal-procs.c
	* app/pdb/layer-cmds.c
	* libgimp/gimpimage_pdb.[ch]
	* libgimp/gimplayer_pdb.[ch]: regenerated.

	* libgimp/gimp.def: updated.


svn path=/trunk/; revision=27039
2008-09-24 08:28:16 +00:00
Michael Natterer e5be5664ed Move the shadow tiles from the image to the drawable. Fixes bug #100469.
2008-04-21  Michael Natterer  <mitch@gimp.org>

	Move the shadow tiles from the image to the drawable.
	Fixes bug #100469.

	* app/core/Makefile.am
	* app/core/gimpdrawable-shadow.[ch]: new files implementing
	the shadow tiles.

	* app/core/gimpimage.[ch]: remove the shadow tile manager from the
	GimpImage struct. Remove gimp_image_get_shadow_tiles() and
	_free_shadow_tiles().

	* app/core/gimpdrawable.[ch]: add the shadow tile manager
	here. Remove get_shadow_tiles() and merge_shadow(). Free the
	shadow tiles in finalize and when the drawable gets removed from
	the image.

	* app/core/gimpdrawable-brightness-contrast.c
	* app/core/gimpdrawable-color-balance.c
	* app/core/gimpdrawable-colorize.c
	* app/core/gimpdrawable-curves.c
	* app/core/gimpdrawable-desaturate.c
	* app/core/gimpdrawable-equalize.c
	* app/core/gimpdrawable-hue-saturation.c
	* app/core/gimpdrawable-invert.c
	* app/core/gimpdrawable-levels.c
	* app/core/gimpdrawable-operation.c
	* app/core/gimpdrawable-posterize.c
	* app/core/gimpdrawable-threshold.c
	* app/core/gimpimagemap.c: changed accordingly. Free the shadow tiles
	after using them.

	* app/plug-in/gimpplugin-cleanup.[ch]: add
	gimp_plug_in_cleanup_add_shadow() and _remove_shadow() which keep
	track of whether shadow tiles were created on behalf of a plug-in
	procedure.

	(gimp_plug_in_cleanup): free shadow tiles which were created but
	not destroyed by a plug-in procedure.

	* app/plug-in/gimpplugin-message.c (plug_in_handle_tile_request):
	call gimp_plug_in_cleanup_add_shadow() whenever a plug-in requests
	shadow tiles.

	* tools/pdbgen/pdb/drawable.pdb: use the new drawable shadow
	API. Add new procedure gimp-drawable-free-shadow. Call
	gimp_plug_in_cleaup_remove_shadow() when it gets called.

	* tools/pdbgen/pdb/image.pdb: deprecate gimp-image-free-shadow.
	Calling it has no effect any longer.

	* app/pdb/drawable-cmds.c
	* app/pdb/image-cmds.c
	* app/pdb/internal-procs.c
	* libgimp/gimpimage_pdb.[ch]
	* libgimp/gimpdrawable_pdb.[ch]: regenerated.


svn path=/trunk/; revision=25510
2008-04-21 17:20:51 +00:00
Sven Neumann 5c4d5416cc create a libgimp C wrapper for gimp-image-get-vectors-by-tattoo; this
2007-11-05  Sven Neumann  <sven@gimp.org>

	* tools/pdbgen/pdb/image.pdb: create a libgimp C wrapper for
	gimp-image-get-vectors-by-tattoo; this function was accidentally
	forgotten in the 2.4 libgimp API.

	* app/pdb/image_cmds.c
	* libgimp/gimpimage_pdb.[ch]: regenerated.


svn path=/trunk/; revision=24066
2007-11-05 18:19:02 +00:00
Sven Neumann 517b0c35ab tools/pdbgen/pdb/display.pdb tools/pdbgen/pdb/drawable.pdb
2007-01-12  Sven Neumann  <sven@gimp.org>

	* tools/pdbgen/pdb/display.pdb
	* tools/pdbgen/pdb/drawable.pdb
	* tools/pdbgen/pdb/image.pdb
	* tools/pdbgen/pdb/vectors.pdb: added PDB functions to validate
	display, drawable, image and vectors IDs.

	* app/pdb/image_cmds.c
	* app/pdb/vectors_cmds.c
	* app/pdb/display_cmds.c
	* app/pdb/internal_procs.c
	* app/pdb/drawable_cmds.c
	* libgimp/gimpimage_pdb.[ch]
	* libgimp/gimpdisplay_pdb.[ch]
	* libgimp/gimpdrawable_pdb.[ch]
	* libgimp/gimpvectors_pdb.[ch]: regenerated.

	* libgimp/gimp.def: updated.


svn path=/trunk/; revision=21697
2007-01-12 19:59:36 +00:00