Sign up

Gtk2 branch--getting a Cairo context from GTK

Hi! I'm slowly working my way through learning to use GtkD (Specifically, the GTK2 version as opposed to GTK3), and I'm trying to figure out how to get a cairo context from a widget to draw on. Other language bindings seem to have a helper function that takes a GdkDrawable and returns a CairoContext, but I'm unable to find such a thing in GtkD.

Am I overlooking something obvious here?

Re: Gtk2 branch--getting a Cairo context from GTK

On 09/11/2013 03:43 PM, E.S. Quinn wrote:

Hi! I'm slowly working my way through learning to use GtkD (Specifically, the GTK2 version as opposed to GTK3), and I'm trying to figure out how to get a cairo context from a widget to draw on. Other language bindings seem to have a helper function that takes a GdkDrawable and returns a CairoContext, but I'm unable to find such a thing in GtkD.

Am I overlooking something obvious here?

On the Gtk2 branch one of the Context constructors accepts a gdk.Drawable.

Drawable draw = widget.getWindow();
Context ct = new Context(draw);