Commit Graph

93 Commits

Author SHA1 Message Date
Jehan 1b7f8533ee libgimp, plug-ins: fix a case of not showing dialog.
Fix a generic case when gimp_window_set_transient() is called on an
already mapped window: the handle argument was missing.

The part in bmp-export though, in fact, I am still a bit at a loss.
Somehow calling gimp_window_set_transient() was making the dialog not
showing up at all, yet kinda blocking the bmp plug-in (waiting for a
response to the non-displayed dialog) and various features in the main
GIMP GUI too.
Calling gtk_widget_show() first, before setting transient was enough to
make the dialog finally work as it should, but this is really not ideal.
I compared to other cases in other plug-ins where the set_transient()
function was called before the dialog was shown and it is working fine.
I just cannot find the proper reason. So this will do for now.
2024-09-23 18:20:46 +02:00
Jehan f4fb6db331 libgimp: new gimp_window_set_transient_for() function.
This allows to easily set a window transient to any other, even from one
plug-in to another.
2024-09-01 00:12:27 +02:00
bootchk fc310e0bed libgimpui: annotation of gimp_ui_init say it can be called often. 2024-03-20 11:35:48 +00:00
Jehan bdcd9cd38a libgimp, plug-ins: let's just call gegl_init() in gimp_ui_init().
bootchk had the case in commit 6781a35668. I again had it with gfig. I think it
just makes sense to init GEGL, especially as the errors are not that explicit
and that the plug-in code may not even call GEGL code directly (so it makes it
harder to guess).
2023-10-05 22:36:40 +02:00
Jehan 4be1166982 app, libgimp: disable again cross-process transient setting.
After testing, setting a window as transient to another from another process is
still broken on Windows and it's hard to diagnose without using Windows
directly. Since it's not just broken, but it even hangs the whole process, which
is quite a blocker issue, let's disable again the whole code on Windows.
2023-10-01 21:02:34 +02:00
Jehan 9a57ab54e9 app, libgimp*: window handle on Windows have the type HANDLE.
Instead of passing a guint32, pass the proper type, since our the HANDLE type
can be 64-bit on Windows (according to links I found).
I was hoping it might be the reason for the breakage under Windows, though I
also found Microsoft documentation saying that the 64-bit handle can be safely
truncated: https://learn.microsoft.com/en-us/windows/win32/winprog64/interprocess-communication?redirectedfrom=MSDN

Nevertheless I'd appreciate testing again from NikcDC or anyone else, as I
reactivated setting transient between processes on Windows.

Note that I also pass the proper types on X11 now (Window), even though guint32
worked fine. Better be thorough.
2023-10-01 21:02:33 +02:00
Jehan 58b3b14082 app, libgimp*, pdb, plug-ins: reimplement generic inter-process transient window.
Having windows ID as guint32 is a mistake. Different systems have
different protocols. In Wayland in particular, Windows handles are
exchanged as strings. What this commit does is the following:

In core:

- get_window_id() virtual function in core GimpProgress is changed to
  return a GBytes, as a generic "data" to represent a window differently
  on different systems.
- All implementations of get_window_id() in various classes implementing
  this interface are updated accordingly:
  * GimpSubProgress
  * GimpDisplay returns the handle of its shell.
  * GimpDisplayShell now creates its window handle at construction with
    libgimpwidget's gimp_widget_set_native_handle() and simply return
    this handle every time it's requested.
  * GimpFileDialog also creates its window handle at construction with
    gimp_widget_set_native_handle().
- gimp_window_set_transient_for() in core is changed to take a
  GimpProgress as argument (instead of a guint32 ID), requests and
  process the ID itself, according to the running platform. In
  particular, the following were improved:
  * Unlike old code, it will work even if the window is not visible yet.
    In such a case, the function simply adds a signal handler to set
    transient at mapping. It makes it easier to use it at construction
    in a reliable way.
  * It now works for Wayland too, additionally to X11.
- GimpPdbProgress now exchanges a GBytes too with the command
  GIMP_PROGRESS_COMMAND_GET_WINDOW.
- display_get_window_id() in gimp-gui.h also returns a GBytes now.

PDB/libgimp:

- gimp_display_get_window_handle() and gimp_progress_get_window_handle()
  now return a GBytes to represent a window handle in an opaque way
  (depending on the running platform).

In libgimp:

- GimpProgress's get_window() virtual function changed to return a
  GBytes and renamed get_window_handle().
- In particular GimpProgressBar is the only implementation of
  get_window_handle(). It creates its handle at object construction with
  libgimpwidget's gimp_widget_set_native_handle() and the virtual
  method's implementation simply returns the GBytes.

In libgimpUi:

- gimp_ui_get_display_window() and gimp_ui_get_progress_window() were
  removed. We should not assume anymore that it is possible to create a
  GdkWindow to be used. For instance this is not possible with Wayland
  which has its own way to set a window transient with a string handle.
- gimp_window_set_transient_for_display() and
  gimp_window_set_transient() now use an internal implementation similar
  to core gimp_window_set_transient_for(), with the same improvements
  (works even at construction when the window is not visible yet + works
  for Wayland too).

In libgimpwidgets:

- New gimp_widget_set_native_handle() is a helper function used both in
  core and libgimp* libraries for widgets which we want to be usable as
  possible parents. It takes care of getting the relevant window handle
  (depending on the running platform) and stores it in a given pointer,
  either immediately or after a callback once the widget is mapped. So
  it can be used at construction. Also it sets a handle for X11 or
  Wayland.

In plug-ins:

- Screenshot uses the new gimp_progress_get_window_handle() directly now
  in its X11 code path and creates out of it a GdkWindows itself with
  gdk_x11_window_foreign_new_for_display().

Our inter-process transient implementation only worked for X11, and with
this commit, it works for Wayland too.

There is code for Windows but it is currently disabled as it apparently
hangs (there is a comment in-code which links to this old report:
https://bugzilla.gnome.org/show_bug.cgi?id=359538). NikcDC tested
yesterday with re-enabling the code and said they experienced a freeze.
;-(

Finally there is no infrastructure yet to make this work on macOS and
apparently there is no implementation of window handle in GDK for macOS
that I could find. I'm not sure if macOS doesn't have this concept of
setting transient on another processus's window or GDK is simply lacking
the implementation.
2023-10-01 21:02:33 +02:00
Simon Budig 6e1747953a libgimp: fix a warning by using an enum of the correct type. 2023-05-20 22:16:06 +02: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 33520a547d app, libgimp: protect a bit GDK X Window calls.
The GDK_WINDOWING_X11 build-time macro check is not enough as GDK can be
built with both X11 and Wayland backends. We need to add a runtime check
of the type of display.
2020-06-21 12:54:13 +02:00
Oleksii Samorukov 3e78c674d8 Return FALSE on gimp_osx_focus_window to avoid endless loop 2020-01-15 17:40:23 +01:00
Jehan cf6dae6f83 libgimp: fix a type cast warning (win32).
I had this warning when cross-building for Windows 64-bit:

> libgimp/gimpui.c:187:52: warning: passing argument 2 of
> 'gdk_win32_window_foreign_new_for_display' makes pointer from integer
> without a cast [-Wint-conversion]

> note: expected 'HWND' {aka 'struct HWND__ *'} but argument is of type 'guint32' {aka 'unsigned int'}
2019-10-10 14:13:49 +02:00
Jehan f59b0db0c8 app, libgimp: fix more unused function warning (Win32).
Similar to commit 9b328167ab. Apparently the same function is duplicated
into app/.
Also add some comments to detail a bit more where this Win32 different
comes from (i.e. bug 359538 on Bugzilla, commit eac61e1e12).

Moreover I tested the same steps as comment 4 in bug 359538 on master
code. The same hanging issue still exists with GTK+ 3.24.1 (in a Windows
VM at least). I have not investigated further, just wanted to check if
this ifndef could not simply be removed by now. Apparently not.
2019-10-10 14:11:40 +02:00
Jehan 9b328167ab libgimp: fix unused function (Win32).
Fixes:
> libgimp/gimpui.c:402:1: warning: 'gimp_window_transient_realized' defined but not used [-Wunused-function]
2019-10-09 16:34:51 +02:00
Michael Natterer df8d5b02ae libgimp, plug-ins: remove the "preview" parameter from gimp_ui_init()
It's dead since a looong time.
2019-09-20 19:56:00 +02:00
Michael Natterer 96c1f754ba libgimp: remove a ton of deprecated API that is unused 2019-08-27 16:32:25 +02:00
Jehan d15388c8c9 libgimp: s/gimp_display_new_by_id/gimp_display_get_by_id/
GimpDisplay objects now also belongs to libgimp!
2019-08-22 15:54:36 +02:00
Jehan 5e6d4d8fbd libgimp: fix the non-generated API with the new class types. 2019-08-22 15:54:36 +02:00
Niels De Graef 5f92ced1f3 Add (nullable) if applicable
Basically this commit makes sure that all return values that are marked
as "Returns:" also have a `(nullable)` annotation if it is mentioned on
the same line that NULL can also be returned.

This will prevent a few problems in GObject-introspection.
2019-08-03 07:53:47 +00:00
Niels De Graef 1dda60154c Use "Returns:" to annotate return values
To be able to annotate return values through GObject-introspection, you
need to make sure it is tagged with `Returns:` and not something else.
2019-08-03 07:53:47 +00:00
Jehan 6fe2508301 libgimp*: fix various missing (transfer) annotations. 2019-08-01 01:52:07 +02:00
Michael Natterer aca5f806c4 libgimp*: lots of doc fixes and new docs for structs and enums 2019-07-24 01:18:30 +02:00
Ell 8c96c3d1bb app, libgimp: communicate dark-theme preference to plug-ins through theme.css
The GUI implementation of gimp_wait() relies on the ability to run
plug-ins (namely, the busy-dialog plug-in) without entering the
main loop.  This prohibits the said plug-ins from making any PDB
calls, which would result in a deadlock.  However, we're currently
calling gimp_gimprc_query() to fetch the prefer-dark-theme option
during gimp_ui_init() (or any time the theme.css file changes).

Instead, communicate this preference through the theme.css file
itself, by writing a /* prefer-dark-theme */ comment to the file
when the option is set.  Yes, it's a bit of a hack :P
2019-02-20 14:40:11 -05:00
Michael Natterer b505f3a5c0 libgimp: make sure plug-ins follow the core's theme
Add a GFileMonitor on "theme.css" and reload the theme when it
changes, also update "gtk-application-prefer-dark-theme" in the same
callback.
2019-01-04 16:39:39 +01:00
Oleksii Samorukov ac26671eb6 Fix plugin focus issues on osx
GTK/OSX does not automatically assign focus to the new windows (upstream
issue), so activateIgnoringOtherApps is called. However, if it is called
before gtk initialized it may cause number of focus issues.

(cherry picked from commit 3adf4a4861)
2018-10-18 14:07:03 +02:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Michael Natterer b36205176e app, libgimp*: remove the config option to disable tooltips
Also remove all traces of it from the plug-in protocol and raise the
protocol version to 0x0100 (we now allow features and therefore
version bumps in stable, and the master protocol version should always
be higher). Fix the code that aborts plug-in startup on protocol
version mismatch, we can't use gimp_message() because we have no
protocol.
2018-06-06 19:23:30 +02:00
Ell 97925de8eb libgimpbase, libgimp, app: pass icon theme dir to plug-ins through config
Pass the current icon theme directory to plug-ins through the
config message, and add a gimp_icon_theme_dir() libgimp function
for retrieving it.  Note that we already have a similar
gimp_icon_get_theme_dir() PDB function, which we keep around, since
it can be used to dynamically query for the current icon dir,
unlike the former, and since it returns a dynamically-allocated
string, while the rest of the config-related functions return
statically allocated strings.

Use the new function, instead of gimp_get_icon_theme_dir(), in
gimp_ui_init().  This allows gimp_ui_init() to run without making
any PDB calls.  Consequently, this allows us to start plug-ins that
call gimp_ui_init() without entering the main loop in the main app.
We're going to add a plug-in that displays an interactive dialog
while the main app is blocking waiting for an operation to
complete, and we need to be able to start the plug-in without
entering the main loop, to avoid the possibility of arbitrary code
being executed during the wait.

Bump the protocol version.
2018-05-29 16:04:28 -04:00
Michael Natterer 0dd8459a1f libgimp: deprecate more cruft, everything not needed by cruft plug-ins 2018-05-20 21:06:29 +02:00
Michael Natterer af1bb43f37 Port theme and gtkrc file loading to CSS files using GtkCssProvider 2018-05-20 21:06:28 +02:00
Michael Natterer 21e51d2c0f port gtkrc files to CSS (incompletely and stuff commented out) 2018-05-20 21:06:28 +02:00
Michael Natterer e6c055a131 libgimp: remove GdkRGB and GdkColorMap calls, these APIs are gone 2018-05-20 21:06:26 +02:00
Jehan c0eb7858a5 Bug 795057 - Insensitive text in plug-ins is unreadable with dark themes
Don't fix too early! In some cases, PixbufStyle class is not found and
the fix failed.
2018-04-21 12:10:49 +02:00
Michael Natterer 53fae39aee Bug 795057 - Insensitive text in plug-ins is unreadable with dark themes
Copy the fix from app/gui/themes.c to libgimp/gimpui.c so insensitive
labels look right in plug-ins too.
2018-04-08 22:55:19 +02:00
Michael Natterer 2334cb41a7 Bug 760579 - Plug-in dialogs fail to use UI themes
Something must have changed in GTK+, probably a long time ago, because
this code definitely used to work in the past.

Anyway, change gimp_ui_init() in libgimpui to use gtk_rc_parse()
instead of gtk_rc_add_default_file() which fixes the plug-in's initial
theme, and install a GFileMonitor on themerc which calls
gtk_rc_reparse_all() when themerc changes.
2016-01-16 19:36:13 +01:00
Michael Natterer 71894bd787 libgimpwidgets: rename gimpstock.[ch] to gimpicons.[ch]
because stock is on its way out, so we better start renaming and
deprecating stuff sooner than later.
2015-12-12 20:44:46 +01:00
Michael Natterer 69f87bcc84 libgimpwidgets: be smarter when changing icon themes, and have fallbacks
Add gimp_stock_set_icon_theme() which can be called at any time, also
before gimp_stock_init(), in which case we avoid setting the configured
icon theme twice on startup. Call it from libgimp/gimpui.c and
from app/gui/icon-themes.c so the app and plug-ins use the same
icon theme.
2015-12-12 19:32:11 +01:00
Michael Natterer 8005eea835 Remove the "GIMP" from all "Since: GIMP 2.x" API doc comments
because it confuses gtk-doc and breaks some links. Also change the
"Index of new symbols in GIMP 2.x" sections to be what seems to be the
modern standard (looked at the GLib and GTK+ docs), and update some
other stuff.
2015-05-31 21:18:09 +02:00
Michael Natterer ab801970ca Bug 677776 - filter popup windows get hidden behind main image window
Simone found a better way than setting plug-in windows to UTILITY: simply
call the proper API, [NSApp arrangeInFront: nil].
2012-11-12 23:42:15 +01:00
Michael Natterer 018fc32727 Bug 677776 - filter popup windows get hidden behind main image window
On OSX, set all transient plug-in windows to UTILITY, so they appear
on top of the image window, which is a bad hack. See the comment in
gimp_window_set_transient_for_display().
2012-11-11 21:19:17 +01:00
Michael Natterer 9e5ed1e70a Bug 684003 - When using the main window in secondary monitor...
If gimp_window_set_transient_for() fails (due to platform
restrictions), at least set GTK_WIN_POS_CENTER on the window, so it
gets centered on the monitor where the mouse is. This also removes the
need for OSX specific centering code in GimpDialog (bug 677776).
2012-11-11 21:09:46 +01:00
Michael Natterer 0b56aa0d13 Bug 677776 - filter popup windows get hidden behind main image window
On OSX, call [NSApp activateIgnoringOtherApps] when a plug-in dialog
is shown, so the plug-in process becomes the active app, and the
dialog gets focussed.

In order to avoid doing this in GimpDialog (which is also used in
the core), do it in gimp_ui_init() which all interactive plug-ins
call, and when gimp_temp_proc_run() is called interactively, to
catch repeated activation of an already running plug-in.

Also, set GimpDialog's initial position to GTK_WIN_POS_CENTER,
or they will pop up in the top left corner.

Inspired by patches from Simone Karin Lehmann and Daniel Sabo.
2012-11-07 23:44:35 +01:00
Michael Natterer 0d481702c7 libgimp*: add GIMP_DEPRECATED macros using G_DEPRECATED
and start using them instead of GIMP_DISABLE_DEPRECATED where possible.
2012-05-03 00:54:21 +02:00
Michael Natterer 24ee3370b8 Depend on GTK+ >= 2.24.3, cairo >= 1.20.1, gdk-pixbuf >= 2.22.1
and completely separate configure and sanity checks for gdk-pixbuf
from GTK+, because it's now distributed as a separate package. Remove
all sorts of conditional compiling based on GDK_CHECK_VERSION() and
CAIRO_VERSION.
2011-04-06 19:58:24 +02:00
Michael Natterer 8333dfde7b Add some #if GTK_CHECK_VERSION (2, 24, 0) for creating foreign window
so we don't use deprecated API and make the gtk3 port simpler.
2011-02-16 22:51:02 +01:00
Sven Neumann 71ead96472 libgimp: deprecate gimp_min_colors() and gimp_install_cmap()
Also remove calls to gdk_rgb_set_min_colors() and gdk_rgb_set_install()
from gimp_ui_init(). These are considered obsolete nowadays.
2010-10-19 09:59:59 +02:00
Michael Natterer c78e4c8d63 libgimp: move docs from template files to inline comments
Also split up the "tools" docs into separate files so it matches
the new autogenerated PDB section headers.
2010-07-07 11:48:10 +02:00
Michael Natterer a2c70822d4 Use accessors from GTK+ 2.20 instead of using sealed members directly 2010-04-19 19:21:07 +02:00
Michael Natterer 1aeb315ecf undef GTK_DISABLE_DEPRECATED in many places which undef GSEAL_ENABLE
because the widget flag access macros (e.g. GTK_WIDGET_REALIZED) are
now deprecated in GTK+ master.
2010-03-06 23:14:29 +01:00
Michael Natterer 8cee9c66a7 Build with GSEAL_ENABLE and #undef it where accessors are missing 2009-10-17 18:55:14 +02:00