Skip to content

ppebb/cosmo-gtk-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cosmo-gtk-template - Maximal GTK sample for Cosmopolitan

This repository contains a full1 stub for GTK (and GSK, GDK), GLib, GIO, GObject, GModule, and GIRepository

Using the Stubs

The stub contains two folders, one for GLib and one for GTK located in the stubs folder. The necessary headers to build are not present, so run scripts/copy_headers.sh to copy the requisite headers into the stubs folder.

Simply copy the stubs folder into your project and import glib_stub.h or gtk_stub.h.

If you use Clangd, a script to generate compile_flags.txt, gen_compile_flags.sh, is present. Run it with the path to cosmopolitan (should contain an include folder). The generated compile_flags.txt should be mostly functional.

Generating the Stub

generate.lua in the scripts directory of this repository was used to generate the stub. If you can manage to make it work you can generate them yourself too. This requires lua >= 5.2 (for use of the goto keyword) and luafilesystem.

As a warning, generating the stub will print a little under 50000 lines to your terminal, you may want to redirect them to a file, especially if something goes wrong.

Dependencies

All of the dependencies of GTK and GLib are required. See the Makefile if you are unsure.

Depending on how you generated the stub, you will need Xlib and wayland-protocol headers.

References

This repository is based off of vkoskiv's cosmo-sdl-template. The code used to stub GTK and GLib is largely the same.

Footnotes

  1. Certain functions making use of variadic arguments do not have an equivalent function which takes a va_list. As a result the arguments passed using ... cannot be forwarded to the stubbed function.