Commit Graph

39 Commits

Author SHA1 Message Date
Jehan 9a2f5b0709 app: rework and fix the logic for copy-pasting multiple drawables.
There were a lot of incertainty of what should happen when we copy layers being
descendant of each other (i.e. when you select a group layer and some of its
children), then when you paste such data. So we sat down with Aryeom and tried
to come up with some consistent behavior which is somewhat expectable, but also
which would allow the most use-case.

Otherwise it was making very weird result when pasting the data, duplicating
some layers and whatnot, which was obviously a buggy behavior and never the
expected result.

We decided that if you select one leaf item, then even if you also selected a
parent item, it would be as though the parent was not selected. This is very
often what you expect anyway when you select a whole bunch of layers and would
work well if, say, you shift-click over many layers in sub-groups. Then you
wouldn't have to manually ctrl-click to unselect every group.

Then what if you were instead expecting to copy many groups? Then you could
shift-click the group arrow, closing all same-level groups. Once they are all
closed, you can shift-click the groups to only select group layers, not their
contents.

This way, both use cases are still quite doable easily with this default choice.
2022-11-12 18:28:58 +01:00
Jehan c928fda8ff app: fix GEX installation with warning while decompressing.
There is not only the ARCHIVE_OK and ARCHIVE_FATAL cases. There are also
ARCHIVE_WARN cases which should not break the installation (I think?). Since I
still want to pass the warning over to extension developers, I am printing it to
stderr.

As an additional fix, prevent such a warning when installing an extension over
itself. In such case, it looks like the archive_entry_size() would be 0, which
was triggering some "Writing to Empty File" warning.
2022-10-12 00:08:28 +02:00
Jacob Boerema 8d9db45dd5 app: fix resource leak warnings caught by static analysis.
In the unlikely case that we have an error we sometimes forget to free
either a dirname or appstring.
Let's fix these to reduce number of warnings.
2021-11-08 22:37:13 -05:00
Jacob Boerema e2b1cc9476 app: fix #6436 *.gih grayscale export crashes GIMP
When we try to export a grayscale image with layers with negative offsets
to a GIH brush GIMP crashes without producing any crashlog.
Running in GDB showed us that there is heap corruption caused by incorrect
computation of buffer sizes because of the negative offsets.

In file_gih_image_to_pipe there is a comment that offsets are assumed
positive, but no checking is done whether that is correct.
Let's add some checks, set offset to 0 if negative and adjust width and
height accordingly.
2021-11-08 17:10:32 -05:00
Jehan 6905b0bbef Issue #5313: consistent "file-pat-save-internal" procedure with…
… multiple drawables as parameter.

Previous commit 7bb892f3 was "making it work" by making the API
inconsistent and also only using the first drawable, which is making the
logics meaningless.

Instead accept multiple drawables, and export only the selected drawable
(when alone) or the merged-down image containing only the selected
drawables (when many).

Note that in current implementation, this is not useful from GUI calls
because the fully merged image is always exported when run interactively
or with last vals (i.e. from the GUI) because gimp_export_image()
flattens the image. So this change would only work when called
non-interactively from other plug-ins. In such a case, multi-layer
images do no longer return an error and whatever items are selected
would change the export result.

See also #7370 for a discussion about how to handle the selected items
during export (because currently the `drawables` parameter of
GimpSaveProcedure's run function is clearly a mostly bogus parameter).
2021-10-15 00:32:10 +02:00
Jehan b93c416e42 app: free a GimpPixPipeParams value (reported by Massimo). 2021-08-16 19:15:48 +02: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
lillolollo 0389e6f9e4 App file-data-gex.c fix incompatible pointer type 2020-03-22 20:06:10 +00:00
Massimo Valentini 5adde64753 Issue 4456: CRITICAL **...: g_object_unref: assertion
...'G_IS_OBJECT (object)' failed
2020-01-05 12:36:01 +01:00
Michael Natterer f3eef8fe83 plug-ins, app: port file-pat to GimpProcedureConfig
Exactly the same changes as in file-gbr.
2019-09-23 23:28:10 +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 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
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 6b0486174d app, pdb: split GimpProcedure's "strings" into "help" and "attribution" 2019-09-08 23:40:34 +02:00
Michael Natterer 26c8286675 app, pdb: take "deprecated" out of GimpProcedure's "strings" API
and add gimp_procedure_set_deprecated().
2019-09-08 23:23:32 +02:00
Michael Natterer 1716666bd1 app: keep the help_id in GimpProcedure not GimpPlugInProcedure 2019-09-08 22:25:26 +02:00
Michael Natterer 303ccbedad pdb: move gimp_plugin_icon_register_invoker() from "plugin" to "pdb"
and call it gimp_pdb_set_proc_icon(). Change icon registration code in
libgimp/ and app/ so it's now possible to register icons for temporary
procedures.
2019-09-08 16:22:32 +02: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
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 11ce199cea app: stop canonicalizing procedure names
on behalf of plug-in authors who have no style or can't type.

Instead, simply reject non-canonical procedure names and remove all
code that keeps aroud the original non-canonical shit just to pass it
back to the plug-in.
2019-08-18 01:55:47 +02:00
Michael Natterer 5a09523214 Remove GIMP_TYPE_INT32 and GimpParamSpecInt32
Use gint and GParamSpecInt instead.
2019-08-15 14:04:56 +02:00
Michael Natterer 32ea28b6b1 app, libgimp, libgimpbase: plug-in and PDB protocol refactoring part two
- Change the wire protocol's GPProcInstall to transmit the entire
  information needed for constructing all GParamSpecs we use, don't
  use GimpPDBArgType in GPProcInstall but an enum private to the wire
  protocol plus the GParamSpec's GType name. Bump the wire protocol
  version.

- Add gimpgpparamspecs.[ch] in both app/plug-in/ and libgimp/ which
  take care of converting between GPParamDef and GParamSpec. They
  share code as far as possible.

- Change pluginrc writing and parsing to re-use GPParamDef and the
  utility functions from gimpgpparamspecs.

- Remove gimp_pdb_compat_param_spec() from app/pdb/gimp-pdb-compat.[ch],
  the entire core uses proper GParamSpecs from the wire protocol now,
  the whole file will follow down the drain once we use a GValue
  representation on the wire too.

- In gimp_plug_in_handle_proc_install(), change the "run-mode"
  parameter to a GParamSpecEnum(GIMP_TYPE_RUN_MODE) (if it is not
  already an enum). and change all places in app/ to treat it as an
  enum value.

- plug-ins: fix cml-explorer to register correctly, a typo in
  "run-mode" was never noticed until now.

- Add gimpgpcompat.[ch] in libgimp to deal with all the transforms
  between old-style wire communication and using GParamSpec and
  GValue, it contains some functions that are subject to change or
  even removal in the next steps.

- Change the libgimp GimpProcedure and GimpPlugIn in many ways to be
  able to actually install procedures the new way.

- plug-ins: change goat-exercise to completely use the new GimpPlugIn
  and GimpProcedure API, look here to see how plug-ins will look in
  the future, of course subject to change until this is finished.

- Next: changing GPParam to transmit all information about a GValue.
2019-07-28 17:34:40 +02:00
Michael Natterer 317b09c90f app: rename gimp_rec_rm() to gimp_file_delete_recursive()
and move it to the right place in gimp-utils.[ch].
2019-05-31 17:11:50 +02:00
Michael Natterer 710cfc1f47 app: fix undoing image parasite attach/detach to emit the right signals
Add "gboolean push_undo" parameters to gimp_image_parasite_attach()
and _detach() and use the API also from undo, instead of implementing
attaching/removing manually and forgetting about the signals.

Fixes updating of the image properties color profile page.
2019-05-30 16:51:29 +02:00
Michael Natterer 0710051e2b app, plug-ins: make sure a GIH brush's spacing is preserved
across load and save, by introducing a gimp-brush-pipe-spacing
parasite.
2019-05-28 00:25:47 +02:00
Jehan 50aa7233b2 app: add extension installation in GimpExtensionManager.
This completes my earlier commit 406279e4ef.
Extension installation is not about just decompressing a file in the
right folder. We must also make the extension manager and the GUI aware
of this newly available extension.
2019-04-29 20:56:28 +09:00
Jehan 406279e4ef app: new "gex" format (GIMP Extension).
File extension (.gex) may still change if anything better is proposed.
This format is currently just a compressed archive containing the
extension data (plug-in, brushes or whatever) and the metadata file.

For now, opening such file will simply install it as a new extension,
keeping all file permissions and structure. Of course in the future, it
will have to trigger a confirmation dialog.

Currently the compression used is zip, which is just a first draft. This
is not a decisive choice as well. We could use some tarball compressed
in whatever other compression algorithm. I use libarchive as a new
dependency to support unarchiving as it seems to be a common library
(and since it is already used by AppStream-glib anyway, this doesn't add
any actual dependency, just make it direct).
2019-04-12 18:49:18 +02:00
Michael Natterer cc7e07fecb app, plug-ins: move brush pipe saving from the file-gih plug-in to the core
As with .gbr and .pat, only the actual saving code, not the export
logic and GUI.
2019-03-03 19:56:04 +01:00
Michael Natterer 861106a0b3 app: factor file_gbr_drawable_to_brush() out of file_gbr_image_to_brush() 2019-03-03 19:44:02 +01:00
Michael Natterer 569f3e1bc2 app: use NON_LINEAR not PERCEPTUAL in file-pat-load and file-gbr-load 2019-02-19 23:43:58 +01:00
Michael Natterer 52adaa1963 app, plug-ins: move file-gih-load from the file-gih plug-in to the core 2019-02-19 23:41:34 +01:00
Michael Natterer 7aa99c8cf0 app: cosmetic change in file_pat_load_invoker()
just for consistency with file_gbr_load_invoker().
2019-02-19 23:16:22 +01:00
Michael Natterer 3b89ae40d0 app: factor file_gbr_brush_to_layer() out of the brush-to-image logic
of file-gbr-load, and add some layer handling magic that doesn't
change a thing for simple brushes, but is needed for loading brush
pipes.
2019-02-19 23:13:59 +01: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 b29ecfb5da app, plug-ins: move pattern saving to the core
but only the actual saving code, not the export magic and dialog.

Add new internal procedure file-pat-save-internal which is not
registered as a file procedure and always works non-interactively on
the passed arguments and only saves the passed drawable. Use the new
internal procedure from the file-pat-save code and remove all file
writing code from the plug-in.

This way all pattern file writing code duplication is killed, while
the whole export mechanism is completely unchanged.
2019-02-12 21:27:13 +01:00
Michael Natterer 410ffc435e app: move file-pat-load from the file-pat plug-in to the core 2019-02-11 18:35:07 +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