def run(self): try: self.window = MainWindow() self.window.show_all() Gtk.main() except: async_engine_command('stop') raise
def on_command_keydown(self, widget, event): command = self.keymap.gtk_event(event) if command is None: return False log.info('key command: {0}'.format(command)) if command == 'send-buffer': text_buffer = self.command_entry.get_buffer() message = text_buffer.get_text(text_buffer.get_start_iter(), text_buffer.get_end_iter(), True).strip() log.info('message: {0}'.format(message)) channel_window = self.current_channel async_engine_command('send', channel_window.network, (channel_window.channel, message)) text_buffer.set_text('') return True elif command == 'window-next': l = [] for n in self.network_channels: for c in self.network_channels[n]: l.append(self.network_channels[n][c]) p = l.index(self.current_channel) + 1 if p == len(l): self.set_channel(l[0]) else: self.set_channel(l[p]) elif command == 'window-previous': l = [] for n in self.network_channels: for c in self.network_channels[n]: l.append(self.network_channels[n][c]) p = l.index(self.current_channel) - 1 if p < 0: self.set_channel(l[-1]) else: self.set_channel(l[p]) elif command == 'quit': self.stop() else: method = command.replace('-', '_') method = getattr(self, method, None) if method is not None: method() return True
def run(self): try: async_engine_command('connect') while self.running: while True: message_type, network, content = self.next_message() if message_type is None: break if message_type == 'print' or message_type == 'debug': print '{0}: {1}'.format(network, content) elif message_type == 'stopped': print 'ui received engine stopped' self.running = False else: source, target, arguments = content print '{0}: {1} from {2} to {3} with {4}'.format(network, message_type, source, target, arguments) r, w, x = select.select([sys.stdin,], [], [], 0.01) if r: command = sys.stdin.readline().strip() if command == '': pass elif command == 'quit': async_engine_command('stop') else: async_engine_command('raw', '*', command) except Exception as e: async_engine_command('stop') raise
def stop(self, widget=None, event=None): async_engine_command('stop')
def start(self, widget): async_engine_command('connect')