Commit Graph

1916 Commits

Author SHA1 Message Date
Jehan b326b68b32 libgimpwidgets: GtkComboBox "active" property must trigger…
… GimpIntComboBox "value" property.
For this, I connect to the "changed" signal, which is equivalent anyway.
Otherwise the link was not bidirectionnal, so selecting a new item in
the combo list was not actually changing the internal value, hence the
binding set by gimp_prop_int_combo_box_new() was not complete either.
Not sure how I missed that. Hopefully not missing anything else!
2020-09-29 17:02:21 +02:00
Jehan db71a8ffc7 libgimpwidgets: add a "value" property to GimpIntComboBox…
… and have gimp_prop_int_combo_box_new() bind to "value" instead of
"active".

The "active" property is defined by GtkComboBox and is the index of the
combo box, not its values, whereas with gimp_prop_int_combo_box_new(),
we want to bind an int property to the combobox value. Therefore the
commit 0828a371c2 was only properly working when we were creating a
combo box with values starting at 0 and incremented by 1.

By adding a "value" property to GimpIntComboBox, I allow binding any
property to the int value rather than the index.

See also !265 where the issue was raised as it affected our HEIF
plug-in.
2020-09-18 15:26:32 +02:00
Jehan 6ef0a5f294 libgimpwidgets: minor alignment and indentation fixes.
Fixing coding style from previous commit.
2020-09-15 20:34:42 +02:00
Niels De Graef 0828a371c2 propwidgets: Use g_bind_property()
Make some property widgets implementations easier by just using
`g_bind_property()`, which does all the property change handling for us.
2020-09-15 16:34:24 +00:00
Niels De Graef 5d3ca7d714 propwidget: Add gimp_prop_switch_new()
Allow developers to add a `GtkSwitch` based on a property. Also start
using it in the first preferences page.
2020-08-22 23:53:49 +00:00
Jehan d886bb1b90 libgimpwidgets: improve/fix more of GimpMemSizeEntry.
Looking further at this widget, many things are not right. Here are the
changes:
- Use binary prefixes (i.e. kibibyte, mebibyte and gibibyte) instead of
  decimal ones. We are making binary shifts so we were actually showing
  the wrong units.
- Round the value to the closest integer when showing it, not towards 0.
  Otherwise I had cases where it was showing 7GiB for an actual value of
  7.69GiB (default as computed by GIMP from my actual physical memory).
  Note that I am actually unsure even rounding makes sense. Shouldn't we
  rather show double values with a few digits after the decimal points?
  For such values, I think it would make sense.
- Do not edit the internally saved accurate value when the entry is
  edited to the same less accurate value as our saved value would be
  shown too. In particular when changing the display unit to a bigger
  one, we don't want to lose accuracy. This is especially true for low
  values. Say you don't have a lot of memory and you set the Tile cache
  size to 1.5GiB (1536MiB), you certainly don't want it to become either
  1 or 2GiB when switching display unit to GiB. Now even if the number
  will still display with less accuracy, the internal value will stay
  accurate.
2020-08-05 14:35:34 +02:00
Jehan 0be4e5c1dc libgimpwidgets: fix setting GimpMemSizeEntry value with unit change.
This bug doesn't happen when setting value through the GUI as in such
case, the unit never changed. It happened when setting a value which
could not be properly displayed by current unit (typically smaller than
1 in this unit, or with remainder).
In such a case, we should not manually set private->shift before
gimp_int_combo_box_set_active(), or the callback was failing to
reconfigure the GtkAdjustement, in particular min and max values.

As a consequence, hitting a Preferences reset, with a GimpMemSizeEntry
in Gigabytes, it got reset to Kilobytes with the max values capped at
4096. So I realized a Reset ended me with a Tile cache size of 4096 KB
in particular, which is of course ridiculously small and would be a
problem if one doesn't notice the issue immediately.
2020-08-05 12:46:28 +02:00
Ell e531023031 libgimpwidgets: handle Enter/Esc keys in GimpSpinButton
In GimpSpinButton, don't propagate Enter key-press events if
updating the spin-button's value in response changes the entered
text.  This prevents confirming dialogs when hitting Enter after
entering a math expression in size entries, updating their value
instead.

Likewise, don't propagate Escape key-press events if a new value
was entered, and restore the original value instead.
2020-07-14 13:00:55 +03:00
Niels De Graef 842dc7535f gir: (skip) functions with varargs
Bindings can't handle these, so they are not introspectable.
2020-05-21 13:49:38 +02:00
Niels De Graef c2d4e7d265 gir: Fix some missing (out) annotations 2020-05-18 13:26:23 +02:00
Niels De Graef 09094fe66f gimpenumwidgets: Apply (transfer none) annotation
`(out)` implies `(transfer full)`, which isn't the case here. Let's fix
it before anyone tries to use it and gets hard to debug problems.
2020-05-18 13:00:58 +02:00
Niels De Graef 65b12c108d libgimpwidgets: UnitStore: Fix conflicting names
`gimp_unit_store_get_value()` clashes with the `get_value()` method of
its parent class GtkTreeStore. This means trouble for bindings, as seen
here in some pseudocode:

```vala
var unit_store = new Gimp.UnitStore();
// Which function are we referencing here, the one from GtkTreeStore or
// the one from GimpUnitStore? Worse, they both have different arguments
unit_store.get_value( ... )
```
2020-05-10 12:06:33 +00:00
Niels De Graef 69c5fd02d4 GimpHelpFunc: don't annotate (closure)
This is incorrect in that bindings trying to pass on the function cannot
pass on a user data (for closures). As such, get rid of the annotation.
2020-05-09 00:16:15 +02:00
Niels De Graef 4f46c9298e gimpintstore: Mark iter (out) annotations 2020-05-08 21:14:35 +02:00
Niels De Graef aa6079fe8a scrolledpreview: Add missing gir annotations 2020-05-08 19:48:11 +02:00
Niels De Graef 4b6362c0bd gir: Mark more (out) annotations 2020-05-08 17:11:14 +02:00
Niels De Graef 86478fe78a gimppropwidgets: Add (nullable) annotation for label 2020-05-08 16:28:48 +02:00
Niels De Graef 7aee2d1ea5 gir: Fix typo nulllable → nullable 2020-05-08 16:04:40 +02:00
Niels De Graef ed310dd48d Fix some gtk-doc comments and GIR annotations 2020-05-08 15:26:42 +02:00
Niels De Graef a8de828195 gimpwidget: Correct gtk-doc docs wrt GtkHBox
GtkHBox is a deprecated version of GtkBox, which we don't even use
anymore. It confuses the gtk-doc a build though, so let's fix it to get
rid of another warning.
2020-05-08 14:17:18 +02:00
Niels De Graef 4729fc8dec Use GIMP_TYPE_RGB instead of G_TYPE_POINTER
That way, bindings can set the correct signature for callbacks.
2020-05-06 10:36:33 +00:00
Niels De Graef 97fcc8ca0f gir: Mark gimp_dialog_new() parent nullable 2020-05-05 19:14:58 +02:00
Niels De Graef 83d6764e0e gir: Add (closure) tags 2020-05-04 21:31:30 +02:00
Niels De Graef 7f58f2d6e5 gir: Add more missing (array) and (out) annotations 2020-05-04 21:29:42 +02:00
Niels De Graef 9c9e310a67 gir: Add missing annotations
Otherwise we won't be able to generate proper API for our bindings
2020-05-04 02:11:57 +02:00
Niels De Graef cf41d1fdf8 colorselector: Rename signal emitters
The GIR parser is giving warnings because both e.g. a signal, a
corresponding vfunc and a method emitting it are named
"channel_changed", which can and will give issues in some bindings.

The easiest option is to follow the general convention of starting the
signal emitters with `emit_`, which also makes clear the intention of
the method.
2020-05-03 23:23:44 +02:00
Niels De Graef db0493aa0d gir: Add more (out) annotations
This will change the API for some bindings, so we probably want to do it
before a release.
2020-05-03 17:57:23 +02:00
Ell 5dc1572b01 libgimpwidgets: fix logarithmic transform in gimp_scale_entry
Use the right GtkAdjustment in gimp_scale_entry_log_to_linear().
See merge request !49.

Thanks to MihailZenkov for spotting this!
2020-04-20 18:45:04 +03:00
Niels De Graef 878804fb01 Cleanup GObject signal marshallers
* Don't generate our own marshallers if they are available in GLib
  already
* Don't set the c_marshaller parameter in `g_signal_new()` if it's a
  default marshaller provided by GLib. See commit message of commit
  39e4aa3c57 on why this is the case.
2020-04-01 21:20:01 +00:00
Jehan ec9dbd8115 libgimpwidgets, app, plug-ins: fix last GIR warnings.
gimp_int_radio_group_new() was still complaining about the scope of
radio_button_callback(). Make it (scope notified) because it needs to
stay alive after the function returns and may be called multiple times.

Also adding a GDestroyNotify to free the callback data once the widget
is destroyed (additionally it will also serve as a notifier for bindings
to properly free the callback closure itself, not only it's data).

With this last one done, GObject Introspection generation now happens
without any warning output.
2020-01-15 14:00:19 +01:00
Ell ac8bf47fa6 libgimpwidgets: control GimpSpinButton scroll increments using modifiers
In GimpSpinButton, adjust the scroll step in response to modifiers:
normal scrolling uses the step increment, Ctrl uses the page
increment, and Shift scales the step increment down by the ratio
between the page and step increments (up to the minimal precision
of the spin button).

This applies to all spin buttons used in GIMP, including spin
scales.
2020-01-08 21:00:57 +02:00
Ell 5646e03eb3 app, icons: add 3D Transform tool
Add a new 3D Transform tool, based on GimpToolTransform3DGrid,
added in the previous commit.  The tool UI provides a notbook with
three tabs, corresponding to the three GimpToolTransform3DGrid
modes:

  Camera - allows setting the primary vanishing point, as well as
  the camera's focal length, expressed either directly, or as the
  camera's angle of view, relative to the whole image or the
  transformed item.  By default, the vanishing point is aligned
  with the item's center, and the angle of view is fixed relative
  to the item; this essentially means that each item is transformed
  using a local perspective, independent of its position and size
  relative to the image.  A global perspective can be achieved by
  using a common vanishing point and focal length (or an image-
  relative angle of view).

  Move   - allows moving the item using X, Y, and Z offsets.

  Rotate - allows rotating the item using X, Y, and Z Euler angles.
  The order of rotation of the different axes can be controlled by
  a set of numbered buttons next to the sliders, and the rotation's
  pivot can be controlled using a pivot selector.
2020-01-06 21:52:54 +02:00
Ell 46e01d37db app, icons: add GimpPivotSelector widget
GimpPivotSelector is a 3x3 grid of toggle buttons, used for
selecting a natural pivot position (e.g., for a transform) relative
to an item: its center, its corners, and the midpoints of its
edges.
2020-01-06 21:35:52 +02:00
Ell a9e357d72d libgimpwidgets: fix percentage use in size-entry arithmetic when lower-bound != 0
In GimpSizeEntry, the value corresponding to 0%, as per
gimp_size_entry_set_size(), may be non-zero.  This works correctly
when using the size entry in percentage mode, but not when using
precentage as part of arithmetic.

Fix this by adding an 'offset' parameter to eevl's unit-resolution
callback, which can be specifies a constant value to add as part
of unit conversion, after scaling the converted value by the
conversion factor.  In GimpSizeEntry, use this parameter to offset
percentages by their lower bound.
2020-01-06 21:35:52 +02:00
Michael Natterer 05896b4e2f libgimpbase: rename and reorder the values of enum GimpSelectCriterion 2019-11-19 22:25:57 +01:00
Michael Natterer c287fb6239 libgimpwidgets: reorder enum GimpIntStoreColumns
so LABEL and ABBREV are next to each other.
2019-11-19 21:06:05 +01:00
Jehan 4150bbb59f libgimpwidgets: (meson) a whole list of headers were not introspected. 2019-10-19 22:45:59 +02:00
Jehan b8d8424ae0 app, libgimp*: (meson) fix all the generated `*-enums.c`.
More of the files were wrong, or at least not absolutely identical to
the files generated by the autotools. I am not doing any code change
other than trying to make both build systems produce identical files
(except for slight differences on 2 files not worth the effort) even
though maybe some things can be improved (especially on the include
list). Maybe to be improved later.

Also fixing 2 of the previously autotools-generated files because of
space typos which should have been committed earlier.

Finally it is to be noted that there is no logics to copy the generated
files back to the source directory in the meson rules. I am not sure
anyway this is really worth it and maybe we should just stop tracking
these generated files eventually.
2019-10-19 22:32:29 +02:00
Jehan 5d79fba823 libgimpwidgets: (meson) fix gimpwidgetsenums.c generation.
Noticed by Massimo.
gimp_type_set_translation_domain() calls were missing.
Also make so that the output is exactly similar (even whitespaces) as
the autotools one, making it easier to diff, hence maintain.
2019-10-19 17:51:21 +02:00
Jehan 9dcdf37ab3 libgimpwidgets: check error return for gtk_icon_theme_load_icon().
In gimp_page_selector_add_frame(), if "gimp-frame" icon cannot be loaded
(which should not happen, but reality can always strike back!), we want
to abort from gimp_page_selector_add_frame() immediately.

Also as a consequence, its return value might be NULL, hence should be
freed with g_clear_object() instead.

This happened here because of broken meson rules (which didn't install
this icon) and ended up in forever looping errors when loading a
multi-page PDF (pages are shown in frames in a dialog):

> (file-pdf-load:12348): GdkPixbuf-CRITICAL **: 11:59:28.513: gdk_pixbuf_copy_area: assertion 'src_pixbuf != NULL' failed
2019-10-12 12:25:55 +02:00
Michael Natterer d02d97e310 libgimpwidgets: add gimp_prop_int_radio_frame,box_new() 2019-10-03 15:59:09 +02:00
Michael Natterer 1f7c823a90 libgimpwidgets: remove the gimp_radio_group_*() functions
they are antique cruft and unused.
2019-09-25 23:37:03 +02:00
Michael Natterer 9593121431 app, libgimpwidgets: return visible widgets from all gimp_prop_foo_new()
and remove a gazillion gtk_widget_show() all over the place, some
places need a gtk_widget_hide() now, and I'm pretty sure I broke at
least one thing in all those files...
2019-09-25 20:24:06 +02:00
Michael Natterer e80c90e17d libgimpwidgets: change gimp_int_store_new()'s signature
to match gimp_int_combo_box_new(), and add gimp_int_store_new_valist().

Move the va_list of (name, value) parsing code to
gimp_int_store_new_valist() and use it from
gimp_int_combo_box_new_valist().

This makes the entire GimpIntStore/GimpIntComboBox stuff useable much
more generically for the price of an incompatible change of a public
function that is used exactly once outside of libgimpwidgets.
2019-09-24 00:20:47 +02:00
Michael Natterer dbd793d631 libgimpconfig: get rid of filenames in all config related APIs
and rename function names which say "gfile" to just "file".
2019-09-21 12:55:12 +02:00
Michael Natterer 693984e235 app, libgimpwidgets: use the new parasite (de)serialization API 2019-09-21 12:26:29 +02:00
Félix Piédallu 65eff6f150 Meson port. 2019-09-11 16:42:04 +02:00
Ell d93fefb174 Issue #3876 - The tool options of some transform tools are vertically centered ...
... in their dockable dialog

In GimpChainButton, override GtkWidget::compute_expand() to avoid
inheriting [hv]expand from the button's chain lines, so that these
propeties don't in turn propagate to the widget's ancestors,
screwing with their layout.
2019-09-09 16:53:52 +03:00
Michael Natterer ea4fe02a6d libgimpwidgets: some docs fixes 2019-08-18 14:07:17 +02:00
Jehan f22290e0a2 libgimpwidgets: fix a warning. 2019-08-17 10:53:45 +02:00