probonopd / go-appimage

Go implementation of AppImage tools
MIT License
691 stars 70 forks source link

Make GTK input methods work #295

Closed pbs3141 closed 2 weeks ago

pbs3141 commented 2 weeks ago

This attempts to get input methods working for packaged apps using GTK3 and GTK4.

First of all, appdirtool.go didn't even handle GTK4 (it was hard-coded to 2 and 3), so GTK's loadable modules weren't even being deployed. The first commit fixes this by adding support for version 4. This resulted in an error in the step "Bundling Default theme for Gtk", since there is no default theme for GTK4, so this step was restricted to versions <= 3. Along the way I noticed "Gtk .ui files found." was running multiple times (once for each GTK version), so this was fixed too.

The above still didn't get input methods working in GTK4 apps, since GTK was looking in the wrong place for its loadable modules, as checked with GTK_DEBUG=modules. This was related to the GTK_EXE_PREFIX variable being set wrong. I couldn't find any value of this variable that would work, so I deleted it and set GTK_PATH instead (third commit).

GTK3 also requires immodules.cache to be bundled and patched (unlike GTK4, which has no such file). So code was added to do this on versions <= 3 (second commit).

I have tested the above changes with Inkscape (GTK4) and confirmed that it works. Although I have tested the GTK3-specific code too, I haven't tested it with a real GTK3 app (GIMP), so could do with some help with that (@brunvonlope).

This PR is supposed to fix https://github.com/probonopd/go-appimage/issues/282. In that issue, there were two suggestions: bundle and patch immodules.cache, and set GTK_IM_MODULE_FILE. The first suggestion is done here, while the second is not since GTK_IM_MODULE_FILE no longer exists in GTK4 (doc), and we want a solution that works for all GTK versions if possible. It might be that it does need to be set though, in which case doing it for GTK <= 3 would be harmless, since it is ignored by GTK4.

probonopd commented 2 weeks ago

Thank you very much @pbs3141.

brunvonlope commented 2 weeks ago

Sorry, @pbs3141, I wasn't able to test in time