Gtk4 how to get the GtkWidget itself from GtkExpression

I was playing with gtk4 demo application try to implement the new ListView Widget in vala in this repo, please note that it doesn’t work yet, the time don’t update, and I can’t draw clock face.
I’m stuck with a few problems and appreciate any guidance.

  1. what is the recommended way to draw a custom widget?
    is it like the c example subclassing GObject, IPaintable or using GtkDrawingArea or like I did directly from GtkWidget?
  2. The Example use the new GtkExpression to bind properties between objects, like time property of Clock and label property of Label. But is there any possibility to get the Widget itself form Expression to add it directly to ListView.

Thank you for your help :wink:

Follow the blog post about drawing custom widgets.

Why would you want to do that?

Thanks for replying.
The c code has a seamless integration between the paintable property of GtkPicture and the custom object implementing IPaintable.

I have subclassed from Widget and I couldn’t find a way to connect GtkPicture to my Clock to draw on it.

I don’t know what IPaintable means, in this context. You mean the GdkPaintable interface?

A GdkPaintable implementation is a delegate object used by a widget to paint itself.

That’s the point of the expression: to bind the Clock instance with the GtkPicture widget instance, so that whenever the GtkPicture widget is drawn, it will delegate the drawing to the Clock instance.

I’ve read the 4 blog posts about drawing model in Gtk4. But to tell the truth I don’t fully grasp the concept of GtkExpressions, and its descendants GtkClosureExpression, GtkPropertyExpression, GtkConstantExpression. I think I have to wait for more code samples and documentations, may be also another blog that explain it a little deeper.

There are already 2 new blog posts about lists and it’s infrastructure published recently.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.