Commit Graph

899 Commits

Author SHA1 Message Date
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
Luca Bacci 9ef4aee21b Fix warning about using %d format modifier for an unsigned type
GetLastError () returns a DWORD, which is a typedef for a 32 bit
unsigned integral.
2022-10-07 10:45:22 +00: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
Jehan ccbf3c4bb0 app, libgimp*: add various stamp files to CLEANFILES.
Fixes:

> ERROR: files left in build directory after distclean:
2022-08-01 23:34:50 +02:00
Jehan 83e465ec16 app, libgimp*: updating autotools script in sync with meson.
Generated *enums.c now have an additional stamp no-op header include
(see last 2 commits). Sync this change into the autotools generation
scripts to prevent back and forth useless generation of these files each
time we switch from one build system to another.
2022-08-01 20:00:01 +02:00
Jehan 979acaaae2 app, libgimp*: commit the newly generated *enums.c files.
They are nearly the same as initially, except that now they include an
intermediate stamp header which will be generated by the build system.

The only 2 enums which don't need these includes (and are not versioned)
are libgimp/gimpenums.c and libgimpthumb/gimpthumb-enums.c.
2022-08-01 20:00:01 +02:00
Jehan 106f2a061d Issue #8145: meson: generation of '*-enums.c' files.
Our meson build system was not properly building the enums.c file,
because they are versionned.

I did a similar trick as what I did for the pdbgen, which is that I used
a wrapper script around the existing perl script, which sets proper
options and generate a stamp file in the end (which is considered by
meson as the actual custom target, not the C file since it is generated
in the source dir).

The most important part is that the stamp file is a generated header
source (not just a random text file) which is **included** by the
generated C file. This is what will force meson to regenerate the C file
if the header is updated, **then** build using this new version, not use
an outdated versionned version (which would make for hard to diagnose
bugs), through the indirection of the intermediate stamp header.

See #4201.
See also: https://github.com/mesonbuild/meson/issues/10196#issuecomment-1080742592
2022-08-01 19:59:53 +02:00
Jehan 0cff1ebe91 Revert "app: force re-querying all plug-ins after a language change."
This reverts commit 82f9ae1ab7.

This is not needed anymore. Cf. previous commit which implements the
force-requery differently and much more widely based on actual language
being stored and compared between runs.
2022-07-06 19:41:00 +02:00
Jehan a7a027706b app: reload plug-ins when language changes between runs.
Since localization is fully handled plug-in side now (see #8124), we
need to make sure the query functions are run again for all plug-ins
when the UI language changes (otherwise we might end up with
localizations from the previously used languages).

We were already reloading plug-ins when explicitly changing the lang in
the Preferences, but this new implementation is much better as it's
generic. In particular, it will also handle the case when the system
language changes (or when you play with locale environment variables).
2022-07-06 19:33:00 +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
Jehan 95abf39066 app, libgimp: reverse internal l10n logic of plug-in labels in core app.
I hesitated a lot whether we should just drop the whole localization of
plug-ins' label and description (blurb) within the core. Actually the
commit messages I wrote a few days ago were moving towards this logic.
It really looks to me like plug-in localization can happen fully within
plug-in themselves. As far as I can see, the only advantage which the
current logic has theoretically is that if we needed, we have access to
both the original strings and their translations (e.g. it could be
useful for text search). Nevertheless I am not sure if we will ever make
use of this, and this is limited cases as all filters turned GEGL ops
don't have such ability anyway.

Nevertheless since previous contributors clearly put quite a lot of work
on this code of localizing the plug-in's label and description within
the main binary, I want to give myself a little more time to think and
study the whole thing because doing anything rash.

In the meantime, what changes is that by default now, a plug-in without
a local gettext catalog is simply not localized. In particular, the core
process doesn't try to localize it using the default catalog, a.k.a.
GETTEXT_PACKAGE"-std-plug-ins" ("gimp30-std-plug-ins"). It just doesn't
make sense and the worst which could happen would be to get unexpected
and wrong translations.
Now by default, plug-ins will try to find a catalog in their main
folder, named as this folder. If it fails to find it, a message is
printed to stderr and localization is disabled (rather than falling back
to a default catalog). It is up to plug-in developers to either install
a catalog, or implement set_i18n() to give the right catalog, folder, or
disable localization with gettext, as handled by libgimp.
2022-06-05 01:57:02 +02:00
Ben Rogalski d90b84ba9d Custom transparency checkerboard colors
Reviewer (Jehan) note: cherry picked from MR !274. Still deciding
whether this will be pushed to gimp-2-10 branch too.

Fixed Conflicts from !274:
	app/dialogs/preferences-dialog.c
	app/display/gimpdisplayshell-draw.c
	app/plug-in/gimppluginmanager-call.c
	libgimp/gimp.c
	libgimp/gimp.h
	libgimpwidgets/gimppreviewarea.c
	libgimpwidgets/gimppreviewarea.h
	libgimpwidgets/gimpscrolledpreview.c
2022-05-14 16:27:15 +02:00
Jehan 82f9ae1ab7 app: force re-querying all plug-ins after a language change.
Some strings might be generated during query() call, in particular all
strings related to procedure parameters. The core will only know the
localized version at query() time, so you could end up in situation with
the core showing you the wrong language. This can be reproduced in the
Procedure Browser when it shows localized procedure data: when you
change the language and restart GIMP, if the plug-ins aren't re-queried,
then it will still show the localization of query time.

Note that it doesn't matter on plug-in side, i.e. anything in the run()
call is properly localized, included the plug-in GUI using the same
procedure parameters for widget labels or tooltips. Only the "vision" of
the core is stuck at what it got when the plug-in was last queried, and
until the next update of the plug-in.
2022-04-27 15:22:32 +02:00
Jehan de1d71bb3f app, libgimp, pdb, plug-ins: batch CLI options now interpreter aware.
The CLI options now know which procedures are batch procedures or not.
First it means that it won't just randomly try any procedure name one
may pass and will properly output an error if you pass a non-existing
interpreter procedure.

Secondly, there is no default interpreter anymore (unless only one
interpreter exists). If you don't set an interpreter procedure with
--batch-interpreter or if you pass a wrong one, it will output the list
of available batch procedure, thus helping you understanding how to use
the --batch option.
2022-04-16 23:28:05 +02:00
Jehan 52b7273294 app, pdb, libgimp: new GimpBatchProcedure class.
This new class will be used to register procedures usable for batch
processing.
2022-04-16 18:50:28 +02:00
Jehan e72f5614da app: properly blink the right locked layer when pixels are locked.
In particular, if painting on a layer whose parent's pixels are locked,
we were blinking an empty lock spot, which is confusing. Now
gimp_item_is_content_locked() will also return the proper item (when
relevant, i.e. when returning TRUE) which is locked. It may or may not
the same item as passed in (it may also be a parent item in particular).
2022-02-15 22:08:23 +01:00
Niels De Graef 8eb7f6df9e Remove GimpStringArray in favor of GStrv
GLib has a specific type of NULL-terminated string arrays:
`G_TYPE_STRV`, which is the `GType` of `char**` aka `GStrv`.

By using this type, we can avoid having a `GimpStringArray` which is a
bit cumbersome to use for both the C API, as well as bindings. By using
`GStrv`, we allow other languages to pass on string lists 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 string 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
2022-02-12 00:07:53 +00:00
Jehan 49e534247a app, libgimp*, pdb, plug-ins: use g_memdup2() instead of g_memdup()
Since it appeared with GLib 2.68.0, we could not change this until we
bumped the dependency which has only become possible a few days ago
(since Debian testing is our baseline for dependency bumps). Cf.
previous commit.

As this is a drop-in replacement (just a guint parameter changed to
gsize to avoid integer overflow), search-and-replace with:

> sed -i 's/g_memdup\>/g_memdup2/g' `grep -rIl 'g_memdup\>' *`

… followed by a few manual alignment tweaks when necessary.

This gets rid of the many deprecation warnings which we had lately when
building with a recent GLib version.
2021-08-26 17:32:09 +02:00
Jehan ee09ae7245 app: fix gimp_plug_in_cleanup_item_new().
This fixes a memory leak as reported by Massimo.
But even more, we fix the code logics, as the cleanup items were never
added to the `item_cleanups` list.
2021-08-14 18:20:49 +02:00
Stanislav Grinkov 619cb91230 Remove unnecessary gimpmarshal.h and gimpwidgetsmarshal.h includes. 2021-08-13 18:01:13 +00:00
Jehan 1566d9437e app: make sure we send the origin display to plug-ins through PDB. 2021-04-30 03:48:12 +02:00
Jehan 2211ca7fd3 app: wait child processes with g_child_watch_add_full() rather than…
… waitpid().

My use case was when testing gimp_brush_select_new(). When doing tests,
if I let the brush dialog opened while letting the plug-in exit cleanly
otherwise, it somehow locked the process (I have stared so long at the
code and still don't understand why).
gimp_plug_in_close() would wait for it forever and the only way out was
to kill GIMP completely. I guess we could try to run waitpid() with
WNOHANG (and finally force-kill the child if it really won't exit) but
it made the whole logics extra complicated.

The logics with g_child_watch_add_full() is that we don't stop waiting
for the child and just set a callback to finalize what needs to be. Now
the worst case scenario would be to leave zombie processes dangling
around, but it's better than freezing GIMP.

Finally as a weird side effect, doing this change even unblocked the
process with an unfinished brush selector so we don't even have a zombie
anymore (at least for this specific case). All good in the end!

Last side effect: it can speed up a tiny bit the plug-in close as we
don't wait for processes anymore, which could be more visible at first
startups (when we reload all the plug-ins). Though there is nothing
scientific to my numbers, after multiple "first startups", it seems it
went down from about 3.5 to 3.2 seconds on my specific machine. Nothing
extra fancy, but we take what we can (and speeding up the startup was
never the goal of this change anyway). It doesn't affect Windows which
has its own logics to handle process termination and I preferred not to
touch it.
2021-04-29 02:19:41 +02:00
bootchk c6fde64815 GIMP-CRITICAL: gimp_marshal_VOID__OBJECT_STRING_STRING: assertion 'n_param_values == 4' failed 2021-04-24 15:00:42 +02:00
Jehan 811d356953 app: GimpAction now has a "reason" parameter to explain being disabled.
In some cases, in particular for actions generated from plug-in
procedure right now, we were displaying the reason of the insensitivity
(typically right now, only the drawable type is cited). This was done by
appending the reason to the tooltip, separated by 2 newlines, which
resulted in extra ugly design, no nice way to style this info directly
(with pango for instance if the widget display allows it, or on a
separate info widget in a possible future, or whatnot).

Also it would mean that the action search could match a disabled action
by mistake if a search word happens to be in the reason message.

This improves the situation with the following changes:
* gimp_action_set_sensitive() now takes an optional reason string to set
  the reason message.
* Same for gimp_action_group_set_action_sensitive().
* gimp_action_get_sensitive() returns an optional reason string.
* gimp_procedure_get_sensitive()'s tooltip return value now becomes a
  reason (it won't contain anymore the tooltip and the reason
  concatenated, only the reason for separate processing).
2021-04-23 19:43:30 +02:00
Jehan dc7853233b app, libgimp, pdb: new API to advertize when procedures are sensitive.
The new function gimp_procedure_set_sensitivity_mask() allows plug-ins
to tell when a procedure should be marked as sensitive or not.
gimp_procedure_get_sensitivity_mask() retrieves this information.

Currently plug-ins are automatically marked as sensitive when an image
is present and a single drawable is selected. Nowadays, we can have
multiple selected layers so we should allow plug-ins to tell us if they
support working on multiple drawables. Actually we could even imagine
new plug-ins which would be made to work only on multiple drawables.
Oppositely, there are a lot of plug-ins which don't care at all if any
drawable is selected at all (so we should allow no drawable selected).

Finally why not even imagine plug-ins which don't care if no image is
shown? E.g. plug-ins to create new images or whatnot. This new API
allows our core to know all this and show procedure sensitivity
accordingly. By default, when the function is not called, the 1 image
with 1 drawable selected case is the default, allowing existing plug-ins
easier update.

Note: this only handles the sensitivity part right now. A plug-in which
would advertize working on several layer would still not work, because
the core won't allow sending several layers. It's coming in further
commits.
2021-04-04 01:40:00 +02:00
Niels De Graef dffab0e9a4 Remove GimpInt16Array
It isn't being used by any plug-in or any code in GIMP at all even.
Let's get rid of it while we can still break API, so we can cut down on
all the complexity of the gimp-param stuff a bit.
2021-02-18 11:32:45 +00:00
Orgad Shaneh b134da1f39 Fix Python execution with autocrlf on Windows
If the interp file contains CRLF, the \r is read as part of the
executable file name, and gimp searches for python3.exe\r.
2021-02-09 21:58:50 +00:00
santouits 6e00a19fd0 Don't compile gimpmarshal source file many times
Also, removes gimpmarshal.h from a source file that didn't need it.
2020-09-13 18:13:29 +03:00
Jehan d3139e0f7c app: support saving/exporting with multi-selection.
This commit just changes our saving API (i.e. the GimpSaveProcedure
class) to take an array of drawables as argument instead of a single
drawable.

It actually doesn't matter much for exporting as the whole API seems
more or less bogus there and all formats plug-ins mostly care only
whether they will merge/flatten all visible layers (the selected ones
don't really matter) or if the format supports layers of some sort. It
may be worth later strengthening a bit this whole logics, and maybe
allow partial exports for instance.

As for saving, it was not even looking at the passed GimpDrawable either
and was simply re-querying the active layer anyway.
Note that I don't implement the multi-selection saving in XCF yet in
this commit. I only updated the API. The reason is that the current
commit won't be backportable to gimp-2-10 because it is an API break. On
the other hand, the code to save multi-selection can still be backported
even though the save() API will only pass a single drawable (as I said
anyway, this argument was mostly bogus until now, hence it doesn't
matter much for 2.10 logics).
2020-05-17 18:32:16 +02:00
Niels De Graef 878804fb01 Cleanup GObject signal marshallers
* Don't generate our own marshallers if they are available in GLib
  already
* Don't set the c_marshaller parameter in `g_signal_new()` if it's a
  default marshaller provided by GLib. See commit message of commit
  39e4aa3c57 on why this is the case.
2020-04-01 21:20:01 +00:00
Sabri Ünal 303ba93c5e 225614 Copy-paste error
Copy-paste error: extensions in proc->extensions looks like a copy-paste error.
Should it say prefixes instead?

(cherry picked from commit c326552872)
2019-10-20 15:27:37 +02:00
Jehan b8d8424ae0 app, libgimp*: (meson) fix all the generated `*-enums.c`.
More of the files were wrong, or at least not absolutely identical to
the files generated by the autotools. I am not doing any code change
other than trying to make both build systems produce identical files
(except for slight differences on 2 files not worth the effort) even
though maybe some things can be improved (especially on the include
list). Maybe to be improved later.

Also fixing 2 of the previously autotools-generated files because of
space typos which should have been committed earlier.

Finally it is to be noted that there is no logics to copy the generated
files back to the source directory in the meson rules. I am not sure
anyway this is really worth it and maybe we should just stop tracking
these generated files eventually.
2019-10-19 22:32:29 +02:00
Michael Natterer 1c7028aaaa app, libgimp: add boolean "export-comment" gimprc property
export it to libgimp via GPConfig and add new API gimp_export_comment().
Bump the protocol version and improve variable names in both GPConfig
and libgimp/gimp.c.
2019-10-10 00:48:28 +02:00
Ell 5cc289b642 libgimpbase, libgimp, app: inherit swap-compression in plug-ins
Pass the swap-compression option set in the preferences down to
plug-ins, so that they use the same swap-compression algorithm as
the main app.
2019-09-22 18:05:24 +03:00
Michael Natterer dbd793d631 libgimpconfig: get rid of filenames in all config related APIs
and rename function names which say "gfile" to just "file".
2019-09-21 12:55:12 +02:00
Michael Natterer 6de4af4ade pdb: change paths and URIs in the "plug_in" group to GFiles 2019-09-11 23:54:53 +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
Michael Natterer a5ac3e45fe libgimpbase, libgimp, app: add libgimp support for passing GFiles
Which means support for GParamSpecObject with value_type ==
G_TYPE_FILE, and converting between GFile and its URI for wire
communication directly above the protocol layer.

This change requires passing a GParamSpec's value type as generic
member of GPParamDef, which in turn makes some members of its
sub-structures obsolete.
2019-09-11 21:40:17 +02:00
lillolollo a2b74147c9 Fixing error on Windors meson build 2019-09-11 17:21:17 +00:00
Félix Piédallu ba6973e791 Fix Meson some changes not pulled from Autotools 2019-09-11 17:10:47 +02:00
Félix Piédallu 65eff6f150 Meson port. 2019-09-11 16:42:04 +02:00
Michael Natterer f3fb3d1a57 Remove the second "raw-filename"/"raw-uri" parameter from file procedures
It's an ancient concept from ancient times when we didn't have URIs
and only filenames (not to speak of GFile), and actually even from
before the ancient time before that ancient time when we first had
ones and zeros, and only had zeros.
2019-09-11 00:21:03 +02:00
Michael Natterer fee551810b app: fix adding file procedures from pluginrc
gimp_plug_in_manager_add_to_db() used to call the PDB in order
to properly register file procedures from pluginrc. This broke
when I moved code to gimpplugin-file.c.

Instead, add gimp_plug_in_manager_add_load_procedure() and
gimp_plug_in_manager_add_save_procedure() and call them from both
gimpplugin-file.c and gimp_plug_in_manager_add_to_db(), which also has
the nice side effect that more GimpFileProcedureGroup logic gets moved
to its place in gimppluginmanager-file.c and less magic is needed in
gimpplugin-file.c.
2019-09-10 21:19:00 +02:00
Michael Natterer 21ff9999e4 app: remove gimppluginmanager-file-procedure.[ch]
and merge it into app/plug-in/gimppluginmanager-file.c, it's used from
nowhere else.
2019-09-10 20:20:40 +02:00
Michael Natterer ff9b469808 app: move the file procedure registering functions into gimpplugin-proc.c
They are simply setting properties on GimpPlugInProcedures, just like
the other functions in gimpplugin-proc.[ch], so there is no reason to
have them elsewhere and with worse checks and error messages.
2019-09-10 20:05:27 +02:00
Jehan b73519830e app: gimp-register-magic-load-handler renamed in a previous commit.
Cf. commit 0745043ddb.
2019-09-10 15:03:28 +02:00
Michael Natterer b1683ce692 app: remove all check for the <Load> and <Save> menu prefixes
they are an ancient concept not supported any longer.
2019-09-10 12:14:57 +02:00
Michael Natterer a88aa27942 app: use GError in all gimpplugin-proc.[ch] functions, not gimp_message() 2019-09-09 12:10:32 +02:00
Michael Natterer 41fa670434 Rename all "nparams" and "nreturn_vals" members in the wire protocol
to "n_params" and "n_return_vals".
2019-09-09 01:00:54 +02:00
Michael Natterer 64572b00f5 app: clean up gimp_plug_in_handle_proc_install()
Remove the hack that turns the first integer argument into
enum GimpRunMode and simplify the UTF-8 validation code.
2019-09-09 00:42:24 +02:00