gtkd-developers / GtkD

GtkD is a D binding and OO wrapper of GTK+ originally created by Antonio Monteiro
http://gtkd.org
Other
322 stars 71 forks source link

Gtk 4.0 released! It's time to upgrade. #315

Open zoujiaqing opened 3 years ago

zoujiaqing commented 3 years ago

https://blog.gtk.org/2020/12/17/who-wrote-gtk4/

TheWeirdDev commented 3 years ago

Yes, please provide the gtk4 bindings.

adnan449 commented 3 years ago

I sincerely hope that D catches up! If I was an expert at GObject introspection, I would work on this for sure.

MikeWey commented 3 years ago

With commit 86174147fce10bd9caf92285709b6a27afc0e2c2 the gtk4 branch of GtkD compiles.

I don't know if the compiled library works and the demos need to be updated.

Still a work in progress.

TheWeirdDev commented 3 years ago

That's awesome. With a bit of tweaking, I was able to run a simple gtk4 application.

Blquinn commented 3 years ago

@MikeWey Is there anything anyone can do to help?

MikeWey commented 3 years ago

I'm currently "slowly" updating the demos to Gtk4 mostly to see if any issues with the generated binding show up.

It would help if someone could work on updating some of the demos and reporting/fixing the issues that surface.

I'm currently working on the two remaining in demos/gtk/.

Blquinn commented 3 years ago

@MikeWey Funny you mention that because I started working through the TestWindow demo, it's compiling now, but I'm not sure if I have time to work through the runtime errors. There's a lot of breakage there, but luckily it seems to be relegated to

  1. Some missing (perhaps intentionally removed) constructors in certain widgets.
  2. Breaking changes in the gtk api.

Here are my full notes, might be missing some stuff:

GtkD 3 -> 4 Discovered breaking changes.

Things that I think might have broken in gir-to-d code gen.

Dialogs

  1. FileChooserDialog(string title, Window win, FileChooserAction action) ctor missing.
  2. FileChooserDialog() ctor missing.
  3. MessageDialog() ctor missing.

TreeModel

  1. getIter*() methods no longer return iters, instead have "out" parameters.

TreeView

  1. TreeViewCollumn(string title, CellRendererIF cellRenderer, string something, int column) ctor is missing. setTitle + addAttribute now used.

Menus

  1. MenuModel missing primary ctor MenuModel()

Frame

  1. Missing ctor(Widget framed, string title)

Button

  1. Button.fromIconName(string iconName) static function missing
  2. Button.withLabel(string label) static function missing
  3. Button(string label, delegate onClicked) convenience ctor missing

GStreamer

  1. DateTime has conflicting ctors

Peas

  1. Gtk.Menu -> GMenu
  2. GtkMenu -> GMenu*

Things that broke in the demo because of Gtk4 Deprecations

Gtk

  1. ColorSelectionDialog renamed to ColorChooserDialog
  2. FontSelectionDialog renamed to FontChooserDialog
  3. Dialogs are now fully async and do not have .run() methods as a result.
  4. Dialogs require window as second arg of ctors
  5. NoteBook.appendPage now requires Widget as second arg, instead of string.
  6. Window.showAll gone

Gdk

  1. GtkPoint gone

Things I'm not really sure what's going on

Many things that seemed to previously take things convertible to a gtk.Value, now require you to wrap them in a gtk.Value. gtk.TreeStore .setValue for example now requires a gtk.Value, and won't accept a string.

Blquinn commented 3 years ago

Created a PR so you can see what I changed... Lots of broken stuff at the moment https://github.com/gtkd-developers/GtkD/pull/320

MikeWey commented 3 years ago

The gtk3 binding still had a lot of thing manually tweaked to be compatible with an older generator that used the HTML documentation as a basis. So when switching to gtk4 i started with a blank slate, and because of that some/a lot of convenience functions may need to re added.

Things that I think might have broken in gir-to-d code gen.

Dialogs

1. FileChooserDialog(string title, Window win, FileChooserAction action) ctor missing.
2. FileChooserDialog() ctor missing.
3. MessageDialog() ctor missing.

Missing because gir-to-d currently doesn't handle variadics, need to be added manually.

TreeModel

1. getIter*() methods no longer return iters, instead have "out" parameters.

The old one also doesn't return the iter, marking it as out is correct.

TreeView

1. TreeViewCollumn(string title, CellRendererIF cellRenderer, string something, int column) ctor is missing. setTitle + addAttribute now used.

Same issue as the dialogs.

Menus

1. MenuModel missing primary ctor `MenuModel()`

On the GIO side MenuModel is an abstract class, so it is correct that it doesn't have a constructor. We could investigate attributing them as 'abstract' on the D side, that would require a solution similar to the one for interfaces to be able to return the abstract class from a wrapper function.

Frame

1. Missing ctor(Widget framed, string title)

Was a manually added convenance function, may need to be re added.

Button

1. Button.fromIconName(string iconName) static function missing
2. Button.withLabel(string label) static function missing
3. Button(string label, delegate onClicked) convenience ctor missing

These also will probably need to be re added, a more general solution for duplicate constructors in gir-to-d would be best.

GStreamer

1. DateTime has conflicting ctors

One of them will need to be replaced with a static function.

Peas

1. Gtk.Menu -> GMenu
2. GtkMenu -> GMenu*

Peas may depend on gtk3 GtkMenu / gtk.Menu was replaced by the gio menu model/classes with gtk4.

Things I'm not really sure what's going on

Many things that seemed to previously take things convertible to a gtk.Value, now require you to wrap them in a gtk.Value. gtk.TreeStore .setValue for example now requires a gtk.Value, and won't accept a string.

Probably a lot of convenience functions that are now missing.

JeysonFlores commented 2 years ago

It has been more than a year since this thread began, is there any improvements?

ichordev commented 2 years ago

Where's the progress on this up to? Is any help needed?

yookoala commented 2 years ago

Posted this issue on BountySource. If you want to see this issue resolved, please help and contribute to the bounty: https://app.bountysource.com/issues/95837122-gtk-4-0-released-it-s-time-to-upgrade

okias commented 1 year ago

At least for Tilix, I would love to see this, but I'm afraid that interest in D is pretty low to make this happen :disappointed:.