Commit Graph

3064 Commits

Author SHA1 Message Date
Jehan 9d7bfb4669 Issue #12940: GimpProcedure base class should default to GIMP_PROCEDURE_SENSITIVE_ALWAYS.
Note that I don't touch the GimpFileProcedure and children because they
are special-cased anyway. As for GimpBatchProcedure, ALWAYS is a good
default too.
2025-02-18 16:50:37 +01:00
Jehan 61f380789e libgimp: all blurbs to GimpProcedure arguments are nullable.
Without this, we cannot set NULL (or equivalent, such as None in Python
3) when calling these functions in bindings.
2025-02-15 17:42:52 +01:00
Jehan e74759184c app, libgimp: change the default sensitivity mask.
After discussing with NikcDC and Wormnest on IRC, we agreed that maybe a
default of being sensitive when one or more drawables are selected seems
better, since the run() signature now has an array of drawables. So most
plug-in developers will consider the case when there are several
selected drawables as an obvious possible case.

And if someone really doesn't want to handle this case, they can always
set the sensitivity mask explicitly.
2025-02-14 20:08:43 +01:00
Jehan c4c3a2f25d libgimp: improve annotations. 2025-02-14 19:52:39 +01:00
Jehan 2c3e56a6aa libgimp: fixing annotation formatting.
This is markup format where the asterisk has some special meaning.
2025-02-14 19:52:39 +01:00
Jehan 7e7281b888 libgimp: add a links to gimp_main() docs from GIMP_MAIN(). 2025-02-14 19:52:39 +01:00
Alx Sa 8d53675d9f libgimp: Convert floating selection to layer on export
On export, when GIMP_EXPORT_CAN_HANDLE_LAYERS is not set
but GIMP_EXPORT_NEEDS_ALPHA is, we merge all layers in the image.
If there's a floating selection however, its attached layer is not included
in the exported image.

This patch converts the floating selection to a regular layer so that both
are included in the final export.
2025-02-14 00:56:22 +00:00
Jehan b01ecf80e6 app, libgimp, pdb: allow NULL input drawable to the new crop procedures.
Cropping relatively to the full image contents is a common usage (it is
in fact the "Crop to Content" feature we have in the Image menu) so I
found it a bit frustrating that these 2 functions only allow to crop
relatively to a single drawable.

Therefore, I make NULL an acceptable input which will default to
cropping to the full image content instead.
2025-02-09 19:24:41 +01:00
Jehan 3c21b768c5 app, libgimp, pdb: improve docs and names of autocrop functions.
- Clean up a bit the 2 procedures' descriptions and add more info in
  gimp_image_autocrop() description to explain how the input drawable is
  used.
- Rename gimp_image_autocrop_layer() to gimp_image_autocrop_selected_layers(),
  which makes it clearer.
2025-02-09 18:23:42 +01:00
lloyd konneker 9e2d8e4e16 API: fix #12860 autocrop is internal, not a compatibility plugin
Rename plug_in_compat.pdb to image_autocrop.pdb so we retain commit history.

All procedures defined there are related to autocrop.
   - made internal, not plugins
   - renamed from plug-in- to gimp-image-
   - exposed in libgimp

If we need plugin compatibility PDB group in the future,
a starting template can be recovered from plug_in_compat.pdb 2.10 or late 2.99.

Fixed plugins that call.  The C plugin now calls libgimp instead of a PDB procedure.
2025-02-09 16:51:13 +00:00
Anders Jonsson 255e942087 python, libgimp: rename gimp_palette_entry_[gs]et_*()
Followup to 151cb9c40c
to make the palette offset and sort scripts work again.
2025-01-29 21:02:22 +01:00
Jehan 679220d8f5 Issue #12568: support GIMP's GEGL operations with a custom config argument…
… in new filter API.
2025-01-27 16:34:11 +01:00
Jehan a353618d53 libgimp: make sure alignment and margin are same for all argument labels.
While fixing individual widget's labels to have proper default is good,
let's also have a centralized re-setting of alignment and margins for
all the labels which we set in the same GtkSizeGroup. This makes nice
and consistent dialogs.

Additionally I set a 4px margin at the end of label (0 elsewhere),
otherwise the longer label in the size group end up sticking too close
to its control widget and it's ugly.
2025-01-26 21:29:21 +01:00
Jehan 995329ac25 Issue #11261: unify argument widget alignment. 2025-01-26 21:10:29 +01:00
Jehan 10808f2830 libgimp, plug-ins: create automatically a GimpFileChooser for GimpParamSpecFile arguments.
This new widget is much nicer, with proper label to document the GUI and
also with support to save files or create folders. It also has mnemonic
support and the label is put into the same size group as other so that
it's nicely aligned.

As a consequence, I remove bad support of object arguments with a GFile
value. People should just create proper GimpParamSpecFile arguments
(also GimpProcedure API now has a function only for such type of file
argument).

I also remove gimp_procedure_dialog_get_file_chooser() which was only
useful when we didn't know what action a file argument was for. Now it's
part of the param spec definition.

libscriptfu was updated too because SF-DIRNAME arguments don't need
special casing anymore.

Finally I change gradients-save-as-css to just make use of the new
automatic widget creation (more than 60 lines of plug-in code replaced
by… 0 lines because it's automatic!).

This whole commit is mostly a lot of code removal now that we have
proper automatization for file arguments! \o/
2025-01-26 18:13:55 +01:00
Jehan 094414186b libgimp: also hide structs for GimpParamSpec(Display|Drawable|Image|Item).
New libgimp functions:

- gimp_param_spec_display_none_allowed()
- gimp_param_spec_drawable_filter_none_allowed()
- gimp_param_spec_image_none_allowed()
- gimp_param_spec_item_none_allowed()

I believe that now all param spec strucs which needed to be hidden are
effectively hidden!
2025-01-25 16:42:26 +01:00
Jehan b1acb256e1 libgimp*, plug-ins: now hide GimpParamSpecChoice struct.
New libgimpbase functions:

- gimp_param_spec_choice_get_choice
- gimp_param_spec_choice_get_default

Now the only GParamSpec in libgimpbase whose struct is visible is
GimpParamSpecObject. This can't change since it is derived into param
specs defined in libgimp and therefore needs to be visible.
2025-01-25 01:28:19 +01:00
Jehan f09d97b9a5 app, libgimp*: GimpParamSpecCoreObjectArray struct hidden too.
New libgimpbase function: gimp_param_spec_core_object_array_get_object_type()
2025-01-25 01:28:19 +01:00
Jehan 6e777c861b app, app, libgimp*: hide struct for several GParamSpec based off GimpParamSpecObject.
As a consequence, here are needed new functions:

* libgimp:
  - gimp_param_spec_resource_defaults_to_context()
  - gimp_param_spec_resource_none_allowed()

* libgimpbase:
  - gimp_param_spec_file_get_action()
  - gimp_param_spec_file_none_allowed()
  - gimp_param_spec_unit_percent_allowed()
  - gimp_param_spec_unit_pixel_allowed()
2025-01-24 23:44:43 +01:00
Jehan 40aa78ac10 libgimp: add support for GimpParamSpecUnit to gimp_procedure_dialog_get_widget(). 2025-01-24 22:09:40 +01:00
Jehan 23c9503bfa app, libgimp, libgimpbase: use GimpParamSpecObject infrastructure for…
… GimpParamSpecUnit's default value.

When I reparented GimpParamSpecUnit to GimpParamSpecObject in commit
ba3da3d338, I clearly forgot to get rid of the redundant default value.
2025-01-24 22:06:56 +01:00
Jehan cb9227a6a1 libgimp: do not call gimp_procedure_dialog_get_file_chooser() from within…
… gimp_procedure_dialog_get_widget().
2025-01-23 23:36:34 +01:00
Jehan d25c97e7c9 libgimp, libgimpbase: fix passing a file spec action through the wire.
I forgot to set meta.m_file.action into the GPParamDef! 🤦

As a side update, let's store the action as gint32 in GPParamDefFile. I
realized that otherwise, depending on the actual size of an enum type,
when casting to a (guint32 *), we crop the value! This works out in
Little Endian because we are only in small number territory, but in Big
Endian, we would always crop any action value to 0!
This was not the bug in this specific case, but it could become the
exact same bug (always passing action 0, i.e. OPEN, through the wire) on
Big Endian hardware.
2025-01-23 00:52:18 +01:00
Jehan e752687321 libgimp: fix introspection.
The variable name was not the same on function declaration and
definition/annotations and this was confusing GIR scanner.
2025-01-22 21:29:16 +01:00
Jehan 161b3c5331 Issue #12045: no defaults for plugin args of type File.
libgimpbase:

  - Mew GimpFileChooserAction enum type: basically a near-mapping of
    GtkFileChooserAction (GTK is not accessible from libgimpbase) with
    an added GIMP_FILE_CHOOSER_ACTION_ANY.
  - New GimpParamSpecFile param spec type: based off
    GimpParamSpecObject, it has a default value, but also a none_ok and
    action argument. This way, we can also know from the argument type
    if this is a file argument meant for selecting a normal file or a
    folder, or for saving into a file, or for creating a directory.

libgimp, plug-ins:

  - All existing file arguments (until now using a standard
    GParamSpecObject param with GFile value type) were moved to the new
    GimpParamSpecFile.
  - Script-Fu in particular will now generate the appropriate param type
    depending on whether it is an SF-FILENAME or SF-DIRNAME.
  - File arguments are now stored between runs as a URI rather than as a
    path. As far as I can tell, a GFile always has a URI, but not always
    a path (in particular remote file won't have a path).
2025-01-22 17:53:21 +01:00
Jehan 6dfc9f96c5 app, libgimp, pdb, plug-ins: improve and rename gimp_file_save_thumbnail() to…
… gimp_file_create_thumbnail().

One more case where "save" is misleading, and even more as it's not a
procedure where we control where an image is stored. We only say
basically "make a thumbnail which maps to this file according to my
platform's rules".

As a side fix, I also improved a bit the logic so that it allows @file
to be the exported or — as last fallback — the imported file.

And finally improve the function's docs.
2025-01-21 20:31:27 +01:00
Jehan 602e8f71c7 app, libgimp, pdb: reword some save/export API documentation.
Followup of the save/export difference, plug-ins can only register
"export" handler procedure (save handlers are registered by core). Also
rename _gimp_pdb_set_file_proc_save_handler() though it's private so it
doesn't matter much.

Now gimp_file_save() is a special case, because it can indeed "save" to
XCF or "export" to any other format. So I just leave it named this way,
but I make the function's documentation more exhaustive.
2025-01-21 17:40:11 +01:00
Jehan 9f204e7441 Issue #12772: fix annotations. 2025-01-21 15:04:34 +01:00
Jehan 18d88c207c app, libgimp, pdb, plug-ins: PDB (gimp-group-layer-new) made public. 2025-01-20 22:38:01 +01:00
Jehan 957d76fd14 app, libgimp, pdb, plug-ins: PDB (gimp-layer-copy) made public.
Not sure what I had in mind with the class method copy() in libgimp
GimpLayer. The core duplicate code already takes care of returning an
object of the right type. Also the GimpTextLayer implementation was not
a perfect copy (only text, font and font size were copied). Now it is
because, again, core has all the duplication code necessary.

Finally this makes this function visible to PDB, hence Script-Fu, again.
2025-01-20 22:38:01 +01:00
Jehan 65635e8a0c app, libgimp, pdb: also get rid of gimp_text_layer_new() wrapper.
See previous commit.
2025-01-20 20:55:48 +01:00
Jehan e125c30cfd Issue #12771: (gimp-layer-new) is missing.
The libgimp wrapper was just calling the PDB procedure. Get rid of the
wrapper and make the PDB proc public. Also reorder the name argument to
be in the second place, just like it was for the wrapper.
2025-01-20 20:55:48 +01:00
Jehan 305303330c app, libgimp, pdb: fix a null_ok/none_ok mixup.
We had 2 flags to indicate that a PDB argument could be nullable:
null_ok and none_ok. That was a huge mixup and the PDB generation code
was using sometimes one, sometimes the other. Let's settle for only
none_ok.

This fixes a bunch of annotations.
2025-01-20 20:55:48 +01:00
Jehan 6e3c60dd66 Issue #12760: make the metadata PDB arguments public. 2025-01-20 17:58:30 +01:00
Jehan d511efb822 libgimp, plug-ins: rename the various "save-*" metadata arguments…
… per discussion with Liam on IRC.

I should have done this sooner, not in a RC, but it's better to do it
now, rather than after 3.0 is released!
2025-01-20 17:58:30 +01:00
Jehan 45af19e917 app, libgimp, pdb: adding concept of core and private PDB procedures.
Core procedures are all the procedures created for libgimp basically. In
opposition, procedures created by plug-ins are not core procedures.

GimpProcedure class in libgimp now has a gimp_procedure_is_core() which
will tell you if a procedure is core or not.

Private procedures already existed, except that they were only marked as
"private" in libgimp (e.g. _gimp_font_get_lookup_name()) starting with
an underscore and marked as G_GNUC_INTERNAL. Now we also store this
information in the procedure object itself for reuse.
2025-01-20 00:01:23 +01:00
lloyd konneker a00fee46af libgimp: fix #12631 set can_recurse on watch on msgs from core
So plugins don't block on second wire msgs for callbacks from remote
core chooser dialogs.
Makes libgimp/plug-in more similar to core/plug-in
2025-01-15 17:20:05 +00:00
Jehan 728b9cdd28 Issue #12707: CRITICAL on choosing gimp-drawable-filter-update. 2025-01-14 17:58:40 +01:00
Jehan 51e719191d Issue #12712: non-configured filter throws CRITICAL when updating. 2025-01-13 20:08:16 +01:00
Alx Sa 54405ddd0f libgimp: Respect alpha setting in color widgets
When creating a color widget in GimpProcedureDialog, we
were not taking into account whether the parameter's
has_alpha boolean was set to FALSE. As a result, all color
widgets allowed for transparency.

This patch checks if the GimpColor's GParamSpec has_alpha value
is FALSE, and if so, sets the color widget's type to
GIMP_COLOR_AREA_FLAT to enforce no transparency for that color.
2025-01-12 19:10:27 +00:00
Jehan 6f197416ec libgimp: switch the relative path to full path.
Without this, the relative path alone was not working fine, likely
because current working directory is not the plug-in dir.
2025-01-10 18:59:37 +01:00
Jehan 49e2abd9ad Issue #12326: Bug in locale directory checking in gimpplugin.c. 2025-01-10 18:43:31 +01:00
lloyd konneker fb3f8e7fe6 libgimp: fix #12494
Change the message for debugging proxy refs: say "DEBUG" instead of "ERROR".

This doesn't fix any logic.
The logic produces a spurious error msg often, scaring users.
The debug message can be seen and analyzed by devs.

Add a comment about what object proxies are normally reffed:
defaults for formal args of temporary procedures kept by persistent plugins.
2025-01-08 08:11:59 -05:00
Daniele Forsi 994137a82e Fix spelling errors found with codespell 2025-01-04 15:11:03 +00:00
Rupert 91f7331125 libgimp: imagemetadata-save - static assert expr. not constant
Fixes #12588. depending on build parameters, the strlen()s weren't
necessarily considered constant.
Changed to use arrays + sizeof instead.
2024-12-29 22:01:30 +00:00
Jehan 61abcd7412 libgimp, plug-ins: update gimp_drawable_append_new_filter() signature.
Adding the mode and opacity arguments makes it very similar to
gimp_drawable_merge_new_filter() signature, but also to its own
Script-fu wrapper (gimp-drawable-append-new-filter).

It's just better to be consistent. Also if either of these args need to
be changed immediately afterwards, then we spare one additional
re-render for nothing (for instance in the PSD load plug-in!).
2024-12-23 15:35:10 +01:00
Øyvind Kolås 3f3b29ba12 app, libgimp, pdb: fix perceptual blend space for linear TRC ICC profiles
In previous versions what has been stored/specified as perceptual blending or
compositing spaces has really been the non-linear variant of the images babl
space.

To maintain loading of old files, the code has been updated to actually mean
non-linear and a new perceptual value has been added to the GimpLayerColorSpace
enum, while preserving all old enum values.

This change bumps XCF file version to 23
2024-12-19 23:23:50 +01:00
Jehan a6392ed84a app, libgimp, pdb, plug-ins: add a few Script-fu wrapper of libgimp filter API.
In particular (gimp-drawable-filter-configure),
(gimp-drawable-merge-filter) and (gimp-drawable-append-filter) are
proper Script-fu methods.

I had to rename the PDB procedures for the 2 latter because they were
clashing with these wrapper. I had not realized that private PDB
procedures are still visible by Script-fu. This is not so glop. :-/

Right now, it doesn't look so useful compared to the -new- one-liner
variant procedures. But it will make sense when I will add aux input C
procedure wrappers.
2024-12-17 16:24:54 +00:00
Jehan 6480ba2ad6 app, libgimp, pdb: new gimp_drawable_filter_set_aux_input() public API.
It is this way possible to set a drawable as auxiliary input to a filter
in C and GObject-Introspected bindings.

Note that such filters can only be merged, not appended
non-destructively for the time being.
2024-12-17 16:24:54 +00:00
Jehan 39c2b83746 libgimp: allow passing GeglParamSeed arguments from plug-ins.
In particular, I encountered some script-fu scripts calling some GEGL
ops with a seed, but this argument wouldn't be reproduced in the config
object. Technically it's just a uint. Let's just pass them as such.
2024-12-17 16:24:54 +00:00