Skip to content

How to migrate to GTK 4

Vincent Magnin edited this page May 13, 2022 · 3 revisions

We present here some advices and resources that will be helpful if you need to migrate a gtk-3-fortran application toward gtk-4-fortran. Note that you can install both the GTK 3 and 4 versions of gtk-fortran on your machine: the pkg-config names are gtk-3-fortran and gtk-4-fortran.

GTK 4 is a major version, released in December 2020, ten years after GTK 3. Some APIs disappeared and were replaced, some were reorganized, the name or arguments of some functions changed, new APIs appeared... Depending on the complexity of your application, on the APIs used, migrating to GTK 4 can be more or less difficult.

  • First read the official GTK document Migrating from GTK 3.x to GTK 4. The advices are divided in two parts:
    • what you should change in your GTK 3 app before migrating to be ready,
    • what you must do at the time of the switch.
  • You can look at the differences in the project examples between the gtk3 and gtk4 branches with git diff, for example:
$ git diff gtk3 gtk4 -- gtkhello.f90
Clone this wiki locally