Commit graph

2167 commits

Author SHA1 Message Date
Jehan
b1616cfaaf libgimpwidgets: argh, silly bug. 2024-10-10 11:50:56 +02:00
Jehan
e8958e417c libgimpwidgets: show the model in the GimpColorSelect label.
Do not only show the space, but also the model. For instance both RGB
and HSV can have the same profiles.
As for LCH, we must not show any space (it is based on CIELAB).

Note that I use the string "Model: %s" which is already used in
libgimpcolor, so I am not breaking string freeze. The "%s - %s" string
though is not localized, even though ideally it should be (and possibly
even be a better joining string in English), but I don't want to break
string freeze for this.

This issue is part of the fix for #10998, more as a UX issue than a bug
per-se. Depending on how you were selecting a color, now you might
select it as HSV, LCh or some other model (this was **not** the case
before, even though the GUI was similar. Yet the stored color was always
RGB. Now it's actually "whatever you choose"). As a consequence, it is
possible that choosing a color in another model may convert to slightly
different numbers, especially within decimal places. I don't think it
was the main issue, but it certainly doesn't help. Now we may be making
clearer what color model is being used in the GimpColorSelect color
areas.
2024-10-10 11:50:56 +02:00
Jehan
d66df2aefe libgimpwidgets: do not set toggles visible when explicitly set not to…
… when changing the model.

Because of this, we had redundant toggles appearing in the Color
Selection dialog, in the GimpColorSelect tab.
2024-10-10 11:50:56 +02:00
Alx Sa
ff1a92b81e libgimpwidgets: Fix infinite loop on appending invalid input
gimp_size_entry_eevl_unit_resolver () loops through all valid units
to find a match for user's inputted value in GimpSizeEntry.
It runs until gimp_unit_get_by_id () returns NULL, where it does a
final check on GIMP_UNIT_PERCENT.
Due to a small logic error, we kept setting the GimpUnit to
gimp_unit_percent () each time it was NULL, so the loop ran forever.
Per Jehan, this patch breaks the logic up so that we terminate the
loop once the percent check fails.
2024-10-02 23:21:05 +00:00
Jehan
49ce5c2aa5 app, libgimpwidgets, plug-ins: add tooltip arg to gimp_help_connect().
As Cheesequake noted in !1673, there may be cases where one would want
to run gimp_help_connect() while also setting a tooltip. So they also
run gimp_help_set_help_data(), even though the latter is implied by the
former. Worse, it makes the order matter too much because if you call
gimp_help_connect() after gimp_help_set_help_data(), the tooltip would
be removed.

Now the reason is that gimp_help_connect() was clearly made to be run on
windows whereas gimp_help_set_help_data() was for other widgets, which
usually don't need to react to F1. Yet the previous commit does add
F1-connect for the lock buttons, which kind of makes sense. So why not
just add this tooltip argument.

As a side fix, I am removing a bunch of gimp_help_connect() on each
button in the layers effect popover. Just run it once on the top
container.
2024-08-24 23:29:39 +02:00
Alx Sa
816fb1c676 tools, libgimpwidgets: Connect SelectionOptions to icon size
This patch resizes the selection mode
icons based on the user's icon size
settings. It creates a new function in
gimpenumwidgets.c to update sizes,
then connects to GimpGuiConfig's icon
size update notifications in GimpSelectionOptions.
2024-08-15 19:07:14 +00:00
Joachim Priesner
b3daeb12b5 libgimpwidgets: Fix stack buffer overrun
3833ab2b1d changed the type of "rgb" from
gdouble[3] to gfloat[3], but it should instead have changed the type of
"lch".

Resolves #11898.
2024-08-13 17:58:18 +00:00
Alx Sa
2286a447c1 libgimpwidgets, app/core: Fix babl formats to float
This patch converts the last instances of
non-RGBA color models from double to
float for babl formats.
2024-08-08 21:44:53 +00:00
Alx Sa
3833ab2b1d libgimpwidgets: Convert CIE LCH(ab) babl format to float
This patch converts the
few instances of CIE LCH(ab) double
to float to match babl's precision.
2024-08-08 19:25:07 +00:00
Jehan
cde861a0e6 app, libgimpwidgets: fixing some obsolete unit format strings I missed. 2024-08-06 13:13:24 +02:00
Jehan
2a00a9e60a Issue #434: remove broken plural support for GimpUnit.
Rather than trying to implement full i18n plural support, we just remove
this failed attempt from the past. The fact is that to get proper
support, we'd basically need to reimplement a Gettext-like plural
definition syntax within our API, then ask people to write down this
plural definition for their language, then to write every plural form…
all this for custom units which only them will ever see!

Moreover code investigation shows that the singular form was simply
never used, and the plural form was always used (whatever the actual
unit value displayed).

As for the "identifier", this was a text which was never shown anywhere
(except in the unit editor) and for all built-in units, as well as
default unitrc units, it was equivalent to the English plural value.

So we now just have a unique name which is the "long label" to be used
everywhere in the GUI, and abbreviation will be basically the "short
label". That's it. No useless (or worse, not actually usable because it
was not generic internationalization) values anymore!
2024-08-06 11:39:57 +02:00
Alx Sa
5161c53f3c libgimpwidgets: Make GimpPickButton a derivable type
Per Jehan, we should remove gimppickbutton-default.[ch] and
move the functions into gimppickbutton.c. Then we can
make the GimpPickButtonPrivate API actually private without
any additional public functions.
2024-08-03 18:24:46 +00:00
Alx Sa
f759b17e45 libgimpwidgets: Reverting GimpPickButton for 80f09fac
Temporarily reverting as the private struct
is shared between various OS versions of
the object and needs to be accessible.
A different approach will be needed to resolve,
and until then, I'd like the Debian pipeline to
work properly.
2024-08-03 08:08:31 +00:00
Alx Sa
80f09fac59 libgimpwidgets: Finish converting classes to derivable type 2024-08-03 06:39:55 +00:00
Alx Sa
438bc4f229 libgimp, libgimpmodule, libgimpwidgets: Port more widgets to derivable type 2024-08-03 02:48:07 +00:00
Jehan
bc73232cd9 app, libgimpwidgets: fix CRITICAL on NULL GimpUnit.
I missed this one because it was using 0 instead of the GIMP_UNIT_PIXEL
macro. This was triggering CRITICALs when using the text tool.
2024-08-03 01:50:27 +02:00
Alx Sa
048b2c437d libgimp, libgimpcolor, libgimpconfig: Convert to derivable types
Also converted GimpPreview and
GimpScrolledPreview as they are the
parents of several of these widgets.
2024-08-02 14:02:30 +00:00
Jehan
d493f0537f Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!

Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.

As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.

Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.

Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-08-02 10:46:38 +02:00
Alx Sa
afce1c1f02 libgimpwidgets: Convert more gimpwidgets to derivable type
Continuation of work from 74e7e16e
2024-08-01 03:55:31 +00:00
Alx Sa
9b6e6effeb libgimpwidgets: Make GimpButton a derivable type 2024-07-30 19:04:53 +00:00
Alx Sa
74e7e16ec3 libgimpwidgets: Convert widgets to final/derived type
This patch converts libgimpwidgets with
no signals to be final or derived types.
The remaining widgets will be converted
in a subsequent patch.
2024-07-29 01:51:38 +00:00
Alx Sa
acefb593c1 libgimpwidgets: Make GimpRuler a final type 2024-07-26 16:51:51 +00:00
Alx Sa
42300d9db0 dialogs, libgimpwidgets: Prevent wide dialogs due to image/profile name
Currently if your image history includes an
image with a long name, the Welcome
Dialog will stretch out to match its width.
If the color profile name is long, then the
color scales will also stretch out due to
the profile label.
This patch adds ellipses to the Welcome
Dialog and a scrollwindow to the
ColorScales to prevent this.
2024-07-22 16:32:47 +00:00
Alx Sa
f036812a94 libgimpwidgets, widgets: Fix icons on Path locks
The visibility lock icon and help ID was accidentally
left off the PathsTreeView set-up.
The Path Attributes also used the wrong icon to indicate
the paths were locked (compared to the one shown in the
Path Attributes dialogue).
2024-07-16 17:50:41 +00:00
Jehan
d08f751626 libgimp, libgimpwidgets: use G_DECLARE_(DERIVABLE|FINAL)_TYPE macros for GimpProcedureDialog…
… and its subclasses, as well as for GimpDialog.
2024-07-13 12:24:49 +02:00
bootchk
0dae61772a Fix #11613 crash Wayland flatpak unreffing GBytes window handle
Refactor: extract method gimp_widget_free_native_handle.
This reduces duplication of code and encapsulates Wayland specific code.

Call the new function in more places.
This is expected to fix #11613 but it is hard to be sure
since the exact sequence of events in 11613 was never determined
and only reproduceable in some flatpak builds.

Calling the new function in more places also should eliminate leaks.
But I did not test there was a leak prior to this fix.
2024-07-09 17:48:53 +00:00
bootchk
bdddc94151 libgimpwidgets: fix #11339 chroma slider fail on small increments
In GimpColorSelector setter, don't change the model if perceptually same.
More than just don't emit changed, don't change the model value.

Also, fix leak by freeing old color.
2024-07-09 15:56:07 +00:00
Alx Sa
d00aacfea2 libgimpwidgets: Fix Procedure Browser description size
Currently when you open the Procedure Browser, part of the
description text is off-screen.
This patch changes the values for the GtkPaned panels so that
the description is completely visible horizontally. It also makes
the vertical scrollbar conditional on the widget height rather
than always showing.
2024-06-11 15:00:00 +00:00
Alx Sa
ceb9747e23 libgimpwidgets: New API to check system animation status
Ports the animation code started in e13cc635
to an independent gimp_widget_animation_enabled()
function. This allows plug-in authors to
also conditionally turn off animations if
the user's system settings say to do so.

The function is applied to the About
Dialogue animation as well as two Easter
Egg animations:
* Wilber's eyes blinking after 23 minutes
on an empty canvas
* Wilber's eyes following the mouse after
a certain sequence of tools is clicked
2024-06-10 13:47:25 +00:00
Jehan
a73881478c libgimpwidgets: new gimp_int_radio_frame_set_title().
This new function allows to set a title with mnemonic.

But also it properly sets the frame label as the mnemonic widget for the
radio buttons, otherwise the mnemonic is mostly bogus and doesn't
actually give focus to the editable widgets (i.e. the radio group).
2024-06-06 21:08:08 +02:00
Jehan
0b2d8fedc3 libgimp, libgimpwidgets: ability to generate a GimpIntRadioFrame for GimpChoice arguments.
This includes a new function gimp_prop_choice_radio_frame_new() which
creates GimpIntRadioFrame from GimpChoice properties.

GimpChoice GimpProcedure arguments are still creating a combo box by
default, but it is now possible to override this default behavior to get
a radio frame by calling first:

```C
gimp_procedure_dialog_get_widget (dialog, "arg-name", GIMP_TYPE_INT_RADIO_FRAME);
```
2024-06-06 20:20:30 +02:00
Niels De Graef
36c201e426 libgimpwidget: Mark gimpcolorscale as introspectable
There's no seemingly good reason for it not to be introspected, so let's
add it to the files. This also fixes an issue where the documentation
for it is not properly generated.
2024-05-21 10:08:07 +02:00
Alx Sa
47dde0580a libgimpwidgets: Fix formatting from 8adcc0cd
Some minor code style issues remained 
that I missed in 8adcc0cd.
After further reflection, I also converted
the code to be a private/internal function.
gimp_prop_check_button_new () should
cover the majority of GtkCheckButtons,
and the function is currently only used
to fix the size of those widgets. We could
revisit it as a public function in the
future if more use cases are found.
2024-05-19 02:10:23 +00:00
Mark Sweeney
8adcc0cdcb libgimpwidgets: Fix GUI twitching due to bold label sizing
Resolves #10026

Selecting a checkbutton makes the label bold. This increases the
width of its label, and if it's the longest item in a box, this
causes minor "twitching" and resizing of the dialogue.
This patch calculates the size of the label when bold and then
requests the label width be set accordingly to resolve the issue.
2024-05-18 21:33:51 +00:00
Niels De Graef
c2971f000a libgimpwidgets: Add missing GIR annotations 2024-05-11 15:30:45 +02:00
Simon Budig
e0564ae69d libgimpwidgets: don't leak dest_profile 2024-05-06 00:35:51 +02:00
Alx Sa
32d64ab1c9 core, widgets: Convert HSV/A to float
Per Pippin, the only color model that can
have double precision is RGB/A.
Therefore, we need to switch all others to
use float instead. This patch converts the
HSV and HSVA double babl formats.
2024-04-21 03:42:27 +00:00
Jehan
d661e8efb1 libgimpcolor: gimprgb-parse finally deleted.
- gimp_rgb_list_names() ported as gimp_color_list_names() using NUL-terminated
  GimpColorArray.
- GimpColorHexEntry uses the new function (and is therefore now GimpRGB free!).
- gimp_rgb_parse_name() deleted as it's unused since my previous commit.

With all this, gimprgb-parse.c is now deleted from the repository! \o/
2024-04-20 20:04:32 +02:00
Jehan
106d18605a libgimpcolor, app: gimp_color_parse_(css|hex|name)() renamed with _substring() suffix.
New functions with the same name as these functions are created, except without
the length argument (i.e. it's equivalent to calling these with -1).

The reason for this is that using strings with a length variant which may be
negative to switch to NUL-terminated strings are not bindable. At least in our
case, when testing in Python, the input string ended up as corrupted garbage and
GObject Introspection docs warns about such interfaces:

> In particular, avoid functions taking a const char * with a signed length that
> can be set to a negative value to let the function compute the string length
> in bytes. These functions are hard to bind, and require manual overrides.

(see: https://gi.readthedocs.io/en/latest/writingbindableapis.html#strings)

So instead, I create a simple version which runs on NUL-terminated strings only
and which is bound, whereas unbinding the generic length-version (making it
C-only, or maybe usable in some other bindings which ignore the (skip)
annotation; apparently some do this).
2024-04-20 12:37:20 +02:00
Jehan
2b27feb2fd app, libgimp*, modules, pdb, plug-ins: new GimpParamColor.
This is meant to obsolete GeglParamColor with at least an additional argument
has_alpha which we need in GIMP. It allows to advertize when a parameter wants
an opaque color, which in particular means we know when displaying a GUI to pick
colors with alpha or not.
2024-04-19 23:25:13 +02:00
Jacob Boerema
ae2cf562e8 libgimpwidgets: fix #10821 Problem with LabelSpin widget
For certain min/max values of the LabelSpin widget, in combination with
zero digits, it proves impossible to change the initial value.
The reason for this is that the step size may become less than 1.0.
In which case, stepping doesn't work because the number of digits is
set to zero.

Let's check for this situation and when digits is zero set the step
to 1.0 and make sure that page is at least the same value.

While testing this I also noticed another issue: when initializing
the upper value was set to 0.0 and the lower to 1.0 which leads to
a critical because lower > upper.
We fix this by switching the initial upper and lower values.
2024-04-16 21:44:22 -04:00
Jehan
956a9fac6c Issue #10715: icon for effects.
We now have a proper icon thanks to Denis Rangelov!
2024-04-16 19:54:06 +02:00
bootchk
4048556171 libgimpwidgets: fix #11255 unterminated Wayland window ID string
Copy the NULL when creating GBytes from a string.
2024-04-16 09:26:00 +00:00
cheesequake
8153dffb92 Issue #9727: Reduced text area to improve Slider UX 2024-04-15 22:31:35 +00:00
Jehan
9a353b9db9 libgimpwidgets: fix undeclared identifier.
Build for macOS on CI breaks with:

> ../gimp3-2.99.19/libgimpwidgets/gimppickbutton-quartz.c:210:45: error: use of undeclared identifier 'monitor_profile'
>       space = gimp_color_profile_get_space (monitor_profile,
2024-04-12 12:24:53 +02:00
Cheesequake
702d5e1e80 Issue #11071: Changed detailed_signal from "map" to "realize" to enable opening animations 2024-04-11 14:59:15 +00:00
lillolollo
9f86d6b8d0 libgimpwidgets: Replace deprecated CGColorSpaceCopyICCProfile with CGColorSpaceCopyICCData 2024-04-11 01:28:16 +00:00
Alx Sa
f726efba76 Don't convert to float before storing...
...in GeglColor. Just use the "u8" format.
2024-04-09 00:48:35 +00:00
Alx Sa
cc74d40769 libgimpwidgets: Port GimpPickButton to GeglColor
Also have "color-picked" signal send a
GeglColor object rather than GimpRGB.
2024-04-09 00:48:35 +00:00
Alx Sa
0ec02a4fa9 libgimpwidgets: Fix CRITICAL when no monitor profile is set
Resolves #11246

On Windows, a CRITICAL was being repeatedly thrown if you
didn't have a monitor profile set. This is because we were trying to
pass a NULL value to g_utf16_to_utf8 () whenever we needed to
convert a GeglColor.
This patch fixes it by checking if the monitor profile filename is NULL
before trying to convert it.
2024-04-07 12:52:24 +00:00