you might want to check up on GTK's Drawing widget
https://docs.gtk.org/gtk3/class.DrawingArea.html
I have seen other entities like PLplot, use this to create their own canvas class to draw widgets like graph or something essentially.
You might be able to replace the canvas in your old code with GtkDrawingArea.