Commit graph

3088 commits

Author SHA1 Message Date
woynert
a188a8db93 app,libgimp: paint blend mode 'overwrite' 2025-06-20 23:24:10 +00:00
Jehan
bcb736db61 libgimp: different widget default for GimpChoice in GimpProcedureDialog…
… depending on the number of choices.

Enforcing a UX decision into code from GIMP/Design/gimp-ux#323.
Note that this is not a perfect automatization, since the right default
widget may still be a combo box even for limited choices arguments, when
the dialog is crowded.
It still improves the defaults, and it is still possible to override the
widget on case by case (just as of now).
2025-06-13 16:50:12 +00:00
Alx Sa
963830fd91 libgimp, libgimpwidgets: Add GimpCoordinates widget...
...to GimpProcedureDialog.
This patch allows plugin developers to create a
GimpCoordinates widget (two GimpSizeEntries linked
together with a chain and with a units combo) in the
GimpProcedureDialog.

It is largely a wrapper for gimp_prop_coordinates_new ().
This patch also makes that function more responsive
to the unit property, now that GimpUnit has a proper
GParamSpec implementation. The default unit and
whether we show pixels, percents, or the resolution
spinners can now be determined via the unit
parameter (if set) rather than relying on
hardcoded values.

As a demonstration, the Tile plug-in's width/height
entries were restored to what they were before the
GimpProcedureDialog port, with units and a chain
link between values.
2025-06-10 19:37:35 +00:00
Michael Natterer
76e82d5572 libgimp: there was an "else" missing in the commit below 2025-05-31 17:00:33 +02:00
Alx Sa
0d08a3c532 libgimp: Create widgets for unsigned integer parameters
gimp_procedure_add_uint_argument () creates an unsigned integer
parameter. It's functionally equivalent for creating dialogue widgets,
but since we only checked for G_TYPE_PARAM_INT, these parameters
did not generate widgets in GimpProcedureDialog.
This patch adds a check for G_TYPE_PARAM_UINT in relevant sections
to resolve the issue.
2025-05-31 14:20:28 +00:00
Jehan
27f6d25677 libgimp: fix incompatible type for exported function address in gimp-win-x86 job.
This fixes:

> ../libgimp/gimp.c:280:27: error: assignment to 't_SetProcessDEPPolicy' {aka 'int (__attribute__((stdcall)) *)(long unsigned int)'} from incompatible pointer type 'FARPROC' {aka 'int (__attribute__((stdcall)) *)(void)'} [-Wincompatible-pointer-types]
>   280 |     p_SetProcessDEPPolicy = GetProcAddress (GetModuleHandleW (L"kernel32.dll"),
2025-05-16 16:56:35 +00:00
Idriss Fekir
8328dfb25b GimpFontFactory: Move font loading to another thread
This is to make sure than regardless of how many fonts there are, font loading
won't delay startup.

FontConfig if compiled against libxml2 might fail to parse huge xml configs.
So instead of passing it a huge xml, pass the xml every MAX_NUM_FONTS_PER_CONFIG (currently 1000) fonts.

Also made GimpFontFactory custom config strings private because there is no reason for them to be public.
2025-05-14 22:42:22 +00:00
Alx Sa
cb0f8a0282 libgimp, libgimpwidgets: Let string widgets expand horizontally
This makes GimpProcedureDialog string argument widgets expand
horizontally by default.
2025-05-11 05:50:49 +00:00
Jehan
15d2e25404 libgimp: further cleanup in GimpGradientChooser code.
- No need of local_grad_data_new(). Just set default variables in init()
  as it should be.
- Also move gimp_gradient_chooser_draw_interior() to the init()
  function, so that the new() function is only a wrapper of
  g_object_new() which is the proper way to implement new classes.
- Get rid of wrong comment.
2025-05-06 15:33:05 +02:00
lloyd konneker
2d7a1a5d6d libgimp: some code reorganization.
This commit message has been rewritten by the reviewer (Jehan) because
the original message was not right. It was originally meant to fix #13189
but it was only doing so as a side effect of getting rid of the slice
API.

We still push it as a second step (with updated message) because it's
not a bad idea to stop using the slice API where we can as it's anyway
no more than a malloc/free synonym since GLib 2.76 and might get
deprecated some day.
2025-05-06 15:33:05 +02:00
Jehan
cbd013d7b2 Issue #13189: free the slice with g_slice_free().
Even though this is mostly the same thing now, it's only true since GLib
2.76, yet our AppImage uses GLib 2.74.6. This explains why the chooser
finalization was crashing plug-ins.
2025-05-06 14:59:19 +02:00
Alx Sa
2c31c0e34d libgimp, plug-ins: Prevent GFig crash with NULL brush
The GFig plug-in assumes that there is always
a valid brush selected when creating its
dialogue. However, a NULL brush is possible,
and GFig's assumption can cause a crash
in GIMP by attempting to get a buffer from
a NULL brush.
This patch adds conditional checks for the
brush to not be NULL before using it.
2025-05-05 09:36:04 +00:00
Bruno Lopes
0fe938939c
libgimp/tests: Bump timeout to 90s (because 60 is not enough on Windows) 2025-04-21 12:30:50 -03:00
Bruno Lopes
f158cc2b6e
libgimp/tests: Port libgimp-run-python-test.sh to Python 2025-04-21 12:30:46 -03:00
Bruno Lopes
23b8867115
libgimp: Port libgimp-run-c-test.sh to Python 2025-04-18 21:53:22 -03:00
Bruno Lopes
00ab5e3a19
.gitlab: Move cp-plug-in-subfolder.py to build/meson
It is not a CI-specific file.
2025-04-18 13:36:31 -03:00
Bruno Lopes
ddcc51204b
libgimp: Port from cat to Python 2025-04-17 15:32:20 -03:00
Bruno Lopes
99bf8defe7
tools: Port in-build-gimp.sh to Python
Both .sh and .py versions take 2:15 minutes to generate all the
assets but the more cross platform the better so Python wins.
2025-04-16 13:41:16 -03:00
Bruno Lopes
63f5ea9dc5
build, meson, gitlab: Generate native .pdb CodeView symbols on Windows
Reverts dc21fb76

The CodeView format introduces some advantages to our Windows build:
- It is way smaller than DWARF, reducing the .exe installer. With
  the strip of COFF symbols too, the installation is 120MB smaller.
- Can be uploaded as .appxsym to be used on demand by MSIX (in thesis)
- Works better with DIA and DbgHelp debuggers like WinDbg and DrMingW,
  respectively. LLDB also works by using LLDB_USE_NATIVE_PDB_READER=1

Context: that was not working before because DrMingw and LLDB seems to
only search for the build-time .pdb path in '.buildid' section of bins.
See: https://github.com/jrfonseca/drmingw/issues/91 and
https://github.com/llvm/llvm-project/issues/125355. So, we will set
_NT_SYMBOL_PATH at least for $PREFIX/bin for now as workaround.
2025-04-14 07:50:43 -03:00
Jacob Boerema
5273f26ef0 app, pdb: fix #13480 inconsistent use of maximum radius...
for generated brushes.
The maximum radius we allowed for generated brushes was not used
consistently everywhere.
In the API call we clamped it to 0.0-32767.0, while the param_spec
set min and max to 0.1 and 4000.0, and the brush editor used a
maximum of 1000.0.
Using a large value (probably anything larger than 4000) would
sooner or later lead to a crash.

Instead of manual changes everywhere, let's define a maximum and
minimum in one place and use that wherever we need the min/max values.
Use the values as set in the param_spec for the defines.
The only place we can't easily do that is in brush.pdb, so we add
a comment above our defines that the values need updating there too.

Actually we should probably use more defines for other values too,
that way there is less chance of min/max values getting out of synch
throughout our code.
2025-04-11 02:02:40 +00:00
Jehan
c381390615 Issue #12636: _gimp_gp_param_def_to_param_spec throws WARNING on…
… a build of type "release".

Thanks to Lloyd Konneker for their original diagnosis of this issue!
2025-03-14 21:52:19 +01:00
Jehan
711be6db8c app, libgimp, pdb: clean up some more code redundancy. 2025-02-25 20:17:05 +01:00
Jehan
1e869b9ce0 libgimp: cleanup and adding missing doc-comment.
The comment about temporary API was added in commit 244b52bf0d for
functions long gone.
2025-02-25 20:01:29 +01:00
Jehan
ad0b02d2b7 app, libgimp, pdb, plug-ins: rename gimp_procedure_is_core() to…
… gimp_procedure_is_internal().

I realized we were already naming these "internal procedures" in the
Procedure Browser and this is in fact a better naming than "core
procedure".
2025-02-25 20:01:29 +01:00
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