Sign up

TestWindow demo working with a new Gtk-4 GtkD bind development

I'm pleased to announce a working GtkD port to Gtk-4 with the TestWindow demo. This is very much work in progress, but already in fairly good shape. The primary purpose of this post is to get feedback on the future direction of this work, especially since there apparently hasn't been much activity with this effort in a while and I'm not yet acquainted with the authors of this project.

Here is a link to the forked repo I created with some sparse details at the top of the README.md of how to get things built:
https://github.com/elementgreen/GtkD/tree/gtk4

My intention is to help create a full featured gtk-4 binding for D, not simply get the demos to work. A lot of this work has already been done in the gtk4 branch of GtkD. However this effort is incomplete with significant issues with the API and non-working demos. These changes address many of the issues with the API and also result in an almost fully working TestWindow demo application.

Current thoughts:

  • Make the D binding similar to the Python binding, which seems fairly clean and straightforward with respect to the C API and underlying Gir interface descriptions.
  • Automatically generate as much of the binding as possible (prefer changes to gir-to-d utility over manual changes to API text files)
  • Non-default object constructors (ones not simply called "new") should just be static object methods with no attempt to have multiple constructors differentiated only by the arguments. This was resulting in a lot of conflicts and hiding the purpose of the constructor. For example: What is now Button.newWithIconName("document-open") would have been attempted to wrap as new Button("document-open") but this would also conflict with the constructor for Button.newWithLabel("My label"), if only differentiating by argument types. This was worked around by creating custom non-standard constructors with arguments differentiating the purpose, increasing complexity and requiring a lot of additional manual binding customization.
  • glib memory slices were being used for simple structure out parameters, which can be very problematic if the slices are not freed through the slice subsystem. Just using malloc/free instead for now.
  • The generated D source files have been removed from the repo. This will be replaced with a consistent way to fetch specific versions of the relevant gir API interface files and a specific version of the gir-to-d utility sub-module in wrap/.

I'm working on a port of a GTK3 C application to GTK4 and D, so that will likely drive additional improvements as I come across issues.

I welcome any comments, questions, or other input on this GtkD GTK4 binding development effort.

Re: TestWindow demo working with a new Gtk-4 GtkD bind development

On Sat, 17 Jun 2023 04:14:28 GMT, Element Green wrote:

I'm pleased to announce a working GtkD port to Gtk-4 with the TestWindow demo. This is very much work in progress, but already in fairly good shape. The primary purpose of this post is to get feedback on the future direction of this work, especially since there apparently hasn't been much activity with this effort in a while and I'm not yet acquainted with the authors of this project.

Did you make a PR to merge your code into the GtkD?

Re: TestWindow demo working with a new Gtk-4 GtkD bind development

On Fri, 30 Jun 2023 10:22:23 GMT, Dejan Lekic wrote:

On Sat, 17 Jun 2023 04:14:28 GMT, Element Green wrote:

I'm pleased to announce a working GtkD port to Gtk-4 with the TestWindow demo. This is very much work in progress, but already in fairly good shape. The primary purpose of this post is to get feedback on the future direction of this work, especially since there apparently hasn't been much activity with this effort in a while and I'm not yet acquainted with the authors of this project.

Did you make a PR to merge your code into the GtkD?

I have not yet done that. I wanted to get a better idea of what the best way is to move forward with this effort. Without any other input on this, it does seem like the best course of action. I'll work on that, since I should probably create multiple separate incremental PRs, so it is easier to review.

Re: TestWindow demo working with a new Gtk-4 GtkD bind development

On Mon, 24 Jul 2023 14:58:06 GMT, Element Green wrote:

I have not yet done that. I wanted to get a better idea of what the best way is to move forward with this effort. Without any other input on this, it does seem like the best course of action. I'll work on that, since I should probably create multiple separate incremental PRs, so it is easier to review.

I completely agree. If you need review please let me know!