Commit graph

8909 commits

Author SHA1 Message Date
Jehan
2ea5dec56e libgimpwidgets: improved gimp_prop_scale_entry_new(), new function…
… gimp_label_spin_set_digits() and deleted gimp_prop_opacity_entry_new()

- The "digits" argument for the number of decimal places in
  gimp_prop_scale_entry_new() is now mostly useless since GimpLabelSpin
  (hence GimpScaleEntry too) got a nice estimation algorithm of sensible
  values.
- Add gimp_label_spin_set_digits() function to manually set the digits
  property when we don't like the estimated value.
- Also add a new "factor" argument to gimp_prop_scale_entry_new(). Its
  role is to allow a GimpScaleEntry showing a factored range, typically
  a [0, 100] range for some types of [0, 1] properties.
- Remove gimp_prop_opacity_entry_new() which was basically a
  special-case of gimp_prop_scale_entry_new() and which can now be
  easily reproduced by simply set factor=100.0.
- Update all usage of gimp_prop_scale_entry_new() in app/ and plug-ins/
  with updated arguments. It is interesting to note that all existing
  usage were either integers (digits=1) or when double, the estimated
  decimal places are the same as the ones which were manually set (hence
  showing the generic estimation is not too bad). So the new function
  gimp_label_spin_set_digits() was not even needed once in current code.
2020-11-25 02:32:22 +01:00
Jehan
3e67d7d676 plug-ins: file-tiff using the new dialog generation. 2020-11-23 02:15:13 +01:00
Jehan
56bfda3dd3 plug-ins: update file-png to new metadata handling.
The plug-in GUI code keeps slimming down. :-)
2020-11-23 02:15:13 +01:00
Jehan
4511de4268 plug-ins: file-tiff dialog now generated too.
72 lines smaller according to git stats. And once again, this is WIP and
may even get smaller with the new ideas I got.
2020-11-20 01:47:18 +01:00
Jacob Boerema
3128047a0b plug-ins: in metadata editor and viewer only convert values to UTF-8 if they are not.
Certain metadata is already UTF-8. Converting them from locale
to UTF-8 again leads to incorrectly shown strings.
2020-11-19 23:25:27 +00:00
Jacob Boerema
d004305019 plug-ins: fix metadata-editor not saving Xmp.photoshop.Urgency and Xmp.xmpRights.Marked.
The values of Description tab - Copyright Status and IPTC tab - Urgency were not saved.
We are fixing that with this commit. Urgency is also saved to Iptc.Application2.Urgency.
2020-11-19 23:25:27 +00:00
Jacob Boerema
47065df53c plug-ins: let metadata-editor also save Iptc tags. 2020-11-19 23:25:27 +00:00
Jacob Boerema
96c5d1c1a1 plug-ins: add missing Iptc equivalents of Xmp tags in metadata-editor.
Also added a comment to Xmp.photoshop.CaptionWriter which
occurs twice in the list.
2020-11-19 23:25:27 +00:00
Jacob Boerema
7cce45b377 plug-ins: In metadata-editor always read iptc equivalent values of xmp tags.
Iptc equivalent tags of Xmp tags were only read if the Xmp tag had no value
which doesn't make sense since there is no guarantee that they are the same.

We changed this to always read the Iptc tags too and if the value differs
from the Xmp tag we add both values. That way the user can decide
which values are relevant.
2020-11-19 23:25:27 +00:00
Jacob Boerema
879b3745d2 plug-ins: fix not showing all values of iptc tags that appear more than once.
This is one of the problems mentioned in issue #5863. This commit fixes
this problem in the metadata-editor by using gexiv2_metadata_get_tag_multiple.
Empty string values will be skipped.
2020-11-19 23:25:27 +00:00
Jacob Boerema
bd2f43bf20 plug-ins: Refactor cleaning xmp values into a separate function in metadata-editor.
The same code was used several times so we move it to  its own function.
2020-11-19 23:25:27 +00:00
Jacob Boerema
c855590ffa plug-ins: fix incorrect struct used for comparison in metadata-editor. 2020-11-19 23:25:27 +00:00
Jacob Boerema
786aaec2a3 plug-ins: fix incorrect single/multi(ple) values for certain iptc tags used in metadata editor. 2020-11-19 23:25:27 +00:00
Jacob Boerema
26db975a84 plug-ins: fix incorrect reading of iptc tags that appear more than once.
This is one of the problems mentioned in issue #5863. This commit only fixes
this problem in the metadata-viewer.
2020-11-19 23:25:27 +00:00
Jacob Boerema
599d91db54 plug-ins: Refactor certain string handling into separate functions in metadata-viewer. 2020-11-19 23:25:27 +00:00
Jehan
501675b8a3 plug-ins: file-png now uses generated dialog.
Basically the same design as before (but a bit prettier, by using a
2 columns flowbox rather than a grid), yet 80 lines smaller according to
git stats. Also still the exact same code logics as before. No feature
loss (and actually a feature gain as there was the "Save comment"
checkbox but no text field to edit the comment as we get in other
plug-ins).

Basically better and prettier dialog in just a few lines. Moreover it's
still work-in-progress. We can even do better, but this is things to
come.
2020-11-20 00:22:21 +01:00
luz paz
bb322d94d7 Fix typos
Found via:
```
codespell -q 3 -S ./ChangeLog*,*.po,./.git,./NEWS* -L als,ang,ba,chello,daa,doubleclick,foto,hist,iff,inport,klass,mut,nd,ower,paeth,params,pard,pevent,sinc,thru,tim,uint
```
2020-11-19 21:56:25 +01:00
Jehan
9a90eefe1f plug-ins: improvement of TIFF loading when TIFFNumberOfDirectories()…
… fails.
My previous commit was just assuming there is one page when the libtiff
function fails. But thinking a bit more on this, there are 2 edge cases
even here:

- If the image is actually really corrupted to the point there are no
  TIFF directories to read.
- If there are actually more available directories. It would be much
  better if GIMP were able to salvage them from a broken file.

To handle these cases, I actually count manually the number of
directories by looping with TIFFSetDirectory() (which still works fine
on our minimal image). I use 65535 as a max value because in libtiff's
TIFFNumberOfDirectories() implementation, it says this is the max value
(even though I couldn't confirm this in the spec; there is a "Number of
Directory Entries" on 2 bytes, but this is about various fields for each
directories, not a number of directories; still anyway this is already a
huge number and since libtiff won't likely be able to handle directories
over this limit, not need to go over either).

I am also adding a test in the end so that we can output an appropriate
message if we actually failed to read any data from the TIFF (whether or
not TIFFNumberOfDirectories() succeeded, when we actually tried to read
the contents, we couldn't).
2020-11-16 16:21:50 +01:00
Jehan
9ff0204230 Issue #5837: TIFF file not recognized.
On a provided minimal 1×1px TIFF file, TIFFNumberOfDirectories() seems
to choke on some missing field and returns 0. I am not sure if the file
is actually valid or not, but let's make some kind of exception
(outputting a warning of our own when we do) by assuming there is at
least 1 page/image in the file when TIFFNumberOfDirectories() returns 0.

Other than this minimal file (which probably has no other interest than
being a test case), it could actually help salvage corrupted TIFF file
by attempting to read more data.
2020-11-16 15:10:07 +01:00
Jehan
7b6f2e5c2b libgimp, libgimpwidgets, plug-ins: improved GimpProcedureDialog API.
- New GimpLabelIntWidget which is a label associated to any widget with
  an integer "value" property.
- New gimp_procedure_dialog_get_int_combo() which creates a labeled
  combo box from an integer property of the GimpProcedureConfig.
- Renamed gimp_procedure_dialog_populate*() with
  gimp_procedure_dialog_fill*(). Naming is hard! I hesitated using
  _pack() as well (similarly to GtkBox API).
- New gimp_procedure_dialog_fill_flowbox*() functions to create a
  GtkFlowBox filled with property widgets (or other container widgets as
  we can pack them one in another). This is an alternative way to build
  your GUI with sane defaults, with list of property names.
2020-11-13 21:27:56 +01:00
Rafał Mikrut
3e35fe4d80 Cppcheck fixes 2020-11-05 19:42:14 +00:00
Jehan
6b846b4600 plug-ins: update file-fli to use the GimpProcedureDialog generation.
Probably one of the simplest plug-in dialogs, with only few properties
and all in the main box. So it's quite easy to port, even with the still
limited generation API.
2020-11-05 18:06:53 +01:00
Jehan
d95f417719 app, libgimpwidgets, modules, plug-ins: code changes after GimpScaleEntry…
… reclassing as GimpLabelSpin subclass.
2020-11-05 18:06:52 +01:00
Ruthra Kumar
b67ca557f0 Issue #5691: Import/Export of GeoTIFF loses important header tags.
file-tiff plugin can read and write GeoTIFF tags
New checkbox 'Save GeoTIFF data' has been added to Export dialog.

Signed-off-by: Ruthra Kumar <ruthrab@gmail.com>
2020-11-01 13:12:37 +01:00
Jehan
0d98969a47 libgimpwidgets, plug-ins: rename gimp_scale_entry_set_range() to…
… gimp_scale_entry_set_bounds().
I realized that this function may look like the set() opposite for
gimp_scale_entry_get_range(), which it is not at all. The get_range() is
for getting back the GtkRange widget packed in the GimpScaleEntry,
whereas the set_range() is to change the minimum and maximum allowed
values.

I had recently renamed the former, and could just rename it back into
gimp_scale_entry_get_scale() as it was, but since the class we rely on
is actually called GtkRange (GtkScale is a subclass), I think it could
be misleading. So in the end, let's rather rename the function setting
the widget minimum and maximum as gimp_scale_entry_set_bounds() instead.
Hopefully this is even more understandable. Naming is hard!
2020-11-01 03:00:09 +01:00
Jehan
b3c0ba061b app, libgimpwidgets, modules, plug-ins: finishing GimpScaleEntry port.
Renaming the temporary function gimp_scale_entry_new2() into
gimp_scale_entry_new() now that the original code is entirely gone. This
is now a fully-fledged widget with a nice and proper introspectable API.
2020-11-01 02:46:20 +01:00
Jehan
77d2a93a52 libgimpwidgets, plug-ins: remove legacy gimp_color_scale_entry_new().
Former gimp_color_scale_entry_new() is finally replaced by the
GimpColorScaleEntry implementation.
Both places which used it (GimpColorScales and compose plug-in) now use
the new widget.

Also making "upper" and "lower" properties of GimpScaleEntry into
construction properties, and create the main GtkAjustment at init, so
that we are sure that lower and upper bounds are properly set before we
set the value (when setting all properties at once, we cannot ensure
that these limit properties are set before the "value" one).
2020-11-01 02:23:03 +01:00
Jehan
f27d172750 libgimpwidgets: new GimpColorScaleEntry class.
Similarly to GimpScaleEntry, this is meant to replace usage of
gimp_color_scale_entry_new() by having a proper widget. This is a child
class of GimpScaleEntry which simply replaces the GtkScale by a
GimpColorScale by adding a GimpScaleEntry class method to create the
scale widget (only restriction: it must be a GtkRange subtype).

This also triggers me to rename gimp_scale_entry_get_scale() into
gimp_scale_entry_get_range() (as well as the 2 plug-ins already using
this function).
2020-11-01 00:08:20 +01:00
Jehan
4fe56cd388 plug-ins: fix GIMPressionist build warning.
Fixes the following warnings (×3):
> warning: using integer absolute value function ‘abs’ when argument is
> of floating point type ‘double’
2020-11-01 00:08:20 +01:00
Jehan
e0854b62b6 plug-ins: port remaining plug-ins using old gimp_scale_entry_new(). 2020-11-01 00:08:20 +01:00
Jacob Boerema
dbc198001e plug-ins: Fix incomplete port of file-openraster.
This fixes #5838 which was caused by an incomplete port
of this plug-in to the new introspection API.

For now we do keep the n_drawables parameter of save_ora until
issue #5312 is fixed. Not doing this would cause saving to fail.
2020-10-31 12:49:54 -04:00
Jehan
52c3b9115b plug-ins: port GIMPressionist to GimpScaleEntry. 2020-10-31 03:44:21 +01:00
Jehan
611e22fd81 plug-ins: port script-fu-interface to GimpScaleEntry. 2020-10-31 02:24:28 +01:00
Jehan
7ebd19636c plug-ins, modules: more port to GimpScaleEntry. 2020-10-31 02:07:35 +01:00
Jehan
f342b566c8 plug-ins: various plug-ins ported to new GimpScaleEntry. 2020-10-30 23:28:57 +01:00
Jehan
10dfaead68 libgimpwidgets, plug-ins: continue GimpScaleEntry port to real widget.
I got rid of gimp_scale_entry_set_sensitive(), as we can now use the
generic gtk_widget_set_sensitive(), and I ported the 2 plug-ins using
this function.
I also created gimp_scale_entry_set_value() to set the value (nicer than
setting object properties).
2020-10-30 21:30:16 +01:00
Jehan
0f05825a29 app, libgimpwidgets, plug-ins: default increments for GimpScaleEntry.
Instead of setting always manually the step and page increments when
creating a GimpScaleEntry, let's just generate some common cases
automatically. Indeed the increments are rarely something you want to
care about. The algorithm used is:
- For a range under 1.0, use a hundredth and a tenth (typically a [0,
  1.0] range will step-increment of 0.01 and page-increment of 0.1).
- For small ranges (under 40), step-increment by 1, page-increment by 2.
- For bigger ranges, step-increment by 1, page-increment by 10.

For use cases when you absolutely want specific increment values, I add
the gimp_scale_entry_set_increments() function. It is much better to
have a small and understandable constructor call followed by
configuration calls (only when needed) rather than a constructor with a
crazy amount of parameters. Hence gimp_scale_entry_new() went from 17
arguments (absolutely unreadable calls) to now 5.
2020-10-30 12:33:46 +01:00
Jehan
d81b151e79 app, plug-ins: use the updated gimp_prop_scale_entry_new() API. 2020-10-30 11:02:20 +01:00
Jehan
c109a35c25 plug-ins: fix PDB data identifier to be canonical.
This is the bug which triggered me to do previous commit because the
error message was talking about a procedure name. Now the error message
is right, but let's not have an error at all! ;-)
2020-10-30 11:02:20 +01:00
Jehan
d48dae7181 plug-ins: implement file-heif proc list in init_procedures() instead…
… of query_procedures().
Since our procedure list is now fully dynamic with runtime check, it's
much better to run it at every startup. Basically if some has updated
libheif with new encoders/decoders, we want GIMP to be aware at it at
next startup even if the plug-in has not been updated.
2020-10-26 17:53:00 +01:00
Jacob Boerema
f336f86f60 plug-ins: use g_message instead of g_printerr when there is data loss.
After discussion with Jehan we concluded that it is better to report
these data loss messages to the user using g_message.
2020-10-24 18:33:26 -04:00
Jacob Boerema
e4514567f9 plug-ins: don't try to read tiff pages with an invalid directory.
We didn't check whether TIFFSetDirectory succeeded nor did
we check TIFFReadScanline for failure which can cause
unresponsiveness.

We will not try to read a tiff page if setting its directory fails
and we will stop reading a page if reading scanline fails.
2020-10-24 13:52:15 -04:00
Jehan
7462945360 plug-ins: fix a type warning.
Since obj->type_data is also int anyway, multiplying by a double value
is unneeded anyway. So let's just make an integer multiplication.
Fixes the following warning:
> warning: using integer absolute value function ‘abs’ when argument is
> of floating point type ‘double’ [-Wabsolute-value]
2020-10-24 02:58:38 +02:00
Jacob Boerema
7957653e98 plug-ins: fix #3757 Exporting invalid tiffs: Missing required "ImageLength" field.
Because of Exif.Thumbnail.* tags file-tiff-save saved an invalid extra page in
exported tif images. Removing these tags fixed this for me.
2020-10-23 17:39:09 -04:00
Jacob Boerema
c10bb098b4 plug-ins: file-tiff-save looks for the wrong exif tags to delete.
The correct tag for sub images is Exif.SubImage instead of
Exif.Image. I also added Exif.Image.InterColorProfile since
that didn't seem to get deleted when saving without
color profile.

Also added a FIXME note since most of this stuff should be
genealized for all gimpmetadata handling.
2020-10-23 12:51:04 -04:00
Jehan
c86d909dda plug-ins: fix parameters of Gimp.file_save().
It now requires a list of drawables (even though still mostly useless,
but this comes with the change of multi-selected layers).
2020-10-23 15:20:21 +02:00
Daniel Novomesky
35c0d7dca6 HEIF plug-in: runtime detection of supported formats 2020-10-22 16:46:51 +00:00
Jehan
05bb84ebed Issue #5788: 10/12 bpc in HEIF export does not mean HDR. 2020-10-19 20:47:07 +02:00
Jehan
cb2268ab21 meson: separate line for HEIC and AVIF support.
libheif pc files provides variables which are actually older than our
minimum libheif requirement (so it's usable generically) to determinate
if libheif was built for HEIC/AVIF support. This is quite useful as we
had our share of annoyance with missing support of some encoder/decoder
even when libheif requirement was alright.

Also adding image/avif (if relevant decoder is present) to list of
supported mimetypes.
2020-10-19 18:56:13 +02:00
Jehan
02cb754b4a plug-ins: run gimp_displays_flush() in foggify.
Without this call, the display is not properly updated and does not show
the newly added fog layer.
2020-10-18 00:41:22 +02:00