Jump to page: 1 2
Thread overview
giD v0.9.2 GObject Introspection binding repository and generator with Gtk4 support
6 days ago
Element Green
6 days ago
Element Green
6 days ago
Andrea Fontana
5 days ago
Dejan Lekic
5 days ago
Element Green
5 days ago
Element Green
4 days ago
Bastiaan Veelo
1 day ago
Dejan Lekic
5 days ago
M. M.
5 days ago
Dejan Lekic
5 days ago
Element Green
5 days ago
M. M.
5 days ago
Element Green
2 days ago
Ian
6 days ago

giD (pronounced giddy) is a repository for GObject Introspection D binding libraries. Current focus has been on adding the Gtk4 graphics toolkit and dependencies with the goal of adding all libraries with GObject Introspection API descriptions which are of interest (any of these from the Python PyGObject project for example).

The bindings were created with gidgen which is a GObject Introspection binding generator CLI application. It generates high quality mostly-automated D bindings from GIR XML API definition files.

Also a part of this project is a giD Gtk4 Example Application as a quick-start to learn how to develop with D and Gtk4.

v0.9.2 Changes

Screenshot

6 days ago

Here is the Clipboard example from the giD Gtk4 Examples project to get an idea of what programming with giD and Gtk4 looks like:

module clipboard;

import Gdk.Clipboard;
import Gdk.ContentProvider;
import Gdk.Display;
import Gdk.Texture;
import Gio.AsyncResult;
import GObject.ObjectG;
import GObject.Value;
import Gtk.Application;
import Gtk.ApplicationWindow;
import Gtk.Box;
import Gtk.Button;
import Gtk.Entry;
import Gtk.Picture;
import Gtk.Types : Align, Orientation;
import Pango.Types : Weight, Style, Underline;

import example;

class ClipboardExample : Example
{
    override @property ExampleCategory category() { return ExampleCategory.Default; }
    override ApplicationWindow createWindow(Application app) { return new ClipboardWindow(app); }
}

class ClipboardWindow : ApplicationWindow
{
    Clipboard clipboard;
    Entry entry;
    Picture picture;

    this(Application app)
    {
        super(app);
        setTitle("Clipboard Example");

        auto box = new Box(Orientation.Vertical, 12);
        setChild(box);

        clipboard = Display.getDefault.getClipboard;

        auto textBox = new Box(Orientation.Horizontal, 6);
        textBox.setHomogeneous(true);
        box.append(textBox);

        entry = new Entry;
        entry.setText("Some text you can copy");
        auto buttonCopyText = Button.newWithLabel("Copy Text");
        buttonCopyText.connectClicked(&onCopyTextClicked);
        auto buttonPasteText = Button.newWithLabel("Paste Text");
        buttonPasteText.connectClicked(&onPasteTextClicked);

        textBox.append(entry);
        textBox.append(buttonCopyText);
        textBox.append(buttonPasteText);

        auto imageBox = new Box(Orientation.Horizontal, 6);
        box.append(imageBox);

        picture = Picture.newForFilename("images/dlang_logo.png");
        picture.setHexpand(true);
        auto buttonCopyImage = Button.newWithLabel("Copy Image");
        buttonCopyImage.setValign(Align.Center);
        buttonCopyImage.connectClicked(&onCopyImageClicked);
        auto buttonPasteImage = Button.newWithLabel("Paste Image");
        buttonPasteImage.setValign(Align.Center);
        buttonPasteImage.connectClicked(&onPasteImageClicked);

        imageBox.append(picture);
        imageBox.append(buttonCopyImage);
        imageBox.append(buttonPasteImage);
    }

    void onCopyTextClicked(Button button)
    {
        clipboard.set(new Value(entry.getText));
    }

    void onPasteTextClicked(Button button)
    {
        clipboard.readTextAsync(null, &clipboardReadTextAsync);
    }

    void clipboardReadTextAsync(ObjectG obj, AsyncResult result)
    {
        if (auto text = clipboard.readTextFinish(result))
            entry.setText(text);
    }

    void onCopyImageClicked(Button button)
    {
        if (auto texture = cast(Texture)picture.getPaintable)
        {
            auto content = ContentProvider.newForBytes("image/png", texture.saveToPngBytes);
            clipboard.setContent(content);
        }
    }

    void onPasteImageClicked(Button button)
    {
        clipboard.readTextureAsync(null, &clipboardReadTextureAsync);
    }

    void clipboardReadTextureAsync(ObjectG obj, AsyncResult result)
    {
        if (auto texture = clipboard.readTextureFinish(result))
            picture.setPaintable(texture);
    }
}
6 days ago

On Sunday, 16 February 2025 at 19:26:24 UTC, Element Green wrote:

>

giD (pronounced giddy) is a repository for GObject Introspection D binding libraries. Current focus has been on adding the Gtk4 graphics toolkit and dependencies with the goal of adding all libraries with GObject Introspection API descriptions which are of interest (any of these from the Python PyGObject project for example).

The bindings were created with gidgen which is a GObject Introspection binding generator CLI application. It generates high quality mostly-automated D bindings from GIR XML API definition files.

Wow! Nice project. Tested the examples and all of them worked fine just running dub build :)

Keep up the good work!

Andrea

5 days ago

On Sunday, 16 February 2025 at 19:26:24 UTC, Element Green wrote:

>

giD (pronounced giddy) is a repository for GObject Introspection D binding libraries. Current focus has been on adding the Gtk4 graphics toolkit and dependencies with the goal of adding all libraries with GObject Introspection API descriptions which are of interest (any of these from the Python PyGObject project for example).

Amazing! The only thing I do not like is that module/package names are upper-case, but GtkD does the same so it should be easier to move to gid/gidgen if it turns to be equally good...

5 days ago

On Sunday, 16 February 2025 at 19:26:24 UTC, Element Green wrote:

>

giD (pronounced giddy) is a repository for GObject Introspection D binding libraries. Current focus has been on adding the Gtk4 graphics toolkit and dependencies with the goal of adding all libraries with GObject Introspection API descriptions which are of interest (any of these from the Python PyGObject project for example).

[...]

I am confused (and not an expert in GUI), but -- does this replace gtkD? (and, cudos, it looks like a fine work!)

5 days ago

On Monday, 17 February 2025 at 12:32:29 UTC, M. M. wrote:

>

I am confused (and not an expert in GUI), but -- does this replace gtkD? (and, cudos, it looks like a fine work!)

It is not replacing gtkD (yet), but it is definitely an alternative to gtkD that includes Gtk4 which most of us are waiting for. On top of Gtk, gid also contains Arrow for an example, something I need too...

5 days ago

On Monday, 17 February 2025 at 12:46:17 UTC, Dejan Lekic wrote:

>

On Monday, 17 February 2025 at 12:32:29 UTC, M. M. wrote:

>

I am confused (and not an expert in GUI), but -- does this replace gtkD? (and, cudos, it looks like a fine work!)

It is not replacing gtkD (yet), but it is definitely an alternative to gtkD that includes Gtk4 which most of us are waiting for. On top of Gtk, gid also contains Arrow for an example, something I need too...

Yes, exactly correct. It does not replace gtkD (yet). I began by working with girtod and an unreleased version of gtkD for Gtk4 and spent months trying to improve it. I eventually abandoned the effort and decided it would be easiest to start from scratch on a new binding utility, which is now gidgen (after about a year of work in my spare time). It is much more advanced than girtod and requires less manual binding work. The intention is to automate as much as possible. Most of the manual effort is to fix issues with the underlying GIR API descriptions, in the form of XML patch commands embedded as comments in D source definition files.

Adding the Arrow binding took a few hours at most, the majority spent trying to build Arrow. It required a few XML patches to designate some return string arrays as null terminated which were automatic suggestions from gidgen and are missing in the GIR API, in order to get 100% coverage.

I think it would make sense to bind Gtk3 as well, since gtkD still leaves much to be desired. This will likely require some changes to gidgen to take the version into account when resolving dependencies. Was just thinking about this actually.

Thanks to all who tried it out. giD and gidgen could use some more unittests and I suspect there could be some memory leaks, which I still need to track down. I'm looking forward to continuing to expand access to other libraries with GObject Introspection APIs to D. I was thinking of starting on gstreamer next. I welcome any other suggestions as well and would be happy to put in the effort or assist if someone wants to learn how to create bindings with gidgen.

5 days ago

On Monday, 17 February 2025 at 15:12:39 UTC, Element Green wrote:

>

On Monday, 17 February 2025 at 12:46:17 UTC, Dejan Lekic wrote:

>

[...]

Yes, exactly correct. It does not replace gtkD (yet). I began by working with girtod and an unreleased version of gtkD for Gtk4 and spent months trying to improve it. I eventually abandoned the effort and decided it would be easiest to start from scratch on a new binding utility, which is now gidgen (after about a year of work in my spare time). It is much more advanced than girtod and requires less manual binding work. The intention is to automate as much as possible. Most of the manual effort is to fix issues with the underlying GIR API descriptions, in the form of XML patch commands embedded as comments in D source definition files.

[...]

quite a cool project and efforts. out of curiosity, what went wrong when you "eventually abandoned trying to improve gtkD for GTK4"?

5 days ago

On Monday, 17 February 2025 at 15:53:39 UTC, M. M. wrote:

>

On Monday, 17 February 2025 at 15:12:39 UTC, Element Green wrote:

>

On Monday, 17 February 2025 at 12:46:17 UTC, Dejan Lekic wrote:

>

[...]

Yes, exactly correct. It does not replace gtkD (yet). I began by working with girtod and an unreleased version of gtkD for Gtk4 and spent months trying to improve it. I eventually abandoned the effort and decided it would be easiest to start from scratch on a new binding utility, which is now gidgen (after about a year of work in my spare time). It is much more advanced than girtod and requires less manual binding work. The intention is to automate as much as possible. Most of the manual effort is to fix issues with the underlying GIR API descriptions, in the form of XML patch commands embedded as comments in D source definition files.

[...]

quite a cool project and efforts. out of curiosity, what went wrong when you "eventually abandoned trying to improve gtkD for GTK4"?

It was a number of factors which all contributed to my decision. Primarily I realized that it would likely be easier for me to start from scratch than try and fully understand gtkD and improve it in all the ways I wanted to. It didn't seem designed with a highly automated binding approach in mind and has a lot of manual binding code and work arounds/exceptions for specific APIs. Ultimately it just seemed easier, and more rewarding for me personally, to go with a bottom up approach instead of trying to work in the other direction.

While I think the result still ended up being rather complex in some ways and could use some improvements, the generated bindings speak for themselves. A very high coverage rate, with minimal manual binding code.

Some features gidgen has over girtod:

  • Individual dub sub-packages for each library with proper dependencies
  • Automatic signal callback generation (delegates or functions)
  • Automatic callback closures with all supported scopes
  • Automatic conversion to/from GLib container types and D dynamic arrays/hashes
  • A more advanced type system which enables a higher automatic coverage rate
  • Automatic generation of GError exceptions (gtkD might have this, can't remember)
  • Uses simpler definition files which are just D language files with gidgen commands in comments
  • Correcting GIR issues is much simpler, since it relies on XML patching commands, which modify the XML tree prior to the binding being generated rather than having a large number of commands to modify different issues after the fact
  • Outputs warnings about unsupported or problematic GIR APIs
  • Provides suggestions of GIR API corrections
  • Generates coverage reports

Its been a while since I worked with gtkD, so I may be misremembering some of its lack of the above features and am probably overlooking some other significant improvements as well.

5 days ago

On Monday, 17 February 2025 at 11:32:06 UTC, Dejan Lekic wrote:

>

On Sunday, 16 February 2025 at 19:26:24 UTC, Element Green wrote:

>

giD (pronounced giddy) is a repository for GObject Introspection D binding libraries. Current focus has been on adding the Gtk4 graphics toolkit and dependencies with the goal of adding all libraries with GObject Introspection API descriptions which are of interest (any of these from the Python PyGObject project for example).

Amazing! The only thing I do not like is that module/package names are upper-case, but GtkD does the same so it should be easier to move to gid/gidgen if it turns to be equally good...

I got another request for making the names lower case. I guess that would be snake_case for the modules and just lowercase for the package names? So for example pangocairo.font_map.FontMap would be the package.module.class. I'm considering making these changes, since it was only recently released and I have the version < 1.0 for a reason. I must admit though that I prefer CamelCase but understand the reasons for using lowercase packages and modules (for case insensitive file systems).

« First   ‹ Prev
1 2