Welcome to the documentation of Mousetrap.jl, a GUI engine for Julia. Mousetrap was created and designed by C. Cords.

This page contains a manual and tutorial, as well as an index of all functions, classes, and enums.

To download and install mousetrap, follow the instructions on the official GitHub page.

Mousetrap.jl, the non-Julia components of mousetrap, this documentation, and all its original assets, are licensed under lGPL3.0, meaning they can be used in both free, open-source, as well as for-profit, proprietary projects.

For frequently asked questions, see here.

Use the navigation area on the left side of this page or the table of contents below to navigate to the appropriate chapter of this manual:




Why is there a C++ Component at all?

The C++ version of mousetrap was originally created for an unrelated commercial, closed-source project in 2022. When the project failed due to funding issues in 2023, I decided that, instead of throwing away all my C++ work, I would instead create a Julia wrapper around it, so it can at least contribute to the Julia ecosysem. Even though Julia-Mousetrap is the face of the project now, C++-Mousetrap existed and was finished before Julia-Mousetrap was ever conceived.

A less valid reason is that mousetrap, in order to extend the GObject type system, makes extensive use of C-macros, which are quite hard to emulate in Julia, as there is no way to ccall a macro, to my knowledge.

What is the difference between mousetrap and GTK4.jl?

Mousetrap is unaffiliated with GTK.jl and GTK4.jl. The only connection these projects share is that both use the GTK4 C library as their basis. Mousetrap is not endorsed by GNOME and has no connection to that organization or any of its contributors.

What advantages does mousetrap have over pure GTK4?

While based on GTK4 and usually calling native GTK4 under the hood, mousetraps interface, that is, the actual architecture of the library, including syntax and names, was reworked from the ground up. Heavy editorializing has taken place, renaming or completely removing certain parts of GTK4 in an effort to make mousetrap more friendly to newcomers and people with no GUI experience, easier to use, and less susceptible to developer error.

Furthermore, mousetrap contains an all-new OpenGL-based rendering engine, which aims to replace the cairo component of native GTK4 to allow for faster, more easily integrated native rendering.

What advantages does pure GTK4 have over mousetrap?

Speaking about the GTK4 C library specifically, not GTK4.jl, GTK4 is much bigger and has many features that went unused in mousetrap, or, if used, were made opaque such that a user of mousetrap cannot interact with these features:

  • Removed Modules: GDK, ATK, gobject, GLib, adwaita
  • Widgets with no mousetrap equivalent: GtkListBox, PasswordEntry, GtkTextView, GtkSourceView, AdwAboutWindow
  • Removed Features: Mnemonics, Stateful Actions, GtkBuilder Interface, GTK_DEBUG, GtkInspector

Furthermore, any classes marked as deprecated in GKT4.10, such as GtkTreeView, where removed completely.

When possible, the adwaita version of a widget was preferred over the native GTK4 version, for example, using AdwWindow instead of GtkWindow, or AdwMessageDialog over GtkAlertDialog.

Julia does not use a build system such as meson and is thus incompatible with distribution through flatpak or similar services.

How do I ship my app?

JuliaComputing and many more contributors are currently working on PackageCompiler, which is supposed to compile a Julia package into a stand-alone binary. Compatibility of mousetrap with PackageCompiler remains untested and may be impossible until further work has been put into either PackageCompiler, or mousetrap itself. There is evidence that static compilation is one of Julias next big goals. Ideally, when static compilation is working 100% of the time, mousetrap will be polished enough to be considered fully stable and easily distributable, therefore making it usable in production.

Until then, the only way to ship a stand-alone Julia app is to bundle the entire Julia runtime along with the app-specific Julia code and resources, which will usually be a folder with a size of 2 GB or more. Alternatively, developers have to force end users to install Julia on their machine globally, after which launching the app is as simple as calling (julia main.jl) from a shell script.