Commit Graph

347 Commits

Author SHA1 Message Date
Idriss Fekir a966297498 Port GimpText to GimpFont
In GimpText, The font used to be stored as a string containing its name,
Now, it is stored as a GimpFont object, which makes more sense and makes
operations on fonts easier (such as serialization).
2023-09-12 14:23:40 +00:00
Jehan 38c717b149 app, libgimp, pdb: private _gimp_resource_get_by_identifiers() PDB function.
This finds the core resource knowing its type, name, collection and internal
state (in other words, the values returned by _gimp_resource_get_identifiers()).
2023-07-27 15:32:16 +02:00
Jehan fe58de7f81 app, libgimp, pdb: new private PDB call _gimp_resource_get_identifiers(). 2023-07-27 15:30:14 +02:00
Jehan 41ed091879 app, libgimp, pdb: add an internal gimp_context_get_resource().
This will be useful in an incoming code to serialize GimpResource PDB arguments.
2023-07-27 15:27:53 +02:00
Jehan 86cbb5232b pdb: fix a typo.
I guess we never use that type nowadays.
2023-07-27 15:27:29 +02:00
Jehan d439e9ff5c app, libgimp, pdb: factorize a bunch of similar code into gimp_pdb_get_resource().
Rather than reimplementing the same checks for every possible resource data
type, just do it once and redirect to the correct factory container.

For the libgimp API, we leave per-type functions `gimp_*_get_by_name()` (where *
can be brush|gradient|font|palette|pattern so far), but internally they all use
gimp_pdb_get_resource().

Note that eventually we want these functions to return a list of resources as it
should be possible to have several resources of a given type with the same name
(since they are made by third-party who might have had the same idea of a name).
2023-07-27 15:25:32 +02:00
Jacob Boerema 0fb801f7f5 pdb: forgot one case of behavior in previous commit 2023-07-21 17:03:32 -04:00
Jehan ae29736ee0 app, libgimp, pdb: fix annotations for resources as return values.
Resources are stored by the plug-in infrastructure and their memory should not
be managed by plug-in code.

My commit 4f69995b46 was crappy and modified a generated function. I was just
too tired with all the heat in here, I guess!
2023-07-11 16:16:21 +02:00
Jacob Boerema 03e32e6fd3 app, pdb: silence coverity warning about integer overflow
Brushes can't be large enough to actually cause overflow here, but
since the result is gsize, it can't hurt to have the intermediate
results to gsize too.
2023-07-10 12:30:24 -04:00
Niels De Graef ed1ad72255 pdb: Fix size in gimp_image_get_colormap
It looks like we left out the multiplication by 3 when passing the
colormap size to get to the number of bytes in commit 89c359ce

This fixes a crash when saving an XPM file

Fixes: https://gitlab.gnome.org/GNOME/gimp/-/issues/9711
2023-07-08 23:08:54 +02:00
Alx Sa 2a94671269 pdb: Allow ripple to take floating point inputs
Partially resolves #7211.
plug-in-ripple is a wrapper for the GEGL ripple effect. GEGL allows for
double values for period and amplitude, while the GIMP PDB only allows 
integers. This patch aligns the datatypes.
Note that Angle and Phi are still limited to the current design.
2023-06-20 15:27:10 +00:00
Øyvind Kolås 21411047ee app,pdb,plug-ins: %s/gegl_node_connect_to/gegl_node_connect/ 2023-06-13 19:58:42 +02:00
Alx Sa f92ecddd53 pdb: Fix NULL check in gimp-file-load-layers
As @bootchk noted, gimp-file-load-layers does not check the result of 
file_open_layers () but the final return variable
which is always NULL at this point in the function.
This patch corrects the problem so it checks the proper variable.
2023-06-13 04:55:13 +00:00
Michael Natterer a858474fe8 pdb: GimpResource: add is_editable(), rename(), duplicate(). delete()
and remove the API from its subclasses.
2023-06-06 16:33:36 +02:00
Michael Natterer 9638102418 Introduce a global ID space for GimpData/GimpResource objects
Much like for images and items. Change the PDB to transmit IDs
instead of names for brush, pattern etc. and refactor a whole
lot of libgimp code to deal with it.

	modified:   libgimp/gimpplugin-private.h
2023-05-31 16:12:04 +02:00
Michael Natterer 26dce72d2c Remove autotools 2023-05-27 00:03:52 +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
Niels De Graef dd3fd682f6 libgimp, pdb: Fix enums_get_type_names annotations
Annotate the array length
2023-05-22 01:19:17 +02:00
Alx Sa 7e371c7884 libgimpbase: Add Middle Gray fill option
Uses CIELAB's 50% lightness (18.42% luminance) for the Middle Gray
color.
2023-04-24 10:25:58 +00:00
Jacob Boerema ef7f955e1e pdb, libgimp: improve function documentation for sample points
- gimp_image_add_sample_point: guide is a left-over from copy-pasting and
add apostrophe
- gimp_image_get_sample_point_position: it was not clear that the
parameter was the y-offset and the return value the x-offset
2023-04-09 21:32:00 -04:00
Jehan 1b780cd8e0 app, libgimp, pdb: minor fixes.
- fix a typo s/Commponent/Component/.
- Add &std_pdb_compat() to the new PDB procedures (I realize that's probably
  what the contributor was asking about, back in !446). Not sure if it's right
  as there were none in this file, but these are clearly just wrappers around
  GEGL ops, so it seems fitting.
- Some alignment fixes.
- More accurate "$since" variables.

(cherry picked from commit 66ef1ef1ef)
2023-02-14 17:18:38 +01:00
Jehan c6972eabde pdb: meson-pdbgen.sh should return the return value of pdbgen.pl.
Otherwise even when the main script fails, hence generation of source files does
not end up correctly, the build continues (and likely fails later).
2023-02-14 15:36:19 +01:00
Ian Martins acdf5a3776 pdb: add a PDB procedure for extract-component
(cherry picked from commit dbf9f277a2)

Committer's (Jehan) updates:

- Component type is now int32 (int8 is not a PDB type available anymore).
- PDB files re-generated to handle changes in API and types.
2023-02-14 15:36:19 +01:00
Jehan fc2925def0 app, libgimp, pdb: gimp_image_set_file() only works for XCF files.
This is not made to set the imported or exported file, but only the XCF file.
See previous commit to see what happens when this API is used to set non-XCF
file extensions (saving fails unless one edits the filename).
2023-02-13 22:54:01 +01:00
Jehan b9a6799082 app, libgimp, pdb: fixing generated code and wrong GEGL op arguments.
This commit is a fixup commit for MR !790 which had a few issues:

- The args for shadows and highlights adjustments are "shadows-ccorrect" and
  "highlights-ccorrect" respectively.
- Also fixing generated code.

(cherry picked from commit e456ab019b)
2023-02-13 14:28:00 +01:00
Ian Martins e238ea07ca pdb: add a PDB procedure for shadows-highlights
(cherry picked from commit 0b96363e10)

Reviewer's (Jehan) note: the generated source files were re-generated and
amended in this commit.
2023-02-13 14:26:04 +01:00
Jehan ba5c423331 Issue #8924: Paste as new image uses the full canvas instead of just…
… the copied selection.
2023-01-24 12:51:30 +01:00
Jehan 24b955bf17 app, libgimp, pdb: various coding-style fixing and struct for final types…
… moved to the implementation file.

When declaring with G_DECLARE_FINAL_TYPE(), the whole concept is that the struct
is made private (which also allows the type to evolve without breaking ABI if we
some day decide to make the class derivable). For this to make sense, the struct
goes in the implementation file, not the header.

For the rest, it's mostly alignment bugs and the like.
2023-01-14 18:44:31 +01:00
lloyd konneker e00f2d7f50 Fix plugins to use new GimpResource. 2023-01-14 17:43:26 +01:00
lloyd konneker d59a7af38c libgimp: API refactor GUI for GimpResource
Simplifies chooser widgets (e.g. GimpBrushSelect) by eliminating attributes (e.g. opacity) of chosen resource.
See #8745, but this commit fixes that by first refactoring the code.

Refactors GUI widgets (e.g. GimpBrushSelectButton and GimpBrushSelect etc.)

Refactor by "Extract class" GimpResourceSelectButton from GimpBrushSelectButton etc.
This moves common code into an inherited class (formerly called GimpSelectButton)
but the subclasses still exist.
The subclasses mainly just do drawing now.

Refactor by "Extract module" GimpResourceSelect from GimpBrushSelect etc.
Moves common code into one file, generic at runtime on type of GimpResource,
that is, the new code dispatches on type i.e. switch statements.
In the future, when core is changed some of that can be deleted.
The files gimpbrushselect.[c,h] etc. are deleted.
The module adapts the API from core to the API of callbacks to libgimp.

Note that core is running the resource chooser (select) widgets remotely.
Core is still calling back over the wire via PDB with more attributes
than necessary.
The new design gets the attributes from the resource themselves,
instead of receiving them from core callback.
The libgimp side adapts by discarding unneeded attributes.
In the future, core (running choosers for plugins) can be simplified also.

Fix gimp_prop_chooser_brush_new same as other resources.

Finish changes, and clean style.

Annotations
2023-01-14 16:38:40 +00:00
lloyd konneker d720375e97 2.99 libgimp: add GimpResource, GimpBrush, GimpPropWidgetBrush
So procedures can declare args and GimpProcedureDialog show chooser
widgets

Fix so is no error dialog on id_is_valid for resources

Palette.pdb changes and testing

Memory mgt changes

Gradient pdb

Font and Pattern tests

Test  brush, palette

Cleanup, remove generator

Rebase, edit docs, install test-dialog.py

Whitespace, and fix failed distcheck

Fix some clang-format, fix fail distcheck

Fix distcheck

Cleanup from review Jehan
2023-01-14 12:58:05 +00:00
Jehan 143496af22 app, menus, pdb: new "Paste as Single Layer( in Place)?" actions.
When the clipboard contains raw image data or single layers, it's the same as
the normal "Paste" (and "Paste In Place" respectively). These actions are useful
if you want to copy a bunch of layers and paste them "merged" into a single
layers (since now the copy-paste of multiple layers will create multiple
layers).
It is somehow similar to the "Copy Visible" action except that it works on
selected layers only and work at paste time, making the action more versatile.
2022-11-12 22:34:51 +01:00
Jehan 3453c8bd55 app, pdb: paste layers over the top selected drawable.
When several drawables were selected, it was pasting at the top of the layer
stack. Instead, paste over the top selected layer ("top" visually in the Layers
dockable).

There was the question of: what should we do when pasting over a layer group.
Should we consistently paste the new layers above the group or inside the group?
After discussions with Aryeom, we decided to stay consistent and paste above, at
least for now.
2022-11-09 17:22:35 +01:00
Jehan a77c64fafe app, pdb: fixing gimp_vectors_export*() libgimp API.
It seems I forgot to fix some usage of core gimp_vectors_export*(),
which now take a list of paths (not a single path anymore since commit
9fc8260c7c), as these were used by PDB functions.
2022-10-20 19:07:16 +02:00
Jehan 759ee663f0 app, pdb: fix a few "incompatible pointer type" conversions.
That's the problem when there are still too many old warnings hiding the
new ones!
2022-10-20 18:56:24 +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
Alx Sa b317eceda9 pdb: Use floating point offset in stroke_translate
Update gimp_vectors_stroke_translate () to accept
floating point values for offset parameters
like gimp_stroke_translate () does.
2022-10-15 18:26:55 +00:00
Jehan 892b62ec36 app, libgimp, pdb, plug-ins: new GimpTextLayer class in libgimp.
Now text layers are proper types, which means that the binding API will also be
nicer (e.g. `txt_layer.set_text('hello world')` in Python).

This commit also adds the param specs allowing to create plug-in procedures with
text layer parameters.

Finally it fixes the few calls in file-pdf-save (apparently the only plug-in
using specific text layer API right now) with explicit type conversion.
2022-09-30 20:55:51 +02:00
Jehan 690949eb34 app, libgimp, pdb: add a note about unsupported markup.
After re-reading #534, I realized I missed the discussion about unsupported
markup by the tool. Then I tested and confirmed what Ian Munsie initially said
in a comment: unsupported markups are properly rendered in the text layer, yet
are simply dropped when editing with the text tool.

This is actually the ideal behavior as it means that with the API, you can even
go further than what is currently possible with the GUI. So it gives nice powers
to people who can script GIMP. We still need some warning in the function
documentation to tell developers about this weakness in the tool GUI.
2022-09-30 00:59:10 +02:00
Ian Munsie 445909bff5 Issue #534: add a function to set the Pango markup of a text layer
This complements the existing text_layer_get_markup function and allows
scripts to create and modify complex text layers.

It adds the <markup> root tag if it was not supplied and will run the
markup through pango_parse_markup() to check for errors.

Reviewer's (Jehan) note: this is a mostly untouched patch contributed in #534,
except that code moved around. I also fixed the header set in the .pdb, a link
to pango markup docs and added the meson changes.
2022-09-30 00:50:34 +02:00
Jehan ca230cb770 meson: fix warnings of deprecated features.
Now that we bumped our meson requirement, meson is complaining about
several features now deprecated even in the minimum required meson
version:

s/meson.source_root/meson.project_source_root/ to fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': meson.source_root. use meson.project_source_root() or meson.global_source_root() instead.

s/meson.build_root/meson.project_build_root/ to fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': meson.build_root. use meson.project_build_root() or meson.global_build_root() instead.

Fixing using path() on xdg_email and python ExternalProgram variables:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.55.0': ExternalProgram.path. use ExternalProgram.full_path() instead

s/get_pkgconfig_variable *(\([^)]*\))/get_variable(pkgconfig: \1)/ to
fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': dependency.get_pkgconfig_variable. use dependency.get_variable(pkgconfig : ...) instead
2022-08-31 01:29:37 +02:00
Alx Sa 0587a10543 core: Add simulation intent and BPC to GimpImage
Adds a simulation_bpc and simulation_intent to GimpImage to allow 
plug-ins to access it
for CMYK import/export.
Four pdb functions were added to enable this access:
image_get_simulation_bpc (), image_set_simulation_bpc (), 
image_get_simulation_intent (), and image_set_simulation_intent ().
Next, it updates menu options and code to support GimpImage's
internal simulation intent and bpc.
New 'simulation-intent-changed' and 'simulation-bpc-changed signal 
are emitted via
GimpColorManagedInterface so that relevant tools 
(such as the
CYMK color picker, GimpColorFrame, and future pop-overs)
 are aware of these changes.
2022-08-13 19:39:47 +00:00
Jehan c857fc58a6 pdb, po-tips: fix meson warnings.
Meson is apparently able to show different warning depending on the
meson version tests we do in specific code paths.

Since our global required meson is 0.53.0 but on some code paths, we
test for 0.57.0, we must use meson.source_root() on older meson and
meson.project_source_root() on newer one.

Fixes:

> pdb/meson.build:141: WARNING: Project targets '>=0.57.0' but uses feature deprecated since '0.56.0': meson.source_root. use meson.project_source_root() or meson.global_source_root() instead.
> pdb/meson.build:141: WARNING: Project targets '>=0.57.0' but uses feature deprecated since '0.56.0': meson.build_root. use meson.project_build_root() or meson.global_build_root() instead.
> po-tips/meson.build:5: WARNING: Project targets '>=0.53.0' but uses feature introduced in '0.56.0': meson.project_source_root.
2022-07-31 18:16:00 +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
Jehan 81b569cb8c Issue #8124: plug-in localization now totally moved plug-in side.
Plug-in localization was always partially plug-in side, especially for
things like custom GUI. But labels or blurb in GIMP (such as in menus or
action search) were localizing GIMP side.

It had many drawbacks:

- To get menu localization, a plug-in had to set up gettext, even though
  they might want to use something else for their GUI (after all, giving
  facilities for gettext is a good idea, but there is no reason to force
  using this system).
- There was a complex internal system passing the localization domain
  name, as well as the catalog file system path to core, then through
  various classes which we can now get rid of.
- There could be domain name clashes, if 2 plug-ins were to use the same
  i18n domain name. This was handled in now removed functions
  gimp_plug_in_manager_get_locale_domains() by simply keeping a unique
  one (and gimp_plug_in_manager_bind_text_domains() would just bind the
  domain to the kept directory). In other words, one of the duplicate
  plug-ins would use the wrong catalog. We could try to make the whole
  thing more complicated or try to forbid plug-ins to use any random
  name (in particular made easier with the new extension wrapper). But
  anyway this whole issue doesn't happen anymore if localization is
  fully made plug-in side, so why bother?

I tried to evaluate the advantages of the core-side localization of
plug-in labels/blurbs and could only find one theoretical: if we wanted
to keep access to the original English text. This could be useful
(theoretically) if we wanted to search (e.g. in the action search) in
both localized and English text; or if we wanted to be able to swap
easily en/l10n text in a UI without reload. But even if we were to ever
do this, it would only be possible for plug-ins (GEGL operations in
particular are localized GEGL-side), so it lacks consistency. And it's
unsure why special-casing English should really make sense for other
language natives who want text in their lang, and search in their lang.
They don't necessarily care about original.

So in the end, I decided to simplify the whole thing, make localization
of plug-ins a plug-in side thing. Core will only receive translated text
and that's it. It cuts a lot of code out of the core, simplify runtime
processing and make plug-in creation simpler to understand.

The only think I still want to look at is how exactly menu paths are
translated right now. Note that it still works, but it's possible that
some things may be worth improving/simplifying on this side too.
2022-07-05 12:22:32 +02:00
Alx Sa 0d7fed93ae core: Add softproof profile to GimpImage
Adds a simulation_profile to GimpImage to allow plug-ins to access it
for CMYK import/export.
Two pdb functions were added to enable this access:
image_get_simulation_profile () and image_set_simulation_profile()
Next, it updates menu options and code to support GimpImage's
internal simulation profile. Menu items are moved from View to Image's
Color Management section.
New 'simulation-profile-changed' signal is emitted via
GimpColorManagedInterface so that relevant tools (such as the
CYMK color picker, GimpColorFrame, and future dockable
dialogue) are aware of these changes.
2022-07-02 15:26:19 +02:00
Jehan 15ec254148 Issue #5946: skip gimp_*get_*() API from GObject Introspection.
The get() API are sometimes nicer in C code because it's just simpler to
loop through C arrays, but they end up with similar API to the list()
variants for binding, or with a useless size return value (since most
higher level languages have length-aware array types, which is what
GList are transformed into).

So let's use the list() variants as the main ones and skip the get()
variants. I hesitated to rename the list() variants to get() with
`(rename-to)` annotations but since I am unsure if the get() bindings
are absolutely useless, I don't think it's the best idea. Maybe on some
other language usable as GI binding, the get() variant might be
different again and nicer to use. So if we shadowed these by renaming
list() ones, the day we change our mind, we'd have to rename get() ones
too (which would be very confusing), or else break bindings' API. To
avoid this, I just skip the get() ones altogether in bindings but leave
their name available in the bindings.
2022-06-27 21:20:06 +02:00
Jehan 01e9253d7e app, pdb: fix PDB string wrapping in generated calls of…
gimp_procedure_set_static_help().

The indentation was wrong, probably because of changes to function
names. Fix the generation scripts and regenerate the PDB C files.
2022-06-05 01:57:02 +02:00
Jehan bdd22cd95b app, libgimp, pdb: change docs of _gimp_plug_in_domain_register().
We changed the logic of _gimp_plug_in_domain_register() which is now
only called when a domain is explicitly registered (which is not the
case by default anymore). Let's update the function documentation and
also make it clear that third-party developers in particular should not
play with it if they want their plug-ins to be properly localized.
2022-06-05 01:57:02 +02:00