Commit Graph

2587 Commits

Author SHA1 Message Date
Jehan 79615541d9 Issue #4291: meson: pdbgen not working.
The build now successfully build the PDB files into the source folder
itself. Unfortunately it seems I can't get meson dependencies to work
properly, once more! I added a "sources" argument to the relevant
library() or static_library() but it still uses old versions to build
these. E.g. if I add an error on purpose to a pdb file, the next build
still passes, yet the second-next fails (as it should have before).

Note that I even tested a declare_dependency() with just the "sources"
arguments, because it says "sources to add to targets (or generated
header files that should be built before sources including them are
built)" (so I assume it means that it should be trigger a rebuild,
otherwise it's useless) but it's just not working. I'll investigate
more.

Still going with this for now, because at least generating the PDB
source was a big miss until now. But we should
2022-03-27 22:18:44 +02:00
Niels De Graef dddb23c6e5 help-browser: Rewrite without GtkAction
The initial attempt of this commit was to remove the `GtkAction` usage,
but grew a bit wider than that. The following happened:

* The dialog became a proper GObject, rather than being a big chunk of
  static variables that were hopefully initialized before you used them.
* The dialog now uses `GAction`s to implement actions, and converted
  some signal handlers to actions as well.
* The plug-in run procedure now uses `GtkApplication`. This is one hand
  necessary to be able to set accelerators for actions, but on the other
  hand is more future-proof, as GTK4 removes `gtk_main()`
2022-03-25 11:49:39 +00:00
Jehan 7fc963decb libgimp: fix annotations for gimp_image_metadata_save_filter().
Fixes:

> libgimp/gimpimagemetadata-save.c:541: Warning: Gimp: gimp_image_metadata_save_filter: return value: Missing (transfer) annotation
2022-03-18 16:26:18 +01:00
Daniel Novomeský ff87bc8d4d libgimp: new gimp_image_metadata_save_filter API
This new function is an alternative to existing
gimp_image_metadata_save_finish, when you want to save metadata
yourself and you need only filtering processing.
It returns filtered metadata allowing the caller
to save the finalized metadata via other means
(via native format’s library for example)
This API can be used to support metadata saving of image formats
not directly supported by gexiv2/exiv2.
2022-03-16 13:00:03 +00:00
Jehan 7ca4d0ca45 libgimp: new gimp_procedure_dialog_get_spin_scale() and support of…
… %GIMP_TYPE_SPIN_SCALE in gimp_procedure_dialog_get_widget().

The dedicated function is for when a plug-in wants to use a scale range
multiplied by a factor. Otherwise using the generic function is fine.
2022-02-19 02:26:11 +01:00
Jehan cf84f0e707 libgimp: fix more gi-docgen "qualifier fragment".
Now the warning is:

WARNING: Invalid fragment for 'Gimp.Config': it should be struct
It implements the [iface@Config] interface and therefore has all its
                  ^~~~~~~~~~~~~~

This warning feels wrong as we use GimpConfig for the name of the
interface, yet in the .gir file, I see `<record name="Config" …>` yet
`<interface name="ConfigInterface" …>`.
I suppose gi-docgen would want us to use [iface@ConfigInterface] if we
want to link the interface. But looking at the gir file, all interesting
interface methods are associated to the Config record. So let's just go
with the [struct@Config] proposed by the warning.
In any case, something feels wrong or broken here, but we need to fix
this for the CI. I hope Niels can look at it at some point.
2022-02-18 14:03:47 +01:00
Jehan 29f23c8f98 libgimp, libgimpconfig: fixing gi-docgen "qualifier fragments".
Fixing these 2 warnings in the CI which end up fatal:

WARNING: Invalid fragment for 'Gimp.Parasite': it should be struct
Serializes the object properties of @config to a [class@Parasite].
                                                 ^~~~~~~~~~~~~~~~
WARNING: Invalid fragment for 'GLib.MainLoop': it should be struct
it has a GUI and is hanging around in a [class@GLib.MainLoop], it must call
                                        ^~~~~~~~~~~~~~~~~~~~~
2022-02-18 12:11:01 +01:00
Jehan 0f36ce596a libgimp: improves the support of GimpParamRGB properties.
Now using the new GimpLabelColor as new default for RGB properties. It
makes more sense that the default is editable widgets. Also it has a
label, which is better default widget.

Also gimp_procedure_dialog_get_color_widget() now only returns
GimpLabelColor widgets.
2022-02-17 23:13:43 +01:00
Jehan 81692874fc Issue #7301: default GimpProcedureDialog widget for string property…
… has no label.

Now fixed with the new GimpLabelEntry created in the previous commit.
2022-02-17 23:13:42 +01:00
Jehan 1918736b99 Issue #6792: broken annotation for GimpRunBrushCallback.
As Massimo notes, the issue is not about the callback being broken in
bindings, but simply that bindings fail to handle random data without an
associated size. So let's just add the size. I confirmed testing API in
the Python binding that it now works fine.
2022-02-13 19:02:54 +01:00
Niels De Graef 1e34a95db7 app, libgimp: pdbgen for previous commit. 2022-02-12 00:07:53 +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 43f44288ef libgimp: new gimp_pdb_run_procedure_config() function.
While we do have quite a few gimp_pdb_run_procedure*() functions now, I
always felt that one based on a config file was missing, even more as we
are getting further and further into using config objects in plug-ins.

In C, the gimp_pdb_run_procedure() function is without a doubt the
easiest one. But such variable arg functions are not available on
bindings, and having to deal with GValue and GimpValueArray is a real
pain.

Also using a config file has the very great advantage that we don't need
to care about order. For instance, if I need to set the 10th argument of
a PDB call (and leave the rest to default values), I don't have to set
all 9 previous arguments. I can set only this one if I want. This
advantage is useful also for C code by the way.

For the record, here is how you could load then export an image with the
"file-png-*" PDB procedures in Python:

> c = Gimp.get_pdb().lookup_procedure('file-png-load').create_config()
> c.set_property('file', Gio.file_new_for_path('/path/sample.png'))
> r = Gimp.get_pdb().run_procedure_config('file-png-load', c)
> d = Gimp.Display.new(r.index(1)) # Give it a display to work on it.

Now exporting:

> img = r.index(1)
> c = Gimp.get_pdb().lookup_procedure('file-png-save').create_config()
> c.set_property('image', img)
> c.set_property('file', Gio.file_new_for_path('/path/exported.png'))
> layers = img.get_layers()
> c.set_property('drawables', Gimp.ObjectArray.new(Gimp.Drawable, layers, False))
> c.set_property('num-drawables', len(layers))
> r = Gimp.get_pdb().run_procedure_config('file-png-save', c)
2022-02-11 17:56:42 +01:00
Jehan 0734ac2aec libgimp: fix gimp_procedure_config_get_values().
The config object has one additional property per construction, which is
the "procedure" property.
2022-02-11 17:42:39 +01:00
Jehan f4c7ea7e02 Revert "libgimp, libgimpconfig: gimp_config_deserialize_file() should not…"
This reverts commit 73c0ee8da7.

Actually I was wrong, there was a bug in gimpconfig-deserialize.c. See
coming commit.
2022-02-10 22:18:03 +01:00
Jehan 73c0ee8da7 libgimp, libgimpconfig: gimp_config_deserialize_file() should not…
… assert the existence of GError.

This is even worse as deserialize() method does not even take a GError
parameter anyway so this assert will always go off when a
deserialization failed (which happened in my case as I was working on a
plug-in API, hence gimp_procedure_config_load_last() actually failed to
load a previous version of the plug-in-settings when I changed a
procedure arg's type).

Just fail the deserialization normally and let the calling code handling
this case. Nevertheless it is kind of useful to bubble-up the error to
calling code, so I add a TODO in the interface header (hopefully to see
and improve this before we release GIMP 3.0).
2022-02-10 18:44:44 +01:00
Jehan 5b01290f94 all, libgimp, pdb: some alignment and param description fix. 2022-02-09 21:23:33 +01:00
Jehan 3e58869dbf libgimp: missing new API in def file.
Ahahah. So many years and I still forget this annoying def file! :P
2022-02-04 18:17:20 +01:00
Jehan d9387811f4 app, libgimp, pdb: new PDB API to enable/disable dynamics.
New libgimp C functions:
- gimp_context_are_dynamics_enabled()
- gimp_context_enable_dynamics()
2022-02-04 13:54:59 +01:00
Jehan f38cd88a00 Issue #7521: VAPI file name different on meson and autotools.
Let's go with major.minor like our other library files, i.e.
gimp-3.0.vapi and gimp-ui-3.0.vapi.
2022-02-02 16:00:07 +01:00
Jehan c76172d971 libgimp: more un-deprecating GExiv2.
Last deprecated usages in this file. Actually there are a few other
calls but deprecated on GExiv2 0.14.0, hence over our current
requirement. So we'll have to handle these later.
2022-01-20 18:45:08 +01:00
Jehan 0d33ede670 libgimp: undeprecate some more GExiv2 calls.
Replace functions gexiv2_metadata_set_xmp_tag_struct() and
gexiv2_metadata_get_tag_type() with their _try_ variants.

Note that I print to stderr rather than raising a warning here as I am
quite unsure where the list of XMP metadata we are gathering comes from.
Is it fully validated by GExiv2, and therefore no errors are ever
supposed to happen? (in such case, we should raise a warning if it does)
Or is it user-provided data (e.g. from a file loaded in GIMP which can
contain broken metadata)? In such a case, we should probably handle the
error slightly differently to warn for non-processable data (hence
possibly metadata loss at export time).

For the time being, then go with this weak handling and take care of
this better when we can look further into this.
2022-01-20 18:26:07 +01:00
Jehan e3c803299a libgimp: port a bunch of gexiv2_metadata_set_tag_string() to …
… gexiv2_metadata_try_set_tag_string().

These are usage where we have full control over tag names and values so
no error is supposed to happen. This is why we use them as code warnings
and not returned error (because if an error did happen, this would be a
bug rather than a user error or a system error).
2022-01-20 17:56:28 +01:00
Jehan 96e25b7817 libgimp: fix and workaround Exif.Photo.UserComment interpretation.
Here are the changes:
- Separate the check for comment contents and the one of whether or not
  it starts with "charset=Ascii ". Indeed in my tests, we still want to
  handle the empty string case or the "binary comment" case even without
  the charset prefix (currently it was both or none, so I encountered
  cases with a broken "binary comment" comment because the charset
  prefix was absent).
- Add some #warning in order not to forget to remove the bogus "binary
  comment" test. Indeed after some digging in Exiv2 code, I could
  confirm this return value got removed in commit 9b510858 of Exiv2
  repository, i.e. since Exiv2 0.27.4. Now in my test case where I had a
  tag containing only 0s, Exiv2 returns an empty string, which is
  perfectly fine (and it's up to us to keep or ignore it).
- Use gexiv2_metadata_try_get_tag_interpreted_string() instead of their
  deprecate non-try counterparses. Right now, I am just outputting any
  error message to stderr, as I'm not sure if this is the kind of errors
  we want to warn people about. I guess it would depend on which type of
  errors exactly are returned, so let's see if we encounter some case in
  the future. For now stderr is fine to detect these.
2022-01-20 16:47:04 +01:00
Jehan 56d6cf6aa1 INSTALL, libgimp: document a bit better the GIR cross-tool exception. 2022-01-06 19:24:32 +01:00
Markus Volk c9fabacca2 meson: make gir buildable
yocto/oe is capable of building gobject introspection despite cross-compiling.
add an option to enable gir build even if cross-compiling

Signed-off-by: Markus Volk <f_l_k@t-online.de>

Reviewer note (Jehan): this whole stuff is a mess. Actually I'd like to
simply get rid of the whole no-gir-when-cross-compiling logics but I
still can't figure out how to cross-build generically with GIR.
Yet since some manage it with yocto, let's unblock them.
See #7208.
2022-01-06 18:58:08 +01:00
Niels De Graef 2da425ea5b libgimp: Migrate gtk-doc annotations to gi-docgen
Move some of the documentation from the constructor to the class itself,
so that it show up more prevalently.
2021-12-29 19:08:22 +01:00
Niels De Graef 0446a9025a docs: Migrate some gtk-doc comments to gi-docgen 2021-12-29 11:21:19 +01:00
Niels De Graef 92e80d12e8 docs: Migrate from gtk-doc to gi-docgen
gtk-doc has been slowly dying for the past few years; with gi-docgen we
have a nice successor.

This also makes sure the C documentation also uses the GIR file, which
in turn means faster build times (since all the C code doesn't have to
be parsed and recompiled again), and has a clear dependency graph.

See the [gi-docgen tutorial] for more info on how the system works.

[gi-docgen tutorial]: https://gnome.pages.gitlab.gnome.org/gi-docgen/tutorial.html
2021-12-27 10:47:34 +01:00
Jehan 084906dbf1 app, devel-docs, libgimp, pdb: remove gimp_item_set_linked().
I cleaned many remaining places where the concept of linked item still
survived.
On loading an XCF file with linked items, we are now going to create a
named sets for the linked items, allowing people to easily select these
back if the relation was still needed.

We don't remove gimp_item_get_linked() yet and in particular, we don't
save stored items into XCF files. This will come in an upcoming change.
2021-12-23 13:45:20 +01:00
Jehan 2ce84b5245 app, devel-docs, libgimp, pdb: delete gimpitem-linked.[ch].
Getting rid of the last usage from these files dedicated to outdated
item link concept.
2021-12-23 13:45:20 +01:00
Jehan 26615fde92 app, devel-docs, libgimp, pdb: now removing gimp_item_linked_rotate(). 2021-12-23 13:45:20 +01:00
Jehan 6f901dfe3e app, devel-docs, libgimp, pdb: get rid of gimp_item_linked_translate().
Similarly to the previous commit, we get rid of "item link" code for
translating items.
2021-12-23 13:45:20 +01:00
Jehan 26d696ce9d app, devel-docs, libgimp, pdb: remove item link ref in flip code.
"Item links" concept is no more in the GUI so we are progressively
removing reference and implementation of this in the core code.
2021-12-23 13:45:20 +01:00
Jehan efaf9e099e app, libgimp, libgimpwidgets: fix "Application icon missing" in tests.
When running tests, the data are not meant to be necessarily installed.
Therefore icons won't be found when calling gimp_widgets_init().

Add some special-casing to find them relatively to the install
directory.
2021-12-23 13:39:43 +01:00
Jehan 47e0e6f519 app, libgimp, pdb: add visibility lock API. 2021-12-23 12:55:11 +01:00
Jehan 345d148e21 libgimp: do not return a possibly invalid pointer.
Fixes the patch from !470 which is mostly right, except that
g_param_spec_sink() may possibly lead to finalizing the GParamSpec
(typically if it was a just-created floating spec). We don't want to
return pointer to freed data. Let's return NULL instead.

Also looking closer at the memory handling here, it looks the right
annotation for @pspec is (transfer floating). Basically we are sinking a
floating object into a full object and taking ownership of this sunk
object. But if the object was already sunk, we are reffing it and
keeping this additional reference, not the passed argument's. Hopefully
it's right since the annotation and handling of floating object with
GObject Introspection seems very unclear to me (even in core GObject
code, I see what looks like contradictory annotations).
2021-10-12 20:13:20 +02:00
Andrzej Hunt a0f2f004aa libgimp: fix pspec leak when procedure argument has already been specified
In the normal flow, pspec is persisted in the arguments array, and is
g_param_spec_ref_sink()'d in order to sink a possible floating ref. To
avoid a leak in the error case, we need to add some g_param_spec_sink().
2021-10-12 20:13:20 +02:00
Jacob Boerema 352ef68c46 app, libgimp: Add metadata preference for saving thumbnail by default
Saving a thumbnail is closely related to the other metadata preferences,
but so far this was the only one that didn't have a preference for a
default user value.
This commit adds a preference in the metadata section where a user can
select whether thumbnail saving is enabled by default or not.
2021-10-12 13:20:47 -04:00
Jacob Boerema d577e516c5 libgimp: set subfiletype to FILETYPE_REDUCEDIMAGE when saving EXIF thumbnails.
Setting the type to reduced image for a thumbnail makes it easier when
loading TIFF images to recognize a page as a thumbnail.
2021-08-27 15:36:49 -04: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 0a83a45732 libgimp: fix (again) the meson build.
My previous commit still is not completely right. Why is my local build
and the CI working so differently?!
2021-08-04 01:19:02 +02:00
Jehan 2026c2db82 libgimp: fix the meson build.
Commit 24dc6bfeac was not totally complete.
2021-08-03 23:19:36 +02:00
Jehan 8176bd0828 libgimp: have gimp_procedure_dialog_new() behave like g_object_new().
It is now discouraged to create constructor-type _new() functions with
custom code, which would make them behave differently that simply
calling g_object_new() with the GType and relevant properties. The main
reason is that some bindings would create objects with g_object_new() so
it should create expected code too.
See: https://gi.readthedocs.io/en/latest/writingbindableapis.html#custom-code-in-constructors

Here it was complicated for a few reasons:
- We hack "title" property to use the procedure's menu label by default
  (without the mnemonic). For this, I overrode the GtkWindow property.
- We want "use-header-bar" to follow the application general settings by
  default. Since it is a CONSTRUCT_ONLY property, g_object_set() is not
  possible in _init() and _constructed(). Instead I had to override the
  constructor() method to set this at construction time (yet still allow
  API users to override this with the property at creation).
- Similarly, "help-func" is a CONSTRUCT_ONLY property, so I used the
  same trick.
- As for "help-id", I now just set it in _constructed(). This was the
  easy one.
2021-08-03 19:47:19 +02:00
Jehan 24dc6bfeac libgimp: libgimpmodule is part of libgimp not libgimpui.
Thanks to Stanislav Grinkov for noticing this error in the meson scripts
(cf. his comment in #6362).
2021-08-03 15:54:49 +02:00
Jehan 1e31b6530d Issue #7106: GIMP 2.99.6 Python Script Fatal Error.
All objects of subclass GtkWindow are special as they are actually owned
by GTK which keeps a list of all top-level windows. So we cannot
actually give ownership to the caller. With GObject Introspection in
particular, it will mean a double-free of the dialog object (by GTK,
then by the GI layer).

See also gobject-introspection#394.
2021-08-02 01:35:44 +02:00
Jehan 2d84ad719f libgimp: do not leak dialog containers' size groups.
As explained in GtkSizeGroup docs, all objects inside a size group holds
a reference to it. So once we destroy the last object inside these, it
will be freed too and we should drop the initial reference after adding
the objects.

Only the main size group reference is kept until the end, because we are
adding and removing objects from it regularly, so it is possible that it
is empty again at some intermediary states. Yet we don't want to free it
when this happens.
2021-08-01 17:56:46 +02:00
Mayank Suman 38cda060b3 libgimp: tooltip added to all widgets in GimpProcedureDialog
Appropriate tooltip is displayed for all widgets in GimpProcedureDialog.
2021-06-18 16:43:26 +05:30
Mayank Suman c99ae3769f libgimp: new GtkSizeGroup for widgets inside a container
All the widgets with label inside GimpProcedureDialog have same
GtkSizeGroup (dialog->priv->label_group), which result in wrong sizes of
widget if any of the label is long. In this commit, a new GtkSizeGroup
is made for each of the container, so that labels are aligned but size
of widget in one container do not affect size of widgets in other
containers.

For the widget not belonging to any of the container, default
GtkSizeGroup (dialog->priv->label_group) is used.
2021-06-18 16:43:18 +05:30
Mayank Suman d8062d1d77 plug-in, libgimp: Fixes #6753: redesign of WebP Export dialog
Added an option for exporting thumbnail in WebP Export dialogbox.

Additionally, introduced a function gimp_procedure_dialog_fill_expander.
The function is similar to gimp_procedure_dialog_fill_frame but allows
adding GtkExpander instead of GtkFrame.
2021-06-18 16:42:08 +05:30