Commit Graph

1987 Commits

Author SHA1 Message Date
Jehan 86dfad30dd libgimpwidgets: GimpCellRendererToggle fallback to "image-missing"…
… when appropriate icon failed to be found.

gtk_icon_theme_lookup_icon_for_scale() apparently does all standard
fallbacks, but not the last "image-missing" one which is supposed to
always be present. To avoid crashing, let's add an explicit fallback
ourselves.

We also encountered this on the test-ui unit test because icons are not
installed (but this could happen anyway when running GIMP normally with
third-party icon themes).
2021-12-23 13:39:43 +01:00
Jehan e671e3b268 libgimpwidgets: add gimp_event_triggers_context_menu() to def file. 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 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
Aryeom Han 09654a421f icons: new lock icons.
To better explain the lock icons, have specific icons instead of reusing
other icons. We also tried to programmatically add the simple lock icon
over the other icons, but we only got ugly render. Better have
custom-made icons.

The gimp-lock icon is the Adwaita system-lock-screen icon, by Jakub
Steiner, simply renamed. Therefore its license is GNU LGPL v3 or
Creative Commons Attribution-Share Alike 3.0.
The other icons are derived from a mix of this same icon and other icons
in our existing set and have the same license too.
2021-12-23 12:47:28 +01:00
Aryeom Han 9efe6014e4 icons: new icon gimp-multi-lock. 2021-12-23 12:47:28 +01:00
Yoshinori Yamakawa 2d1c447508 libgimpwidgets: Migration from GetICMProfile() to WcsGetDefaultColorProfile() 2021-12-17 21:58:03 +00:00
Niels De Graef e82f6d5b0f libgimpwidgets: Use Screenshot portal for picking
Freedesktop (XDG) portals are a collection of D-Bus APIs that work
across desktop environments, display servers and work within
containerized applications, like Flatpak. The internal implementation
can then choose to implement these in such a way that takes into account
security considerations, as well as making sure the user consents to
certain actions.

One such portal is the `Screenshot` portal, which contains a
`Screenshot()` method as well as `PickColor()`. We already use the
former for taking a screenshot, and this commit makes sure our color
picker also makes use of the latter.

By doing this, color picking is now possible on the major Wayland
compositors.

(Honestly, we should remove DE-specific backends like that of KWin, to
have less variation on the possible results of a color picking
operation).

Fixes https://gitlab.gnome.org/GNOME/gimp/-/issues/1074
2021-12-14 23:15:49 +01:00
Niels De Graef 06de8abd6e libgimpwidgets: use GtkGestureDrag in ScrolledPreview
This allows us to simplify some of the dragging logic, and makes us a
tiny bit more future-proof for GTK4, which uses a similar construction
with `GtkEventController`s.

While we're at it, stop storing a separate `priv` pointer, which would
allow us to use `G_DECLARE_DERIVABLE_TYPE()` in the future.
2021-12-12 22:27:48 +01:00
Niels De Graef dcd1dd29a8 libgimpcolor: Fix gimp_rgb_list_names() for introspection
This functions has 2 `(out) (array)` arguments, where the array length
is defined by the return value. This can't be expressed in GIR
annotations unfortunately, so just add it as another `(out)` argument.

Also, by default `(out)` args are assumed to be `(transfer full)`, while
these were actually `(transfer container)`.
2021-12-02 12:43:57 +01:00
Luca Bacci 7decb7d3af
GimpFrame: Switch to using the GtkContainer::add signal
The GtkContainer::child signal is deprecated and it's write-only,
thus the notify::child signal won't work.

Use the GtkContainer::add signal instead.

Fixes https://gitlab.gnome.org/GNOME/gimp/-/issues/2928
2021-11-18 11:43:14 +01: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
Ondřej Míchal edc719c004 libgimpwidgets: Stop using deprecated APIs
The minimum required version of GLib is still 2.68.
2021-10-19 20:53:45 +00:00
Jehan e43d6217fa libgimpwidgets: fix warnings on Windows/macOS.
The variables `screen` and `display` are only for the GDK_WINDOWING_X11
code path.

Fixing the following warnings:

libgimpwidgets/gimpwidgetsutils.c: In function 'gimp_monitor_get_color_profile':
libgimpwidgets/gimpwidgetsutils.c:502:21: warning: unused variable 'screen' [-Wunused-variable]
  502 |   GdkScreen        *screen;
      |                     ^~~~~~
libgimpwidgets/gimpwidgetsutils.c:501:21: warning: variable 'display' set but not used [-Wunused-but-set-variable]
  501 |   GdkDisplay       *display;
      |                     ^~~~~~~
2021-10-12 17:05:47 +02:00
Jehan 22f234e5b0 libgimpwidgets: do not free cache before using it for debug output.
Thanks to Massimo for noticing this use-after-free bug.
2021-10-01 12:25:34 +02:00
Jehan dd38b88cc2 libgimpwidgets: free leaked GError.
Thanks to Massimo for reporting.
2021-08-22 12:22:50 +02:00
Stanislav Grinkov 6892326e8e Remove use of custom marshallers in favor of GLib ones 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
Jehan 8ca232252a libgimpwidgets: fix incomplete relocatable build commit.
Commit 8025962a20 was meant to make the icon code work on relocatable
builds, yet I realize that the gdk_pixbuf_new_from_file() calls were
still using the DATAROOTDIR build-time macro. I had forgotten to update
these.

Also update a bit the error handling by adding a GError (for more
debugging info) and a newline for pretty-printing.
2021-07-07 20:20:31 +02:00
Jehan 4a00a993f2 libgimpwidgets: use g_printerr() instead of g_warning() for app icons.
Unit testing consider warnings as criticals and doesn't like when it
cannot find the installed application icons. To fix the `make check`,
just print the missing icon information to stderr, but don't make it a
GLib warning.
2021-07-06 18:51:16 +02:00
Jehan 8025962a20 libgimpwidgets: fix meson/mingw-w64 build and relocatable builds.
While passing the DATADIR macro works fine natively on Linux, it somehow
failed with the mingw-w64 build with a very weird error:

> <command-line>: error: expected identifier or '(' before string constant

I could not understand what it means, as the '-DDATADIR="/some/path"'
syntax is completely fine as far as I can see.
Anyway since I see that DATAROOTDIR is already defined in meson config.h
(but not in the autotools build, just the meson one!), and using
datarootdir instead of datadir seems to be just fine (actually maybe
even more appropriate when it comes to looking up the hicolor
application icons), I just switched to using it.

In the same time, I realized that my code using build-time macros won't
work for relocatable builds anyway. So this commit also adds a bit of
code path variant using gimp_installation_directory() in the case of
ENABLE_RELOCATABLE_RESOURCES code path.
2021-07-06 13:37:33 +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
Marie-P c112a55958 libgimp*, plug-ins: fix some warnings 2021-05-24 20:36:31 +00:00
Povilas Kanapickas 51d1ab9bce libgimpwidgets: Introduce GIMP_ZOOM_PINCH
This zoom mode is handled pretty much the same as GIMP_ZOOM_SMOOTH
except that we do not apply adjustments for the scaling delta. Pinch
zooming is ultimately a different physical activity than smooth
scrolling and users likely expect different sensitivity.
2021-04-22 17:45:32 +00:00
Jehan 22586485aa libgimp, libgimpwidgets: fix def files.
Argh, I always forget. Sorry all Windows devs!
2021-04-20 18:14:42 +02:00
Jehan ca72c41fcd libgimp, libgimpwidgets: support of GimpRGB properties in…
… GimpProcedureDialog.

Technically I added:
- New gimp_prop_color_select_new() property widget to create a
  GimpColorButton for a given GimpRGB property.
- gimp_procedure_dialog_get_widget() now supports a GimpRGB property and
  will create a GimpColorArea by default.
- When the default doesn't suit you, a new function
  gimp_procedure_dialog_get_color_widget() allows to create either a
  GimpColorArea or a GimpColorButton (editable = TRUE), as well as
  choose the area type (small or large checks, as well as flat area,
  i.e. no alpha support).
2021-04-20 16:54:40 +02: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
luz paz 6457394069 Issue #6446: Typo fixes. 2021-02-24 12:33:03 +01:00
Jehan 579cfc064c libgimpwidgets: on HiPPI display, fix stroked eye when parent item…
… is invisible.
The GimpCellRendererToggle inconsistent state was not HiPPI-aware.
2021-02-21 16:52:25 +01:00
Jacob Boerema 1850f69dbf libgimpwidgets: fix Gtk warning about wrong state for GimpChainLine.
When GIMP_DEBUG=Gtk we can get a warning like
State 0 for GimpChainLine doesn't match state 128 set via
gtk_style_context_set_state () when moving the mouse over
a chain like the one in the Scale Image Dialog.

Let's remove this warning by setting the correct flags by
calling gtk_widget_get_state_flags.
2021-01-27 22:47:00 -05:00
Niels De Graef e8b6ba5c10 libgimpwidgets: Set transient_for on scrolledpreview
This makes sure that the navigation popup actually shows up on certain
window managers (like those based on Wayland).
2020-12-30 10:24:48 +01:00
Niels De Graef 434107731a libgimpwidgets: Use g_object_notify_by_pspec for zoommodel
`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:14:19 +01:00
Niels De Graef 76e380244b libgimpwidgets: Use g_object_notify_by_pspec for ruler
`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:14:19 +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
Niels De Graef df28349c17 GIR: Try to return more specific GtkWidget subclass
In GTK, a common scheme is to let a function creating a specific widget
to return a `GtkWidget *`, rather than the specific subtype, since you
often need to call API of GtkWidget, avoiding some useless casts.

For bindings however (and especially bindings to compiled languages),
this is a bit annoying, as you have to explicitly change the type of the
return value (downcast), which is not trivial (or at least desirable) in
each language.

Luckily, we can use `(type ...)` annotation for this use case, leaving
the C API unchanged, while improving the experience for bindings.
2020-12-25 15:05:16 +01:00
Niels De Graef e34c051d78 gimpintcombobox: Add (array length) annotation
So that bindings can properly use the array constructor
2020-12-25 15:04:21 +01:00
Niels De Graef 73252da4f4 GIR: Add some missing (nullable) annotations 2020-12-25 15:02:09 +01:00
Jehan 91728164cd libgimpwidgets: allow prop labels on read-only properties.
When creating a label bound to a property, only make the binding
directional if the property is read-write.
This fixes WARNINGs and broken label in the GimpDeviceInfoEditor widget,
such as this one:
> The source object of type GimpDeviceInfo has no writable property called 'vendor-id'
2020-12-02 00:29:09 +01:00
Jehan b7d55fa066 libgimp, libgimpwidgets: fix gimp_prop_scale_entry_new() for integer…
… properties.
Also a forgotten fix in a call of this function in GimpProcedureDialog.
2020-11-26 00:28:14 +01:00
Jehan 2ea5dec56e libgimpwidgets: improved gimp_prop_scale_entry_new(), new function…
… gimp_label_spin_set_digits() and deleted gimp_prop_opacity_entry_new()

- The "digits" argument for the number of decimal places in
  gimp_prop_scale_entry_new() is now mostly useless since GimpLabelSpin
  (hence GimpScaleEntry too) got a nice estimation algorithm of sensible
  values.
- Add gimp_label_spin_set_digits() function to manually set the digits
  property when we don't like the estimated value.
- Also add a new "factor" argument to gimp_prop_scale_entry_new(). Its
  role is to allow a GimpScaleEntry showing a factored range, typically
  a [0, 100] range for some types of [0, 1] properties.
- Remove gimp_prop_opacity_entry_new() which was basically a
  special-case of gimp_prop_scale_entry_new() and which can now be
  easily reproduced by simply set factor=100.0.
- Update all usage of gimp_prop_scale_entry_new() in app/ and plug-ins/
  with updated arguments. It is interesting to note that all existing
  usage were either integers (digits=1) or when double, the estimated
  decimal places are the same as the ones which were manually set (hence
  showing the generic estimation is not too bad). So the new function
  gimp_label_spin_set_digits() was not even needed once in current code.
2020-11-25 02:32:22 +01:00
Jehan 8d5008d76f libgimp, libgimpbase, libgimpwidgets: new gimp_range_estimate_settings()
Similar code was used in 2 places basically (GimpLabelSpin and
GimpProcedureDialog) so just make it an utils function. It's good anyway
to have a generic function to estimate suitable increments and decimal
places depending on a range.

As a consequence also gimp_label_spin_new() now takes a gint digits
(instead of guint), with -1 meaning we want digits computed from the
range.
Similarly gimp_prop_scale_entry_new() docs adds the -1 meaning too.
2020-11-25 01:34:36 +01:00
Thomas Manni e1cdb9f54e app, icons: add Paint Select tool in the playground
A -quick done- first step towards the addition of a smart selection tool.
Require the gegl:paint-select workshop operation.
Still LOT of work to do (wip):
- fluctuations removal (GEGL side)
- multilevels pyramid approach + banded graphcut for instant result on large
   image (GEGL ? GIMP ?)
- Gaussian Mixtures for color models (GEGL side)
- drawable offsets (GIMP side)
- undo / redo (GIMP side)
- scribbles edition mode (GIMP side)
- dedicated icons
- ...
2020-11-24 12:10:40 +01:00
Jehan f9f516a99a libgimpwidgets: fix missing doc comments and annotations. 2020-11-20 11:36:11 +01:00
Jehan 9f03bdce30 libgimpwidgets: fix the def file. 2020-11-20 10:10:47 +01:00
Jehan bc3602a787 libgimpwidgets: new gimp_label_int_widget_get_widget() function. 2020-11-20 01:47:18 +01:00
Jehan 5fa38d5765 libgimp: bug fixes and design improvements for generated widgets. 2020-11-20 00:06:27 +01:00
luz paz bb322d94d7 Fix typos
Found via:
```
codespell -q 3 -S ./ChangeLog*,*.po,./.git,./NEWS* -L als,ang,ba,chello,daa,doubleclick,foto,hist,iff,inport,klass,mut,nd,ower,paeth,params,pard,pevent,sinc,thru,tim,uint
```
2020-11-19 21:56:25 +01:00
Jehan 74eb2b1f8a libgimp, libgimpwidgets: re-argh - fix the def files too.
Should fix distcheck and Windows builds.
2020-11-14 17:29:50 +01:00
Jehan e16f5bc1a1 libgimpwidgets: argh forgot to edit the autotools Makefile too! 2020-11-14 16:50:13 +01:00
Jehan 7b6f2e5c2b libgimp, libgimpwidgets, plug-ins: improved GimpProcedureDialog API.
- New GimpLabelIntWidget which is a label associated to any widget with
  an integer "value" property.
- New gimp_procedure_dialog_get_int_combo() which creates a labeled
  combo box from an integer property of the GimpProcedureConfig.
- Renamed gimp_procedure_dialog_populate*() with
  gimp_procedure_dialog_fill*(). Naming is hard! I hesitated using
  _pack() as well (similarly to GtkBox API).
- New gimp_procedure_dialog_fill_flowbox*() functions to create a
  GtkFlowBox filled with property widgets (or other container widgets as
  we can pack them one in another). This is an alternative way to build
  your GUI with sane defaults, with list of property names.
2020-11-13 21:27:56 +01:00