def server(server=None, port=6667, network=None, connect=True): network_info = {} if server: network_info["name"] = server network_info["server"] = server if port: network_info["port"] = port get_network_info(server, network_info) if not network: network = irc.Network(**network_info) windows.new(windows.StatusWindow, network, "status").activate() else: if "server" in network_info: network.name = network_info['name'] network.server = network_info['server'] if not network.status: window = windows.get_default(network, core.manager) if window: window.update() if "port" in network_info: network.port = network_info["port"] if network.status: network.quit() if connect: network.connect() #core.window.write("* Connecting to %s on port %s" % (network.server, network.port)) windows.get_default(network, core.manager).write( "* Connecting to %s on port %s" % (network.server, network.port) ) return network
def onClose(e): nwindows = list(windows.get_with(core.manager, network=e.window.network)) if isinstance(e.window, windows.ChannelWindow): cwindows = list( windows.get_with(core.manager, network=e.window.network, wclass=windows.ChannelWindow)) #if we only have one window for the network, don't bother to part as # we'll soon be quitting anyway if len(nwindows) != 1 and irc_script.ischan(e.window.network, e.window.id): e.window.network.part(e.window.id) if len(nwindows) == 1: core.events.trigger("CloseNetwork", window=e.window, network=e.window.network) elif isinstance(e.window, windows.StatusWindow) and conf.get('status'): core.events.trigger("CloseNetwork", window=e.window, network=e.window.network) for window in nwindows: if window != e.window: window.close() if len(core.manager) == 1: windows.new(windows.StatusWindow, irc.Network(), "status", core)
def onKeyPress(e): if e.key in shortcuts: e.window.input.insert(shortcuts[e.key]) elif e.key == '!c': e.window.output.copy() elif e.key == 'Page_Up': e.window.output.y = e.window.output.y - e.window.output.height / 2 elif e.key == 'Page_Down': e.window.output.y = e.window.output.y + e.window.output.height / 2 elif e.key == '^Home': e.window.output.y = 0 elif e.key == '^End': e.window.output.y = e.window.output.ymax elif e.key in ('^Page_Up', '^Page_Down'): winlist = list(windows.manager) index = winlist.index(e.window) + ((e.key == '^Page_Down') and 1 or -1) if 0 <= index < len(winlist): winlist[index].activate() elif e.key == '!a': winlist = list(windows.manager) winlist = winlist[winlist.index(e.window):] + winlist w = [w for w in winlist if widgets.HILIT in w.activity] if not w: w = [w for w in winlist if widgets.TEXT in w.activity] if w: windows.manager.set_active(w[0]) # tabbed browsing elif e.key == '^t': windows.new(windows.StatusWindow, irc.Network(core), 'status', core).activate() elif e.key == '^w': windows.manager.get_active().close() elif e.key == '^f': window = windows.manager.get_active() find = widgets.FindBox(window) window.pack_start(find, expand=False) find.textbox.grab_focus() elif len(e.key) == 2 and e.key.startswith('!') and e.key[1].isdigit(): n = int(e.key[1]) if n and n <= len(core.manager): list(core.manager)[n - 1].activate()
def __init__(self, activity): self.window = None self.trigger = Trigger() self.events = self.trigger.events self.manager = widgets.UrkUITabs(self) self.channels = [] mods = self.trigger.get_modules() for m in mods: m.core = self m.manager = self.manager if not self.window: self.window = windows.new( windows.StatusWindow, irc.Network(self, activity), "status", self) self.window.activate()