diff options
author | Eduardo Silva <edsiper@gmail.com> | 2007-08-21 16:18:38 (GMT) |
---|---|---|
committer | Eduardo Silva <edsiper@gmail.com> | 2007-08-21 16:18:38 (GMT) |
commit | 2ed32d1a11670cd2593c77cc13826579cba597d8 (patch) | |
tree | 3a8f1611acc441354fbd3eb23d9970c7a62d1c05 /services/console/lib/purk/scripts/ui_script.py | |
parent | 7215de2dfcbeb03f88ff03c49e6a743965a62157 (diff) |
DevConsole: New IRC Client interface
Diffstat (limited to 'services/console/lib/purk/scripts/ui_script.py')
-rw-r--r-- | services/console/lib/purk/scripts/ui_script.py | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/services/console/lib/purk/scripts/ui_script.py b/services/console/lib/purk/scripts/ui_script.py new file mode 100644 index 0000000..459de96 --- /dev/null +++ b/services/console/lib/purk/scripts/ui_script.py @@ -0,0 +1,132 @@ +import irc +import ui +import windows +import irc_script +from conf import conf + +# FIXME: meh still might want rid of these, I'm not sure yet + +def onActive(e): + e.window.activity = None + + ui.register_idle(windows.manager.set_title) + +def setupNick(e): + if e.source == e.network.me: + for w in windows.get_with(core.manager, network=e.network): + try: + w.nick_label.update(e.target) + except AttributeError: + pass + +def onExit(e): + for n in set(w.network for w in windows.manager): + if n: + n.quit() + +def setupJoin(e): + if e.source == e.network.me: + window = windows.get(windows.StatusWindow, e.network, 'status', core) + + if window and not conf.get('status'): + window.mutate(windows.ChannelWindow, e.network, e.target) + else: + window = windows.new(windows.ChannelWindow, e.network, e.target, core) + + if e.requested: + window.activate() + + e.window = windows.get(windows.ChannelWindow, e.network, e.target, core) or e.window + +def setupText(e): + if e.target == e.network.me: + e.window = windows.new(windows.QueryWindow, e.network, e.source, core) + else: + e.window = \ + windows.get(windows.ChannelWindow, e.network, e.target, core) or \ + windows.get(windows.QueryWindow, e.network, e.source, core) or \ + e.window + +setupAction = setupText + +def setupNotice(e): + if e.target != e.network.me: + e.window = \ + windows.get(windows.ChannelWindow, e.network, e.target, core) or e.window + +def setupOwnText(e): + e.window = \ + windows.get(windows.ChannelWindow, e.network, e.target, core) or \ + windows.get(windows.QueryWindow, e.network, e.target, core) or \ + e.window + +setupOwnAction = setupOwnText + +def setdownPart(e): + if e.source == e.network.me: + window = windows.get(windows.ChannelWindow, e.network, e.target, core) + + if window: + cwindows = list(windows.get_with( + network=window.network, + wclass=windows.ChannelWindow + )) + + if len(cwindows) == 1 and not list(windows.get_with(network=window.network, wclass=windows.StatusWindow)): + window.mutate(windows.StatusWindow, e.network, 'status') + if e.requested: + window.activate() + elif e.requested: + window.close() + +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 onConnecting(e): + return + window = windows.get_default(e.network) + if window: + window.update() + +onDisconnect = onConnecting + +def setupPart(e): + e.window = windows.get(windows.ChannelWindow, e.network, e.target, core) or e.window + +setupTopic = setupPart + +def setupKick(e): + e.window = windows.get(windows.ChannelWindow, e.network, e.channel, core) or e.window + +def setupMode(e): + if e.target != e.network.me: + e.window = windows.get(windows.ChannelWindow, e.network, e.target, core) or e.window + +def onWindowMenu(e): + if isinstance(e.window, windows.ChannelWindow): + e.channel = e.window.id + e.network = e.window.network + core.events.trigger('ChannelMenu', e) |