예제 #1
0
파일: __init__.py 프로젝트: hendiko/pyranha
class GtkUI(UserInterface):

    def __init__(self):
        GObject.threads_init()
        Gdk.threads_init()
        super(GtkUI, self).__init__()

    def async_message(self, message_type, network=None, content=None):
        """Override the default async_message implementation to tell Gtk's main loop
        to run process_message with the given message attributes."""
        GObject.idle_add(self.process_message, (message_type, network, content))

    def run(self):
        try:
            self.window = MainWindow()
            self.window.show_all()
            Gtk.main()
        except:
            async_engine_command('stop')
            raise

    def process_message(self, (message_type, network, content)):
        if message_type == 'stopped':
            Gtk.main_quit()

        elif message_type == 'focus-entry':
            self.window.command_entry.grab_focus()

        elif message_type == 'new_channel':
            self.window.on_new_channel(network, content)

        elif message_type == 'message':
            self.window.on_message(network, content)
예제 #2
0
파일: __init__.py 프로젝트: hendiko/pyranha
 def run(self):
     try:
         self.window = MainWindow()
         self.window.show_all()
         Gtk.main()
     except:
         async_engine_command('stop')
         raise