Commit Graph

23927 Commits

Author SHA1 Message Date
Jehan 6c6cd2df24 app: make sure va_start() is matched by va_end().
xcf_save_prop() starts with va_start(), hence must end with va_end(). Yet any of
the xcf_write*_check_error() macros could end this function abruptly. Therefore
I'm adding a "cleanup" argument to the macros, allowing to add any code
necessary to clean the current function before returning.
2023-05-11 15:18:33 +02:00
Jehan d1118a5e15 app: missing break statement. 2023-05-11 14:19:37 +02:00
Jehan e22c027bbf app: keep the GtkStyleProvider alive.
While GTK keeps a reference to it, we should simply not release our own
reference at init(). This was a case where we freed this twice.
2023-05-11 12:46:57 +02:00
Jehan f9993b85b6 app: use G_DECLARE_INTERFACE() to declare GimpAction interface.
Less boiler plate code so less reasons to mess up.
For this to be feasible, I also had to define a cleanup function for
GimpObject.
2023-05-11 12:46:57 +02:00
Jehan bb4438789a app: fix some s/G_TYPE_FROM_CLASS/G_TYPE_FROM_INTERFACE/ calls. 2023-05-11 12:46:57 +02:00
Alx Sa bca4535c40 icons: Restore GIMP icons replaced by GTK defaults
Five icons in the Layer dockable were being replaced by GTK defaults at
runtime. A "gimp-" prefix was added so that GIMP's version would always
be used. A few dialogues were fixed to use constants rather than
hardcoding the filename, to make it easier to update the icon in the
future.
2023-04-30 13:58:39 +00:00
Shubham de5c805cbb app: Modify stroke selection dialog
Changed stroke selection dialog to use GtkStackSwitcher instead of radio
buttons. Make options hidden under "Advanced options" visible by
default.
2023-04-25 12:59:35 +00:00
Alx Sa 7e371c7884 libgimpbase: Add Middle Gray fill option
Uses CIELAB's 50% lightness (18.42% luminance) for the Middle Gray
color.
2023-04-24 10:25:58 +00:00
Alx Sa 769e36d7cf core: color pick in image's RGB space
Replaces GimpPickableInterface's pixel_to_srgb () functions with
pixel_to_rgb(). Now GimpRGB's values should be in the correct
image color space from the beginning of the process.
2023-04-23 22:03:29 +00:00
Jehan 0d95b960c5 app: replace deprecated GLib function.
This fixes:

> app/core/gimpitemlist.c:632:7: warning: ‘g_pattern_match_string’ is deprecated: Use 'g_pattern_spec_match_string' instead [-Wdeprecated-declarations]

The new function appeared in GLib 2.70 which is our current minimum GLib
requirement, so the replacement is fine.
2023-04-21 01:09:35 +02:00
Idriss Fekir 99644ff5c9 Issue 7826: "select all" should not be reapplied
To check if "all" is selected call a function added to to channel interface
"is_full".
2023-04-20 21:49:03 +00:00
Jehan 466349762d app: fix broken preset menus in tool options (tool-options-menu.ui).
Generated actions are not necessarily application-wide actions ("app." prefix of
detailed action name). As is the case here, they can be actions specific to a
group only.
2023-04-20 16:56:49 +02:00
Jehan 4b36bff01a app: get rid of unused variable warning.
Warning was:

> gimpsourcetool.c:232:22: warning: unused variable ‘paint_tool’
2023-04-20 15:38:17 +02:00
Jehan c6906e77da app: get rid of dummy "*-menu" and "*-popup" actions.
With our old code, we needed dummy actions for every submenu. This is not needed
anymore. Actions are only for end menu items (items which actually do something,
not just open a submenu).
Get rid of them all, as well as the code to ignore any action ending with such
suffixes in action-listing pieces of code.
2023-04-20 15:36:11 +02:00
Jehan 8a8914bc21 app: a bit of code cleanup.
Especially some remnants of when Gimp(Toggle|Radio)Action were not descendants
of GimpActionImpl and had to reimplement GimpAction interface.

Also fixing a few details here and there.
2023-04-20 15:36:11 +02:00
Jehan e3bb3bf57f app: fix address sanitizer error.
The error is:

> app/widgets/gimpdeviceinfo.c:387:13: runtime error: null pointer passed as argument 1, which is declared to never be nul
2023-04-20 15:36:11 +02:00
Jehan 86693d1839 app: free GimpActionGroup's action list in dispose().
This helps make sure we break circular references as soon as possible when
destroying an action group. I also steal the pointer before freeing objects to
make sure the list is empty immediately and any further signal from the actions
won't affect this group.
2023-04-20 15:36:11 +02:00
Jehan d5aa4f73ac app: add a "color" property to GimpMenuModel.
Note that it will only work for a model attached to a GimpMenu. In particular,
it won't work for the menu bar set to a GtkApplication with gtk_application_set_menubar().

In other words, it won't work on macOS where we let the OS handle the menu.
2023-04-20 15:36:11 +02:00
Jehan 564103fdc1 app: allow changing submenu's labels with gimp_menu_model_set_title().
Use this for the "View > Zoom" and "View > Flip & Rotate" submenus which used to
display the zoom level and rotation angle. This regression is now fixed.
2023-04-19 15:21:48 +02:00
Jehan b0916fe701 Issue #9362: ordered argument format in printf requires no argument "holes".
Though it actually worked in some cases, and failed in others (I have not
figured out which build option exactly makes the format with hole work anyway),
printf manual actually explicitly says:

> There may be no gaps in the numbers of arguments specified using '$'; for
> example, if arguments 1 and 3 are specified, argument 2 must also be specified
> somewhere in the format string.

This explained while it was crashing GIMP (again, only with some build options,
or lack of build options):

> *** invalid %N$ use detected ***

There were 2 possible solutions for this: either ensure that the order number is
always used, but that defeats the purpose of plural localization. Instead I
reorder the argument so that the file name (which must always be shown for sure)
is first in arguments. This way, even if the order number is sometimes omitted
(be it in English or in any language), we avoid the crash.
2023-04-19 14:30:11 +02:00
Alx Sa e3074df900 tools: Correct Fixed Size toggle behavior
gimp_rectangle_options_fixed_rule_changed is called when either the
checkbox or the dropdown for Fixed Size is changed.
However, the "fixed-size-active" property was not updated until after
it ran, so the toggle behavior is inverted.
This checks to see if the toggle was changed and updates the boolean 
before setting the size field as (in)sensitive.
2023-04-18 01:37:25 +00:00
Jehan 24048ef862 app: add some longer label variant for dialog actions.
Just "Layers" or "Patterns" was always very confusing. It was even worse when
both tools and dialogs had nearly6 the same name (for instance "Gradient" was
the tool action, but "Gradients" was the dialog).

Now these dialog actions will be labelled more obviously in the action search,
such as "Layers Dialog" or "Gradients Dialog".

Of course, the short name will stay in contextualized menus, such as in the
"Windows > Dockable Dialogs" top submenu, or in the Dockbooks' "Add Tab"
submenu.
2023-04-14 19:27:24 +02:00
Jehan 2511c70e8d Issue #9349: long label variant for tool actions.
While the short label can be "Gradient" for instance, because it is in the
submenu "Tools > Paint Tools", this is a confusing label say in the action
search.

Now the longer label will be used in there and will say:

> Activate tool "Gradient"
2023-04-14 19:15:16 +02:00
Jehan ea1205f094 Issue #9349: removing 2 duplicate "*-short" actions.
"edit-paste-as-new-image-short" and "vectors-selection-to-vectors-short" were
just duplicate of the action named the same, except for the "-short" suffix, and
the only point was to have different labels.

Not though that this time, it was not enough to conclude that the action in a
menu shoud have the short variant. These were both used differently depending on
the menu.
Instead I added the concept of "label-variant" attribute in .ui menu files. When
the "long" variant is set, then we simply use the longer label.

There is still one more "-short" action: "tools-by-color-select-short", but I am
a still unsure how to handle this one.
2023-04-14 18:54:16 +02:00
Jehan 89772351c9 Issue #9349: Add concept of "short" (contextual) vs "long" label for actions.
All Gimp*ActionEntry (except GimpProcedureActionEntry) now have a short_label
member.
This commit doesn't add any new short label yet. It just fixes the struct usage,
and fixes a few localization contexts here and there when I saw such broken
strings.

I also fixed a few gradient editor action strings which were not proper labels
(like "splitmidpoint" or "splituniform", or missing uppercase, etc.).
2023-04-14 17:48:57 +02:00
Jehan 4aa141603b app: remove unused finalize().
Get rid of an unused variable warning, though the whole function was useless
anyway.
2023-04-14 16:50:18 +02:00
Jehan 6e980dbe36 app: fix weird broken indentation.
Apparently my vim indentation rules got confused by a comment.
2023-04-14 16:35:50 +02:00
Jehan 1b932d10d3 Issue #9349: short and long labels for "windows-display-*" actions.
The short labels are just the file names as we have all the context in the menu
to understand what these actions do (in Windows menu, ordered by view position
and with a `Ctrl+n` shortcut next to each, increasing by position).

In the action search for instance, we keep a 'Show "<image name>"' label.

Also I'm adding a relevant tooltip to further explain what each of these actions
do, using the view position.
2023-04-14 16:33:35 +02:00
Jehan 341fd90958 Issue #9349: add concept of "short" (contextual) vs "long" label for actions.
Basically actions in menus should show the short label (we assume the menu
position brings contextuality) when available, whereas it will use the longer
label in GUI lacking contextuality.

As a first such usage, the `file-open-recent-*` actions have the file name which
will be opened as short label. This is used in menus since the submenu `File >
Open Recent` ensures that the action which will run is perfectly understandable.
On the other hand, in the action search, the action is named 'Open "<file
name>"' since an action named only with a file name would not be understandable.
2023-04-14 00:17:15 +02:00
Jehan 747cbf70db app: add a "Filters > Generic > GEGL Operations" submenu with generated actions.
Since we now generate actions for GEGL ops, we might as well generate menu items
for these too.

What I did:

- Move the "GEGL Operation…" tool (generic dialog with a drop-down list of all
  non-ignored GEGL ops) to Tools menu.
- Create a "GEGL Operations" submenu in Filters > Generic.
- Move "GEGL Graph" to the top of this new submenu.
- Generate a new menu item for each generated action tied to a GEGL plug-in,
  alphabetically sorted.
2023-04-13 23:06:54 +02:00
Jehan d51c64ec06 Issue #9228: make GEGL Operation tool's operations their own actions too.
Though the GEGL Operation tool is still useful as a generic dialog, let's
generate also per-operation (the ones not ignored and not already special-cased
in the rest of the GUI) tools and actions.

These "tools" are mostly hidden (e.g. not selectable in toolbox where it would
be a bit useless as they would show with the generic GEGL icon or none), but
they can be searched with the action search, shortcuts can be assigned and they
can be added to menus.
2023-04-13 21:28:52 +02:00
Jehan c7c5f126b1 app: disable some unit tests temporarily.
Since the recent changes, these 3 tests are not working:
- tools
- session-2-8-compatibility-multi-window
- session-2-8-compatibility-single-window

(the 2 latters were only working with xvfb anyway)

I could just dig further as I did a bit these last few days, and tweak more and
more the testing code. But I think our current unit-testing framework is just
non-reliable and for all these years, we have spent more time fixing the tests
than actually relying on them to tell us there is a bug in GIMP.
Furthermore creating new tests is so cumbersome that basically none do it.

I have a plan laid out in #9339 for a much better and more reliable unit testing
infrastructure, based on the GIMP executable itself and a very simple syntax to
create new test scenari (so that even non-developers should be able to create
them eventually). So until then, let's disable these tests and stop wasting
time.
2023-04-12 22:07:09 +02:00
Jehan aa8ccf3ba8 Issue #6612: support numpad's divide ('/') as secondary action search shortcut. 2023-04-12 22:07:09 +02:00
Jehan af5612eda2 Issue #3834: keys Copy, Cut and Paste now supported as secondary shortcuts. 2023-04-12 22:07:09 +02:00
Jehan ab33d032ad app: support Forward and Back keys.
Same as ZoomIn/Out keys, these are implemented as secondary shortcuts to actions
"windows-show-display-next" and "windows-show-display-previous" respectively.

See issue #637.
2023-04-12 22:07:09 +02:00
Jehan 9e8304aeb9 Issue #637: support ZoomIn and ZoomOut special keys.
These will simply be recorded as secondary shortcuts for view-zoom-in and
view-zoom-out.
2023-04-12 22:07:09 +02:00
Jehan 71c8ff1f21 app: change all action entry structs to allow several shortcuts.
- The `accelerator` variable is a NULL-terminated array, allowing up to 3
  accelerators per action (so far, none has more than 2).
- Only the struct GimpProcedureActionEntry still has a single accelerator as I
  don't think it makes sense that we change the plug-in API to allow a plug-in
  to register more than 1 shortcut for a procedure (e.g. we don't want a plug-in
  to just register all possible keys for their procedure!).
  Of course, users will still be allowed to register more shortcuts for plug-in
  actions through the shortcut dialog. It's only the initialization which
  1-shortcut max for procedure actions.
- Remove all actions ending up in "-accel" as these were only a trick to
  register more shortcut for a same action. Now we just have the real
  possibility (rather than creating bogus duplicate actions). As a consequence,
  these actions accelerators have been moved as secondary accelerator to their
  main action.
  The deleted actions are: "view-zoom-out-accel", "view-zoom-in-accel",
  "view-zoom-16-1-accel", "view-zoom-4-1-accel", "view-zoom-2-1-accel" and
  "view-zoom-1-1-accel".
2023-04-12 22:07:09 +02:00
Jehan d6a86b1ab7 app: fix "Remove all Keyboard Shortcuts" and "Reset Keyboard Shortcuts to…
… Default Values" buttons in Preferences.

I considered just deleting the "Remove all shortcuts" action, because really I
am wondering how useful (and often used) it is, and if we are not over-featuring
the shortcut code.
I could find the origin commit 6da388be93, from 2006. Basically the use case is
for people who want such a different mapping overall that it's much better to
start from a blank slate (e.g. DVORAK users, like in the original report).
See: https://bugzilla.gnome.org/show_bug.cgi?id=331839

So in the end, I just reimplemented this with newer code.

Also this commit fixes the "Reset Keyboard Shortcuts to Default Values" code.
2023-04-12 22:07:09 +02:00
Jehan beb093f549 app: remove the "Save" button from the "Configure Keyboard Shortcuts" dialog.
This was always confusing to people that they had to click "Save" then "Close".
With new code anyway, any change is instantly put into effect, and the only
point of "Save" is to actually store immediately in the shortcutsrc file. But
this is clearly not very clear to people (and it can be done in the Preferences
dialog too).

Instead let's just have a "OK" button. The file will be actually updated on exit
only (if "Save keyboard shortcuts on exit" is checked). And that's it.

The only missing feature would be the ability to cancel the latest changes
before hitting OK, i.e. having a "Cancel" button too. Let's see to do this
later.
2023-04-12 22:07:09 +02:00
Jehan 817ee1c660 app, docs, etc.: transform menurc in shortcutsrc after an update.
Also get rid of various old references to menurc and don't install it anymore to
etc/ (neither the new shortcutsrc as it doesn't look like it brings much value
to do so).
2023-04-12 22:07:09 +02:00
Jehan 42bc6ba1c0 app: fix ignoring paths with parentheses.
I had the case of a path with parentheses in the folder name. Just don't assume
any character should not be in a path.
2023-04-12 22:07:09 +02:00
Jehan 73f607fd73 app: the menu "paths" must be based on the English original whereas…
… the actual labels can be localized.

This fixes menu creation when GIMP is localized.
2023-04-12 22:07:09 +02:00
Jehan df0bd8c183 app: cleanly delete the UI manager and action groups associated to finalized…
… dock windows.

This fixes crashes which happen when switching from multi-window mode to single
window mode.
2023-04-12 22:07:09 +02:00
Jehan 2967020d16 app: verify shortcutsrc exists before parsing it. 2023-04-12 22:07:09 +02:00
Jehan 7d1155af4a Issue #5601: Command Search (/) Results to show Menu Path. 2023-04-12 22:07:09 +02:00
Jehan 32f93c49de app: handle duplicate accelerators in shortcutsrc parsing. 2023-04-12 22:07:09 +02:00
Jehan 8383928790 app: comment-out actions using default shortcuts in shortcutsrc.
This uses a new concept of "default shortcuts" which must be called only once at
most per action. Any subsequent shortcuts setting are custom settings.

Commenting these lines out is mostly informational as it allows to see in a
quick glimpse in shortcutsrc file which are custom shortcuts or not.
2023-04-12 22:07:09 +02:00
Jehan 94ebb4f821 app: serialize and deserialize the actions' accelerators.
gtk_accel_map_load()/gtk_accel_map_save() are not working with the new
GAction-based code. GtkApplication does not seem to have helper functions to
simply load and save accelerators in a file, so we just implement it ourselves.

A few things are missing right now, namely:

- On parsing, it doesn't handle any kind of duplicate accelerators (possible
  especially if someone edited the new shortcutsrc manually).
- On reading, maybe we should only write down the changed (from defaults)
  actions, while keeping the old ones commented-out, as menurc used to be. This
  is actually useful info both for debugging or even for users who want to look
  at this file and see what they changed.
- We should add import code to transform the menurc into shortcutsrc when
  updating GIMP, otherwise all custom shortcuts would get lost.

There is still the question on whether we should add the group name too. I think
we should, expecially for plug-in's procedure actions, though right now these
are just added in the GtkApplication's main action group anyway. I'll see later
to refine this.
2023-04-12 22:07:09 +02:00
Jehan 0278480f87 app: new gimp_action_set_group() and gimp_action_get_group().
Now that we don't have any action duplicated in groups based on names (i.e. that
there could just be 2 actions with the same name in different groups), let's
have the GimpAction also store its group.

Use this to fix some code which was now crashing when confirming erasing an
existing shortcut.
2023-04-12 22:07:09 +02:00
Jehan d4fb4362c9 app: fix unit tests with GUI.
Run them with the new GApplication logic, otherwise the various new
parts (such as actions) are not properly loaded.
2023-04-12 22:07:09 +02:00