Commit Graph

1320 Commits

Author SHA1 Message Date
lloyd konneker 36521f5db2 Fix so that ScriptFu test scripts are not localized. 2022-08-06 14:37:56 +00:00
lloyd konneker ceddb0d369 Fix #8465 2022-08-06 10:02:17 -04:00
lloyd konneker 031601a92a Fix 8452, crashing scripts.
Bugs in earlier enhancements re GFile, GEnum.
2022-08-03 15:51:15 -04:00
lloyd konneker 974f694cd2 ScriptFu: scripts use v3 API for multilayer gimp_image_get_selected_drawables etc.
Commit a6aba929 deleted the old functions.

Misc drive-by fixes for gtk_adjustment step not < pages

Issue #8155 discusses alternative fixes, convenience functions for compatibility in ScriptFu.
There is one compat function defined already in ScriptFu, temporarily: gimp-image-get-active-drawable
which was written so that testing clothify-v3.scm could proceed.
2022-08-03 12:48:07 +00:00
lloyd konneker 12c0c18036 ScriptFu: script-fu-register-filter for GimpImageProcedure.
Resolves #8382

Also v2 scripts infer and set sensitivity to drawables

Add two test plugins clothify-v3.scm and test-sphere-v3.scm.
Temporary, to be removed when 3.0 ships.

Some refactoring (extracting methods, moving functions to new files).

Some drive-by fixes to script-fu-arg.c revealed by using GimpProcedureDialog.
2022-08-02 07:45:35 +00:00
Jehan ca1a0e3650 plug-ins: gimp-plug-in-domain-register PDB procedure doesn't exist…
… any longer.

It's not deprecated in favor of a new name, it just doesn't exist as it
was removed in commit 81b569cb8c.
2022-07-06 16:14:03 +02:00
lloyd konneker c2b13d6f91 ScriptFu: register args with proper GParamSpecs
Resolves #8328

Except existing GimpParamSpecs seem inadequate to specify less generic widget kinds.
2022-07-05 19:17:52 +00:00
Jehan df074bfe09 plug-ins: label and documentation of plug-ins localized plug-in side.
This is the consequence of previous commit. Plug-ins' label and
documentation are now localized before sending these data to GIMP core.
In other words, we replace N_() macros with basic gettext calls.
2022-07-05 12:23:51 +02:00
lloyd konneker fadae20618 ScriptFu: Extract informal class SFArg from script-fu-script.c
Why: puts most methods for SFArg (a struct) in one place, for ease of maintenance.
Prepares to fix issue 8328.  Prepares to make SF use GimpProcedureDialog.

Mostly moving code, with no intended change in functionality,
except fixed an property.nick for an arg is now what a script author provided,
instead of generated.

All internal to libscriptfu.  No changes to the exported API or to i18n.

Lightly tested, since more substantive changes coming for issue 8328.
ScriptFu>Test>Sphere is the test case.
2022-07-04 08:28:19 +00:00
lloyd konneker ea81ae747d ScriptFu: delete unneeded #define G_LOG_DOMAIN
It clutters the compile log.
Compile flag -DG_LOG_DOMAIN="scriptfu" now does this.
2022-06-30 13:44:07 -04:00
lloyd konneker d5a83429b4 ScriptFu: Add script-fu-interpreter akin to other interpreters
Why:
1) users can install .scm scripts to plug-ins dir
2) Crashing scripts do not crash extension-script-fu

Scripts (.scm files) have a shebang and are executable
and in a same-named subdir of plugin dir.

Interpreter/scripts create PDB procs of type PLUGIN unlike extension-script-fu
which creates PDB procs of type TEMPORARY, owned by extension-script-fu.

Unlike other interpreters, the interpreter is-a plugin outright,
not by virtue of the script subclassing GimpPlugin and using GI.

More details in /plug-ins/script-fu/interpreter/README
2022-06-30 13:39:45 +00:00
lloyd konneker 07ceb5a086 ScriptFu: extract PDB proc script-fu-server from plugin script-fu
Create new plugin file script-fu-server-plugin.c
with code extracted from script-fu.c, which is an omnibus plugin
implementing PDB proc extension-script-fu and other PDB procs.

Why:

1. extension-script-fu is smaller and doesn't doesn't link to socket libraries.
   (GIMP always starts extension-script-fu and it stays running.)

2. packagers/admins can omit script-fu-server executable from an installation,
   if they think letting users serve net ports is not secure.

3. crashing script-fu-server does not crash extension-script-fu,
   which requires restart of GIMP

The changes are mostly a simple refactor, extracting code.
No functional change apparent to users.
Low risk of introduced bugs.
Extremely few users use script-fu-server anyway.
Added some logging.
While at it, use G_DECLARE_FINAL_TYPE
2022-06-19 19:18:39 +00:00
Jehan 73868afe15 plug-ins: fix script-fu build in meson.
Fixes:

> plug-ins/script-fu/meson.build:44:0: ERROR: Bad source of type 'SharedLibrary' in target 'script-fu'.
2022-06-15 21:18:37 +02:00
lloyd konneker 5cc3becf16 ScriptFu: build shared libgimp-scriptfu-3.0.so separate from executable script-fu
Changes are mostly to the dir structures and build system for ScriptFu.
Some changes to the outer plugin source to call the library.

Why: so that other executables (future gimp-scheme-interpreter,
or a future separated script-fu-server) can exist in separate directories,
and share the library in memory (when built shared.)

Whether the library is built shared and installed on its own
(versus static and not installed)
is a compile time option (both automake LibTool and meson abstract it away)
The default is shared and installed, say as libgimp-scriptfu-3.0.so.

Installed alongside other shared libraries (e.g. wherever libgimp is installed)
to simplify packaging.

A preliminary refactoring which helps enable MR gimp!647
2022-06-11 08:58:30 -04:00
Jehan 18c37f7084 plug-ins, libgimp: override set_i18n() for all our core plug-ins.
Hence avoiding the stderr messages. These are going to be localized with
centrally installed catalogs "gimp*-std-plugins", "gimp*-script-fu" and
"gimp*-python".

We now handle core plug-in localizations differently and in particular,
with kind of a reverse logic:

- We don't consider "gimp*-std-plugins" to be the default catalog
  anymore. It made sense in the old world where we would consider the
  core plug-ins to be the most important and numerous ones. But we want
  to push a world where people are even more encouraged to develop their
  own plug-ins. These won't use the standard catalog anymore (because
  there are nearly no reasons that the strings are the same, it's only a
  confusing logic). So let's explicitly set the standard catalogs with
  DEFINE_STD_SET_I18N macro (which maps to a different catalog for
  script-fu plug-ins).
- Doing something similar for Python plug-ins which have again their own
  catalog.
- Getting rid of the INIT_I18N macro since now all the locale domain
  binding is done automatically by libgimp when using the set_i18n()
  method infrastructure.
2022-06-05 01:57:02 +02:00
Kevin Cozens 38e4d5490b Eliminated possible compiler warning. From r130 of TinyScheme in SourceForge. 2022-05-31 19:31:05 -04:00
Kevin Cozens 0af582f309 Allow only one exponent in numbers. From r129 of TinyScheme in SourceForge. 2022-05-31 19:31:05 -04:00
Kevin Cozens 4772f57827 Use trunc() from C99. From revision 128 of TinyScheme in SourceForge. 2022-05-31 19:31:05 -04:00
Kevin Cozens afca1926f1 Use x and y at top of opexe_2 to save repeating some car() and cadr() calls.
From SVN version 127 of offical version of TinyScheme.
2022-05-31 19:31:05 -04:00
Kevin Cozens 511ada844e Syncing TinyScheme with the 1.42 version in the SourceForge repository.
This picks up changes applied in SVN revisions 120 and 124 which
both clean up compiler warnings.
2022-05-31 19:31:05 -04:00
Kevin Cozens 73e5ef394f R5RS compliance fix. Return proper type for remainder and modulo.
Also fixed quotient to only take two arguments. Applied minor
optimization in execution of quotient, remainder, and modulo.
From revision 122 of the TinyScheme repository in SourceForge.
2022-05-31 19:31:05 -04:00
Kevin Cozens 53b7a0935e String-ref, string-set!, vector-ref, and vector-set! index must be integer.
R5RS compliance fix. From bug #42 reported in the SourgeForge bug tracker.
2022-05-31 19:31:04 -04:00
Kevin Cozens e0b6a9cab2 Syncing TinyScheme with the 1.42 version in the SourceForge repository.
This picks up changes applied in SVN revisions 100, 103, 106, and 113.
The TinyScheme version number has been updated.
2022-05-31 19:31:04 -04:00
lloyd konneker a3b242b2c5 ScriptFu: Break mutual includes between script-fu-server and scheme-wrapper
Instead, make outer script-fu-server register callbacks with inner scheme-wrapper.

Why? the inner scheme-wrapper should not know about the outer script-fu-server.
The change will allow a future, smaller scriptfu shared library,
that does not contain networking code.
We want a scriptfu library shared by separate script-fu-server,
future gimp-scheme-interpreter (!647), and script-fu executables.

This change does not alter observable functioning of the script-fu-server.
Except that I also changing the logging by script-fu-server,
so that I could test the changes.
I put a test plan in the comments.
2022-05-29 08:48:17 -04:00
Jacob Boerema e268d38fb1 plug-ins: remove unnecessary Windows specific code in tinyscheme
Removal of the snprintf define was also part of the UCRT Windows patch
in MINGW. Although it builds fine without this change, there is no need
anymore to redefine snprintf. In addition, I seem to remember that
_snprintf had a shortcoming.

So let's remove the Windows specific code, since it works fine without it.
2022-05-17 17:23:06 -04:00
lloyd konneker 5e9c92c5de plug-ins: fix script-fu-font-map error receiving GStrv
Why: MR !389 changed the signature of PDB procedures to return GStrv instead of (int, GimpStringArray)
This changes handling of results from a call to such a changed signature, in a Scheme script.

The symptom was a cryptic TinyScheme "Error: car: argument 1 must be : pair"

Most changed procedures are named like "-list".
I did a cursory grep to look for other instances.

Updated porting guide doc.
2022-05-07 19:14:42 +00:00
lloyd konneker 1846f91305 Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.
Why: in v3 the signature for gimp-edit-foo PDB procedures changed to support multilayer selection.

This finishes the task for ScriptFu scripts in the GIMP repo.
This is not a complete list, since some calls were changed incidentally by prior commits.
You can grep for "edit-copy" etc. in script-fu/scripts to find instances.

This also makes incidental changes, to script calls to plug-in-tile,
which now also has a changed signature to support multilayer.

The changes are simple code transformations.
The changes to gimp-edit-paste calls are more complex,
a mixed bag of a few lines transformed to more lines.
I did not try to understand the larger logic of the changed plugins.
I did not test the changed plugins functionally.
I used a harness to call each changed plugin with improvised parameters,
only checking that the test plugin did not throw runtime errors,
not checking that they produced correct images.

As noted in the issue, this might be undone if the original signatures
for gimp-edit-foo are restored as convenience functions.
2022-05-06 20:44:33 +00:00
lloyd konneker 5e1dd03c52 plug-ins: fix PDB proc script-fu-selection-to-pattern
Why: this commit fixes PATTERN using code that commit 708f3228  fixed for BRUSH.

Importance:
There doesn't seem to be any issues it resolves.
No code in the GIMP repo seems to call this procedure.
I don't know whether third party plug-ins rely on this procedure.
Anyway, fix it so a brute force test works.
2022-05-05 13:10:48 +00:00
lloyd konneker a1f0757ee7 Fix #8091 ScriptFu scripts use v3 API for drawables in calls to file procedures
This change is part of multilayer select feature of v3.

Only fixes ScriptFu plugins, not Python or C.
Only fixes calls to file load/save procedures and other plugins already multilayer capable.
Any future PDB procedures changed to have multilayer signature will require changes to all callers.

The new code is verbose: "drawable" => "1 (vector drawable)"
Issue 5919 proposes a change to the PDB that would make this less verbose:
"drawable" => (vector drawable)" (without the number of drawables)

Tested that changed procedures will interpret without syntax errors, on one path.
Did not test each changed procedure for functional correctness.
2022-05-03 16:17:44 +00:00
lloyd konneker 513d331ae2 Fix #6842 by deleting second of two strings passed for filenames, in scripts 2022-04-30 11:53:02 +00:00
Jehan c1d2f35b73 app, plug-ins: redirect plug-in-script-fu-eval to text console in…
… plug-in code.

In particular, we should not hardcode this in core code anymore. The
behavior is otherwise exactly the same, except that we made the core
code generic as it should be.
2022-04-17 14:25:44 +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 0555a6815e plug-ins: port plug-in-script-fu-eval to GimpBatchProcedure. 2022-04-16 18:50:29 +02:00
Nikc 14fd817b24 Fixes issues with fade-out breaking the script
(cherry picked from commit 09eccc9989)
2022-03-30 20:53:06 +02:00
lloyd konneker dd828f94cc Fix #6839 by deleting call to gimp-context-set-transform-recursion 2022-03-25 18:05:26 +00: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 7dda738e8b plug-ins: update more script-fu scripts.
(gimp-image-get|set-active-layer) now ported into calls to
(gimp-image-get|set-selected-layers).
2021-12-23 12:55:11 +01:00
Jehan 708f3228d9 plug-ins: fix select-to-brush script.
The following calls needed to be updated:
gimp-image-set-selected-layers, gimp-edit-copy, gimp-edit-paste and
file-gbr-save.
2021-12-23 12:55:11 +01:00
Jehan 9dd6c1c467 plug-ins: fix lava script-fu script.
It was calling plug-in-gradmap with old single-layer API hence failing.
Also replacing all calls to (gimp-image-set-active-layer) and
(gimp-image-get-active-layer) in this file with
(gimp-image-set-selected-layers) and (gimp-image-get-selected-layers)
respectively.
2021-12-23 12:55:11 +01:00
Emily Gonyer 3afa37cbc6 app, libgimp*, plug-ins: Changed gendered terms to be gender-neutral
Changed a handful of gendered terms to be gender-neutral, and one typo 
of 'he' to 'the' where appropriate.
2021-11-14 11:22:24 +00:00
Ondřej Míchal 01516591f6 plug-ins: Silence some warnings 2021-10-18 09:32:25 +00:00
programmer-ceds 6664b31d68 SF-ADJUSTMENT Slider Duplicate Label Fix 2021-08-04 00:23:04 +00:00
lloyd konneker e57304f71a Issue #5402 Scriptfu handle GFile and GimpObjectArray types 2021-05-24 13:28:50 +00:00
Jacob Boerema ed35579861 script-fu: fix #6741 Round Corners script fails to work on layer masks
The round corners script was assuming that the drawable always
was a layer, which is incorrect when a layer mask is selected.

We fix this by always requesting the active layer instead of
active drawable.

We also enable this script for RGB and GRAY with alpha
channel. Although it might not always make sense to
use this script when an alpha channel is present, there
can be use cases where it is perfectly fine.

So let the designer decide if this script is suited or not
instead of GIMP making that judgement.
2021-04-24 12:41:41 -04:00
Jehan 69fdcf5d3f plug-ins: use g_mkdir() for generic cross-platform code.
This fixes the following error when building for Windows:

> error: too many arguments to function ‘mkdir’

On Windows, mkdir() is deprecated, it is an alias for _mkdir() which
doesn't have a mode parameter. The GLib version duplicates the POSIX
signature and is cross-platform (mode is simply ignored on Windows).
2021-04-24 17:03:43 +02:00
saul 11906fa82c plug-ins: Add 'dir-make' procedure to Script-fu.
Closes: GNOME/gimp#541

Reviewer note: thanks to Stanislav Grinkov for cleaning up and reworking
a bit the patch, such as renaming the procedure to dir-make, as per
Kevin Cozens' review.
2021-04-24 15:09:24 +02:00
bootchk 877d585271 Partial fix 5426. Lets old scriptfu script call old name gimp-image-is-valid,
mapped to new PDB procedure gimp-image-id-is-valid (same signature), for example.

Edit a few comments in new code.

Style changes, no logic change.
2021-04-22 11:27:22 -04:00
bootchk 34150ddda7 Use g_logging and migrate functions for author's errors to separate source file.
Eliminate conditional compile for debugging.
2021-04-22 11:01:43 -04:00
Jehan 65e10faf50 plug-ins: change non-existing brush.
Fixes:
> Calling error for procedure 'gimp-brush-get-pixels':
> Brush 'Circle (03)' not found

The data/brushes/Circle-3.vbr brush doesn't exist since commit
7aa12175a4 in 2012 as far as I can see.
2021-04-21 17:50:24 +02:00
Jehan fb84b9eba7 plug-ins: fix a bunch of Scheme scripts after API functions renaming.
Since we renamed a bunch of functions for consistency (the like of
gimp_image_width() to gimp_image_get_width() and others), most Scheme
scripts ended up broken. This is a simple bash fix with `sed` to at
least take care of these simple renaming cases.

Many scripts are still broken for other reasons after our API evolution
(to be continued).
2021-04-20 17:47:11 +02:00