Commit af395c1

mo khan <mokha@cisco.com>
2014-02-14 03:46:53
replace application shell with proxy to actual window.
1 parent 8d7a061
lib/presentation/presenters/application_shell_presenter.rb
@@ -7,7 +7,7 @@ class ApplicationShellPresenter
   def present
     @view.set_title("Hello World")
     @view.bind_to(self)
-    Build.menu_bar.with(File.menu(@event_aggregator)).add_to(@view)
+    #Build.menu_bar.with(File.menu(@event_aggregator)).add_to(@view)
     @view.show_all
   end
 
lib/presentation/windows/application_shell.rb
@@ -1,15 +1,41 @@
 require "window"
 
-class ApplicationShell < Window
+#class ApplicationShell < Window
+  #def initialize
+    #super
+    #modify_bg(Gtk::STATE_NORMAL, Gdk::Color.new(6400, 6400, 6440))
+    #self.maximize
+  #end
+
+  #def bind_to(presenter)
+    #self.on(:destroy) do
+      #presenter.shutdown
+    #end
+  #end
+#end
+
+class ApplicationShell
   def initialize
-    super
-    modify_bg(Gtk::STATE_NORMAL, Gdk::Color.new(6400, 6400, 6440))
-    self.maximize
+    builder = Gtk::Builder.new
+    file = File.join(File.dirname(__FILE__), 'tutorial.xml')
+    builder.add_from_file(file)
+    builder.connect_signals { |signal| Proc.new { publish(signal) } }
+    @window = builder.get_object('window')
+  end
+
+  def set_title(title)
+    @window.set_title(title)
+  end
+
+  def show_all
+    @window.show_all
   end
 
   def bind_to(presenter)
-    self.on(:destroy) do
-      presenter.shutdown
-    end
+    @presenter = presenter
+  end
+
+  def publish(signal)
+    @presenter.public_send(signal)
   end
 end
lib/presentation/windows/tutorial.xml
@@ -4,7 +4,7 @@
   <object class="GtkWindow" id="window">
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">GTK+ Text Editor</property>
-    <signal handler="on_window_destroy" name="destroy" swapped="no"/>
+    <signal handler="shutdown" name="destroy" swapped="no"/>
     <child>
       <object class="GtkVBox" id="vbox1">
         <property name="visible">True</property>
lib/application.rb
@@ -10,10 +10,11 @@ end
 class Application
   def run(arguments)
     Gtk.init
+
     container = Spank::Container.new
     ContainerConfiguration.then(EventsRegistration).run(container)
-
-    container.resolve(:shell_presenter).present
+    presenter = container.resolve(:shell_presenter)
+    presenter.present
     Gtk.main
   end
 end