Saturday, February 12, 2011

More Progress

Been slogging along with the process of auditing API and fixing samples to compile and not crash instantly. Things got a whole lot more stable in the last couple evenings. I pushed a bunch of updates today that allow the cairo drawing sample in the Gtk# samples to run cleanly.

The configure now requires the gtk+-3.0.0 release since it has hit the streets. There was a bit of API churn between 2.99.0 and 3.0.0, which accounted for one of the more insidious crashes to track down. Geoff Norton helped me figure that one out today, and when I reparsed for the 3.0 API a lot of things fell into place.

The size negotiation and drawing API changes are going to make for a little work when people start switching over. These are the most common trip-ups I'm experiencing in the samples. Any custom widgets which overloaded Widget.OnSizeRequested in 2.x will need to pick one or more of the new negotiation VMs and port to them. For example, in the PolarFixed sample, I made the existing OnSizeRequested method private and delegated to it from new overrides for OnGetPreferredWidth and OnGetPreferredHeight.

In CairoSample, the only substantial change required was converting the old OnExposeEvent override to a new OnDrawn method. The new method utilizes the new AllocatedWidth and AllocatedHeight properties to obtain sizing info to pass into the rendering methods. Of course, the code was already drawing to a Cairo.Context, so the logic was ready to go. A widget using the Gdk drawing API, or Style painting may have substantially more work to make the shift.

I'll try to blog more impressions of the porting effort as I move through the samples, and I encourage anyone who decides to dig in with their own apps to try to capture the knowledge, be it by sending a message to gtk-sharp-list, blogging, or adding them directly to the porting guide I've started on the wiki.


Sandy said...

Great news, thanks for working on this!

mdi said...

Love the wiki page with the migration strategies!