diff options
author | Florent Le Coz <louiz@louiz.org> | 2011-02-14 14:37:36 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2011-02-14 14:37:36 +0100 |
commit | 3e550f4ae7ef13496fcc2e19ae406f324a2ee8e2 (patch) | |
tree | 4b3d63cd5783b118f6f8e70db8d3c958cc36eae6 | |
parent | ac99467965ba04282b6dbc63c5c04ab91ba1b007 (diff) | |
download | poezio-3e550f4ae7ef13496fcc2e19ae406f324a2ee8e2.tar.gz poezio-3e550f4ae7ef13496fcc2e19ae406f324a2ee8e2.tar.bz2 poezio-3e550f4ae7ef13496fcc2e19ae406f324a2ee8e2.tar.xz poezio-3e550f4ae7ef13496fcc2e19ae406f324a2ee8e2.zip |
Properly remove the info_win from the list of the
global information_buffer to make it Garbage Collected
when we close the tab
-rw-r--r-- | src/tabs.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/tabs.py b/src/tabs.py index 3c91fc14..aa5ccab3 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -259,6 +259,16 @@ class ChatTab(Tab): def command_say(self, line): raise NotImplementedError +class TabWithInfoWin(Tab): + def __init__(self): + self.info_win = windows.TextWin() + self.core.information_buffer.add_window(self.info_win) + + def __del__(self): + self.core.information_buffer.del_window(self.info_win) + del self.info_win + Tab.__del__(self) + class InfoTab(ChatTab): """ The information tab, used to display global informations @@ -267,8 +277,6 @@ class InfoTab(ChatTab): def __init__(self, core): Tab.__init__(self, core) self.tab_win = windows.GlobalInfoBar() - self.info_win = windows.TextWin() - self.core.information_buffer.add_window(self.info_win) self.input = windows.Input() self.name = "Info" self.color_state = theme.COLOR_TAB_NORMAL @@ -338,21 +346,20 @@ class InfoTab(ChatTab): def on_close(self): return -class MucTab(ChatTab): +class MucTab(ChatTab, TabWithInfoWin): """ The tab containing a multi-user-chat room. It contains an userlist, an input, a topic, an information and a chat zone """ def __init__(self, core, room): ChatTab.__init__(self, core, room) + TabWithInfoWin.__init__(self) self.topic_win = windows.Topic() self.text_win = windows.TextWin() room.add_window(self.text_win) self.v_separator = windows.VerticalSeparator() self.user_win = windows.UserList() self.info_header = windows.MucInfoWin() - self.info_win = windows.TextWin() - self.core.information_buffer.add_window(self.info_win) self.tab_win = windows.GlobalInfoBar() self.input = windows.MessageInput() self.ignores = [] # set of Users @@ -662,17 +669,16 @@ class MucTab(ChatTab): def on_close(self): return -class PrivateTab(ChatTab): +class PrivateTab(ChatTab, TabWithInfoWin): """ The tab containg a private conversation (someone from a MUC) """ def __init__(self, core, room): ChatTab.__init__(self, core, room) + TabWithInfoWin.__init__(self) self.text_win = windows.TextWin() room.add_window(self.text_win) self.info_header = windows.PrivateInfoWin() - self.info_win = windows.TextWin() - self.core.information_buffer.add_window(self.info_win) self.tab_win = windows.GlobalInfoBar() self.input = windows.MessageInput() # keys @@ -1043,21 +1049,20 @@ class RosterInfoTab(Tab): def on_close(self): return -class ConversationTab(ChatTab): +class ConversationTab(ChatTab, TabWithInfoWin): """ The tab containg a normal conversation (not from a MUC) """ def __init__(self, core, jid): txt_buff = text_buffer.TextBuffer() ChatTab.__init__(self, core, txt_buff) + TabWithInfoWin.__init__(self) self.color_state = theme.COLOR_TAB_NORMAL self._name = jid # a conversation tab is linked to one specific full jid OR bare jid self.text_win = windows.TextWin() txt_buff.add_window(self.text_win) self.upper_bar = windows.ConversationStatusMessageWin() self.info_header = windows.ConversationInfoWin() - self.info_win = windows.TextWin() - self.core.information_buffer.add_window(self.info_win) self.tab_win = windows.GlobalInfoBar() self.input = windows.MessageInput() # keys |