Commit graph

2241 commits

Author SHA1 Message Date
kaushik_B
ca931fbe33 Issue #14972: Fix GimpLabelSpin CRITICAL warnings for small double ranges
During instantiation, the widget bypassed saving the PROP_DIGITS state
because the spinbutton was not populated, leaving digits at 0. This
forced the widget into an integer state, causing step calculations to
break for small fractional ranges (e.g., 0.001 to 1.0).

Added G_PARAM_CONSTRUCT to the digits property and moved the internal
assignment outside the spinbutton check so the correct initial state
is saved immediately.

Added a check to ensure step and page do not go out of range.
2026-02-28 13:19:04 +00:00
Lukas Oberhuber
cb730621e6 Issue #11998: do not steal focus from spin widget when double clicking 2026-02-21 13:48:16 +00:00
Alx Sa
29f991cbf2 libgimpwidgets: Reorder GimpPropToggle docs
The documentation for gimp_prop_toggle_new ()
had "icon_name" and "label" in the wrong order.
This patch fixes the documentation to be consistent
with the API.
2026-02-13 05:29:53 +00:00
Jehan
3d707b42e4 libgimpwidgets: have gimp_widget_get_monitor() work on Wayland too.
Our historical heuristic looking for the main monitor based on the
position of the center point in a widget just won't work on Wayland,
where reported positions are always (0, 0). This is the security policy
for this protocol.

Instead we must now use gdk_display_get_monitor_at_window() which is
meant to do the approximation of determining the monitor a surface is
in, for us.

This is one step of implementing color management for Wayland (#15827),
except we still need the code to get the ICC profile of a monitor (but
now at least, we know which monitor we are on).
2026-02-09 14:09:58 +01:00
Bruno Lopes
801d845011 libgimpwidgets: Mark gimpcolorscales and gimpcolorselect as introspectable 2026-01-28 14:48:48 +00:00
Jehan
e28c97d28f libgimpwidgets: add an API warning for deleting GIMP_ICON_TEXTURE later. 2026-01-21 21:45:29 +01:00
Gabriele Barbero
08abaa721a libgimpwidgets: make GimpBrowser emit "stop-search" signal
This commit enables GimpBrowser to emit the "stop-search" signal,
originally emitted only by the internal GtkSearchEntry.
It also connects this signal to all widgets embedding a GimpBrowser,
so they can intercept it and close themselves.
This restores the behaviour that existed before the GtkSearchEntry update
2025-12-07 19:46:03 +01:00
Jehan
38881a8925 libgimpwidgets: gegl_init() unneeded here.
Plug-in developers should just call gimp_ui_init() when using libgimpui.
This takes care of initializing GEGL for you.
2025-12-05 23:06:26 +01:00
Jehan
c558e41517 libgimpwidgets: update color area correctly when updating color.
Since we don't necessarily re-render the color area when the color
change, let's store the actually rendered color, additionally to the
supposedly rendered color. Otherwise when changing the color by very
small increments, small enough that the color is always perceptually
identical to the previous color, we never re-render the widget, even
when the rendered color is now quite different. Indeed the "identical
color" algorithm, based on CIE2000 distance, is not transitive.

Additionally I do not check for perceptual identity in
GimpColorSelection anymore, because we also check for this in the
GimpColorArea. Better always having the right color set in the area.

This was raised in #11339 (even though the initial issue was about the
hexadecimal field).
2025-11-21 19:33:09 +01:00
Alx Sa
5fde1b9e89 libgimpwidgets, theme: Group radio buttons together
This patch swaps out the GtkBox in
gimp_enum_icon_box_new_with_toggle ()
with a GtkButtonBox and sets it to EXPAND
so that the buttons are pressed together.
It also adds some CSS style to complete
the effect.
2025-11-15 02:50:17 +00:00
Ondřej Míchal
a8da6d3ba5 libgimpwidgets: Cast ints to doubles before division 2025-11-05 18:48:29 +02:00
Jehan
a5fe4f1ca5 Issue #11613: crashing when freeing window handle (again).
This is a followup of commit 0ff960c45b which was the right fix, except
that we must make sure that gimp_widget_free_native_handle() is called
**before** chaining up with the widget's parent dispose().

Failing to do so, the first parent's dispose() was destroying the
associated GdkWindow, which made it impossible to call
gdk_wayland_window_unexport_handle() on it. And therefore we were still
getting handle callbacks possibly run after the window was destroyed, if
we were very fast enough to destroy a window immediately when it is
being shown.

I was still experiencing a crash when closing the Export file dialog
very fast with Esc while it was reappearing after canceling a plug-in's
export dialog.

This followup commit reorders the one case where we still had the crash
because of this order issue, and adds some docs comment to tell
developers how to use the freeing function.
2025-10-30 18:53:00 +01:00
Jehan
0ff960c45b Issue #11613: crashing when freeing window handle.
It is a tentative fix as I had this crash once but could not reproduce
it, even redoing dozens of times the same thing I had done.

It is mostly based on something which GDK docs of
gdk_wayland_window_export_handle() says:

> To unexport the window, gdk_wayland_window_unexport_handle() must be
> called the same number of times as gdk_wayland_window_export_handle()
> was called. Any 'exported' callback may still be invoked until the
> window is unexported or destroyed.

So when the GdkWindow of the widget still exists, let's make sure we
call gdk_wayland_window_unexport_handle() as many times as necessary (no
less, but also no more!), and also that we disconnect all handlers which
could possibly call more export_handle().
2025-10-24 02:24:53 +02:00
Jehan
b879deb323 libgimpwidgets: clean documentation and implementation.
- Added some link annotations to other types or functions.
- Rename argument @handle to @window_handle in
  gimp_widget_set_native_handle() docs to be similar to the same
  argument of gimp_widget_free_native_handle().
- Fix annotation of the handle to (inout) though I do wonder if this can
  really be usable in bindings anyway because of the asynchronous logic.
  Maybe these functions should be skipped for bindings?
- Better docs globally, and in particular remove implementation details
  in gimp_widget_free_native_handle() docs. The point is that the handle
  is to be considered opaque data and you have to run this when you ran
  gimp_widget_set_native_handle(). No need to talk about Wayland or
  explain that it's a GBytes or meanings of "handle".
- Also clean the free() implementation with far too many comments, and
  in particular we don't need to check if the handle is NULL.
  g_clear_pointer() steps out by itself if the pointed data is NULL.
2025-10-24 02:24:53 +02:00
Jehan
faa288300f libgimpwidgets: consider NULL value of GimpLabelEntry as empty string.
Fixes:

> (file-svg:125356): Gtk-CRITICAL **: 22:11:43.459: gtk_entry_buffer_set_text: assertion 'chars != NULL' failed

… when running file-svg-export because the default of the "title" string
argument is NULL.

I did hesitate considering this was a bug in file-svg code on the
premises that a NULL value was not valid (hence replacing it as ""), but
in the end, I went with the more flexible solution, which is that NULL
is considered equivalent to "". So GimpLabelEntry code will just
transform the NULL pointer internally to an empty string.
2025-10-14 22:28:37 +02:00
Ondřej Míchal
a3274d78eb libgimpwidgets: Use GtkSearchEntry in GimpBrowser
Instead of using a makeshift search entry use the one provided by GTK.
As a side-product it allows the procedure browser to shrink its left
panel a little more.
2025-10-12 16:04:07 -03:00
Ondřej Míchal
08218c7056 libgimpwidgets: Enforce minimal sizes of panels in GimpBrowser
The 'Plugin Browser' and 'Procedure Browser' use the same logic for
enforcing the minimum size of the details page and the list views. And
both are doing it by first setting the minimum: size of GtkTreeView and
then they climb up the widget tree to do the same. This is not ideal.

Setting the minimum size of GtkTreeView is not necessary because it is
inside of GtkScrolledWindow which makes this request moot. It also does
not enforce the minimum height of the widget for that reason. And if
GimpBrowser ever changes, both browsers will need to update their logic.
Moving the size enforcing a level up is logical and more robust.
2025-10-12 16:04:07 -03:00
Jehan
7c7f7b4898 app, libgimpwidgets: add 2 new icon macros.
New libgimpwidgets icon macros: GIMP_ICON_LAYER_LINK_LAYER and
GIMP_ICON_LAYER_VECTOR_LAYER. Note that the actual icons still need to
be done so I use temporary actual icon designs for now.

Also adding some TODOs for these.

Fix run warning:

> WARNING: icon theme has no icon 'gimp-vector-layer'.
2025-10-10 23:34:37 +02:00
Anders Jonsson
becd662315 libgimpwidgets: fix overlapping ngettext usage
In the page selector the translation for "All n pages selected"
was always used, even if all pages weren't selected. This was
caused by the same singular msgid being used in multiple places
with different msgid_plural.

These were then all smashed into a single translation. Replace one
of the singular msgid:s to avoid this. This string is never shown
since the n_selected == 1 case is already covered earlier in the
code.
2025-10-08 22:14:24 +02:00
Bruno Lopes
f09007507f
Declare gexiv2 dependency on many targets (due to gimpmetadata.h)
Our build files were relying 'sysroot' to find gexiv2.h but this is
not possible with Apple Clang om which sysroot points to macOS SDK.
So, exotic environments like Homebrew were failing. Let's fix this.
2025-10-03 18:31:53 -03:00
Alx Sa
23a9758a7b libgimpwidgets: Update hex color as you type
This patch connects the gimp_color_hex_entry_events ()
function to "key-release-event" and adjusts the code
to update valid colors as you type. Pressing Enter
will work as before, converting back to the last valid
color if an invalid one is typed.
2025-09-25 11:48:17 +00:00
Lukas Oberhuber
cacb8d2035 clipboard: Fix #14639
This is the recommended fix from Gtk to use our own mime type rather than depend on a mimetype
that has a different expectation of payload.

This means drag and drop of colors uses `application/x-geglcolor` rather than `application/x-color` which expects an RGBA color rather than a structure.
2025-09-21 00:06:15 +01:00
Alx Sa
c8cf2219ce libgimpbase, libgimpwidgets, tools, app: Remove warnings
This patch fixes a few (mostly Windows-specific) warnings on build.
* Hides functions like gimp_get_foreign_window () and variables
like transient_set that aren't used in Windows.
* Changes hollow_g_shell_quote () to not return a const gchar *,
since the value it returns is actually not const.
* Cast update_interval to double to remove warning about mixing
enums and doubles in division.
2025-09-07 18:41:13 +00:00
Jehan
6c1c497ce0 libgimpwidgets: fix build warning.
This fixes the following warning when compiling with CLang:

> libgimpwidgets/gimppropwidgets.c:3961:11: warning: variable 'unit_type' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
>  3961 |       if (pspec_unit && GIMP_IS_PARAM_SPEC_UNIT (pspec_unit))

If a unit property name is set, it must be a valid unit property. Let's
check, output a CRITICAL and return NULL otherwise.
2025-08-31 17:49:24 +02:00
Jehan
bbb0be8413 Revert "libgimpwidgets: #pragma once, and formatting and ordering"
This reverts commit c71661bf24.

See https://gitlab.gnome.org/GNOME/gimp/-/issues/14668
2025-08-14 00:54:52 +02:00
Alx Sa
d58b17cb10 libgimpwidgets: No decimal for u8 RGB color selector
This patch uses the is_u8 variable in GimpColorScales's
create_group () function to conditionally set decimals to
0 when creating u8 RGB color selectors.
This change will help further distinguish between the 0...00
and 0..255 views in the Color Selectors. It will also better
convey to users that u8 is an integer value rather than a
floating point.
2025-08-07 04:05:48 +00:00
Alx Sa
9a1984a707 libgimpwidgets: Use arrows for GimpSpinScale cursors
The "grabbing" cursor currently used is quite large on
newer versions of GTK3, and makes it difficult for users
to see where they're grabbing. This patch switches to
using "pointer" cursor for hovering over the slider area,
and "col-resize" when actually moving the slider.
It also reverts padding changes in CSS so that the progress
bar aligns with the place the user clicks. Padding is added
in Cairo for the label, though the number entry is now
flush against the input buttons.
2025-08-06 18:19:36 +00:00
Gabriele Barbero
e9090f9b55 libgimpwidgets: enable expression parser for GimpSizeEntry
This commit allows the "reference value" spinbuttons in GimpSizeEntry
to accept and evaluate mathematical expressions, just like the main
value fields. The GimpEevl parser is now attached to both value and
reference value spinbuttons.
2025-08-05 23:43:30 +00:00
Michael Natterer
c71661bf24 libgimpwidgets: #pragma once, and formatting and ordering 2025-07-13 12:23:24 +02:00
Michael Natterer
50ce759eca libgimp*: revert using g_set_str() outside app/ 2025-07-10 23:27:54 +02:00
Michael Natterer
89ea91df96 app, libgimp*: more g_set_str() and some other stuff in the same
spirit
2025-07-08 00:37:26 +02:00
Michael Natterer
76caac9481 libgimp, libgimpwidgets: fix (closure) annotations. 2025-07-07 17:59:32 +02:00
Alx Sa
963830fd91 libgimp, libgimpwidgets: Add GimpCoordinates widget...
...to GimpProcedureDialog.
This patch allows plugin developers to create a
GimpCoordinates widget (two GimpSizeEntries linked
together with a chain and with a units combo) in the
GimpProcedureDialog.

It is largely a wrapper for gimp_prop_coordinates_new ().
This patch also makes that function more responsive
to the unit property, now that GimpUnit has a proper
GParamSpec implementation. The default unit and
whether we show pixels, percents, or the resolution
spinners can now be determined via the unit
parameter (if set) rather than relying on
hardcoded values.

As a demonstration, the Tile plug-in's width/height
entries were restored to what they were before the
GimpProcedureDialog port, with units and a chain
link between values.
2025-06-10 19:37:35 +00:00
Jehan
e8ffb8ff0e libgimpwidgets: new gimp_prop_toggle_new() property widget function. 2025-05-22 21:14:20 +00:00
Jacob Boerema
7add94f868 libgimpwidgets: gtk-fallback-icon-theme is deprecated...
since GTK 3.10 and according to the GTK3 documentation the setting
is ignored.

Remove the reference to it and thus setting a fallback. According to
the GTK docs `hicolor` is the fallback icon theme.
Since `gimp_icons_notify_system_icon_theme` was only used to add
the fallback, remove the function and setting it with
`g_signal_connect`.
2025-05-22 16:18:44 -04:00
Alx Sa
cb0f8a0282 libgimp, libgimpwidgets: Let string widgets expand horizontally
This makes GimpProcedureDialog string argument widgets expand
horizontally by default.
2025-05-11 05:50:49 +00:00
Jehan
0e7c4fec14 libgimpwidgets: slightly better form.
Previous code was right and equivalent because
gdk_wayland_window_export_handle() works asynchronously in the same
thread (so phandle can't get overridden by mistake). Nevertheless a
quick code scan felt surprising, so to avoid any such future surprise,
let's just switch the order of statements.
2025-03-23 18:10:25 +01:00
Alx Sa
c997349eec libgimpwidgets: Add default response for GimpQueryBox dialogues
Resolves #13293
This patch fixes a regression from 2.10. The OK button
was not set to be the default response for certain
Selection dialogues like Shrink/Grow/Border, so
users could not just press Enter to apply if they were
fine with the default values. This patch adds a call to
gtk_dialog_set_default_response () to restore this
behavior.
2025-03-22 02:10:46 +00:00
Alx Sa
a74287c5cc libgimpwidgets: Shrink width of GimpSizeEntry
In 2baa518a, to avoid a critical we use
the resolution as the width of GimpScaleEntry
when the unit is set to pixels.
This had the side-effect of making the
width of the GimpSizeEntry very long when
the unit is initially set to pixels.
Since GimpUnit is now an object, the original
critical no longer displays. Therefore, we
partially revert 2baa518a and refer to the
value as entry_width instead for clarity.
The minimum width is set to 7 to match
the minimum width of GimpSpinButton.
2025-03-01 03:45:13 +00:00
lloyd konneker
cdf7a58dd1 libgimp: GimpFileChooser: fix #12847 inf loop in signal handler 2025-02-07 07:23:42 -05:00
Jehan
dd15b6a9a3 libgimpwidgets: GimpFileChooser should also be start-aligned. 2025-01-26 21:17:33 +01:00
Jehan
db2d3cffa2 libgimpwidgets: new GimpFileChooser widget.
This widget will replace our usage of GtkFileChooserButton, except that
it has a title label and also it contains GUI implementation for the
SAVE and CREATE_FOLDER actions (unlike the GTK button). Moreover this
widget was removed in GTK4. So it is a good idea to start encapsulating
such GTK widget anyway.

I'm also adding a propwidget function to create such a widget bound to a
GimpParamSpecFile property.

New functions:

- gimp_file_chooser_get_action
- gimp_file_chooser_get_file
- gimp_file_chooser_get_label
- gimp_file_chooser_get_label_widget
- gimp_file_chooser_get_title
- gimp_file_chooser_get_type
- gimp_file_chooser_new
- gimp_file_chooser_set_action
- gimp_file_chooser_set_file
- gimp_file_chooser_set_label
- gimp_file_chooser_set_title
- gimp_prop_file_chooser_new
2025-01-26 18:13:55 +01:00
Alx Sa
0097d34a8f libgimpwidgets, plug-in: Reduce height of Load PDF dialog
This patch does the following to reduce the
height of the Load PDF GUI:
* Hides the title label if the PDF does not
have a title.
* Reduce the padding around elements
* Reduces the requested height of the
GimpPageSelector widget.
* Alter the GimpPageSelector widget so
that the layer/image combobox and the
range entry are on the same line.
2025-01-25 17:27:55 +00:00
Jehan
b1acb256e1 libgimp*, plug-ins: now hide GimpParamSpecChoice struct.
New libgimpbase functions:

- gimp_param_spec_choice_get_choice
- gimp_param_spec_choice_get_default

Now the only GParamSpec in libgimpbase whose struct is visible is
GimpParamSpecObject. This can't change since it is derived into param
specs defined in libgimp and therefore needs to be visible.
2025-01-25 01:28:19 +01:00
Jehan
3115d97248 libgimpwidgets: fix crashing prop file chooser button with GFile arg.
This same widget is used for GFile args and GimpParamSpecConfigPath
specs. The latter are string-based. So we need different code to handle
both types of arguments.

This was crashing when a change was coming from the config object,
rather than from the GUI, such as when doing a reset to factory values.
2025-01-23 23:36:34 +01:00
Alx Sa
201ab6ff7a actions: Add new Navigation dockable icons
This patch connects the new icons made by Denis Rangelov
for the Shrink Wrap and Fill Window zoom actions in the
Navigation Dockable.
2024-12-26 17:00:17 +00:00
Alx Sa
e409a74ec2 libgimpwidgets: Ellipsize GimpColorSelect color profile labels
Similar to 42300d9d, we want to prevent overly long color profile
labels from stretching out dialogues with GimpColorSelect too far.
This patch adds gtk_label_set_ellipsize () to both the color profile
and simulation profile labels, and adds them to a grid instead of
letting them free-flow.
2024-11-26 21:56:11 +00:00
Alx Sa
9b23c35c30 libgimpwidgets: Replaced deprecated gtk_icon_theme_add_builtin_icon ()...
...with gtk_icon_theme_add_resource_path (). Per Wormnest in !1027, this function
might not even be necessary at all. But until removing it can be completely tested,
this patch at least removes the deprecation warning for GIMP 3.0 RC1.
2024-11-02 23:26:18 +00:00
Jehan
5f4464445f libgimp*: keep 10 reserved spots for future virtual functions in every derivable class.
Hopefully this should be enough to add new features in the future
without breaking ABI, at least until GIMP 4!
2024-11-01 17:22:07 +01:00
Jehan
724e317272 libgimpwidgets: GimpFileEntry is not public anymore.
The whole widget was made deprecated in 2006 (commit 99f979e118) but it
is still being used by another widget. Since we can break API, I at
least hide the functions and type by making these private.

This will give us time to think if we really need this widget (or a
nicer implementation for this widget) or if we just want to get rid of
it.
2024-10-31 19:54:43 +01:00