Commit Graph

23560 Commits

Author SHA1 Message Date
Jehan 0db6dd9f25 app: make sure the GimpContainerPopup shows the right item as selected…
… for the case of data managed by the GimpContext.

Checking stable and dev builds, it looks this just never worked and used
to just show no selection. Now it is more annoying as it shows a
selected item, but not the right one. Just make sure it shows whatever
is currently selected.
2021-12-23 13:43:51 +01:00
Jehan 28f6b1b268 app: fix gimp_container_view_multi_selected().
The whole hack for types managed by context is not needed anymore. It
works fine with generic code. Also because of this hack, there was a bug
when clicking on some button raising a container popup (such as the
"Dynamics" button in tool options) would reset the context to default
value (e.g. reset to "Basic Dynamics") on the first click, without
raising the popup. Only the second click would raise a popup.
2021-12-23 13:43:51 +01:00
Jehan 9a1a7a766c app: implement GimpContainerViewInterface's get_selected() for…
… GimpContainerComboBox and add a warning when the implementation is
missing.

Basically the default get_selected() implementation only works for
context properties, not for more generic usage of GimpContainerView. The
new warning will be a lot more informative and will help any future
cases where we might experience this bug.
2021-12-23 13:43:51 +01:00
Jehan 0a43a7063c app: add an implementation for get_selected() of GimpContainerEntry.
This fixes the container entry never showing (e.g. brush/dynamics) names
because after commit ca3c480314, the class could not properly detect if
the selection changed (as default implementation for this virtual
function does not suit this subclass).
2021-12-23 13:43:29 +01:00
Jehan ac1721917c app: reording private functions' declarations and definitions.
Keep them all together and in the same order, instead of mixing public
and private functions.
2021-12-23 13:39:43 +01:00
Jehan ca3c480314 app: check selected items changed before running "select-items".
This prevents repeatitively running the same signals when it is useless.

In particular, I encountered a case of infinite loops between
"floating-selection-changed" and "select-items" ending up infinitely
calling each other (then crashing GIMP).
2021-12-23 13:39:43 +01:00
Jehan 6a8910749a app: special-case icon theme loading when testing build.
It's a bit ugly, but it's not like this is run many times (only once
when loading the icon theme, or changing it).

Fixes this error appearing in various unit tests' output:

> gimp_icons_sanity_check: Icon theme path has no 'hicolor' subdirectory: /builds/GNOME/gimp/_install/share/gimp/2.99/icons

(even though it was not a test-failure error, it's still better to limit
output for debugging)
2021-12-23 13:39:43 +01:00
Jehan 72f8e63441 app: find templaterc and controllerrc when testing the build.
This should fix these errors when running `ninja test` or `make check`:

> GIMP-Error: Failed to open file ?/builds/GNOME/gimp/_install/etc/gimp/2.99/templaterc?: open() failed: No such file or directory
> GIMP-Error: Failed to open file ?/builds/GNOME/gimp/_install/etc/gimp/2.99/controllerrc?: open() failed: No such file or directory
2021-12-23 13:39:43 +01:00
Jehan efaf9e099e app, libgimp, libgimpwidgets: fix "Application icon missing" in tests.
When running tests, the data are not meant to be necessarily installed.
Therefore icons won't be found when calling gimp_widgets_init().

Add some special-casing to find them relatively to the install
directory.
2021-12-23 13:39:43 +01:00
Jehan b4892931c8 app: fix critical when filtering items in Palette dockable.
An item with no path is actually not always a bug. It can very well be
normal if the tree view has a filtering logics where some items which
were selected suddenly get hidden.
2021-12-23 13:39:43 +01:00
Jehan a6dccf5c2f app: fix icons for the "*-lock-*" actions.
Now that we have dedicated icons made by Aryeom!
2021-12-23 13:39:43 +01:00
Jehan d9846ac9dd app: get rid of all "*-linked" actions.
I.e.: "layers-linked", "channels-linked", "vectors-linked" and
"drawable-linked".
2021-12-23 13:39:43 +01:00
Jehan 9d23216566 app: remove the "Linked" switch from the item options dialog. 2021-12-23 13:39:42 +01:00
Jehan 5ac6d57b7b app: add a preferences for choosing your prefered search pattern format.
The 3 available formats are: simple text search, regular expressions and
glob patterns (cf. previous commit). I did a small step back from
previous commit by getting "is-pattern" property back in GimpItemList
instead of having this case as a value of GimpSelectMethod. The reason
is that it would render a useless value in the Preferences combo box.

Text search is the default.
2021-12-23 13:39:42 +01:00
Jehan 01b47863c2 app: GimpItemList supports glob, regular expression and simple text…
… search syntaxes.

The layer tree view is only using regexp so far, but the core code is
updated to allow more.

Simple text search is actually a bit more than "simple". It implies
tokenization of the text, Unicode normalization and case-folding. It
will also search with ASCII alternatives when possible. This includes
things like non-accented ASCII characters matching accented variants
which is neat.

Now it's not perfect. For instance tokenization seems very limited to
writing systems with spaces or alike. In particular, I tested with
Japanese and since you would typically write without spaces, a whole
group of several words would be one token. Since the text search
algorithm only search from token start, this is quite a failure as you
can't search with intermediate words only.
2021-12-23 12:55:11 +01:00
Jehan 767674fc5b app: fix weird pointer behavior when clicking out of lock popover.
It was like small drag'n drop were occuring, sometimes actually ending
up in moving layers or the like.
2021-12-23 12:55:11 +01:00
Jehan d774a8ff9d app: add multi-vectors drag'n drop ability. 2021-12-23 12:55:11 +01:00
Jehan 5c63c2478f app: duplicate and delete channel actions multi-channel aware. 2021-12-23 12:55:11 +01:00
Jehan 718177b8bc app: raise/lower channels one step or to top/bottom multi-channel aware. 2021-12-23 12:55:11 +01:00
Jehan fcd59784e0 app: improve "Select Top|Bottom Layer" actions.
Similarly to how I improved "Select Top|Bottom Channel", we should set
the actions sensitive not only when the selected layers are not the
top/bottom ones, but also when there are no selected layers at all.
2021-12-23 12:55:11 +01:00
Jehan 8d38b72446 app: channel selection actions now multi-channel aware. 2021-12-23 12:55:11 +01:00
Jehan 670a7fcc9c app: generate a critical with some more information.
I had a weird case where g_return_val_if_fail() ran but I could not
reproduce and am not sure how this happened. Adding the item name may
help diagnose the next time it happens.
2021-12-23 12:55:11 +01:00
Jehan 566e55e72e app: "Bend the text along the currently active path" multi-layer aware.
It still only requires one single path selected to work, but I updated
the internal API used.
2021-12-23 12:55:11 +01:00
Jehan b9eb289b5c app: implement multi-paths selection.
For now, highlighting, snapping and moving (position change with move
tool) have been implemented.
2021-12-23 12:55:11 +01:00
Jehan 45e18f696c app: add multi-channel drag'n drop ability. 2021-12-23 12:55:11 +01:00
Jehan 58302ee332 app, pdb: get rid of various gimp_image_get_active_channel().
Replace them with gimp_image_get_selected_channels().
2021-12-23 12:55:11 +01:00
Jehan bd038b1864 app: implement multi-channel selection.
Similar to commit 592cea6b87, but this
type for the Channels dockable.
2021-12-23 12:55:11 +01:00
Jehan 8faf6a832c app: get rid of GimpContainerViewInterface select_item signal.
Now that we have implementations for select_items everywhere and that
all the code is only wired to call or handle select_items, the single
item variant select_item is of no use anymore. Let's make a big cleanup.
2021-12-23 12:55:11 +01:00
Jehan 8a46a72d7d app: all remaining select-item handlers replaced by select-items ones. 2021-12-23 12:55:11 +01:00
Jehan 2a404cb41d app: more "select-item" signal handlers changed to "select-items" ones. 2021-12-23 12:55:11 +01:00
Jehan 4b681eb448 app, libgimpwidgets: new gimp_event_triggers_context_menu() and use it…
… for the container tree view contextual menu.

A very annoying point of contextual menus is that they happen on button
press whereas menu item selection happens on button release. When the
menu corner is positionned on the click position, nothing bad happens;
yet when place is missing on screen, the menu might get positionned over
the pointer position. And worse, the mouse position might be just over
an activatable menu item. So we end up in this weird situation where a
click implies: press, menu opens, release, random item (whatever is
below the pointer) is selected and menu closes.

To get rid of this weird case, let's have our contextual menu happen on
button release. In reality, I don't think anyone cares that it happens
on press or release, you just "click". But what you certainly don't want
is to click random menu items!
2021-12-23 12:55:11 +01:00
Jehan 8a91d973cd app: fix clicking on unsaved images in Quit / Close All dialog.
Let's now use the "select-items" signal only (even in cases where we
expect only one selection per construction).
2021-12-23 12:55:11 +01:00
Jehan 9d46e47653 app: one more select_items() implementation which I had forgotten. 2021-12-23 12:55:11 +01:00
Jehan a404500f3e app: add a select_items() implementation on various classes…
… implementing GimpContainerViewInterface.
2021-12-23 12:55:11 +01:00
Jehan 367901875f app: check if an item was already inserted by actually looking it up in…
… the container.

There was this weird case which we somehow could only reproduce on
Aryeom's computer/build, not mine, with the same code and reproduction
steps (reproducible at will on her build only). Basically when drag'n
dropping a duplicated layer inside a collapsed layer group, the
row-expanded handler would try to select the moved layer before it is
actually inserted. This would end up into crash-happy code.

I'm still unsure of why the order of operation is different here, but
anyway what is for sure is that the `inserting_item` boolean flag was
not protecting much. It's not like it's an actual mutex and anyway this
is not multi-threaded code either so this flag was mostly useless (which
is why we were crashing). Instead let's actually look if the item is in
the container or not.
2021-12-23 12:55:11 +01:00
Jehan 1a3dbe2099 app: implement a select_items() method for GimpContainerComboBox…
… and use gimp_container_view_select_items() when the context changes.

Even though some types of containers still expect only a single
selected content, we should slowly move to multiple item code. The
reason is to avoid 2 code paths which makes the code more complicated
and bug-prone. When all child classes of GimpContainerView will have a
valid select_items() implementation, we can work on getting rid of the
select_item() in favor of the multi-item one.
2021-12-23 12:55:11 +01:00
Jehan 47e0e6f519 app, libgimp, pdb: add visibility lock API. 2021-12-23 12:55:11 +01:00
Jehan de6a57d5c2 app: fix coordinate conversion.
I was doing it the wrong way, and it became impossible to drop layers
into a layer folder (unless it already had some layers in it).
2021-12-23 12:47:28 +01:00
Jehan 9b7c868f4d app: more coordinate conversion in GimpContainerTreeView. 2021-12-23 12:47:28 +01:00
Jehan 9d25482c03 app: use the new lock icons. 2021-12-23 12:47:28 +01:00
Jehan cd3b3b8dd4 app: fix crash with a NULL highlight area. 2021-12-23 12:47:28 +01:00
Jehan 1ba3c3d4b5 app: fix gimp_item_tree_view_blink_lock().
The bin window coordinates must be converted to the widget coordinates.
This was not a problem before, but now with the column header, if I
don't do this, the position is wrong.

Similarly fix the lock popover position.
2021-12-23 12:47:28 +01:00
Jehan 59f3d0097c app: show GimpItemTreeView's header.
The header shows a lock icon, making the column more discoverable, as
well as where to click.
Also the title for the item column will now be used for the
multi-selection label (counting items) instead of using
GimpItemTreeView's options box.

Finally use the new gimp-multi-lock icon to show multiple locks.

This makes for much nicer and usable item tree.
2021-12-23 12:47:28 +01:00
Jehan 18fab4e257 app: add Alt-click on visibility and locks for exclusive switch within…
… the selected items only.
This is the exact same algorithm as Shift-click, except that Shift-click
switch exclusivity within the whole level of items. Alt-click does the
same but only within selected items in the list.
2021-12-23 12:47:28 +01:00
Jehan cd7f399006 app: implement exclusive lock switching (Shift-click).
Similar to exclusive visibility switch on layers, now for locks too, if
one wants to lock all layers within a same level for instance by
Shift-clicking the lock icon.

Also once again I factorized the exclusive switching code to ensure it
will always works the same for all similar features (visibility and all
locks).
2021-12-23 12:47:28 +01:00
Jehan c9812c29f9 app: hide the lock popup when clicking on shown same cell's. 2021-12-23 12:47:28 +01:00
Jehan 8508eda45f app: more responsive lock and link popovers.
First of all, let's use gtk_widget_show|hide() instead of
gtk_popover_popup|down() because these GtkPopover API sometimes "block"
when clicking very fast on the item list, sometimes up to 2 or 3 seconds
(at least it feels like seconds, I haven't actually timed it!). I'm sure
the ones who developed it thought it was nice to have slow popping
dialogs, but when working fast, this can only be frustrating).

The second responsiveness change is that when clicking out of useful
lock popover area, it should not only close, but the event should be
passed onto the item tree view when relevant. This allows for instance
to directly click on an eye cell to change a layer visibility without
having to click twice.
2021-12-23 12:46:59 +01:00
Jehan 302bf53a67 app: blink the lock cell when failing to switch visibility (eye). 2021-12-23 12:20:43 +01:00
Jehan 1c1b84b88b app: also use gimp_item_tree_view_add_lock() for default locks.
All locks now use the exact same code, which makes for very nice code
factorization, but also ensures consistent behavior.
2021-12-23 12:20:43 +01:00
Jehan dda15cb0e8 app: improve item lock management with gimp_item_tree_view_add_lock().
Use this for the alpha lock brought by GimpLayerTreeView.
Also use the new gimp_widget_blink_rect() to only blink the appropriate
cell when a lock is preventing you from doing something.
2021-12-23 12:20:43 +01:00
Jehan 0a5a20cbb8 app: use gimp-layer as visibility lock icon.
The 2 eyes next to each other are just weird in this layout.
2021-12-23 12:20:43 +01:00
Jehan 33e2d18a59 app: new gimp_widget_blink_rect().
Also change signature of gimp_highlight_widget().
These functions allow to highlight or blink specific widget areas only
when needed.
2021-12-23 12:20:43 +01:00
Jehan b356ea6aac app: show lock state as cell icon in Layers dockable…
… and drop the link cell (the lock cell takes the space).

This is an experiment with the following logics:
* I am getting rid on the linked item logics, so the icon cell
  disappears anyway.
* The lock buttons are not so visible above the Layers dockable and so
  many have I seen people frustrated of not being able to do some action
  until they realize they locked something in the layer (even sometimes
  advanced users).
  The icon next to the eye is much more visible. Also I will now display
  different icons depending on the type of locks. If a single lock is in
  effect, I show the corresponding icon. If 2 or more locks are in
  effect, I show a generic lock icon.
* With multi-selection of items in particular, this top lock row was a
  lot more weird and could show inconsistent state (some of the
  selection is locked, other is not). Now the per-row lock icon allows a
  much nicer granularity.
2021-12-23 12:20:43 +01:00
Jehan 9492affda3 app: add an item visibility lock.
Sometimes one may want to lock visibility of a given layer. This is very
useful in particular when shift-clicking a layer visibility. In this
case, it won't be included in the list of layer to update. This can be
used for instance if you want some layers always visible (or always
hidden) while setting exclusive visibility of some other layers only.
2021-12-23 12:20:43 +01:00
Jehan a0fc5a025a app: allow storing regular expression-based item sets.
Instead of just storing list of layers, I created a new simple type
GimpItemList (actually GimpItemSet would be better named, but
unfortunately we use this name for an enum type). So far, this new class
can handle 2 types of item sets: named fixed sets and pattern-generated
sets.
2021-12-23 12:20:43 +01:00
Jehan ec99784d6e app: add a placeholder to the stored layer set list.
This is nice for better discovery of the feature allowing to store your
layer selection.
2021-12-23 12:20:43 +01:00
Jehan da987a1485 app: add layer selection by regular expression.
I am unsure if regular expression is the right choice as it may
obviously be a bit too technical. I hesitated with glob-type match for a
while. We'll see!
2021-12-23 12:20:43 +01:00
Jehan 25adf686a5 app: add logical operations on layer sets. 2021-12-23 12:20:43 +01:00
Jehan 4fad4bf89f app: new concept of sets of layers stored in GimpImage.
The eventual goal is to replace the "linked layers" concept, which is
why I am using similar vocabulary. The point is that linked layers are
mostly useless/redundant now with multiplie layer selection, except for
one thing: they kind of serve like a way to "save" a selection of layers
(to be moved/transformed together mostly). Apart from this, multiple
selection is more powerful on any way. You can do much more than
transforming the layers together (you can reorganize them together,
delete them, crop them and so on).

Therefore this new feature is the way to fill the only weakness of layer
selection: its ephemerality. Now we can save a given set of layers, not
even only one, but as many as we want, and under a meaningful name, for
later reuse.
Moreover it will make layer-handling core code much simpler as we
currently have 2 concepts of layer set: multiple selection and links.
The new stored links are only a way to recreate multiple selections.

More is to come, for instance right now, these are not stored in the XCF
format. Also it would be awesome to add logical operators (Shift for
union of layer sets, Ctrl for subtraction and Shift-Ctrl for
intersection). And finally I was thinking about a way to select by
pattern (regular expression? Shell-style glob patterns?) and even store
these patterns. So if you save a "Marmot .*" selection pattern, then
when you select it later, new layers matching this pattern will be
included too (instead of fixed-in-time list of layers).
2021-12-23 12:20:43 +01:00
Lukas Oberhuber 41ff82acbf macos: style cleanup in gimp wrapper code 2021-12-22 12:59:06 +00:00
Lukas Oberhuber e41250394d gimptextstyleeditor: Fix crash on exit
Messages were being sent to editor after editor had been destroyed. This
stops that.
2021-12-22 12:58:32 +00:00
Lukas Oberhuber d8afa6c829 gimp: macOS run from build directory
This change allows gimp to run from the build
directory rather than having to wait for the
full packaging process to complete.

However, 'gi' modules are not loading properly
so that might be something to fix.
2021-12-22 01:34:58 +00:00
Øyvind Kolås 124239202c app,build: depend on GEGL-0.4.34 2021-12-19 00:59:33 +01:00
Niels De Graef bba495999d app: Use g_clear_object() in main.c
Also no need to do a null-check if you're doing g_free(), it can handle
that already.
2021-12-17 09:49:05 +01:00
Niels De Graef bb4403fd49 app: Remove old GimpUiManager popup API
The code used `gtk_menu_popup()`, which was deprecated a while ago, as
it was broken on certain GDK backends, like Wayland.

Fixes https://gitlab.gnome.org/GNOME/gimp/-/issues/5319
2021-12-13 20:57:23 +01:00
Niels De Graef eed28c0941 app: Popup menu at rect in GimpEditor
Rather than trying to fix up our own heuristics using a
`GtkMenuPositionFunc`, use whatever GTK provides to position given a
specific rectangle, which also has the benefit of nicely integrating
with GDK backends such as Wayland. Another advantage is that we can use
GdkGravity to center the popup.

Since GTK 3, GtkWidget also gained a "popup-menu" signal, which we
can/should use instead of rolling our own context signals.
2021-12-13 20:57:21 +01:00
Niels De Graef 67fd1f0c52 app: Popup menu at pointer in GimpEditor
Rather than trying to fix up our own heuristics using a
`GtkMenuPositionFunc`, use the API that GTK provides to have popup
nicely placed near the pointer, which also has the benefit of nicely
integrating with GDK backends such as Wayland.
2021-12-13 20:56:54 +01:00
Lukas Oberhuber 6821636a7b gimp_macos_setenv: set GI_TYPELIB_PATH macos
This sets the GI_TYPELIB_PATH so that macOS
gobject-introspection can find the typelib files.
2021-12-03 10:14:35 +00:00
Lukas Oberhuber b0547a72c6 macos env: Fix #7567, crash on new and open dialog
Fixes https://gitlab.gnome.org/GNOME/gimp/-/issues/7567
2021-12-01 23:12:44 +00:00
Lukas Oberhuber ee30d50d60 packaging: Update paths for MacOS
Updates the various path variables used to run the applicaition on Mac.
This includes update to python.
2021-11-30 17:09:00 +00:00
Jehan bb4ab851df app: replace using the "draw" signal by "expose-event" on GTK+2.
Not sure why but adding a handler to the "expose-event" signal of
GimpDisplayShell (similarly to how we do it in master branch on "draw")
just didn't work. But it works on the already existing signal handling
on the canvas instead (which actually is not a bad deal, as we also
remove the coordinates translation so maybe we should test this on
`master` too).

Note: why we are backporting all this logics to gimp-2-10 is because
changes in macOS BigSur broke the selection's marching ants the same way
they broke on Wayland and it was confirmed this fix worked for BigSur as
well, at least on the dev builds.
It is unnecessary to backport for Wayland (because GIMP 2.10 is based on
GTK2 which anyway works only through XWayland, hence doesn't have the
issue), we do it only for macOS BigSur (and further). Well at least the
fix will hopefully work on the stable branch, because I cannot test
myself.

See issue #5952.

(cherry picked from commit 6be014fc59)

Cherry-pick note: it was initially only for gimp-2-10 but actually also
works fine on the GTK3 branch and fixes some selection coordinates issue
when rotating the canvas.
2021-11-17 21:33:43 +01:00
Jacob Boerema d2c5591088 app: fix #383 Large PBM files exported from GIMP are blank
Fix as suggested by Massimo with formatting adjustments by me.
The use of gulong and glong is not cross platform safe: on Windows it is
32-bit and on most other platforms 64-bit.

Let's use guint64 and gint64 instead.
2021-11-14 18:06:56 -05:00
Emily Gonyer 3afa37cbc6 app, libgimp*, plug-ins: Changed gendered terms to be gender-neutral
Changed a handful of gendered terms to be gender-neutral, and one typo 
of 'he' to 'the' where appropriate.
2021-11-14 11:22:24 +00:00
Jacob Boerema 8d9db45dd5 app: fix resource leak warnings caught by static analysis.
In the unlikely case that we have an error we sometimes forget to free
either a dirname or appstring.
Let's fix these to reduce number of warnings.
2021-11-08 22:37:13 -05:00
Jacob Boerema e2b1cc9476 app: fix #6436 *.gih grayscale export crashes GIMP
When we try to export a grayscale image with layers with negative offsets
to a GIH brush GIMP crashes without producing any crashlog.
Running in GDB showed us that there is heap corruption caused by incorrect
computation of buffer sizes because of the negative offsets.

In file_gih_image_to_pipe there is a comment that offsets are assumed
positive, but no checking is done whether that is correct.
Let's add some checks, set offset to 0 if negative and adjust width and
height accordingly.
2021-11-08 17:10:32 -05:00
Jehan 40ca022c81 app, docs: fix GIMP's version in --dump-gimprc-manpage and update…
… gimprc's manpage as a consequence.

When running `gimp-console-2.99 --dump-gimprc-manpage` to output a man,
a line was:

> .TH GIMPRC 5 "Version @GIMP_VERSION@" "GIMP Manual Pages"

This is clearly the autotools substitution syntax, which is not being
used here (this is not a .in file processed by the build system), maybe
from some older build logics.
2021-10-21 22:10:31 +02:00
Jehan 6905b0bbef Issue #5313: consistent "file-pat-save-internal" procedure with…
… multiple drawables as parameter.

Previous commit 7bb892f3 was "making it work" by making the API
inconsistent and also only using the first drawable, which is making the
logics meaningless.

Instead accept multiple drawables, and export only the selected drawable
(when alone) or the merged-down image containing only the selected
drawables (when many).

Note that in current implementation, this is not useful from GUI calls
because the fully merged image is always exported when run interactively
or with last vals (i.e. from the GUI) because gimp_export_image()
flattens the image. So this change would only work when called
non-interactively from other plug-ins. In such a case, multi-layer
images do no longer return an error and whatever items are selected
would change the export result.

See also #7370 for a discussion about how to handle the selected items
during export (because currently the `drawables` parameter of
GimpSaveProcedure's run function is clearly a mostly bogus parameter).
2021-10-15 00:32:10 +02:00
Jehan 7e3cab1475 app: replace a g_free_error() by g_clear_error().
As a review fix of MR !470 since the contributor Andrzej Hunt is
unfortunately not responding.
2021-10-12 20:13:20 +02:00
Andrzej Hunt 59eae13aec xcf-load: g_free name in error cases to avoid leak
In all 3 cases:
 - xcf_read_string allocates a new string into name.
 - If an error is detected, we return early - name remains unused.
Therefore we add g_free (name) to these early returns to avoid a leak.
2021-10-12 20:13:20 +02:00
Andrzej Hunt 76b11a5f69 gimptagcache: free error to avoid leak
If gimp_xml_parser_parse_gfile returns FALSE, we know that error might
be set. Therefore we add a g_error_free to avoid leaking the error.
2021-10-12 20:13:20 +02:00
Jacob Boerema 352ef68c46 app, libgimp: Add metadata preference for saving thumbnail by default
Saving a thumbnail is closely related to the other metadata preferences,
but so far this was the only one that didn't have a preference for a
default user value.
This commit adds a preference in the metadata section where a user can
select whether thumbnail saving is enabled by default or not.
2021-10-12 13:20:47 -04:00
Jacob Boerema 970665f2b2 app: fix no console output on Windows for --dump-gimprc
On Windows the --dump-gimprc, --dump-gimprc-system and --dump-gimprc-manpage
command line parameters do not produce any console output.
Apparently we need to request the handle for stdout instead of directly
using1 for stdout.

After this commit there still is a problem when redirecting output to a
file. It seems that the buffer where stdout is stored is not flushed or
the file pointer is reset to 0 every time causing overwrites instead of
appending to the file.
2021-10-12 11:50:11 -04:00
Jacob Boerema 206bc06eab app: fix Gimp-Config warning Can't tell anything about a gint64.
When running gimp-console-2.99.exe --dump-gimprc-system we get two
warnings:
(gimp-console-2.99.exe:23000): Gimp-Config-WARNING **: 16:08:29.604:
 FIXME: Can't tell anything about a gint64.

Let's fix this by adding G_TYPE_INT64 as a known integer value.
2021-10-12 11:11:17 -04:00
Jehan 52928e04a5 Issue #7327: Cannot build GIMP3 on MSYS2 using Meson.
This is untested on my side, because the bug only happens on native
builds with meson (our CI has cross-builds with meson and native builds
with autotools and I only do cross-builds locally) but I think/hope it
will work.

Basically we were using .full_path() because these rc files were also
used as input of some configure_file() calls which doesn't like custom
target objects as input (it wants strings or file objects). Yet a bug
in meson didn't like the colon used in native Windows full paths ('C:'
and such) when used in windows.compile_resources(). This has been fixed
by Luca Bacci in: https://github.com/mesonbuild/meson/pull/9368
Yet we just cannot depend on very early meson (or worse dev meson code).

On the other hand, if the input is a custom_tgt object, it uses the
object ID which we give as first parameter of custom_target() so we know
it's appropriately named without colons (such as 'gimp_plugins_rc').
Thus we should not bump into this issue again.

For the few usage in configure_file(), I just add a .full_path() only
when needed at call time.

Last but not least, I replace the bogus `meson --version` call by a
`python3 -c 'exit()'` as advised by Eli Schwartz:
2afa019c70 (note_1284951)

The reason is that it is apparently possible (or will be when some
reimplementation of meson will be done) that the `meson` executable
itself does not exist. On the other hand, `python3` should always be
there, as a mandatory dependency of the build tool.

In order to use an appropriate `python3`, I made the
pythonmod.find_installation() check required in our build (which should
not be a problem since it's a meson requirement as well), even when the
-Dpython option is false (this one depends on other requirements too
anyway, such as version and pygobject). This way I can call this meson
variable of discovered python in my bogus call, instead of calling a
(potentially different) python from PATH environment.
2021-10-12 17:06:18 +02:00
Lukas Oberhuber 5ff5d38985 Macro name change to GDK_OSX_BIGSUR 2021-10-04 20:40:30 +00:00
Lukas Oberhuber 0ac0e4bdc9 gdkquartz-cocoa-access.h is not correct yet 2021-10-04 20:06:35 +00:00
Lukas Oberhuber e14f9fc500 app: allow compiling on Mac OS where gimpimagewindow.c needs…
… an API that went private in GTK 3.

Note from reviewer (Jehan): this API became public again in commit
gtk@242b76a7, available since GTK 3.24.29. Before this, the function 
(gdk_quartz_window_get_nswindow()) was actually still in the ABI, so we
could declare the function locally before using it. This is an ugly
workaround, but it works.
What we do is providing both solutions depending on GTK version, leaving
build warnings as constant reminders so that we remember to get rid of
the workaround when we bump minimum GTK requirement.

Cf. discussions in gtk#2452 and gimp!483.
2021-10-03 11:20:15 +00:00
Jehan fd9f96f174 app: get rid of a wrong return-after-free report.
Reported by Massimo, though this one is wrong, as far as I can see.

`ninja scan-build` apparently reports `result` as being returned after
being freed here. But actually since we are setting the `error` with
g_set_error() in the same time we free `result`, we would also enter the
`if (*error)` block a few lines later, which would return NULL and not
`result` anyway. I guess the static analyzer could not see that far.

Still, set the pointer to NULL with g_clear_pointer(), which should be
enough to make the static analyzer happy.
2021-10-01 12:51:48 +02:00
Jordi Mas 6aaa017d34 Remove unnecessary space at the end of the string 2021-09-28 10:42:58 +00:00
Jehan d4733e5b21 app: fix drag'n drop of fg/bg colors under Wayland.
Commit 086ae77929 had broken dnd of colors from toolbox's color area on
Wayland. Clearly Wayland did not like we changed focus on a click,
breaking the drag.

To fix this, do not propagate button press and release events from the
GimpFgBgEditor editor anymore. Yet, since changing colors is usually to
be used (often immediately) on the canvas, giving back the focus to
canvas still makes sense. Therefore, instead of using press/release
events, add semantic signals to GimpFgBgEditor: color-dropped,
colors-swapped and colors-default (additionally to already existing
color-clicked). Then connect to these new signals to grab focus for
canvas when relevant.

Thanks to Massimo for raising the broken color dnd feature.
2021-09-26 19:06:26 +02:00
Jehan 78d9f9799f app: fix dragging color boxes into item dockables.
Commit 83b3d9e5 broke dragging color widgets into channels dockables or
other item dockables.
Thanks to Massimo for raising that these lines were needed for this.
2021-09-26 17:06:57 +02:00
Jehan 6374481f4f Issue #6909: Crash after cancelling out of avif export dialog.
Do not leave dangling signal handler.
2021-09-26 16:30:29 +02:00
Jehan 1abb4543cd app, pdb: move "src-drawables" from core to option object for…
… "gimp-clone" and "gimp-heal" PDB calls.

Untested but this should work. Anyway we will take a close look at the
whole API before releasing.
2021-09-14 17:59:47 +02:00
Jehan 6ad00cdbba app: improve source tool options GUI.
The "Source" dropdown to choose an image or pattern, and to check
"Sample merged" seem important enough that I moved them up the source
tool options. I also added a label giving information about the image
source being currently set, i.e. in particular which image (when the
source is another image), how many composited layers (or all of them
with "Sample merged" checked), or if each layer is its own source.

For this to happen, I moved src-drawables property from GimpSourceCore
to GimpSourceOptions (though without making it a config property,
because we don't want this option to be saved in config files). It
actually makes sense, it is a kind of "option" of how the tool will
behave, and then it is also visible by the options GUI.
2021-09-14 17:59:47 +02:00
Jehan 370db868a3 app: "Registered" alignment makes no sense with self-to-self painting.
The "Registered" alignment is used to paint from one layer to another
(in same or different image) at exactly the same image coordinates. It
doesn't make much sense with the self-to-self painting when having
multiple drawables selected.

Note that it still works with the other new feature using multiple
layers as a composited source (limited "Sample merged"-like painting,
but only from specific layers).
2021-09-14 17:59:47 +02:00
Jehan b86c927210 app: fixing painting with a selection. 2021-09-14 17:59:47 +02:00
Jehan d5670644b4 app: make painting with applicator working in multi-drawable mode. 2021-09-14 17:59:47 +02:00
Jehan 03edaf5cea app: fix more broken offset in other tools.
Similar to the source core fix, but a bit simpler because we don't have
to deal with a source and a target offset, let's fix offset handling in:
- Blur / Sharpen tool.
- Dodge / Burn tool.
- Ink tool.
- MyPaint brush tool.
- Smudge tool.
2021-09-14 17:59:47 +02:00
Jehan 977807985b app: fix broken source painting offset.
As expected from early changes of code, painting was widely broken with
offsetted layers, because previous code used to process the drawable
offset earlier in the painting process, on paint tool level, whereas now
the tool gives coordinates in image space to the paint core (because it
gives a list of drawables which may have different offsets, hence image
space is the only valid coordinates space). This means the various paint
core algorithms must handle each drawable's offset at actual painting
time.
2021-09-14 17:59:47 +02:00
Jehan 231ab4413b app: make Perspective Clone tool also work with multiple drawables. 2021-09-14 17:59:47 +02:00
Jehan 3a9462b219 app, pdb: properly save the list of source drawables.
By doing this, I also add the ability to use a composited projection of
the selected drawables as source. This is similar to "Sample merged"
except that instead of using the whole visible image, we use what would
have been visible if only the selected layers existed.

Note that this doesn't work together with the previously added ability
of multi-cloning from each layer to itself. This ability works for
cloning from multiple layers to one.
2021-09-14 17:59:47 +02:00
Jehan b4d189f8ef app: add ability to clone/heal from/on multiple layers.
When multiple layers are selected, the "sample merged" button won't
work. In such a context, each selected layer will pick from itself into
itself.
2021-09-14 17:59:47 +02:00
Jehan 8934d43975 app: make painting possibly multi-drawable aware.
- Make the various virtual methods of GimpPaintCore use a list of
  drawables as argument instead of a single drawable.
- gimp_brush_core_eval_transform_dynamics() can work with an image as
  argument rather than a drawable as it doesn't actually depends on
  specific drawable data.
- New function gimp_paint_tool_enable_multi_paint() to be used in init()
  method of paint tools to announce that this tool can work with
  multiple layers selected.
- Use gimp_paint_tool_enable_multi_paint() in the GimpSourceTool base
  class only for now.

This is a first step for multi-layer drawing, but we don't want it to be
possible in just any random cases, which is why I add a special function
to advertize this capability. We will use it for special-casing the
clone (as well as heal and perspective tools most likely) tool to work
on several layers at once. At this step, it is still very bugged and not
really working properly. In particular, since we don't process the
drawable offset early anymore (because it makes no sense when we pass a
list of drawables with different offsets), I suspect that all the
offset-related code will be very broken.
2021-09-14 17:59:47 +02:00
Øyvind Kolås 127bf7abfb configure,meson,app: depend on GEGL-0.4.32 2021-09-05 20:34:59 +02:00
Stanislav Grinkov 8516221662
app: Correctly place merged down layer...
when the image is in indexed color mode, and bottom layer doesn't
have an alpha channel.

Resolves: #4945
2021-09-02 13:04:13 +06:00
Jehan 49e534247a app, libgimp*, pdb, plug-ins: use g_memdup2() instead of g_memdup()
Since it appeared with GLib 2.68.0, we could not change this until we
bumped the dependency which has only become possible a few days ago
(since Debian testing is our baseline for dependency bumps). Cf.
previous commit.

As this is a drop-in replacement (just a guint parameter changed to
gsize to avoid integer overflow), search-and-replace with:

> sed -i 's/g_memdup\>/g_memdup2/g' `grep -rIl 'g_memdup\>' *`

… followed by a few manual alignment tweaks when necessary.

This gets rid of the many deprecation warnings which we had lately when
building with a recent GLib version.
2021-08-26 17:32:09 +02:00
Luca Bacci 1685746579
Only select available API's 2021-08-25 20:35:08 +02:00
Luca Bacci 825ea9dc1c
Move initialization order 2021-08-25 20:35:02 +02:00
Luca Bacci 012df8514a
Add a config enum for the pointer input API to use on Windows 2021-08-25 18:24:54 +02:00
Luca Bacci f6fc9d4245
Rename GimpLangRc to GimpEarlyRc 2021-08-25 18:23:17 +02:00
Jehan f888a6f2f0 app: update menurc migration.
- Migrate "view-rotate-reset" to "view-reset" (there is a
  "view-rotate-reset" in GIMP 3, but it will be only for rotate; what
  was really doing the same-named action in 2.10 is now what
  "view-reset" does).
- Make sure we don't migrate "file-export" from a 2.10 config. From a
  2.8 or below, we don't to migrate it (same as for 2.8 to 2.10), but in
  a 2.10 config, it is already the same action as the one in GIMP 3.
2021-08-23 19:10:27 +02:00
Jehan 15fb4a7be0 Issue #1168 - Allow resetting rotation view and flip view separately.
Action "view-rotate-reset" renamed to "view-reset" (resets both flipping
and rotate). New "view-rotate-reset" and "view-flip-rotate" for
resetting rotation and flipping respectively.
2021-08-23 15:46:11 +02:00
Jehan 753e994e1d app: forgot to also properly migrate the docks size.
Same as last commit, avoiding to end up with twice too big docks.
2021-08-23 13:57:38 +02:00
Jehan c43de62e99 app: config folder migration update for GIMP 3.
Fix the search for previous folders, which was broken as it was
specifically expecting 1-digit numbers so far.

The differences of the GIMP 3 config import are:

- update sizes and positions in the sessionrc according to the scale
  factor, because GTK2 doesn't have scale support. It means that, e.g.
  with a 2× display, all sizes and positions in GIMP 2.x must be divided
  by 2 (otherwise the first thing many people will get when testing GIMP
  3 for the first time is an off-screen window).
  Of course, I even wondered if it would not be nice to just drop the
  sessionrc altogether and start with a nice blank slate, but then you
  also lose the opened dock and their organization and some settings
  (such as whether you chose single or multi window mode, etc.).
- scripts/ and plug-ins/ are not imported. Probably makes no sense so
  far as they would end up broken (but maybe it's not true for all
  script-fu scripts?).
2021-08-23 13:37:11 +02:00
Jehan ef87f34ba4 Issue #6843: "Canvas Size" dialog takes too much vertical space.
Since the recent changes to add template ability, there are just too
many widgets stacked up vertically. Let's use a little better the
horizontal space.

To do this, I moved the preview on the right side of the "Canvas Size"
and "Offset" number fields, and the "Center" button just below it.
2021-08-22 18:21:37 +02:00
Jehan 38a0b7611c app: free mypaint_brush_path, mypaint_brush_path_writable and…
… default_mypaint_brush in gimp_core_config_finalize().

As reported by Massimo.
2021-08-22 12:10:11 +02:00
Jehan 3fa68be264 app: date string in the About dialog was not always freed.
Let's move the g_date_time_format() to the inner block when it's
actually used, hence also make sure we allocate and free at the same
code level, which is a better practice to limit leaks.

Reported by Massimo.
2021-08-22 12:01:38 +02:00
Jehan 0fe7e147b5 app: unref the GtkSizeGroup-s.
As explained in GTK docs, size groups are referenced by every internal
widget hence can be immediately unref-ed after we added widgets in it.
In the end, when the widgets are destroyed (thus removed from the
group), the group will end up freed too.

Reported by Massimo.
2021-08-22 11:55:12 +02:00
Jehan 62827563c4 app: unref the newly created GVariant-s.
I first sink these, because they are floating references. This is
actually quite unneeded here, because callbacks given to
gimp_action_group_add_procedure_actions() (this is what
filters_history_cmd_callback() is for) are not taking ownership of the
GVariant anyway. Yet just in case this ever changes, this is the proper
way to do it to avoid a double-free in the future. We take ownership in
the calling code, hence we free the variable there after using it.
2021-08-22 11:32:59 +02:00
Jehan 456327eff0 app: unfreed GList.
Thanks to Massimo for reporting.
2021-08-22 10:56:13 +02:00
Jehan 9a0876b9bd app: forgotten GList freeing.
Thanks to Massimo for the report.
2021-08-21 19:06:14 +02:00
Jehan 1ece3675c9 app: another leaked GtkTreePath.
Thanks to Massimo, again and again. ;-)
2021-08-20 22:00:03 +02:00
Jehan 025cebf76f app: free an unusing allocated string when not used as a result.
Another leak reported by Massimo.
2021-08-20 21:53:41 +02:00
Jehan ef56fed9cb app: string allocated by gtk_tree_path_to_string() must be freed.
Thanks again to Massimo for the report!
2021-08-20 21:43:55 +02:00
Jehan 411c279610 app: return value of gtk_tree_path_new_from_string() must be freed.
Thanks to Massimo for reporting this leak.
2021-08-20 21:37:45 +02:00
Jehan f5ea8e9b2a app: fix leak of a GdkPoint and improve stable zoom centering logics.
This started as yet another report of leak by Massimo. But really the
leak of the GdkPoint created by the function
gimp_display_shell_push_zoom_focus_pointer_pos() is not only when
delta_y is 0. There are a few code paths in gimp_display_shell_scale()
when we would not pop this point. One of them is for instance when
window resizing in multi-window mode is allowed. There might be more
(but the code is convoluted enough not to be 100% sure if these are
possible with our specific case).

This specific function was initially created only to be used for unit
testing code (commit 7e3898da09), but it ended up being also used
internally (commit 792cd581a2). Since I see that the test for which
this code was initially created even seem broken right now (the assert
part for position check is commented out!), I even wonder if we should
keep it. We could indeed instead just add optional start_x|y arguments
to gimp_display_shell_scale(), which would be much cleaner. But I leave
it for now.

Instead I just make sure we clean the created GdkPoint after calling
gimp_display_shell_scale(). Also I get rid of the GQueue. It is clear in
the code that we are not expecting queuing interaction of several
positions. Worse right now, we could end up in weird cases where the
pushed points are not used when they should, then could end up being
used later in totally unrelated interactions (this would make the shell
position jump here and there). So let's just make it a single point.
Finally adding some appropriate comments in parts which are still a bit
wrong.
2021-08-20 20:51:29 +02:00
Jehan 24e44c13cd app: fix leaking a GimpMybrushSurface struct.
Reported by Massimo, as again and again! \o/
2021-08-16 22:39:06 +02:00
Jehan 0359427756 app: allow image_merge_layers_callback() to be called with NULL dialog.
This function is not only used as "response" callback to the merge
dialog, but also called directly with a NULL dialog in
image_merge_layers_last_vals_cmd_callback().

This commit fixes:
> (gimp-2.99:130330): Gtk-CRITICAL **: 22:17:59.774: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed

Reported by Massimo.
2021-08-16 22:20:07 +02:00
Jehan 3603441037 app: return of gimp_image_get_selected_drawables() must be freed.
One more report by Massimo.
2021-08-16 20:22:44 +02:00
Jehan 140652a478 app: free GList (leak reported by Massimo). 2021-08-16 19:29:46 +02:00
Jehan b93c416e42 app: free a GimpPixPipeParams value (reported by Massimo). 2021-08-16 19:15:48 +02:00
Jehan 968cc3c758 app: free unused return value of gimp_procedure_execute().
Another leak reported by Massimo.
2021-08-16 19:08:40 +02:00
Jehan 4336b7a8e3 app: fix memory leak reported by Massimo. 2021-08-16 18:57:21 +02:00
Jehan abb904d64d app: improve/fix the most-recently used layers stack management.
A few issues existed in the code:
- When the layers selection is changed, make sure we remove all
  duplicates (not only the first one). This should not be a problem
  anyway because we also do this duplication cleanup elsewhere now, but
  still…
- Fix gimp_image_layer_stack_cmp(): we were comparing a GList element to
  the data of another, so we were actually never finding duplicates.
- Add gimp_image_clean_layer_stack() for internal layers stack
  management/cleanup. It takes care of recursively making sure we don't
  leave duplicates, and remove all empty lists.
- Now use this new cleanup function inside
  gimp_image_remove_from_layer_stack() instead of doing some incomplete
  and broken element removal. This was especially broken as we were
  removing a GSList element from a list we were iterating on (so we were
  dereferencing a now freed element). This last issue was reported by
  Massimo, and this is how I found the more general failure in this
  layers stack management.
2021-08-16 15:06:00 +02:00
Jehan 70f2192bff app: fix leaked queue created at init() (as reported by Massimo). 2021-08-16 12:16:52 +02:00
Jehan 2d1d2340db app: fix one more ugly leak.
This one was definitely tricky. Thanks again to Massimo for catching it!
2021-08-15 01:44:46 +02:00
Jehan a10bb056ed app: fix 2 possible leaks.
In some cases, the `src_viewables` and `drop_path` variables may leak.
Thanks to Massimo for the report on `src_viewables`!
2021-08-14 19:57:00 +02:00
Jehan b1afc33971 app: fix list leak, as reported by Massimo. 2021-08-14 19:02:29 +02:00
Jehan ee09ae7245 app: fix gimp_plug_in_cleanup_item_new().
This fixes a memory leak as reported by Massimo.
But even more, we fix the code logics, as the cleanup items were never
added to the `item_cleanups` list.
2021-08-14 18:20:49 +02:00
Jehan c7b3c3c629 app: free leaking drawable list (as reported by Massimo). 2021-08-14 13:35:48 +02:00
Jehan 4f7dceff15 app: fix string array leak as reported by Massimo. 2021-08-14 12:54:13 +02:00
Luca Bacci ac0a084e6e Show message dialogs in preferences dialog 2021-08-13 20:45:15 +00:00
Stanislav Grinkov 428b944334 Remove unnecessary linking with genmarshal from meson build rules 2021-08-13 18:01:13 +00:00
Stanislav Grinkov 619cb91230 Remove unnecessary gimpmarshal.h and gimpwidgetsmarshal.h includes. 2021-08-13 18:01:13 +00:00
Massimo Valentini dd03716fae Issue 7128: Mouse wheel zoom when cursor is over the zoom scrolldown. 2021-08-10 15:01:14 +02:00
Jacob Boerema 317b5d9cff app: improve error message loading pattern that is too large
As noted in issue #6032 the error message when trying to open a pattern
file with dimension larger than supported could be a little clearer.

We do this by adding the maximum allowed dimensions to the error message.
2021-08-09 18:08:33 -04:00
Jacob Boerema f130fe1917 app: disallow saving of patterns larger than max allowed dimensions
For GIMP patterns we have maximum allowed dimensions which we check when
loading a pattern. However, we did not check this when saving a pattern.
See issue #6032.

This commit adds a check when saving a pattern and adds a descriptive
error to make clear why saving fails.
2021-08-09 16:37:28 -04:00
lloyd konneker c324ec3e8c Fix #6980 /app/pdb/gimppdb.c unnecessarily includes core/gimpmarshal.h 2021-08-06 14:21:51 +00:00
Jehan 7982a5d18c Issue #5386: Gimp crashes when setting AdobeRGB image to Indexed colors.
Similar to the fix of commit c0e605ef for RGB images with a profile as
notified by Massimo.
2021-08-05 18:53:15 +02:00
Massimo Valentini 3b2a8f79f0 Issue #5267: Cage transform tool causes artifacts.
I somewhat bisected GEGL commits between 0.4.20 and 0.4.24 and found
that the one that introduced the env var GEGL_OPERATION_INIT_OUTPUT is
the first showing the problem.

Reviewer (Jehan) note: so it would be commit 6e9610e65c on GEGL repo.
This fix makes sense as it means that since this commit, the output
buffer could have random values. It's not a problem for any operation
where we fill every value, but I guess it's not the case for
"gimp:cage-coef-calc" which was likely relying on the old behavior of
being 0-initialized.
2021-08-05 16:58:55 +02:00
Des McGuinness 4f9b7373e6 Issue #5989 - performance improvement patches for gtk and gimp
Reviewer comment (Jehan): we have used this patch successfully on our
installers since start of 2021 (see commit b4d665d of our gtk-osx fork)
and it really improved the situation. I only fixed minor coding style
stuff in the patch.
Looking at what it does, I guess it is not ideal long-term if related to
10-bit display (as I understand from the comment), which a graphics app
would want to support properly. But for now, this is better than
extra-slow display until we get macOS developers able to look at this
more in depth in the future (I don't think that our dependencies are
really ready yet for 10-bit display support anyway, though I may be
wrong).
Some other forums seem to say it comes from macOS invalidating now more
than it should (i.e. the whole area instead of only the changed area)
and this NSViewUsesAutomaticLayerBackingStores flag would disable this
behavior. It might be one of these reasons, the other or both. This is
anyway a good first start for future contributors.
2021-08-04 21:47:26 +02:00
lloyd konneker 37593d6da3 Fix #6979 meson build fails link libexecinfo on Alpine 2021-08-04 18:21:22 +00:00
Jehan f2fb98cb69 Issue #6610: crashes on free select for images of certain dimensions.
g_alloca() is unadvised. Even though it might be more efficient in some
specific cases, it is pretty subject to stack overflow when a lot of
memory is requested.

Let's allocate dynamic memory instead. To avoid doing it too much, let's
just reuse the same pointer especially since region of interest will
usually be the same size when iterating a buffer, except for border
ones (which would usually be smaller, so we can use the same allocated
buffer again). I still make size checks, just in case.
2021-08-04 14:41:44 +00:00
Jehan cc57860837 Issue #7115: properly chaining up finalize() methods.
Thanks to Massimo Valentini for finding these.
Fixes:

> GLib-GObject-CRITICAL **: 13:21:53.256: Object 0x5485140 of type GimpLineArt not finalized correctly.
> GLib-GObject-CRITICAL **: 13:21:57.472: Object 0x231f520 of type GimpExtension not finalized correctly.

Outputted when glib is built with -Dglib_debug=enabled and GIMP is run
with GOBJECT_DEBUG=objects.
2021-08-04 01:59:41 +02:00
Jacob Boerema af909b82b2 app: fix #6724 When creating keyboard shortcut the section being edited disappears
After updating a keyboard shortcut in the Configure Keyboard Shortcuts
Dialog, the section containing the changed shortcut disappeared.

Apparently a changed shortcut makes its parent invisible so we make the
parent visible again.
We also store a text version of the selected path in the tree to the
shortcut and then use that to restore the path after making the parent
visible again.
2021-07-29 17:59:30 -04:00
Jacob Boerema 42fe8abc98 app: fix #5153 keyboard shortcuts Shift+[ and ] don't work on most keyboards
On most keyboards the [ and ] keys are shared with { and }. Which means
that if you press Shift+[ you get {. We were using this key combination
to increase the tool's size by 10 and the other to decrease it by 10.

However, on all keyboards where these keys share the same physical spot
on the keyboard, this wasn't working.
So, let's change the actual keys to do this to { and }.
2021-07-28 13:38:26 -04:00
Jehan f8f768c077 app: adding a comment for translators.
As per comment by Alexandre Franke, so that translators are aware this
is not about a "map" like a "world map", but like "mapping" filters.

Cf. https://gitlab.gnome.org/Teams/Translation/fr/-/issues/17#note_1209282
2021-07-22 17:11:16 +02:00
Jehan 3598562472 app, libgimpwidgets: drop the thumbnail icon feature.
From years of discussions, it turns out that:
- The thumbnailed-Wilber icon replacing the generic icon of GIMP often
  makes the application harder to spot in the icon list of running
  processes.
- In single-window mode in particular, it makes even less sense as we
  just show the one active image anyway.
- Even in multi-window mode, nowadays many OSes or desktop group windows
  of a same application under one icon. So we end up with several image
  windows under a thumbnail only showing the top image. This happens in
  KDE, GNOME, Cinnamon and Windows at least apparently (as far as is
  being reported).
- Some platforms would just use only the OS-declared icon and not care
  about runtime-declared ones. This is apparently the case on macOS, and
  also on GNOME when the desktop file is seen by the desktop
  environment. So all our code about generating thumbnailed icon is
  wasted on these platform anyway.
- When intensively testing the current behavior, I had cases when the
  icon was not properly updated. We could of course investigate and fix
  the issues, but considering all the previous points, it might make
  more sense to simply drop the feature which is mostly useless, or
  worse bothersome, hence simplify the code greatly.
- Finally API to set icons from GdkPixbuf data has been removed in GTK4.
  So long term, trying to keep this whole machinery feels like just
  making our life difficult for a feature which all OSes seem to
  deprecate and which might not be possible anymore soon (or just get
  harder and harder to implement).

Note that I don't use gtk_window_set_default_icon_name() because it
would use the icon from our theme, yet so far we are not sure it makes
sense for the application icon which we probably always want to be the
same, whatever the chosen theme. Finally I just list various common icon
sizes because GTK API doesn't seem to be clever enough yet. I can't just
give it 1 SVG image (e.g. with gtk_window_set_default_icon_from_file())
and hope it does the resizing at the last minute. It turns out it
doesn't and we get an extra-small icon. So instead, let's generate
common sizes ourselves from the same SVG.
2021-07-06 11:21:37 +02:00
Jehan d3105e5c72 app: add a comment and some newlines before the debug data section.
The markdown triple-quote (```) has to be on its own at the start of a
newline. Schumaml was telling me that too many reporters would paste
just after some text, which would therefore break the markdown syntax.

Instead let's add 3 newlines before the triple-quote, so that even
people who would not hit the "Copy Bug Information" button (but instead
select and copy) have a hint that these newlines are made on purpose.
Also add a comment (which is discarded by Gitlab) to make this even more
obvious.

Then even when pasting just after some text on the same line, the
triple-quote will end up on its own line.
2021-07-05 16:44:54 +02:00
Jehan 086ae77929 app: new gimp_display_grab_focus() function.
The goal of this function is to give the focus to the active image
display. This is implemented as a core GimpDisplay virtual function
(with the actual implementation in GimpDisplayImpl), allowing to be used
even in core code, without actual GUI code (this was not necessary right
now, but I think it will be useful in future use).

This function is now called from the toolbox code (cf. 2 commits
earlier), avoiding code duplication. I also added a usage at the end of
toolbox_paste_received() so that a newly opened image by middle-click
paste in the toolbox directly gains focus.
2021-07-05 15:31:36 +02:00
Jehan 2d123b8290 app: fix wrong unref-ing.
Testing this middle-click opening of image by their PATH/URI in the
toolbox, I realized there was a bug. The original author was obviously
intending to unref the toolbox which was ref-ed when calling
gtk_clipboard_request_text(), not freeing the toolbox context, which
could have dire consequences!

Fixes this CRITICAL:

> g_object_unref: assertion 'G_IS_OBJECT (object)' failed
2021-07-05 13:01:47 +02:00
Jehan 3d9996f1a6 Issue #6869: Toolbox buttons should focus the canvas as side effect.
Toolbox buttons don't require focus keeping (no further keyboard input
needed and navigating through/selecting tools can be done in various
other ways with a keyboard), which is why I removed focusability of
toolbox buttons years ago (cf. commit c83ee61c07).

Nevertheless this is not enough, and since toolbox is meant to work on
the canvas anyway, let's give back canvas focus as soon as any click
happens on dead areas of the toolbox, as well as on the Wilber (dnd)
drawing, but also each time a toolbox button is selected (though not on
the longer clicks to see tool groups' contents without selecting a tool
in the end).
This will allow to directly start working on the image without requiring
a click first (for instance panning with Space or similar interactions
which would not give focus to the image canvas).

This can also count as an alternative to the "Esc" shortcut to get
canvas focus back, with a mouse click instead of a keyboard key.
2021-07-05 12:45:24 +02:00
Niels De Graef def862bae4 meson: Always enable CPU extensions
Don't enable conditionally based on the buildtype.

Further, don't use `add_project_arguments()` to enable the instructions:
this will lead to crashes within g-ir-scanner, which can't properly
parse these instructions.

https://gitlab.gnome.org/GNOME/gimp/-/issues/5053
2021-06-15 21:15:32 +00:00
Ian Martins 825067eab7 plug-ins: fix #6859 Hurl random pct limits in PDB are incorrect
(cherry picked from commit a038051bb8)
2021-05-24 18:45:48 +02:00
lloyd konneker 003f137dc0 6872 gimp-pdb-dump print type of GValue instead of type of GParamSpec 2021-05-24 15:26:30 +00:00
Pavel Artsishevsky 603c5dcb2c app: call parent's window_state_event() from GimpImageWindow
Fixes #6883
2021-05-24 11:34:41 +00:00
Stanislav Grinkov 203393a9fc core: function documentation clarification
Update api documentation of GimpObject and GimpThumbnail classes to
clarify who and when will take care of disposing passed strings.
2021-05-24 11:04:44 +00:00
Stanislav Grinkov f8320ce535
core: minor memleak fixes
Fix several memory leaks when uri obtained by g_file_get_uri ()
was not g_free'd ().
2021-05-23 20:57:44 +06:00
Jehan 0625902d71 app: set "OK" the default button to the "Create a New Image" dialog.
In Linux, I never paid attention to it because it was already working as
expected (i.e. Ctrl-n followed by Enter for instance would directly
create the image), but when testing GIMP on Windows for the installer,
these last few days, I realized that hitting Enter when focus was on the
dimension entries was doing nothing. Having to move the pointer to click
a button on Windows was frustrating. So let's make OK the official
"default response" directive for this dialog.
2021-05-20 20:45:28 +02:00
Jehan 668c9de5a5 app: add back a timeout-based idle function to queue a canvas redraw.
I'm still very unclear why exactly but it would seem that just queuing
the redraw with an idle function is not enough. At least on Windows,
Jacob was having cases where opening an image would get stuck unless the
mouse was moved (causing draw events most likely).

So let's use a timeout function instead. Probably no need to queue the
idle followed by the timeout function as we had before commit
4fee04b839. Instead just directly queue a draw if relevant, then run the
timeout at regular interval (marching ants speed).
2021-05-11 19:36:20 +02:00
Marc Espie 6dc98fe7f0 Issue #6850: support for memory in the dashboard under OpenBSD. 2021-05-09 19:57:49 +02:00
Jehan 6466d46052 app: check the time before last selection draw before queuing a redraw.
This way, we would queue a lot less canvas region unnecessary redraws.
We still remake the time-before-last-draw check in the draw() signal
handling before we want to update the marching ants index for draw
events coming for other reasons (canvas updates, moving/zooming on
canvas, exposition changes, etc.).
2021-05-09 15:51:20 +02:00
Jehan e8a531e51e app: fix selection display on right/bottom borders when rulers are…
… displayed.

We should use the dimensions from the GimpDisplayShell not the the
GimpCanvas. Indeed the canvas is shorter when rulers are visible, hence
the selection next to the extreme sides (bottom and right sides of the
canvas) was not drawn.
2021-05-09 15:37:22 +02:00
Jehan 4fee04b839 Issue #5640: Selection tools not showing selection on Wayland.
As suggested in a comment (itself coming from an IRC discussion), we
should not use gdk_window_(begin|end)_draw_frame() functions as this
works on X, but not on Wayland anymore. Instead draw directly during
draw() call of the shell widget, and force it to happen regularly, to
update the marching ants, via gtk_widget_queue_draw_region().

This is tested and works on Wayland. Please everyone, test thoroughly to
make sure it works well in all situations, and also that we don't get
any unexpected slowdowns.

Since the symptoms are very similar, it is highly possible that it also
fixes the issue #5952 too, for selection not showing on macOS since Big
Sur 11 (maybe they changed the same way as Wayland did). Unfortunately I
can't check this myself. Please test, whoever has access to a macOS Big
Sur and can build GIMP!
2021-05-09 02:47:47 +02:00
Jehan 6c1a0e8be7 app: gui_free_progress() should accept any GimpProcess widget.
Simply it should free only GimpProgressDialog as these would be
dedicated dialog (with no meaning once progression is done), and leave
alone other GimpProgress widgets. In any case, it should not output
CRITICAL errors on these.

Fixing the following CRITICAL:
> GIMP-CRITICAL: gui_free_progress: assertion 'GIMP_IS_PROGRESS_DIALOG (progress)' failed

When dropping an image on the toolbox.
2021-05-06 00:19:25 +02:00
Jehan 1566d9437e app: make sure we send the origin display to plug-ins through PDB. 2021-04-30 03:48:12 +02:00
Jehan 7eaa4f1ca9 app, libgimp, pdb: new gimp_display_present() PDB call. 2021-04-30 03:46:52 +02:00
Jehan 2211ca7fd3 app: wait child processes with g_child_watch_add_full() rather than…
… waitpid().

My use case was when testing gimp_brush_select_new(). When doing tests,
if I let the brush dialog opened while letting the plug-in exit cleanly
otherwise, it somehow locked the process (I have stared so long at the
code and still don't understand why).
gimp_plug_in_close() would wait for it forever and the only way out was
to kill GIMP completely. I guess we could try to run waitpid() with
WNOHANG (and finally force-kill the child if it really won't exit) but
it made the whole logics extra complicated.

The logics with g_child_watch_add_full() is that we don't stop waiting
for the child and just set a callback to finalize what needs to be. Now
the worst case scenario would be to leave zombie processes dangling
around, but it's better than freezing GIMP.

Finally as a weird side effect, doing this change even unblocked the
process with an unfinished brush selector so we don't even have a zombie
anymore (at least for this specific case). All good in the end!

Last side effect: it can speed up a tiny bit the plug-in close as we
don't wait for processes anymore, which could be more visible at first
startups (when we reload all the plug-ins). Though there is nothing
scientific to my numbers, after multiple "first startups", it seems it
went down from about 3.5 to 3.2 seconds on my specific machine. Nothing
extra fancy, but we take what we can (and speeding up the startup was
never the goal of this change anyway). It doesn't affect Windows which
has its own logics to handle process termination and I preferred not to
touch it.
2021-04-29 02:19:41 +02:00
Jehan 4ee3a9caa1 app: fix core crash when a plug-in calling a GimpPdbDialog crashes.
There are 2 parts for this fix:
- First expect the GimpPdbDialog to possibly disappear while
  gimp_pdb_dialog_run_callback() is running. This can indeed happen as
  this core dialog is tied to a PDB call. If the calling processus
  crashes (which may happen, and has to be expected for third-party
  plug-ins), then this dialog may just end up closing at anytime (signal
  "plug-in-closed" from the plug-in manager which implies a
  GTK_RESPONSE_CLOSE, hence dialog destruction).
  To account for this, we check the dialog availability with a weak
  pointer and returns the info to the caller as well.
- Don't connect to "value-changed" on the spacing adjustment because
  when a crash happened, I had cases when the adjustment was finalized
  while being set (crash in GTK code). This one is a bit harder to
  explain (I had to look long at backtraces) but having a proper signal
  "spacing-changed" on the GimpBrushFactoryView is actually much cleaner
  code than relying on a public object anyway and it fixes this crash.

Note: this fix is related to my previous commit. When running
gimp_brush_select_new() from Python code, the plug-in crashed when
trying to run the callback, which also resulted into core crash (and
this part is obviously not acceptable at all).
2021-04-28 02:47:24 +02:00
Ian Martins c97cf30e6e pdb: add a PDB compat procedure for median-blur
(cherry picked from commit eb9eec4acb)

Reviewer note: with re-generated C files for the updated PDB in the main
branch.
2021-04-25 15:56:41 +02:00
Jehan c8020c20a5 app: don't print a NULL insensitive action reason.
Print an empty string itself, otherwise it actually displays "(null)".
And anyway it's not clean code to use a NULL pointer in a printf format.
2021-04-24 23:26:33 +02:00
Jehan ef2402bf8e app, libgimp, pdb, plug-ins: allow pasting multiple full layers.
When a selection exists, we are copying then pasting the selection
contents. In particular, with multi-layer selection, it means pasting a
merged result of the selected layers (like a sample merged but limited
to selected layers).

Yet when no selection exists, with a single layer selected, a cut in
particular would remove the layer fully, then a paste would copy it
elsewhere (in the same image or even on a different image). This was
still working, but not with multiple layers. This is now fixed and we
can now copy/cut then paste several layers (without merge), which is
sometimes a very practical way to move layers (sometimes simpler than
drag'n drop, especially between images).

As a consequence, the PDB function gimp_edit_paste() now also returns an
array of layers (not a single layer).
2021-04-24 23:22:58 +02:00
Jehan 11e1f6ea5e app: fix out-of-gamut representation (pink triangle).
The small pink triangles were completely broken, i.e. displayed at the
wrong coordinates.
2021-04-24 19:32:13 +02:00
bootchk c6fde64815 GIMP-CRITICAL: gimp_marshal_VOID__OBJECT_STRING_STRING: assertion 'n_param_values == 4' failed 2021-04-24 15:00:42 +02:00
Jehan d6dac25579 Issue #5008: Always true condition (i>=0) inside fill_inverse_cmap_gray.
Removing useless condition, add a g_return_if_fail() assertion for the
only (impossible unless bug) case which we don't expect. Also set
default mindist to G_MAXLONG instead of a magic number (which was ok now
but might become a problem if some day colormap allowed more than 16-bit
per channel colors).
Finally break when we reach a distance of 0 since we won't get lower
anyway, so better stop early.

Thanks to Rafał Mikrut and Øyvind Kolås for code commenting.
2021-04-24 14:48:22 +02:00
Jehan c0e605ef96 app: fix an assertion when converting grayscale images to indexed.
We cannot just compare the drawable format with the model-type specs of
the color model. We need to include the space now.
In my case, some random screenshot converted to gray then indexed would
assert because the format is "Y' u8-space-gray-sRGB" (or for layers with
alpha: "Y'A u8-space-gray-sRGB"), hence indexed conversion failed and
ended up dark.
2021-04-24 14:12:57 +02:00
Jehan 13a02aea23 app: append insensitive reason to GimpAction proxy tooltip.
With my previous commit, I improved the search action display and search
algorithm (which was returning wrong results), but we had lost showing
the non-sensitive reason in menu item tooltips. This fixes it, by
actually appending the reason, but only in the end, on the GtkWidget
tooltip (not in the action's tooltip itself).
2021-04-23 19:48:37 +02:00
Jehan 811d356953 app: GimpAction now has a "reason" parameter to explain being disabled.
In some cases, in particular for actions generated from plug-in
procedure right now, we were displaying the reason of the insensitivity
(typically right now, only the drawable type is cited). This was done by
appending the reason to the tooltip, separated by 2 newlines, which
resulted in extra ugly design, no nice way to style this info directly
(with pango for instance if the widget display allows it, or on a
separate info widget in a possible future, or whatnot).

Also it would mean that the action search could match a disabled action
by mistake if a search word happens to be in the reason message.

This improves the situation with the following changes:
* gimp_action_set_sensitive() now takes an optional reason string to set
  the reason message.
* Same for gimp_action_group_set_action_sensitive().
* gimp_action_get_sensitive() returns an optional reason string.
* gimp_procedure_get_sensitive()'s tooltip return value now becomes a
  reason (it won't contain anymore the tooltip and the reason
  concatenated, only the reason for separate processing).
2021-04-23 19:43:30 +02:00
Povilas Kanapickas a8b258cd84 app: Implement canvas support for touchpad gesture zoom by pinch 2021-04-22 17:45:32 +00:00
lloyd konneker 34c1dbde13 Fix #6676 brush select crash, pass GimpArray->data instead of GimpArray*
Same issue for brush, pattern, gradient
2021-04-21 15:38:23 +00:00
Jehan 68dcb4b421 app: fix sending signals to finalized object.
Fixing:

> GLib-GObject-WARNING **: 01:43:13.747: instance with invalid (NULL) class pointer
> GLib-GObject-CRITICAL **: 14:15:37.327: g_signal_emit_valist: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

When changing brushes through tool options. Thanks to ankh for noticing
this.
2021-04-21 14:19:05 +02:00
Jehan 3f9184f576 app, pdb: plug-in-autocrop-layer() multi-layer aware.
This PDB procedure will now crop all selected layers relatively to the
input drawable.
2021-04-21 00:13:24 +02:00
Jehan 60b9c5633e app, libgimp: validate procedure arguments taking class heritage into…
… account.
2021-04-21 00:00:32 +02:00
Jehan 0b750eca6f app: print to standard error output when procedure uses deprecated…
… single drawable run() function.
All Scheme scripts use a single drawable and I am not so sure where to
change this (or rather I hope someone will handle this rather than I).
So let's not output a warning which would result into a stacktrace,
blocking the GUI for a second or 2 and displaying an annoying popup each
time. Let's just output to stderr for now until we get into a better
state.
2021-04-20 17:43:53 +02:00
Sebastien e8b23d6e4b typo in pdb/groups/plug_in_compat.pdb 2021-04-19 14:44:00 +00:00
Michael Schumacher 530dc883ca app, libgimp*: glib-genmarshal warns about --header --body
Using --header --body is mentioned as being deprecated, the way to get the desired result said to be
--prototypes --body now.
2021-04-17 22:50:49 +02:00
Jacob Boerema 4aaad4f749 app: fix 3d transform tool not added to gimphelp-ids.h 2021-04-09 18:01:04 -04:00
Stanislav Grinkov b21865328c
gui: Add pixel density selector to canvas size dialog ...
which will be shown when selected template pixel density don't
match the image pixel density.

Then user can either keep current image ppi and scale the
template or set image ppi to match the template ppi.

Density selector displayed only when template and image ppi
differs and template unit is matches one of real world units
(e.g. inch, mm, etc).

Closes: GNOME/gimp#1140
2021-04-08 22:09:26 +06:00
Jehan 5ae7bb6aa2 app: fix folder when showing again the export dialog.
This should not be necessary and I could not find the bug in GIMP. It
might be in GTK. In any case, after hiding, then showing back the export
dialog, the file name is right but not the output folder (apparently
revert to current working directory?).
With this, we force it to be the same folder as we left the dialog.
2021-04-06 22:18:03 +02:00
Jehan ca8bc2bc1d app, libgimp, pdb, plug-ins: more functions moved to get|set().
The gimp_drawable_type() is an issue though as gimp_drawable_get_type()
is already defined as a common GObject API.
Though I'm actually wondering if GimpImageType is well called. Rather
than Type, shouldn't we go with ColorModel?

sed -i 's/\<gimp_drawable_bpp\>/gimp_drawable_get_bpp/g' "$@"
sed -i 's/\<gimp_drawable_width\>/gimp_drawable_get_width/g' "$@"
sed -i 's/\<gimp_drawable_height\>/gimp_drawable_get_height/g' "$@"
sed -i 's/\<gimp_drawable_offsets\>/gimp_drawable_get_offsets/g' "$@"
2021-04-06 14:34:31 +02:00
Jehan fa16152757 app, libgimp, pdb, plug-ins: update some more functions to get|set().
s/gimp_image_base_type/gimp_image_get_base_type/
s/gimp_image_width/gimp_image_get_width/
s/gimp_image_height/gimp_image_get_height/

Sorry plug-in developers, more porting work! But really this seems like
the right thing to do in order not to get stuck with inconsistent naming
for many more years to come.
2021-04-06 00:49:07 +02:00
Jehan 70a9576f27 app, devel-docs, libgimpbase: s/gimp_parasite_name/gimp_parasite_get_name/…
… and s/gimp_parasite_flags/gimp_parasite_get_flags/

It is better to have a consistent API and the fact is that most
getter/setter functions use the _get|set_ naming, but these didn't.

I wondered if this was such a great idea to rename these anyway because
even though we are breaking API in GIMP 3, is it the best idea to rename
when no functional change happened? After discussing with Wormnest, we
still agreed it was still better to go for consistency rather than
regret later (and be stuck with these names for many more years).

Also this fixes these warnings:

> [649/1205] Generating gimp-3.0.vapi with a custom command
> Gimp-3.0.gir:24162.7-24162.56: warning: Field `Gimp.Parasite.flags' conflicts with method of the same name
> Gimp-3.0.gir:24318.7-24318.52: warning: Field `Gimp.Parasite.name' conflicts with method of the same name
2021-04-05 18:36:44 +02:00
Simon McVittie dda65d85c3 app: Don't second-guess the dependency system
Removing this check makes the treatment of LittleCMS consistent with
all the other dependencies checked in the same file, which only check
that the runtime version is at least the required version.

As long as we were compiled against LittleCMS >= 2.8, and are now
running against a version that has at least the same symbols, it doesn't
necessarily matter whether the version we are running against is the
same one we were compiled against.

Distributions like Debian and Ubuntu track the versions in which
individual symbols were introduced, which allows runtime dependencies
to be weakened when no newer symbols are actually used; this is
practically necessary when working with very large numbers of packages,
to avoid a new version of a dependency library unnecessarily blocking
upgrade of dependent packages. However, this doesn't work if dependent
packages add their own checks that bypass this mechanism.

Signed-off-by: Simon McVittie <smcv@debian.org>
2021-04-04 12:08:51 +01:00
Simon McVittie e54bfa58b1 app: Print 2-digit LittleCMS minor versions correctly
LittleCMS 2.12.0 defines LCMS_VERSION as 2120. We want to print that
as 2.12.0, not 2.2.0.

Resolves: https://gitlab.gnome.org/GNOME/gimp/-/issues/6505
Signed-off-by: Simon McVittie <smcv@debian.org>
2021-04-03 23:47:39 +00:00
Jehan 6dd48d1a82 app, libgimp, pdb: improve gimp_image_get_layers() docs.
I always found the docs misleading because when it says "Returns the
list of layers contained in the specified image", I really read "all the
layers, at any level", except it doesn't. It only returns the root
layers and it is up to the plug-in developer to loop through these if
one needs to go deeper.

So let's make the function docs clearer.
2021-04-04 01:40:00 +02:00
Jehan 353c73457a app, libgimp, libgimpconfig, extensions: image procedures now with…
… drawable array instead of a single drawable.

Instead of expecting a single drawable, GimpImageProcedure's run()
function will now have an array of drawable as parameter.
As a consequence, all existing plug-ins are broken again. I am going to
fix them in the next commit so that this change can be easily reviewed
and examined if needed later.

I only fix the Vala demo plug-in now (or rather, I just use the first
layer in the array for now) because otherwise the build fails.
2021-04-04 01:40:00 +02:00
Jehan dc7853233b app, libgimp, pdb: new API to advertize when procedures are sensitive.
The new function gimp_procedure_set_sensitivity_mask() allows plug-ins
to tell when a procedure should be marked as sensitive or not.
gimp_procedure_get_sensitivity_mask() retrieves this information.

Currently plug-ins are automatically marked as sensitive when an image
is present and a single drawable is selected. Nowadays, we can have
multiple selected layers so we should allow plug-ins to tell us if they
support working on multiple drawables. Actually we could even imagine
new plug-ins which would be made to work only on multiple drawables.
Oppositely, there are a lot of plug-ins which don't care at all if any
drawable is selected at all (so we should allow no drawable selected).

Finally why not even imagine plug-ins which don't care if no image is
shown? E.g. plug-ins to create new images or whatnot. This new API
allows our core to know all this and show procedure sensitivity
accordingly. By default, when the function is not called, the 1 image
with 1 drawable selected case is the default, allowing existing plug-ins
easier update.

Note: this only handles the sensitivity part right now. A plug-in which
would advertize working on several layer would still not work, because
the core won't allow sending several layers. It's coming in further
commits.
2021-04-04 01:40:00 +02:00
Jehan 5e68a953ee app: fix the test for XCF version with off-canvas guides. 2021-03-30 23:53:02 +02:00
Øyvind Kolås 95900ae6f1 configure,meson,app: depend on GEGL-0.4.30 2021-03-27 20:26:52 +01:00
Jehan 03d6bc9726 app: do not use PATH_MAX and realpath() on macOS.
See the comments in MR!424.
Basically realpath relies on false assumptions (probably ones which used
to be true when the API got created) on the max size of a path. Actually
nowadays paths can be much bigger than what the macro advertizes or can
even be unbounded.
The Linux version of realpath() allows the second parameter to be NULL,
in which case it would allocate the buffer, exactly for this reason
(written in the BUGS section on the man). Unfortunately this behavior is
not standardized in POSIX and the man from Apple I found does not
indicate it will do this.

So let's use g_canonicalize_filename() instead, which seems to do the
right thing. Similarly use g_strdup_printf instead of g_snprintf().
2021-03-25 03:15:50 +01:00
Stanislav Grinkov 1cab305231 tools: Made 'Crop tool' aware of color or pattern changes
Crop tool used stale color / pattern values when performed crop with
'Allow growing' option. Its context was not notified when fg/bg/pattern
value was changed.

Closes: #4103
2021-03-08 18:14:37 +00:00
Stanislav Grinkov 8977c1055d
gui: Update text of 'Crop tool' option to 'Selected layers only'
To better reflect that tool can crop multiple selected layers.
2021-02-25 23:02:04 +06:00
Stanislav Grinkov 6959426603
tools: Rectangle select. Incorrect center_xy after converting channel selection to rectangle
Was caused by widget tool fixed_center_x and fixed_center_y coordinates set to
coordinates of mouse click instead of rectangle center after converting channel
selection bbox to rectangle.

Now rectangle fixed_center_x and fixed_center_y coordinates are always updated
when tool widget x1, x2, y1, or y2 coordinates are updated.

Closes #6487
2021-02-24 22:18:43 +06:00
luz paz 6457394069 Issue #6446: Typo fixes. 2021-02-24 12:33:03 +01:00
Jehan d9840893c0 app: remove useless code.
Fixes warning brought by my commit 015f49467d:
> warning: variable ‘max_position’ set but not used [-Wunused-but-set-variable]
2021-02-22 00:10:17 +01:00
Jehan c800b262b0 app, pdb, libgimp: new PDB call gimp-image-set-selected-layers. 2021-02-22 00:00:55 +01:00
Jehan 02fa354254 app: replace more gimp_(s|g)et_active_layer() to *_selected_layers(). 2021-02-22 00:00:47 +01:00
Niels De Graef dffab0e9a4 Remove GimpInt16Array
It isn't being used by any plug-in or any code in GIMP at all even.
Let's get rid of it while we can still break API, so we can cut down on
all the complexity of the gimp-param stuff a bit.
2021-02-18 11:32:45 +00:00
Jehan 015f49467d Issue #6435: Off canvas guides.
Allow guides with off-canvas position since we can now view and work
outside the canvas.

The guide deletion interaction does not change too much, except you
don't delete a guide because it's dropped off-canvas but off the display
viewport area instead.

The XCF format is technically unchanged as PROP_GUIDES was already
expecting an int32 coordinate (with max value at GIMP_MAX_IMAGE_SIZE,
way below uint32 max anyway). Yet our code and XCF docs was explicitly
asking to ignore negative coordinate guides, which makes a change in
behavior for the XCF parser, hence a new version XCF 15. Loading will
still ignore negative position guides (even also bigger than image
dimension guides now) for XCF 14 and below, but will now accept any
position for XCF 15 and above.
2021-02-15 22:52:27 +01:00
Jehan 82438728fb Issue #288: Point snapping to guides does not work outside the canvas.
This commit also makes snap to grid and snap to vectors work off-canvas.
Since we now have off-canvas viewing, it just makes sense that snapping
would work there too.

Note that I disable snap to grid when "Show All" is OFF. I am actually
unsure this is right (as "Show All" is a view action, and we usually
don't change behavior based on view actions; for instance snap to guides
are not disabled if guides are hidden). Yet I noticed we do this in
various other features when off-canvas. We kind of use this view flag as
a switch for features working off-canvas (for instance, color picking
works off-canvas only when "Show All" is ON). So let's keep the same
logics for now at least.

Snap to guide or snap to vectors will always work though, because guides
and vectors are always visible off-canvas (even when "Show All" is OFF).
They always have been (visible, not snappable off-canvas; now they are
both).
2021-02-13 13:02:48 +01:00
Orgad Shaneh b134da1f39 Fix Python execution with autocrlf on Windows
If the interp file contains CRLF, the \r is read as part of the
executable file name, and gimp searches for python3.exe\r.
2021-02-09 21:58:50 +00:00
Jehan 118c0c6734 app: fix max size computation for status message.
Our error/message handling code was checking if the status bar label was
big enough to hold the message by checking the GtkLabel allocation. This
means that error message ended up on status bar only if a status text
bigger than the error message was previously displayed.
Even setting gtk_widget_set_hexpand() or the "expand" container child
property on the label, I could not find a way for GTK to actually give
it as much space as possible on the status bar.

Instead, I am computing the full container box size, starting from the
label x coordinate (assuming the label is the last shown widget on the
status bar, as usually the progress bar and the cancel buttons are not
shown in the same time as the message label). This gives me a much more
appropriate result of the maximum size which this label can hold without
ellipsizing.
2021-02-09 18:40:43 +01:00
Jehan b7e7561583 app: fix wrong enum type bug. 2021-02-03 21:34:26 +01:00
Stanislav Grinkov a6037760da
gui: #1140 Add image size template selector to resize canvas dialog
Adds option for selecting predefined page sizes using the same
template selector as on "New Image" dialog.

Syncs up size and offset unit selectors to have the same value
when changing template and when resetting whole dialog.
2021-02-01 09:31:21 +06:00
Jehan 7a363f9095 app: s/GEGL graph/GEGL Graph/
Let's have the same casing as other menu items.
2021-01-31 17:59:17 +01:00
Stanislav Grinkov ce93d5c3ab gui: #5339 Disable GEGL Op menu action if no image is open
Because "GEGL Operations..." menu action should be active only
if image is open
2021-01-31 16:47:03 +00:00
Jehan 90d0a7f628 app, menus: move "GEGL Operation" from Tools to Filters > Generic menu.
See the discussion in #5339. Basically this is now technically a tool
(i.e. a child class of GimpTool) and tools can be activated anytime,
even when no images are opened, i.e. when they are useless (for instance
paint tools). Filters on the other hand were historically only
activatable with opened images. With time, tools and filters difference
got slimmer (until there are technically none nowadays where GEGL ops,
levels or curves are implemented as GimpTool too) if not only a
conceptual difference.

Since here GEGL Operation is really more on the "filter" side, let's
just move it to the "Filters > Generic" submenu, just next to "GEGL
Graph", also removing the mention of it being a "tool" from the help
message.
Then I will merge !402 for it to be (in)active depending on images, as
other filters do.
2021-01-31 17:46:29 +01:00
Thomas Manni 0d519a606f app: fix config properties / spin buttons mapping for Convolution Matrix filter
The filter's output is now correct, and rotating/flipping the matrix works as
expected.
2021-01-31 13:09:15 +01:00
Thomas Manni b8abac1777 app: fix crash when deleting channel 2021-01-31 10:16:59 +01:00
Jehan 73a64a4ee8 app: use the GimpDisplay as progress object when exporting.
Since we now hide the file dialog when exporting, progression ends up
invisible, which is especially a problem with big files. Therefore use
the image display as a GimpProgress to show progression.
2021-01-30 10:44:36 +01:00
Jehan ef3d4cddc4 app: fix crash when opening several times an export plug-in.
When running several times an export plug-in while one is still running,
the export file dialog may get destroyed and the second running plug-in
would try to call functions on a destroyed dialog, hence crashing core
GIMP.
2021-01-30 01:04:44 +01:00
Jehan ee26a39049 app: replace gimp_parasite_data*() with gimp_parasite_get_data(). 2021-01-29 23:52:03 +01:00
Jacob Boerema 6df6332f9b Issue #987 Corrupt 'gimp-metadata' parasite. Parsing XMP data failed.
XMP metadata saved by GIMP 2.8.x or earlier can have duplicate tags
making the XMP data invalid. There's not much we can do without a
whole lot of processing and complicated code and even then no
guarantee we would catch everything.

Instead let's just try to improve the message to the user so they
will be more likely to understand what's going on.
2021-01-22 12:44:00 -05:00
Niels De Graef 25d80faaf3 app: Use GtkListBox for icon themes preference
Using a `GtkListBox` allows us to make more complex widgets when trying
to showcase an icon theme. For example, we can make the example icon a
bit bigger so you don't have to squeeze your eyes to distinsguish them
one from another.

Other possibilities we can do with this widget, is for example making
the folder label clickable to open the file explorer, or add a flat
button at the end with the same purpose. Since it's now just a
`GtkLabel`, we can also make the path selectable (for copy-pasting).
2021-01-22 11:33:31 +00:00
Niels De Graef 93baaa64f2 app: Use GtkListBox for title formats preference
Using a `GtkListBox` in the "Image Window Title & Statusbar formats"
preference pane allows us to make more complex rows, such as adding a
visual example of how the format string behaves on a given image title.

This commit just converts the `GtkTreeView` into a `GtkListBox`, so
nothing has functionally changed (yet), except that rows now give
feedback when the user hovers over them.
2021-01-22 11:33:31 +00:00
Jacob Boerema 6b65998bf7 xcf: fix #6138 Stack Overflow when saving xcf.
Although I haven't been able to reproduce it, it is apparently
possible to get a Stack Overflow when loading xcf files with
presumably very large dimensions on Windows. From what
I'm reading Windows normally has a smaller stack size than
Linux, probably why it hasn't surfaced there.

Instead of allocating on the stack let's do a g_malloc0
combined with g_free.
2021-01-21 11:39:34 -05:00
Jehan fee221167c app, libgimp, pdb: improve gimp_vectors_stroke_get_length() docs.
The `precision` parameter in particular had no min/max, which meant we
could provide a forbidden parameter (e.g. a negative precision) which
would cause a core CRITICAL. We must forbid illegal values from PDB side
(hence outputting a normal plug-in error message, not a core bug).

Also improving a bit the description of this parameter as I was
wondering what precision was needed exactly to get a stroke length. This
is the precision for determining whether a portion of the stroke is
"straight enough" or if we want to break it into smaller pieces until we
get a straight portion.
2021-01-20 20:33:41 +01:00
Jehan e813d90fbb app: allow 0.0 precision for gimp_coords_interpolate_bezier().
All it will mean is that we are looking for perfectly straight lines
when deciding if a bezier curve can be considered straight. It's a fair
condition and represents perfectly what a precision of 0.0 would mean.
2021-01-20 20:14:06 +01:00
Adam Fontenot 00bbeabaf4 Issue #6210: Subpixel font rendering system settings should only…
… apply to GIMP GUI not text layer rendering in image.

Reviewer note: this is the theoretical fix, but it won't work right now
because Cairo explicitly bypasses grayscale antialiasing when system set
subpixel one. Still let's push this first patch, but the issue will be
actually fixed when Cairo will merge my MR too:
https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/114
2021-01-19 13:47:27 +01:00
Thomas Manni 041104b5ec Paint Select tool: enable viewport-based local selection
The tool now takes care of the portion of the layer effectively displayed
on the screen. This allows faster expansion/shrink of the selection since
an area smaller than the whole layer is used.

It will also limit the impact of the incoming multilevels processing, which
tends to decrease the segmentation accuracy on thin structures, since users
often zoom-in to work on such thin details.
2021-01-18 18:43:39 +01:00
Thomas Manni 7d753c6f54 Paint Select tool: apply a threshold on the image mask before triggering...
...the automatic expansion to simplify mask handling in the gegl
paint-select operation.
2021-01-10 15:28:46 +01:00
Thomas Manni 4d0ba4392b Paint Select tool: add a dedicated function to check tool requirements 2021-01-10 13:04:31 +01:00
Niels De Graef c328da6bd3 app: Hide CSD when going fullscreen
By default, GTK keeps on showing client-side decorations when going
fullscreen, as it might contain buttons or other functionality that
would be lost. As such, we have to make sure we hide the titlebar.

Getting to that titlebar to update its "visible" property needs a bit of
effort, since it's an internal child of the GtkWindow that isn't exposed
in any way, so we take a little detour using `gtk_container_forall()`.
2021-01-02 10:27:18 +01:00
Niels De Graef 5a1dd584e9 app: Partially correct gimp_window_get_native_id()
Most important of all, we shouldn't assume that if a given GDK backend
is enabled at compile time, that this is also the one that is being
used. For example, on Linux, both `GDK_WINDOWING_X11` and
`GDK_WINDOWING_WAYLAND` can be set, but you still need to do a runtime
check if you're running under one WM or the the other.

A small cleanup is that we immediately check if a widget is realized by
checking if it's `GdkWindow` is NULL or not and return immediately
(since we need to check its type later on anyway).

Finally, we can remove `GDK_NATIVE_WINDOW_POINTER` as that is a GTK+ 2.0
construct, so it's dead code anyway.
2020-12-30 12:23:22 +01:00
Niels De Graef f1aae9ad6d app: tagpopup: Try to set transient-for property
Setting the `"transient-for`" property for popups is important to
certain window managers (such as Wayland), so that they know what the
parent surface is and can position the popup accordingly.

This fixes the `GimpTagPopup` in wayland giving a critical message, and
getting a random position somewhere on the screen.
2020-12-30 09:15:17 +00:00
Niels De Graef 4d100cc20c app: Use g_object_notify_by_pspec for GimpItem
`g_object_notify()` actually takes a global lock to look up the property
by its name, which means there is a performance hit (albeit tiny) every
time this function is called. For this reason, we should try to use
`g_object_notify_by_pspec()` instead.
2020-12-29 22:37:24 +01:00
Jacob Boerema b3f3120e32 libgimpwidgets, app: silence warnings about State 0 for GimpRuler and GtkScrolledWindow doesn't match state 128 set via gtk_style_context_set_state ()
When run with GIMP_DEBUG=Gtk we get a lot of debug warnings for GimpRuler and once in a while for GtkScrolledWindow that State 0
doesn't match state 128 set via gtk_style_context_set_state (). This happens because we didn't enter the current state flags of
the widget but 0 and apparently Gtk isn't happy about that.

Let's fix this by using the actual state flags by calling gtk_widget_get_state_flags.
2020-12-28 14:05:09 -05:00
Jehan b1abc5b6a6 app: improve Paint Select Tool description.
Based on other tools wording, as well as the algorithm description. In
any case, it looks a bit better than the previous description (with a
typo even).
2020-12-22 23:13:45 +01:00
Érico Rolim dfbf1d5d7b app/widgets/gimpactiongroup: protect against calling gettext with NULL msgid
Use the same conditional that was being used for
g_dpgettext2(entries[i].tooltip) with gettext(entries[i].tooltip).
2020-12-20 22:06:35 -03:00
Érico Rolim aa151a08a0 app/dialogs: protect against calling gettext(NULL).
In gimp_dialog_factory_register_entry(), strings were passed to gettext
without checking for a NULL pointer. The gettext documentation [1]
points out that that's undefined behavior, and musl libc's
implementation of gettext segfaults in that case.

[1] https://www.gnu.org/software/gettext/manual/gettext.html#Interface-to-gettext
2020-12-20 22:06:35 -03:00