Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFran Rogers <fran@dumetella.net>2010-11-21 15:50:13 (GMT)
committer Fran Rogers <fran@dumetella.net>2010-11-21 15:50:13 (GMT)
commit755896c11d315fdb8afbf2b5d67952f0d5ae1023 (patch)
treeef2b03a9376e9c70a1dea6953456c6c8ef6881c7
parentd253a425994ef476c5e260fcf1b233d28e0562b3 (diff)
Test whether a window is a channel/query using explicit methods, not isinstance()
-rw-r--r--ircactivity.py6
-rw-r--r--purk/scripts/irc_script.py12
-rw-r--r--purk/windows.py12
3 files changed, 21 insertions, 9 deletions
diff --git a/ircactivity.py b/ircactivity.py
index 310485f..ed5f245 100644
--- a/ircactivity.py
+++ b/ircactivity.py
@@ -87,11 +87,11 @@ class IRCActivity(activity.Activity):
self.client.core.window.network.requested_joins = set()
for winid in data['scrollback'].keys():
if winid in data['channels']:
- win = purk.windows.new(purk.windows.ChannelWindow,
+ win = purk.windows.new(windows.ChannelWindow,
self.client.core.window.network,
winid, self.client.core)
else:
- win = purk.windows.new(purk.windows.QueryWindow,
+ win = purk.windows.new(windows.QueryWindow,
self.client.core.window.network,
winid, self.client.core)
win.output.get_buffer().set_text(data['scrollback'][winid])
@@ -116,7 +116,7 @@ class IRCActivity(activity.Activity):
win = self.client.core.manager.tabs.get_nth_page(i)
if win.id == "status":
continue
- if hasattr(win, 'nicklist'):
+ if win.is_channel():
data['channels'].append(win.id)
buf = win.output.get_buffer()
data['scrollback'][win.id] = buf.get_text(buf.get_start_iter(), buf.get_end_iter(), True)
diff --git a/purk/scripts/irc_script.py b/purk/scripts/irc_script.py
index ea67b25..41e9075 100644
--- a/purk/scripts/irc_script.py
+++ b/purk/scripts/irc_script.py
@@ -244,7 +244,7 @@ def setupInput(e):
e.done = True
def onCommandSay(e):
- if isinstance(e.window, windows.ChannelWindow) or isinstance(e.window, windows.QueryWindow):
+ if e.window.is_query() or e.window.is_channel():
e.network.msg(e.window.id, ' '.join(e.args))
else:
raise core.events.CommandError("There's no one here to speak to.")
@@ -271,7 +271,7 @@ def onCommandQuery(e):
e.network.msg(e.args[0], ' '.join(e.args[1:]))
def onCommandAction(e):
- if isinstance(e.window, windows.ChannelWindow) or isinstance(e.window, windows.QueryWindow):
+ if e.window.is_query() or e.window.is_channel():
e.network.msg(e.window.id, '\x01ACTION ' + ' '.join(e.args) + '\x01')
else:
raise core.events.CommandError("There's no one here to speak to.")
@@ -350,7 +350,7 @@ def onCommandJoin(e):
e.network.join(' '.join(e.args), requested = 'n' not in e.switches)
else:
raise core.events.CommandError("We're not connected.")
- elif isinstance(e.window, windows.ChannelWindow):
+ elif e.window.is_channel():
e.window.network.join(e.window.id, requested = 'n' not in e.switches)
else:
raise core.events.CommandError("You must supply a channel.")
@@ -363,7 +363,7 @@ def onCommandPart(e):
e.network.part(' '.join(e.args), requested = 'n' not in e.switches)
else:
raise core.events.CommandError("We're not connected.")
- elif isinstance(e.window, windows.ChannelWindow):
+ elif e.window.is_channel():
e.window.network.part(e.window.id, requested = 'n' not in e.switches)
else:
raise core.events.CommandError("You must supply a channel.")
@@ -375,7 +375,7 @@ def onCommandHop(e):
e.network.join(' '.join(e.args), requested = False)
else:
raise core.events.CommandError("We're not connected.")
- elif isinstance(e.window, windows.ChannelWindow):
+ elif e.window.is_channel():
e.window.network.part(e.window.id, requested = False)
e.window.network.join(e.window.id, requested = False)
else:
@@ -516,7 +516,7 @@ needschan = {
def setupCommand(e):
if not e.done:
- if e.name in needschan and isinstance(e.window, windows.ChannelWindow):
+ if e.name in needschan and e.window.is_channel():
valid_chan_prefixes = e.network.isupport.get('CHANTYPES', '#&+')
chan_pos = needschan[e.name]
diff --git a/purk/windows.py b/purk/windows.py
index 2e3c1fa..b48630b 100644
--- a/purk/windows.py
+++ b/purk/windows.py
@@ -141,6 +141,12 @@ class Window(gtk.VBox):
self.rawid = id
self.__activity = set()
+
+ def is_query(self):
+ return False
+
+ def is_channel(self):
+ return False
class SimpleWindow(Window):
def __init__(self, network, id, core):
@@ -215,6 +221,9 @@ class QueryWindow(Window):
self.show_all()
+ def is_query(self):
+ return True
+
def move_nicklist(paned, event):
paned._moving = (
event.type == gtk.gdk._2BUTTON_PRESS,
@@ -285,3 +294,6 @@ class ChannelWindow(Window):
self.pack_end(pane)
self.show_all()
+
+ def is_channel(self):
+ return True