Commit Graph

74 Commits

Author SHA1 Message Date
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
Michael Natterer 9cb62f5f9a libgimp: move "image" and "run_mode" from gimp_procedure_config_end_run()
and remember them internally between begin_run() and end_run().
Simplifies plug-in code even more.

Move the begin_run() before gimp_export_image() block in all export
plug-ins.
2019-09-26 00:44:52 +02:00
Michael Natterer 58bf1d431d libgimp: add a "status" parameter to gimp_procedure_config_end_run()
and require it to be always called paired with begin_run(), which is
more straightforward and makes the resulting code more future-proof.
2019-09-25 12:09:03 +02:00
Michael Natterer 104ddb1374 plug-ins: minor follow-up cleanup in file-gbr 2019-09-23 23:24:42 +02:00
Michael Natterer b8fb09d330 plug-ins, app: port file-gbr to GimpProcedureConfig
and use the new feature of saving the last config in an image
parasite.

In app/file-data/fie-data-gbr.c, manually construct the same parasite
when loading a brush, so its spacing and description are stored in the
image.

This replaces the "gimp-brush-name" parasite which is now obsolete.
2019-09-23 19:49:36 +02:00
Michael Natterer df8d5b02ae libgimp, plug-ins: remove the "preview" parameter from gimp_ui_init()
It's dead since a looong time.
2019-09-20 19:56:00 +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
Sabri Ünal a60ac57207 Missing mnemonics on several file dialogs
This path corrects missing mnemonics on several save/open/export dialogs.

save: file
open: file, dds, fits, tiff
export: bmp, dds, fli, gbr, gih, mng, pat, pnm, pdf, raw, sunras, sgi, webp
2019-09-09 18:06:29 +00:00
Michael Natterer 8a78203aed Properly prefix the values of enum GimpPDBProcType
to be GIMP_PDB_PROC_TYPE_PLUGIN, _EXTENSION etc.
2019-08-30 12:52:28 +02:00
Michael Natterer 392f00baf5 app, libgimp: get rid of all ID GTypes and ID param specs
Turn all ID param specs into object param specs (e.g. GimpParamImageID
becomes GimpParamImage) and convert between IDs and objects in
gimpgpparams.c directly above the the wire protocol, so all of app/,
libgimp/ and plug-ins/ can deal directly with objects down to the
lowest level and not care about IDs.

Use the actual object param specs for procedure arguments and return
values again instead of a plain g_param_spec_object() and bring back
the none_ok parameter.

This implies changing the PDB type checking functions to work on pure
integers instead of IDs (one can't check whether object creation is
possible if performing that check requires the object to already
exist).

For example gimp_foo_is_valid() becomes gimp_foo_id_is_valid() and is
not involved in automatic object creation magic at the protocol
level. Added wrappers which still say gimp_foo_is_valid() and take the
respective objects.

Adapted all code, and it all becomes nicer and less convoluted, even
the generated PDB wrappers in app/ and libgimp/.
2019-08-29 11:39:34 +02:00
Jehan d6365c778e plug-in: port file-gbr to GimpImage/GimpDrawable. 2019-08-22 15:54:36 +02:00
Michael Natterer 4cb4b3ef3a plug-ins: port all plug-ins to the new macros 2019-08-20 01:03:38 +02:00
Michael Natterer d62e75a41f Move GimpParamSpecString from libgimp back to app
It's just too weird to be public. Remove its properties from the wire
protocol and from pluginrc. Instead, have all GParamSpecs' flags on
the wire and in pluginrc, so we can use stuff like
GIMP_PARAM_NO_VALIDATE.

Port the remaining few places to GIMP_PROC_ARG_STRING().

I'm sure something is broken now wrt UTF-8 validation,
will add tighter checks in the next commit.
2019-08-19 12:54:52 +02:00
Michael Natterer de121374ef Change the "handles uri" flag of file procedures to "handle remote"
And always pass URIs to all file procedures, the ones what didn't
register as "handles remove" will only ever get local file:// URIs.

Change all file plug-ins (also legacy ones) to expect URIs instead
of filenames, and convert to local paths in the plug-in.

The wire protocol should now be almost 100% clean of non-UTF-8 strings.
2019-08-19 12:05:12 +02:00
Michael Natterer 9cabc8c8d0 libgimp, plug-ins: use the new macros everwhere
Except for gimp_param_spec_string() which is on its way back to the
core.
2019-08-19 10:02:07 +02:00
Michael Natterer 15019fef52 plug-ins: port many plug-ins from GimpProcedure to GimpImageProcedure
Also move the call to set_icon_name() after set_menu_label(), all
ported plug-ins should look the same so we are a good example for copy
and paste ;)
2019-08-18 13:45:58 +02:00
Michael Natterer b007269729 Use g_strlcpy() instead of strncpy() everywhere
except where I didn't understand the code after 10 seconds of
looking..
2019-08-14 23:52:38 +02:00
Michael Natterer 1e717a0dc6 plug-ins: port file-gbr to GimpPlugIn, and clean up file-pat a bit 2019-08-13 13:36:20 +02:00
Ell 8954d1f386 libgimpwidgets, app, plug-ins: use GimpSpinButton everywhere
Replace all direct uses of GtkSpinButton with GimpSpinButton, so
that its modified behavior extends to all our spin buttons.
2019-03-09 07:28:52 -05:00
Michael Natterer 90164c4951 app, plug-ins: move brush (gbr) saving to the core
just the export logic remains in the plug-in, just as for patterns.
2019-02-16 19:01:33 +01:00
Michael Natterer a4e77e57f6 app, plug-ins: start consolidating brush and pattern loading/saving code
We currently have brush and pattern I/O code in both the core and
plug-ins. This commit starts removing plug-in code in favor of having
one copy of the code in the core, much like XCF loading and saving is
implemented.

Add app/file-data/ module with file procedure registering code, for
now just with an implementation of file-gbr-load.

Remove the file-gbr-load code from the file-gbr plug-in.
2019-02-11 12:51:31 +01:00
Jehan 66ec467217 plug-ins: make various usage of g_file_replace() safer.
As I did on app/, finalizing an output stream also implicitly flushes
and closes it. Hence if an export ended with an error, we'd end up with
incomplete data file (possibly overwriting a previously exported image).
Only 2 plug-ins I haven't fixed yet are file-tiff-io and file-gif-save.
The later one don't even clean up its memory (which somehow is good here
as at least the output stream is never finalized hence sane files are
not overwritten in case of errors). As for the former (TIFF plug-in), it
doesn't even seem to have any error control AFAICS, apart from printing
error messages on standard error output.
2018-11-27 12:41:22 +01:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Michael Natterer 9b56ca8c1d Issue #1730 - pat file that crashes gimp-2.10
Introduce GIMP_PATTERN_MAX_SIZE (10000) and GIMP_PATTERN_MAX_NAME (256)
and validate pattern dimensions and pattern name length against them.

Add GIMP_BRUSH_MAX_NAME and validate that too.

Also make sure that the names are properly terminated, and some
cleanup.
2018-07-06 13:07:28 +02:00
Michael Natterer 8195a56261 app, plug-ins: move GIMP_BRUSH_MAX_SIZE to gimpbrush-header.h
and use it in the brush file plug-ins.
2018-07-06 12:31:06 +02:00
Michael Natterer e759ce3558 app, plug-ins: clean up gimpbrush-header.h and gimppattern-header.h
Namespace the header structs, s/GBRUSH/GIMP_BRUSH/,
s/GPATTERN/GIMP_PATTERN/.
2018-07-06 12:06:08 +02:00
Michael Natterer 80997a8646 Remove most GTK_ADJUSTMENT() and (GtkAdjutment *) casts
they are obsolete in GTK+ 3.x because GtkAdjustment cannot be passed
around as GtkObject any longer, GtkObject is gone.
2018-06-24 18:15:16 +02:00
Simon Budig def4acc842 common: kill GtkTable in a ton of plugins 2018-05-20 21:06:33 +02:00
Tobias Stoeckmann 764056e124 Bug 789612 - Prevent heap overflow in GBR parser
It is possible to trigger a heap overflow with insanely large GBR
files with a deprecated file format on 32 bit systems.

The problem is that old versions of GBR allowed an additional pattern
after the brush data. These patterns have always 4 bytes per pixel,
but the initial size check is performed with the bytes per pixel of
the brush, which can be different.

If the brush has 1 byte per pixel and the dimensions are sufficiently
large, this can trigger a heap overflow with attacker-controlled
amount and content of data.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2018-01-01 17:15:38 +01:00
Jehan ba759fbcfd Revert "Bug 790784 - (CVE-2017-17784) heap overread in gbr parser / load_image."
This reverts commit 06d24a79af.

The CVE is still fixed but now in a different way. Commit 4fa0cd4dcf
passes instead the accurate string length when using the string, hence
making it work even when not NUL-terminated. This has the advantage of
having the GBR file loaded in the end, despite such file format error. I
am personally not persuaded this is the best path since a file with such
an error may either be corrupted, or worse may have been constructed on
purpose to be harmful, so rejecting it directly may be the safe choice.
Nevertheless I may also be too doubtful and maybe trying to save a
slightly corrupted file may be the nicest choice indeed.
2017-12-21 22:14:39 +01:00
Tobias Stoeckmann 4fa0cd4dcf gbr/pat: Fix out of boundary read on illegal names
The file formats GBR and PAT contain names which are supposed to be
NUL-terminated within the files. If no such terminating NUL byte
exists, the parsers of GBR and PAT trigger an out of boundary read
during utf-8 conversion.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2017-12-21 22:09:54 +01:00
Jehan 5b9e277625 app, plug-ins: clean up previous commit by using g_error_set()...
... instead of g_message().
2017-12-21 21:55:04 +01:00
Massimo Valentini 657a754f98 Bug 789610: invalid gbr brush crashing GIMP 2017-12-21 21:50:09 +01:00
Jehan 06d24a79af Bug 790784 - (CVE-2017-17784) heap overread in gbr parser / load_image.
We were assuming the input name was well formed, hence was
nul-terminated. As any data coming from external input, this has to be
thorougly checked.
2017-12-21 12:15:34 +01:00
Michael Natterer e16c8a2352 Move the new "default_new_layer_mode" APIs to the image...
...in both the core and libgimp.

Images now know what the default mode for new layers is:

- NORMAL for empty images
- NORMAL for images with any non-legacy layer
- NORMAL_LEGAVY for images with only legacy layers

This changes behavior when layers are created from the UI, but *also*
when created by plug-ins (yes there is a compat issue here):

- Most (all?) single-layer file importers now create NORMAL layers
- Screenshot, Webpage etc also create NORMAL layers

Scripts that create images from scratch (logos etc) should not be
affected because they usually have NORMAL_LEGACY hardcoded.

3rd party plug-ins and scripts will also behave old-style unless they
get ported to gimp_image_get_default_new_layer_mode().
2017-08-21 20:18:00 +02:00
Michael Natterer 838449254a plug-ins: use gimp_get_default_new_layer_mode() for most new layers
instead of hardcoding NORMAL_LEGACY.
2017-08-20 17:12:46 +02:00
Tobias Stoeckmann 13ed12d2b3 plug-ins: avoid OOB write on malicious GIH files.
Integer overflows allow out of boundary writes while reading GIH files.

The checks are copied from file-gbr.c. In turn, the necessary gsize
casts are added in file-gbr.c, too. These are important on 64 bit
systems. Without these casts, the precision of the calculation is still
32 bit, allowing overflows.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2017-04-08 22:31:50 +02:00
Michael Natterer dda54c1df8 Deprecate stock items for good and change all icon defines to GIMP_ICON_*
Try to sort all GIMP_ICON_* defines into FDO categories like in
https://specifications.freedesktop.org/icon-naming-spec/latest/ar01s04.html

Add defines for all icons we override, rename some icons to their FDO
standard names, and mark the ones we duplicate with a comment so we
don't forget to rename those to standard names in 3.0.
2017-03-05 16:01:59 +01:00
Michael Natterer 3cf423f0cd *: rename NORMAL to NORMAL_LEGACY and NORMAL_LINEAR to NORMAL
and make NORMAL_LEGACY immutable.
2017-02-26 16:26:34 +01:00
Michael Natterer 66060e3307 app, libgimp*, plug-ins: replace enum GimpLayerModeEffects by GimpLayerMode
with proper value names. Mark most values as _BROKEN because they use
weird alpha compositing that has to die. Move GimpLayerModeEffects to
libgimpbase, deprecate it, and set it as compat enum for GimpLayerMode.
Add the GimpLayerModeEffects values as compat constants to script-fu
and pygimp.
2017-01-08 23:00:19 +01:00
Jehan ec27b539ea plug-ins: various s/save/export/ replacement on visible strings. 2016-02-16 02:35:43 +01:00
Michael Natterer 84182125cf Bug 739488 - Set default brush, brush pipe, pattern name to the file's basename
If there is no gimp-[brush|pattern|brush-pipe]-name parasite,
default to the file's basename without extension, instead of
always "GIMP Brush" etc.

Also clean up the code, and make the plug-ins do the same things the
same way.
2014-11-05 02:38:04 +01:00
Michael Natterer 51c35d4c78 Bug 739486 - Enter doesn't confirm "export image as brush"
Set the "activates-default" property on the spinbutton and entry in
the file-gbr-save dialog.
2014-11-01 15:00:08 +01:00
Michael Natterer 849481a861 Clean up code around calls to g_file_replace()
- use G_FILE_CREATE_NONE instead of 0
- don't put "Could not open <file> for writing: <error>" around the
  returned error, the returned message is already verbose
2014-10-04 02:44:54 +02:00
Michael Natterer 14978bfe5d Simplify calls to g_output_stream_write_all()
It returns TRUE only if all bytes were written, so there is no need to
get and check the bytes_written return value.
2014-09-07 20:30:14 +02:00
Michael Natterer f28878b6d3 plug-ins: start the progress before opening files for loading/saving
so the user gets feedback as early as possible.
2014-07-23 21:37:13 +02:00
Michael Natterer 6914bbc65f plug-ins: more gimp_spin_button_new() -> gtk_spin_button_new() 2014-06-22 23:01:31 +02:00
Michael Natterer de08267f06 libgimpbase, *: add enum value GIMP_ICON_TYPE_ICON_NAME
and keep GIMP_ICON_TYPE_STOCK_ID as a deprecated alias. Change all
plug-ins accordingly and increase the pluginrc file version number so
it gets regenerated with "icon-name" instead of "stock-id".
2014-05-11 23:56:30 +02:00
Michael Natterer cecd3fb057 plug-ins: use the same compat loading code in file-gih and file-gbr
It was the same before, but now it's even more consistent.
2013-11-17 14:52:27 +01:00
Michael Natterer 03df8c6af4 plug-ins: pass the format's name again in calls to gimp_export_image()
and clean up the formatting of the call and the lines around it. Now
we can check the various (disabled) export options for regressions
again by changing a single line in gimp_export_image().
2013-11-10 00:18:48 +01:00