|
|
Log in / Subscribe / Register

GTK 4.0

GTK 4.0

Posted Dec 17, 2020 10:06 UTC (Thu) by mchehab (subscriber, #41156)
In reply to: GTK 4.0 by atnot
Parent article: GTK 4.0

> Gtk4 is not a major release in the sense that Gtk3 was. Most applications will require very minimal porting, they've learned their lesson.

I did a port of Camorama from Gtk3 to Gtk3 two years ago, and I tried to keep it ready for Gtk4.

Camorama works by creating a GtkDrawingArea, mapping a callback that would allow filling the pixbuf area from the data retrieved from the camera. It turns that they dropped support for gdk_cairo_surface_create_from_pixbuf(). The git log is short, and just says that "it's unused", without providing any glue about how to replace it:

https://gitlab.gnome.org/GNOME/gtk/commit/7ef8696a7dc2c7a...

I remember I tried hard on that time (Gtk 3.94) to see a replacement for that. I found none. The migration instructions at:

https://developer.gnome.org/gtk4/stable/gtk-migrating-3-t...

Also doesn't help.


to post comments

GTK 4.0

Posted Dec 17, 2020 11:56 UTC (Thu) by alexl (guest, #19068) [Link] (1 responses)

Why do you need to convert a pixbuf to a cairo surface to draw it? Just call gdk_cairo_set_source_pixbuf() to draw it onto the cairo_t.

Of course, with Gtk 4 you ideally don't want to use cairo to draw at all as it is really the old "fallback" software rendering codepath.

The modern way to draw is to implement snapshot and create render nodes which will avoid any cairo work and just do OpenGL rendering.

However snapshot is kind of lowlevel. Its used if you want to do some custom specialized rendering. If you just want to render an image in your UI, just put the pixbuf in a in a GtkPicture subwindow. One of the nice advantages of Gtk4 is that everything, even sub-parts of widgets are just widgets. You very rarely have to have a custom drawing function that draws multiple things.

GTK 4.0

Posted Dec 17, 2020 12:05 UTC (Thu) by alexl (guest, #19068) [Link]

eh, subwidget, not subwindow


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds