Exemplo n.º 1
0
class ApplicationGTK:
    _controller = None
    _logger = None
    _configuration = None
    
    _threadtest = None


    def __init__(self):
        self._controller = ApplicationDownloader()
        self._controller.ConfigurationCreationCallbacks.append(self.configurationCreated)
        self._controller.LoggerCreationCallbacks.append(self.loggerCreated)
        #self._controller.ConfigurationCreation += self.configurationCreated
        #self._controller.LoggerCreation += self.loggerCreated
          
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)
        self.window.set_size_request(300, 200)
        self.window.set_border_width(2)
        
        self.button = gtk.Button("Hello World")
        self.button.connect("clicked", self.hello, None)
        self.button.connect_object("clicked", gtk.Widget.destroy, self.window)
        
        #self.window.add(self.button)
        
        #self.button.show() 
        self.window.set_title("BinDownloader")
        self.window.show()
        
   
    def hello(self,widget, data=None):
        #print "hello clicked"
        pass


    def destroy(self, widget, data=None):
        self._controller.stop_process()
        #self._threadtest.stop_process()
        gtk.main_quit()
        
    def delete_event(self, widget, event, data=None):
        #print "delete event occurred"

        # Change FALSE to TRUE and the main window will not be destroyed
        # with a "delete_event".
        return False
    
    def configurationCreated(self, caller, configuration):
        self._configuration = ConfigurationGTK(configuration)
        
    def loggerCreated(self, caller, logger):
        #warn("ApplicationGTK.loggerCreated()")
        self._logger = LoggerGTK(logger)
        gobject.idle_add(self.window.add, self._logger._gui)
        
    def __str__(self):
        return "<ApplicationGTK instance>"

    def main(self):
        gobject.threads_init()

        self._controller.start()

        gtk.main()