Batata: Yet another gtk4 app

Hi everyone,

I wrote a terminal emulator (it uses libvte4 that does the real stuff) for me and it may be useful for someone else.

I needed to write an UI component for a project of mine to hold widgets in tiled stacks, and all this inside tabs, then I as a (now former) Tilix user realized that this UI approach would be very interesting for terminal emulators, so Batata was born.

It still having some glitches here and there and leaking a bit of memory until I fix some known issue in GTK4 bindings… but I use it every day and enjoy :heart: , if you spawn several terminals and want to easily switch between them you may like it too.

It’s Linux/Gtk and there’s a flatpak build script, however I didn’t submit it to flathub yet.

You can find it at GitHub - hugopl/batata: An opinionated terminal emulator or see a small/ugly/improvised demo here https://www.youtube.com/watch?v=SdpsOAt3JpI

7 Likes

build and install successful like following:

 ╰─ $   make build
crystal build --release --debug -Dstrict_multi_assign -Duse_pcre2 -Dpreview_overload_order -s --link-flags='-Wl,--as-needed' src/main.cr -o bin/batata
Parse:                             00:00:00.000204198 (   1.07MB)
Semantic (top level):              00:00:00.866403959 ( 410.18MB)
Semantic (new):                    00:00:00.014242404 ( 418.18MB)
Semantic (type declarations):      00:00:00.260646734 ( 434.18MB)
Semantic (abstract def check):     00:00:00.024187582 ( 434.18MB)
Semantic (restrictions augmenter): 00:00:00.042106475 ( 434.18MB)
Semantic (ivars initializers):     00:00:00.037109780 ( 442.18MB)
Semantic (cvars initializers):     00:00:00.067973462 ( 490.18MB)
Semantic (main):                   00:00:00.922464873 ( 634.24MB)
Semantic (cleanup):                00:00:00.001532809 ( 634.24MB)
Semantic (recursive struct check): 00:00:00.006650100 ( 642.24MB)
Codegen (crystal):                 00:00:00.748321299 ( 714.24MB)
Codegen (bc+obj):                  00:00:09.310205013 ( 714.24MB)
Codegen (linking):                 00:00:01.260105657 ( 714.24MB)

Macro runs:
 - /home/zw963/Crystal/git/batata/src/macros/license.cr: reused previous compilation (00:00:00.003278072)

Codegen (bc+obj):
 - no previous .o files were reused

 ╰─ $ 2  sudo make install
install -D -m 0755 bin/batata /usr/bin/batata
install -D -m 0644 data/batata.desktop /usr/share/applications/io.github.hugopl.Batata.desktop
install -D -m 0644 data/batata.svg /usr/share/icons/hicolor/scalable/apps/io.github.hugopl.Batata.svg
# Settings schema
install -D -m644 data/gschema.xml /usr/share/glib-2.0/schemas/io.github.hugopl.Batata.gschema.xml
# Schemes
install -d /usr/share/batata/themes
install -D -m644 data/themes/*.json /usr/share/batata/themes
# License
install -D -m0644 LICENSE /usr/share/licenses/batata/LICENSE
# Changelog
install -D -m0644 CHANGELOG.md /usr/share/doc/batata/CHANGELOG.md
gzip -9fn /usr/share/doc/batata/CHANGELOG.md

But not work.

 ╰─ $ batata

(batata:37524): GLib-GIO-ERROR **: 12:40:21.766: Settings schema 'io.github.hugopl.Batata' is not installed
Trace/breakpoint trap (core dumped)

Thanks

Also no success here (GNU Make 4.3):
Translated to English:
make: *** There is no rule to create target ‘.WAIT’ needed for all ‘all’. Stopt.

batata on  main is 📦 v0.1.0 via 🔮 v1.13.3 
❯ shards install
Resolving dependencies
Fetching https://github.com/hugopl/vte.cr.git
Fetching https://github.com/geopjr/libadwaita.cr.git
Fetching https://github.com/hugopl/gtk4.cr.git
Fetching https://github.com/hugopl/gi-crystal.git
Fetching https://github.com/hugopl/pango.cr.git
Fetching https://github.com/hugopl/harfbuzz.cr.git
Installing gi-crystal (0.24.0 at e230d25)
Postinstall of gi-crystal: shards build
Installing harfbuzz (0.2.0)
Installing pango (0.3.1)
Installing gtk4 (0.17.0)
Installing vte (0.1.0 at 3955f90)
Installing libadwaita (1.0.0 at cffabb5)

batata on  main is 📦 v0.1.0 via 🔮 v1.13.3 took 26s 
❯ make
make: *** Er is geen regel om doel '.WAIT' te maken, nodig voor 'all'.  Gestopt.

batata on  main is 📦 v0.1.0 via 🔮 v1.13.3 
❯ make build
crystal build --release --debug -Dstrict_multi_assign -Duse_pcre2 -Dpreview_overload_order -s --link-flags='-Wl,--as-needed' src/main.cr -o bin/batata
Parse:                             00:00:00.000303796 (   1.07MB)
Showing last frame. Use --error-trace for full trace.

In lib/libadwaita/src/libadwaita.cr:2:11

 2 | GICrystal.require("Adw", "1")
               ^------
Error: Bindings for Adw-1 not yet generated, run ./bin/gi-crystal first.
make: *** [Makefile:8: build] Fout 1

batata on  main is 📦 v0.1.0 via 🔮 v1.13.3 
❯ bin/gi-crystal 
info - Starting at 2024-10-09 18:18:55 +02:00, project dir: /home/kees/Src/Crystal/batata
info - Gi-Crystal version 0.24.0, built with Crystal 1.13.3.
info - Generating bindings at /home/kees/Src/Crystal/batata/lib/gi-crystal/src/auto
info - Using binding config at /home/kees/Src/Crystal/batata/lib/gi-crystal/src/bindings/g_lib/binding.yml
info - Using binding config at /home/kees/Src/Crystal/batata/lib/gi-crystal/src/bindings/g_object/binding.yml
info - Using binding config at /home/kees/Src/Crystal/batata/lib/gi-crystal/src/bindings/gio/binding.yml
info - Using binding config at /home/kees/Src/Crystal/batata/lib/harfbuzz/src/bindings/harfbuzz/binding.yml
info - Using binding config at /home/kees/Src/Crystal/batata/lib/pango/src/bindings/pango/binding.yml
info - Using binding config at /home/kees/Src/Crystal/batata/lib/gtk4/src/bindings/gdk/binding.yml
info - Using binding config at /home/kees/Src/Crystal/batata/lib/gtk4/src/bindings/gsk/binding.yml
info - Using binding config at /home/kees/Src/Crystal/batata/lib/gtk4/src/bindings/gtk/binding.yml
info - Using binding config at /home/kees/Src/Crystal/batata/lib/vte/src/bindings/vte/binding.yml
info - Using binding config at /home/kees/Src/Crystal/batata/lib/libadwaita/src/bindings/binding.yml
warn - g_cancellable_connect - Callback without user_data!
warn - Gio::ActionEntry padding field - Unknown conversion to crystal for fixed size array.
warn - Gio::DBusInterfaceVTable padding field - Unknown conversion to crystal for fixed size array.
warn - Gio::DBusSubtreeVTable padding field - Unknown conversion to crystal for fixed size array.
warn - HarfBuzz - Interface constant not supported.
info - Pango - No binding config found for cairo-1.0.
info - Gdk - No binding config found for PangoCairo-1.0.
info - Gdk - No binding config found for GdkPixbuf-2.0.
warn - Gdk - SeatCapabilities::All (0xf) doesn't have all possible bits set (0x1f).
warn - Gdk::TimeCoord axes field - Unknown conversion to crystal for fixed size array.
info - GdkPixbuf - No binding config found for GModule-2.0.
warn - gdk_pixbuf_get_options - Unknown conversion to crystal for GHash
info - Gsk - No binding config found for Graphene-1.0.
warn - gsk_border_node_get_widths - Unknown conversion to crystal for fixed size array.
warn - Boxed not working for enums
warn - Gtk::BuildableParser padding field - Unknown conversion to crystal for fixed size array.
error - Failed to load Vte: Typelib file for namespace 'Vte', version '3.91' not found

you need to run sudo make post-install, so it does things that usually the distro packages do, like update gnome icon cache and compile the gschema. I’ll add this to the readme.

You need the development package of the vte library, on ArchLinux it’s named vte4.

README.md updated.

Thanks for your reply!
My vte version is too low.
Tried to build vte myself, but the meson version was also too low.
I give up, I hope you can provide executables.
Since I can’t upgrade my Linux Mint 21.3 to 22, I’m investigating rolling linux distro’s Arch and Rhino, I’'l have to reinstall anyway…

you need to run sudo make post-install,

It works! it is really cool(no title bar)

1 Like

Did you try build the flatpak package? It was meant to solve exaclty these kind of problems.

Downloaded the sources to compile the interpreter, building without gave an error, but flatpak-builder seems to be missing

batata on  main is 📦 v0.1.0 via 🔮 v1.15.0-dev 
❯ make flatpak
./bin/create-flatpack-file.cr data/io.github.hugopl.Batata.in.yml > data/io.github.hugopl.Batata.yml
Using compiled compiler at /home/kees/Src/Crystal/crystal/.build/crystal
Crystal interpreter 1.15.0-dev [991f9d003] (2024-10-10).
EXPERIMENTAL SOFTWARE: if you find a bug, please consider opening an issue in
https://github.com/crystal-lang/crystal/issues/new/
flatpak install flathub org.gnome.Sdk//47
Looking for matches…


        ID                                              Branch                Op            Remote             Download
 1. [✓] org.freedesktop.Platform.GL.default             24.08                 u             flathub             61,4 MB / 146,7 MB
 2. [✓] org.freedesktop.Platform.GL.default             24.08extra            u             flathub             26,5 MB / 146,7 MB
 3. [✓] org.freedesktop.Platform.VAAPI.Intel            24.08                 u             flathub              1,0 kB / 14,5 MB
 4. [✓] org.gnome.Sdk.Locale                            47                    i             flathub             60,8 kB / 391,6 MB
 5. [✓] org.gnome.Sdk                                   47                    i             flathub            516,9 MB / 775,1 MB

Changes complete.
flatpak-builder --force-clean ./build data/io.github.hugopl.Batata.yml --user --install
make: flatpak-builder: File or map does not exist.
make: *** [Makefile:57: flatpak] Error 127

I translated the Dutch error messages to English, because, I guess your Dutch is just as bad as my Portuguese :crazy_face:

You need to install the flatpak-bulder. There’s probably a package for your distro.
oops, no, you have the flatpak-builder.

Indeed, I could install flatpack-builder from the distro’s repo.
The building took quite a while, managed to keep all my 4 processors at 100%, but finally gave an error:

error - Failed to load Vte: Typelib file for namespace 'Vte', version '3.91' not found
Running: make build
crystal build --release --debug -Dstrict_multi_assign -Duse_pcre2 -Dpreview_overload_order -s --link-flags='-Wl,--as-needed' src/main.cr -o bin/batata
Parse:                             00:00:00.000931376 (   1.05MB)
Showing last frame. Use --error-trace for full trace.

In lib/vte/src/vte.cr:3:11

 3 | GICrystal.require("Vte", "3.91")
               ^------
Error: Bindings for Vte-3.91 not yet generated, run ./bin/gi-crystal first.
make: *** [Makefile:8: build] Error 1
Error: module batata: Child process ended with  code 2
make: *** [Makefile:57: flatpak] Error 1

Any idea?

Seems it failed to compile vte?

The error is from gi-crystal, it didn’t find the vte files with introspection data for binding generation.

I ran the make flatpak here yesterday and it worked, I really have no idea why it failed with you… I’ll submit the flatpak to flathub soon, hope guys there could point anything that I may be doing wrong in the flatpak file.

The flatpak file is here, there’s a script that just inject the Crystal dependencies.