Commit cff34af

mo khan <mo@mokhan.ca>
2013-12-08 01:18:58
extract presenter for main shell.
1 parent 6a89526
Changed files (3)
lib/presentation/presenters/application_shell_presenter.rb
@@ -0,0 +1,16 @@
+class ApplicationShellPresenter
+  def initialize(view)
+    @view = view
+  end
+
+  def present
+    @view.set_title("Hello World")
+    @view.set_title("Hello World")
+    @view.signal_connect "destroy" do
+      Gtk.main_quit
+    end
+    @view.set_default_size 250, 200
+    @view.set_window_position Gtk::Window::POS_CENTER
+    @view.show_all
+  end
+end
lib/presentation/windows/application_shell.rb
@@ -1,12 +1,5 @@
 class ApplicationShell < Gtk::Window
   def initialize
     super
-    set_title("Hello World")
-    signal_connect "destroy" do
-      Gtk.main_quit
-    end
-    set_default_size 250, 200
-    set_window_position Gtk::Window::POS_CENTER
-    show
   end
 end
lib/application.rb
@@ -1,10 +1,12 @@
 require 'gtk2'
 require 'presentation/windows/application_shell'
+require 'presentation/presenters/application_shell_presenter'
 
 class Application
   def run(arguments)
     Gtk.init
-    ApplicationShell.new
+    presenter = ApplicationShellPresenter.new(ApplicationShell.new)
+    presenter.present
     Gtk.main
   end
 end