Well I decided to call my mp3 player app bluefunk. I’ve been shifting it over to use the MVC model used in GTK, so now the playlist is stored as a model that is displayed in the playlist treeview. It’s quite nice in that I don’t have to convert between playlist and treeview internal representations any more because changes to the playlist automatically show up in the treeview. The program is also more stable now. It’s all quite nice. I still need to find a nice C# mp3 tag library, though; if anyone knows one could they tell me.
I have been using Swing recently, as well as Gtk. Swing also uses a variation of MVC to store items for many of its widgets. I’ve been using the Table and TableModel classes of Swing to present some data.
A quick detour into what MVC is, for those of you confused by all this talk. It stands for Model View Controller and is a method of managing the data shown by the GUI. The idea is that you store the data in the model. I.e. the Model models some data you want to display. Then the View knows how to display the Model. Finally the Controller makes changes to the Model in response to user actions. This splits the responsibilities into neat, separate concerns that can be separately implemented. It is nice because it helps to avoid very messy code where logic is combined with display code is combined with modification code.
The main thing I’ve noticed is how simplistic the native Windows controls are in comparison to both Gtk and Swing. I would guess this is so they draw fast. In addition, the simplicity of the Windows controls makes small applications easier to do because you don’t have to do a lot of under-the-hood plumbing code. This is one area where Gtk falls down: the learning curve is pretty steep and you have to do a fair amount of plumbing code. I think each approach has its good and bad aspects. At the moment, however, I’m enjoying Gtk with its complexity. When it all comes together it’s very neat, and I like neat.
I think this is an example about how Windows is designed to be easy to code for. Simple things are easier to grasp. I’m still having a terrible time trying to get my head around all the aspects of the Gtk treeview after two evenings. Still, it’s fun to learn these things, and hopefully I’ll come out better for it.
I’ll let you know how it goes.