Commit Graph

6250 Commits

Author SHA1 Message Date
Jehan 77712347d1 app: fix a random segmentation fault.
I had this one case at GIMP exit where destroying editor->selection
inside gimp_colormap_editor_set_context() was segfaulting, very likely
because the widget was already destroyed so the pointer was dangling.

Therefore set a weak pointer, and clear it in dispose, so that whatever
comes first at destruction time will reset the pointer to NULL.
2024-08-26 13:35:49 +02: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
cheesequake aad228cfeb widgets: Set up help-ids properly
This patch adds gimp_help_connect () calls before
gImp_set_help_data () to set up F1 keybind to work
properly. It also adds lock_visibility_help_id to channel
view.

Resolves #11718
2024-08-24 23:20:23 +02:00
Jehan 6ca0a78452 Issue #7497: Unable to drag layers in the layer list of another open project. 2024-08-20 12:38:09 +02:00
Alx Sa 3beb2e88ec widgets: Restore GTK2 tab scrolling behavior
In GTK2 and GIMP 2.10, you can use the mouse scroller to
switch between dockable tabs if you hover over the bar.
This behavior was removed from GtkNotebook in GTK3.
This patch follows other GTK3 applications in re-implementing
the behavior with a scroll-event callback.
2024-08-19 15:59:34 +00:00
Jehan 59eeae66fd app, tools: fix build without iso-codes package. 2024-08-17 21:16:00 +02:00
Jehan 70ef4bb507 Issue #10439: Recently Closed Docks shows empty submenu after reopening…
… closed docks.
2024-08-17 14:07:33 +02:00
Jehan 32d18f28e7 app: fix a crash when editing the shortcut not on an actual action.
Liam was hitting Backspace on "histogram" which is an action section and
would likely not return a proper GimpAction through
gimp_action_view_get_accel_action().

Therefore let's make sure we initialize properly the action to NULL.
2024-08-17 00:15:09 +02:00
Alx Sa 4e0897f56d widgets: Fix bug loading tool presets in translated UIs
The submenu labels for tool-options-popup were
hardcoded as English in GimpToolOptionsEditor's calls
to the Save, Restore, and Delete Tool Presets buttons.
This meant that these menus always fail when called in
non-English UIs, since we compare the path name and
submenu labels to only load the correct submenu items.

This patch attaches the English labels to the submenu
object so that we can retrieve it for comparison in
gimp_menu_model_get_submodel ().
2024-08-16 15:15:20 -04:00
Jehan e31087a1f0 Issue #9757: radio button menu items not correctly updating (on macOS). 2024-08-16 20:03:29 +02:00
Jehan ee2f86105c app: move "System Language" out of GIMP_L10N_LANGS_SIZE.
This is the only "language" from the list whose name is special and
should be localized at runtime, yet before we set any Preferences
language. It needs to be localized as the System Language itself which
will be run-dependant.

For instance, if your system is in French, it will be displayed as
"Langue système" but if you change your system to Korean, at next run,
it would show "시스템 언어". It is a per-run localization, independant
from the language selected in Preferences, and even less dependant from
build-time system language.
2024-08-15 20:57:02 +02:00
Jehan a106acd408 app, tools: localization for GimpLanguageStore languages must happen at runtime.
Unlike the GimpTranslationStore which can use a list of pre-localized
languages (each language in its own name), the GimpLanguageStore must be
displayed in the currently used locale.
2024-08-15 15:50:30 +02:00
Jehan 5f9083f251 app, tools: generate the language list at build-time.
Instead of always parsing the ISO-639 listing at each and every startup,
let's just generate the list of languages, their English name, and the
self-localized names as static struct.
This will just be much faster, and no worrying on the size of the XML
(or json) to parse.
2024-08-15 15:50:30 +02:00
Jacob Boerema 8838481d12 app: fix #11626 Language selection: name for ckb shows up as ???
We have translations for ckb (Central Kurdish), which is only
available in iso codes 639_3. For our language selection we only
parse 639(_2), which causes this language to show up as `??? (ckb)`.
This is of course not a good user experience since users need to know
that ckb is the abbreviation of their language.

We fix this by parsing `iso_639_3.xml` instead of `iso_639.xml`. This
works, but, since this file is a lot bigger, it takes a lot more time
(more than 1 second difference) to parse this.

Now, this is only done on startup, but this can certainly be a
noticeable delay.
2024-08-15 15:50:30 +02:00
Jehan 51c8709e05 Issue #11906: action search followed by down arrow key stops responding…
… to keyboard input.

Removing a GtkBindingSet entry actually removes it from all GtkTreeView.
It's not limited to the ones contained in GimpContainerTreeView (which
makes sense, since it relies on the class) so it broke various
interactions across the software.

Let's just connect to signal key-press-event instead and block further
propagation. Not sure anyway why GTK has so many ways to handle key
interactions!

I'm also moving the implementation to GimpItemTreeView because this
enhanced keyboard handling is really about the items tree dockables
only, for the time being at least.
2024-08-15 12:32:48 +02:00
Jehan 576554a0af app: Up/Down in GimpContainerTreeView should select items "visually".
layers-select-next/layers-select-previous don't work well as up/down
arrow behavior because they only work within each selected layer's
level. But historically (and that's what makes the most sense IMO, and
is the most expected behavior), up/down arrows would walk through the
layer list visually. I.e. that it would select next whatever is the next
layer displayed in the Layers dockable, even if it means selecting
children or going down one layer group level.

The 2 new actions "layers-select-flattened-previous" and
"layers-select-flattened-next" do this. Say you have this tree:

Layer 1
Layer 2
 | - Layer 3
 | - Layer 4
Layer 5

With the "flattened" actions, after Layer 2, there is Layer 3, and after
Layer 4, there is Layer 5… unless… Layer 2 (layer group) is collapsed.
In which case, after Layer 2 is Layer 5. This selection movement indeed
takes into account the state of the layer group expanders.

This makes the Up/Down arrows work similarly to how they used to work
with default GtkTreeView implementation, except that the logic now also
works well with multiple selected items.
2024-08-13 16:41:21 +02:00
Jehan 5a51bfe868 app: update up/down PageUp/Down and Home/End behavior with multi-selection in mind.
This should likely eventually be re-specified in gimp-ux tracker,
especially as anyway we are planning on rewriting the GimpItemTreeView
from scratch.
But for now, this is better than the behavior where the arrow keys are
losing multi-item selections by default, and also the PageUp|Down
assigned actions are eaten away (as noted by Jacob in #11729).

Now we still don't go through to the PageUp|Down actions (in fact we do,
if we consider the default ones, but it's hardcoded, because after
careful consideration, I do indeed think that when such a tree view has
focus, the arrow and PageUp|Down buttons would have special meaning
anyway), even though I had a first version of this patch which did this.
We simply have much nicer hardcoded behavior!
2024-08-13 12:54:27 +02:00
Alx Sa cdd5174055 tools: Add option for destructive filters
Adds a checkbox in the Filter tool so that
users can choose to apply a filter
destructively or non-destructively.
Currently only layers can have NDE effects
so it's not shown for masks and other
drawables.
Additionally, filters are moved to the top
or the bottom of the filter stack depending on
the setting (as destructive filters are applied
directly to the layer while NDE filters are
put on the top by default).
2024-08-10 13:47:42 +00:00
Jehan 3c388c78ac app: fixing bug created in commit cde861a0e6.
While other parts of the commits were fine, this specific change was
clearly me going too fast. This is the format for a printf() call.

Fixes:

> app/widgets/gimpimagepropview.c:461:50: warning: format ‘%a’ expects argument of type ‘double’, but argument 4 has type ‘const gchar *’ {aka ‘const char *’} [-Wformat=]
2024-08-09 19:29:55 +02: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
Jehan a9af5509ab app: fix crashes after having closed Colors dockable.
Various signal handlers must be removed when the dockable is closed, by
using g_signal_connect_object() when relevant.
2024-08-06 11:39:57 +02:00
Jehan f75e0aa321 app: fix random crash when GimpColorHistory is finalized.
I encountered this one when closing GIMP. Issue #9591 seems to be the
same crash, though when just closing the Colors dockable. I fail to
reproduce willingly now, though it looks like the problem could happen
in some cases when the stored GimpContext is freed before
GimpColorHistory is freed.
Let's increment the reference to make sure the referenced object stays
alive as long the history is alive.
2024-08-05 13:20:44 +02:00
Jehan d46d26933b app, menus: rename all "vectors-" actions to "paths-".
Though these are not as user-facing as other strings, the action names
still are somewhat user-facing. Let's rename them consistently with the
GUI and the API.

This commit also handles user config migration so that custom shortcuts
are not lost.
2024-08-05 12:08:59 +02:00
Alx Sa 6bbaaeb39e dialogs, gui, widgets: Connect GimpPrefsBox to icon size changes
Inspired by Mark Sweeney's work.
This patch allows the icons in the tree
view in Preferences Dialog to scale based
on user icon scale preferences.
Rather than add a GimpGuiConfig to
GimpPrefsBox, we make a call to style_updated ()
from the Preferences Dialog to signal a
change.
2024-08-04 12:55:58 +00:00
Jehan 9f5db5c153 Issue #11828: reverting a string change in commit f036812a94.
This had already been handled in commit 8bd3d5e0bb, but somehow the old
name slipped back in commit f036812a94.
2024-08-03 12:45:50 +02:00
Alx Sa 80f09fac59 libgimpwidgets: Finish converting classes to derivable type 2024-08-03 06:39:55 +00:00
Alx Sa 175b50ead5 libgimpthumb, app: Make gimpthumbnail attributes private
Move all public attributes of GimpThumbnail
from the header to a private struct in
GimpThumbnail.c. Also replace direct
access of these attributes in app/core and
app/widget with get/set calls.
2024-08-03 04:25:33 +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
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 70ae12eb16 widgets, gui: Connect GimpToolBox to icon size changes
Inspired by Mark Sweeney's work.
This patch allows the active image, brush,
pattern, and gradient areas in the toolbox
to scale based on user icon scale
preferences.
Note that if the pattern itself is smaller
than the icon size, it currently won't scale
larger. This is a separate issue in the
renderer.
2024-07-28 13:25:51 +00:00
Alx Sa 9d40d79e4a gui, widgets: Scale Swap & Default Color icons...
...based on icon size preferences.
Inspired by Mark Sweeney's work.
Since the icon size is based on a formula,
the CSS value determines the maximum
size rather than being used directly.
2024-07-21 03:05:43 +00:00
bootchk 4a50143ba6 Fix 9066 Encapsulate access to dock_columns of dock_window
Needs backport to 2.10

gimp_dock_windows_constructed creates a GimpDockColumns, a child widget,
and keeps a private reference to it at dock_window->p->dock_columns.
Then it connects the signal dock_columns.doc_removed to two callbacks:
gimp_dock_window_dock_removed() and gimp_dock_window_update_title().
gimp_dock_window_dock_removed() callback is called first and can
destroy the GimpDockWindow widget and its child widget GimpDockColumns.
Then gimp_dock_window_update_title is called
and tries to call dock_window->p->dock_columns.get_docks()
but it is already destroyed.

The fix is to nullify the internal pointer to dock_columns when destroyed,
and encapsulate access to dock_columns.get_docks so that it
returns a valid but empty list when dock_columns has already been destroyed.

Alternatively, you might be able to fix it by rearranging the order
of connections to dock-removed signal, but then the title would be wrong.

Another alternative might be to rethink the whole destruction sequence.
2024-07-20 21:26:59 +00:00
Alx Sa ff9f71e9a6 widgets: Connect GimpToolPresetEditor to icon size changes
Inspired by Mark Sweeney's work.
GimpToolPresetEditor has an icon next to its title which does
not react to icon size changes.
GimpToolPresetEditor's parent_instance, GimpEditor, already
has a "button-icon-size" CSS style which can be accessed in
its children. This patch adds signals to listen for icon size
changes and update the icon size accordingly.
2024-07-20 01:55:01 +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
Alx Sa 2e6938b3da app: Rename app/core GimpVectors vectors API...
...to path.
Changes the names of
gimp_vectors_* () API to
gimp_path[s]_* (). Renames related files
to [path] instead of [vectors], along with
relevant enums and functions.
2024-07-13 05:07:57 +00:00
Alx Sa e8df68fb65 libgimp, app, pdb: Rename GimpVectors to GimpPath
This commit renames the GimpVectors
object to GimpPath in both app/core and
in libgimp. It also renames the files
to gimppath.[ch] and updates the relevant
build and translation files.
There are still outstanding gimp_vectors_* ()
functions on the app side that need to be renamed
in a subsequent commit.
2024-07-12 06:16:25 +00:00
Alx Sa 853f37bed9 app: Rename app/core GimpImage vectors API...
...to paths.
Similar to d0bdbdfd, but covering the
app/core versions of the API instead of
libgimp. Changes the names of
gimp_image_*_vectors () API to
gimp_image_*_path[s] ().
Also renames some related functions such
as gimp_image_pick_path (). The next step
will be to rename the gimp_vectors_* () to
gimp_path_* ().
2024-07-11 01:17:49 +00:00
Alx Sa c1bd108bba widgets: Connect Configure this tab icon to icon size changes
Inspired by Mark Sweeney's work.
GimpDockbook's dockable tabs update whenever the icon size is
changed. However, the Configure this tab button icon does not,
so it always remains at 12px. This patch adds code to resize it to 75%
of the current tab icon's size, which mirrors the default relationship
of 12px to 16px. This allows the icon to grow when the icon size is
set to Large or Huge.
2024-07-10 10:03:32 +00: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 5cc187b597 Fix #9851 radio menu groups fail show any active item
End the radio group of a submenu when the submenu ends.
So subsequent radio menu items are in a new radio group.
2024-07-09 15:42:50 +00:00
Alx Sa ea63e99ab8 widgets: Cast GimpColorDialog to GtkWidget...
...when passing it in gimp_color_dialog_style_updated ().
This fixes a compiler error introduced in c5efa0b8 on
some Windows builds.
2024-07-05 11:43:40 +00:00
Alx Sa b3b32c7765 widgets: Disconnect gimp_color_editor_display_changed...
...when dockable is closed.
Resolves #11748

gimp_color_editor_display_changed () was still connected to
the user context when the Color dockable was closed. This
resulted in either a critical or crash if a new Color dockable
was opened or if the GIMP was closed. This patch should
cause the signal to be disconnected automatically when
the editor is destroyed.
2024-06-30 04:14:48 +00:00
Alx Sa c5efa0b874 gui, widgets: Connect GimpColorNotebook to icon size changes
Inspired by Mark Sweeney's work.
GimpColorNotebook has existing code to
update the color selector tab icon sizes
via CSS. However, it was not set up to be
notified of icon size changes from the GUI.
Since GimpColorNotebook is in libgimpwidgets,
we call its style_updated () function from
the style_updated () functions of the two
widgets its created in - GimpColorEditor
and GimpColorDialog.
2024-06-29 20:10:26 +00:00
Jacob Boerema 0c3bf56d83 app: fix help id for layer-lock-visibility is not set 2024-06-26 15:16:45 -04:00
Jacob Boerema 6dbf144f6b app: add missing help ids for the text tool 2024-06-22 16:47:44 -04:00
Jacob Boerema d190c37a2c app: add missing help-id for layer effects
Note that this isn't enough for F1 to work, but that is a separate
issue.
I think that for now one help-id for all the layer effects is enough,
until we get a more final UI.
2024-06-19 13:42:49 -04:00
Alx Sa dc0449b05e widgets: Fix label background on Curves tool
Resolves #11702
In 2.10, the x/y label background on the Curves tool used
GtkStateType enums to get the widget's background color.
These enums were depreciated in GTK3, and during the
port the gdk_cairo_set_source_rgba() command was left
out. This resulted in the current line color being used instead,
making it hard to read the label in some instances.

This patch restores the Cairo color update command, using
the gridline color as an equivalent to the background color
from 2.10.
2024-06-17 13:05:38 +00:00
Alx Sa 9256a15363 widgets: Prevent image name from affecting the dialogue width
Resolves #7588
After the port to GTK3, the Filter dialogue's width started
to be affected the length of the image name. If the name
was very long, the filter dialogue would expand to fit it.

This patch encloses the image title label in a GtkScrolledWindow
with polices of EXTERNAL width and NEVER height. This ensures
there will not be a scrollbar, and the label will not influence the
width of the dialogue. A tooltip was added in case the user wants
to hover to see the full name.
2024-06-16 16:12:16 +00:00
Alx Sa 0be5db0b77 widgets: Allow deleting inactive filters
Resolves #11687
Previously gimp_drawable_has_filters () was used to check
if a drawable had filters before deleting them. However,
this function actually only checks if there's an active filter -
if filters are attached but set to invisible, this returns false.
This mean that you could not delete filters if they were
invisible.
This patch switches to using gimp_container_have () instead
as it checks if the filter is in the drawable's filter stack.
2024-06-12 13:44:21 +00:00