[Gtk-sharp-list] GTK# Code Structure
foxandxss at gmail.com
Sat May 16 06:17:07 EDT 2009
Hello Andy, thank you for the answer.
I'm using WPF for the GUI. WPF helps with the code structure. I will explain
With MVP, every View or UserControl has Presenter. The presenter does all
the view job, like managing events (the view will delegate the event to the
presenter). The presenter talks to the view and to the model. The mainView
has the MainPresenter. This presenter does the main job of the application
and the other presenters give the data of the other presenters' views to it
and the MainPresenter does the job.
The advantage of using MVP on WPF is the DataContext, I can "attach" a
Presenter to the View with the DataContext property of the View and the view
can talk to the objects of the Presenter directly.
On the other hand, in Linux I prefer GTK# over WinForms. I have experiencie
with GTK+ but I learnt how to structure my code with WPF and I don't know if
this pattern will fit on GTK#.
And yes, I can use the same model / presenter in a GTK# application, but I
have to figure out the best way to handle the view / presenter communication
without the DataContext.
Thanks for your answer again :)
2009/5/16 Andy Selvig <ajselvig at gmail.com>
> Without knowing exactly what sort of code structure you're doing or what
> GUI toolkit you're using, it's difficult to give an exact answer. Basically,
> though, the Gtk# controls behave much like WinForms controls. That is, in
> the view you create controls, place them on screen, and attach handlers for
> their interaction events. The placement is different (better) in that it's
> using dynamic containers instead of statically specifying their coordinates.
> As for MVP, I briefly read over the Wikipedia article but don't have a firm
> idea of what differentiates a Controller from a Presenter. But, it seems
> like the concept applies just as well to Gtk#. You can make your view (a
> Window or custom control) implement some interface that the presenter
> expects, then tie have your view tie it's interaction events to handlers in
> the presenter. In fact, assuming that your model and presenter code don't
> contain anything specific to WinForms, it should be fairly straightforward
> to use the same model/presenter code with a new Gtk# view. The primary
> project that I'm working on uses this method (I call it a controller, but
> same idea), with the same controller working with a WPF view on Windows and
> a Gtk# view on Linux.
> Also keep in mind that Mono provides a full implementation of WinForms,
> although folks on this list will generally prefer Gtk#. If you have any more
> detailed questions, we'd be glad to help.
> On Fri, May 15, 2009 at 5:21 PM, Jesus Rodriguez <foxandxss at gmail.com>wrote:
>> Hello there :)
>> I have a little question about GTK# programming. I am a Windows developer
>> using .NET. Well, I Use MVP (a MVC variation) for the code structure, that
>> is, for separating the view from the business logic using an intermediate
>> presenter (a kind of controller).
>> How do you people make the code structure of your GTK# application?
>> I remember that my GTK# was hell :P
>> Thanks in advance for your help.
>> Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gtk-sharp-list