[MonoDevelop] Use of partial classes with the Stetic GUI designer
lluis at ximian.com
Mon Jan 15 11:33:35 EST 2007
I just committed a patch which adds support for generating the Stetic
gui code in partial classes. It means that for every window or dialog in
a project, MD will create one partial class split in two files. One
partial class will be implemented by the programmer, and will contain
the signal handlers and all the logic of the window. The other partial
class is generated by stetic in the hidden gtk-gui folder, and contains
a the Build method that creates the contents of the window, as well as
field members for all widgets and menu actions. As a result of this
change, the infamous "Bind to Field" button is not needed anymore, since
all widgets are automatically bound to fields.
MonoDevelop still supports the old way of generating code without
partial classes, and this mode will be used to keep old projects
buildable, and to support languages which don't have partial classes.
So, old projects should still build without errors, since MD will use
the old mode. HOWEVER, MD will now always generate one file for each
window in the gtk-gui folder. If your project is under version control,
don't forget to add it to your repository.
In case you want to convert your project to the partial class mode,
you'll have to do some manual changes:
* Open the .mdp file of your project in a text editor, look for
the GtkDesignInfo xml element, and add a partialTypes attribute
* After this change, open the project in MD, and for each
window/dialog/custom widget do the following:
* add the "partial" keyword to the class
* replace the call to Stetic.Gui.Build(...) call by a
simple this.Build() call (without parameters).
* Remove all fields bound to widgets (since those are now
generated in the partial class).
More information about the Monodevelop-list