groupchat window is now also a subclass of chat class
This commit is contained in:
parent
c1a075785b
commit
3967d11750
4 changed files with 72 additions and 316 deletions
|
@ -37,8 +37,6 @@ gtk.glade.textdomain(APP)
|
||||||
|
|
||||||
GTKGUI_GLADE='plugins/gtkgui/gtkgui.glade'
|
GTKGUI_GLADE='plugins/gtkgui/gtkgui.glade'
|
||||||
|
|
||||||
#the child of the tab must be called tab_vbox
|
|
||||||
|
|
||||||
class chat:
|
class chat:
|
||||||
"""Class for tabbed chat window"""
|
"""Class for tabbed chat window"""
|
||||||
def __init__(self, plugin, account, widget_name):
|
def __init__(self, plugin, account, widget_name):
|
||||||
|
@ -56,6 +54,7 @@ class chat:
|
||||||
self.last_message_time = {}
|
self.last_message_time = {}
|
||||||
self.print_time_timeout_id = {}
|
self.print_time_timeout_id = {}
|
||||||
self.names = {} # what is printed in the tab : user.name for example
|
self.names = {} # what is printed in the tab : user.name for example
|
||||||
|
self.childs = {}
|
||||||
self.window = self.xml.get_widget(widget_name)
|
self.window = self.xml.get_widget(widget_name)
|
||||||
|
|
||||||
def update_tags(self):
|
def update_tags(self):
|
||||||
|
@ -102,7 +101,7 @@ class chat:
|
||||||
start = "[" + str(self.nb_unread[jid]) + "] "
|
start = "[" + str(self.nb_unread[jid]) + "] "
|
||||||
elif self.nb_unread[jid] == 1:
|
elif self.nb_unread[jid] == 1:
|
||||||
start = "* "
|
start = "* "
|
||||||
child = self.xmls[jid].get_widget('tab_vbox')
|
child = self.childs[jid]
|
||||||
tab_label = self.notebook.get_tab_label(child).get_children()[0]
|
tab_label = self.notebook.get_tab_label(child).get_children()[0]
|
||||||
tab_label.set_text(start + self.names[jid])
|
tab_label.set_text(start + self.names[jid])
|
||||||
|
|
||||||
|
@ -120,8 +119,7 @@ class chat:
|
||||||
self.notebook.get_current_page())
|
self.notebook.get_current_page())
|
||||||
active_jid = ''
|
active_jid = ''
|
||||||
for jid in self.xmls:
|
for jid in self.xmls:
|
||||||
child = self.xmls[jid].get_widget('tab_vbox')
|
if self.childs[jid] == active_child:
|
||||||
if child == active_child:
|
|
||||||
active_jid = jid
|
active_jid = jid
|
||||||
break
|
break
|
||||||
return active_jid
|
return active_jid
|
||||||
|
@ -152,8 +150,7 @@ class chat:
|
||||||
new_child = notebook.get_nth_page(page_num)
|
new_child = notebook.get_nth_page(page_num)
|
||||||
new_jid = ''
|
new_jid = ''
|
||||||
for jid in self.xmls:
|
for jid in self.xmls:
|
||||||
child = self.xmls[jid].get_widget('tab_vbox')
|
if self.childs[jid] == new_child:
|
||||||
if child == new_child:
|
|
||||||
new_jid = jid
|
new_jid = jid
|
||||||
break
|
break
|
||||||
conversation_textview = self.xmls[new_jid].\
|
conversation_textview = self.xmls[new_jid].\
|
||||||
|
@ -171,9 +168,8 @@ class chat:
|
||||||
self.plugin.systray.remove_jid(new_jid, self.account)
|
self.plugin.systray.remove_jid(new_jid, self.account)
|
||||||
|
|
||||||
def active_tab(self, jid):
|
def active_tab(self, jid):
|
||||||
child = self.xmls[jid].get_widget('tab_vbox')
|
|
||||||
self.notebook.set_current_page(\
|
self.notebook.set_current_page(\
|
||||||
self.notebook.page_num(child))
|
self.notebook.page_num(self.childs[jid]))
|
||||||
|
|
||||||
def remove_tab(self, jid, kind): #kind is 'chats' or 'gc'
|
def remove_tab(self, jid, kind): #kind is 'chats' or 'gc'
|
||||||
if len(self.xmls) == 1:
|
if len(self.xmls) == 1:
|
||||||
|
@ -182,9 +178,8 @@ class chat:
|
||||||
if self.print_time_timeout_id.has_key(jid):
|
if self.print_time_timeout_id.has_key(jid):
|
||||||
gobject.source_remove(self.print_time_timeout_id[jid])
|
gobject.source_remove(self.print_time_timeout_id[jid])
|
||||||
del self.print_time_timeout_id[jid]
|
del self.print_time_timeout_id[jid]
|
||||||
child = self.xmls[jid].get_widget('tab_vbox')
|
|
||||||
self.notebook.remove_page(\
|
self.notebook.remove_page(\
|
||||||
self.notebook.page_num(child))
|
self.notebook.page_num(self.childs[jid]))
|
||||||
del self.plugin.windows[self.account][kind][jid]
|
del self.plugin.windows[self.account][kind][jid]
|
||||||
del self.nb_unread[jid]
|
del self.nb_unread[jid]
|
||||||
del self.last_message_time[jid]
|
del self.last_message_time[jid]
|
||||||
|
@ -199,7 +194,6 @@ class chat:
|
||||||
def new_tab(self, jid):
|
def new_tab(self, jid):
|
||||||
self.nb_unread[jid] = 0
|
self.nb_unread[jid] = 0
|
||||||
self.last_message_time[jid] = 0
|
self.last_message_time[jid] = 0
|
||||||
self.xmls[jid] = gtk.glade.XML(GTKGUI_GLADE, 'tab_vbox', APP)
|
|
||||||
|
|
||||||
conversation_textview = \
|
conversation_textview = \
|
||||||
self.xmls[jid].get_widget('conversation_textview')
|
self.xmls[jid].get_widget('conversation_textview')
|
||||||
|
@ -246,14 +240,20 @@ class chat:
|
||||||
conversation_scrolledwindow.get_vadjustment().connect('value-changed', \
|
conversation_scrolledwindow.get_vadjustment().connect('value-changed', \
|
||||||
self.on_conversation_vadjustment_value_changed)
|
self.on_conversation_vadjustment_value_changed)
|
||||||
|
|
||||||
child = self.xmls[jid].get_widget('tab_vbox')
|
child = self.childs[jid]
|
||||||
self.notebook.append_page(child)
|
self.notebook.append_page(child)
|
||||||
if len(self.xmls) > 1:
|
if len(self.xmls) > 1:
|
||||||
self.notebook.set_show_tabs(True)
|
self.notebook.set_show_tabs(True)
|
||||||
|
|
||||||
|
xm = gtk.glade.XML(GTKGUI_GLADE, 'tab_hbox', APP)
|
||||||
|
tab_hbox = xm.get_widget('tab_hbox')
|
||||||
|
xm.signal_connect('on_close_button_clicked', \
|
||||||
|
self.on_close_button_clicked, jid)
|
||||||
|
self.notebook.set_tab_label(child, tab_hbox)
|
||||||
|
|
||||||
self.show_title()
|
self.show_title()
|
||||||
|
|
||||||
def on_chat_window_key_press_event(self, widget, event):
|
def on_chat_notebook_key_press_event(self, widget, event):
|
||||||
st = '1234567890' # zero is here cause humans count from 1, pc from 0 :P
|
st = '1234567890' # zero is here cause humans count from 1, pc from 0 :P
|
||||||
jid = self.get_active_jid()
|
jid = self.get_active_jid()
|
||||||
if event.keyval == gtk.keysyms.Escape: # ESCAPE
|
if event.keyval == gtk.keysyms.Escape: # ESCAPE
|
||||||
|
@ -301,7 +301,6 @@ class chat:
|
||||||
# we pressed a control key or ctrl+sth : we don't block the event
|
# we pressed a control key or ctrl+sth : we don't block the event
|
||||||
# in order to let ctrl+c do its work
|
# in order to let ctrl+c do its work
|
||||||
pass
|
pass
|
||||||
#FIXME: will not work with gc
|
|
||||||
else: # it's a normal key press make sure message_textview has focus
|
else: # it's a normal key press make sure message_textview has focus
|
||||||
message_textview = self.xmls[jid].get_widget('message_textview')
|
message_textview = self.xmls[jid].get_widget('message_textview')
|
||||||
if not message_textview.is_focus():
|
if not message_textview.is_focus():
|
||||||
|
|
|
@ -26,6 +26,8 @@ import time
|
||||||
import sre #usefull later
|
import sre #usefull later
|
||||||
|
|
||||||
from dialogs import *
|
from dialogs import *
|
||||||
|
from chat import *
|
||||||
|
from gtkgui import ImageCellRenderer
|
||||||
|
|
||||||
from common import i18n
|
from common import i18n
|
||||||
|
|
||||||
|
@ -36,7 +38,27 @@ gtk.glade.textdomain(APP)
|
||||||
|
|
||||||
GTKGUI_GLADE='plugins/gtkgui/gtkgui.glade'
|
GTKGUI_GLADE='plugins/gtkgui/gtkgui.glade'
|
||||||
|
|
||||||
class Groupchat_window:
|
class Groupchat_window(chat):
|
||||||
|
def __init__(self, room_jid, nick, plugin, account):
|
||||||
|
chat.__init__(self, plugin, account, 'groupchat_window')
|
||||||
|
self.nicks = {}
|
||||||
|
self.list_treeview = {}
|
||||||
|
self.subjects = {}
|
||||||
|
self.new_group(room_jid, nick)
|
||||||
|
self.show_title()
|
||||||
|
self.xml.signal_connect('on_groupchat_window_destroy', \
|
||||||
|
self.on_groupchat_window_destroy)
|
||||||
|
self.xml.signal_connect('on_groupchat_window_delete_event', \
|
||||||
|
self.on_groupchat_window_delete_event)
|
||||||
|
self.xml.signal_connect('on_groupchat_window_focus_in_event', \
|
||||||
|
self.on_groupchat_window_focus_in_event)
|
||||||
|
self.xml.signal_connect('on_chat_notebook_key_press_event', \
|
||||||
|
self.on_chat_notebook_key_press_event)
|
||||||
|
self.xml.signal_connect('on_chat_notebook_switch_page', \
|
||||||
|
self.on_chat_notebook_switch_page)
|
||||||
|
self.xml.signal_connect('on_set_button_clicked', \
|
||||||
|
self.on_set_button_clicked)
|
||||||
|
|
||||||
def on_groupchat_window_delete_event(self, widget, event):
|
def on_groupchat_window_delete_event(self, widget, event):
|
||||||
"""close window"""
|
"""close window"""
|
||||||
for room_jid in self.xmls:
|
for room_jid in self.xmls:
|
||||||
|
@ -50,20 +72,14 @@ class Groupchat_window:
|
||||||
for room_jid in self.xmls:
|
for room_jid in self.xmls:
|
||||||
self.plugin.send('GC_STATUS', self.account, (self.nicks[room_jid], \
|
self.plugin.send('GC_STATUS', self.account, (self.nicks[room_jid], \
|
||||||
room_jid, 'offline', 'offline'))
|
room_jid, 'offline', 'offline'))
|
||||||
del self.plugin.windows[self.account]['gc'][room_jid]
|
chat.on_window_destroy(self, widget, 'gc')
|
||||||
if self.plugin.windows[self.account]['gc'].has_key('tabbed'):
|
|
||||||
del self.plugin.windows[self.account]['gc']['tabbed']
|
|
||||||
|
|
||||||
def update_tags(self):
|
def on_groupchat_window_focus_in_event(self, widget, event):
|
||||||
for room_jid in self.tagIn:
|
"""When window get focus"""
|
||||||
self.tagIn[room_jid].set_property('foreground', \
|
chat.on_chat_window_focus_in_event(self, widget, event)
|
||||||
self.plugin.config['inmsgcolor'])
|
|
||||||
self.tagInBold[room_jid].set_property('foreground', \
|
def on_chat_notebook_key_press_event(self, widget, event):
|
||||||
self.plugin.config['inmsgcolor'])
|
chat.on_chat_notebook_key_press_event(self, widget, event)
|
||||||
self.tagOut[room_jid].set_property('foreground', \
|
|
||||||
self.plugin.config['outmsgcolor'])
|
|
||||||
self.tagStatus[room_jid].set_property('foreground', \
|
|
||||||
self.plugin.config['statusmsgcolor'])
|
|
||||||
|
|
||||||
def get_role_iter(self, room_jid, role):
|
def get_role_iter(self, room_jid, role):
|
||||||
model = self.list_treeview[room_jid].get_model()
|
model = self.list_treeview[room_jid].get_model()
|
||||||
|
@ -179,43 +195,6 @@ class Groupchat_window:
|
||||||
img = self.plugin.roster.pixbufs[show]
|
img = self.plugin.roster.pixbufs[show]
|
||||||
model.set_value(iter, 0, img)
|
model.set_value(iter, 0, img)
|
||||||
|
|
||||||
def show_title(self):
|
|
||||||
"""redraw the window's title"""
|
|
||||||
unread = 0
|
|
||||||
for room_jid in self.nb_unread:
|
|
||||||
unread += self.nb_unread[room_jid]
|
|
||||||
start = ""
|
|
||||||
if unread > 1:
|
|
||||||
start = "[" + str(unread) + "] "
|
|
||||||
elif unread == 1:
|
|
||||||
start = "* "
|
|
||||||
chat = 'Groupchat in ' + room_jid
|
|
||||||
if len(self.xmls) > 1:
|
|
||||||
chat = 'Groupchat'
|
|
||||||
self.window.set_title(start + chat + ' (' + self.account + ')')
|
|
||||||
|
|
||||||
def redraw_tab(self, room_jid):
|
|
||||||
"""redraw the label of the tab"""
|
|
||||||
start = ''
|
|
||||||
if self.nb_unread[room_jid] > 1:
|
|
||||||
start = "[" + str(self.nb_unread[room_jid]) + "] "
|
|
||||||
elif self.nb_unread[room_jid] == 1:
|
|
||||||
start = "* "
|
|
||||||
room = room_jid.split('@')[0]
|
|
||||||
child = self.xmls[room_jid].get_widget('group_vbox')
|
|
||||||
self.chat_notebook.set_tab_label_text(child, start + room)
|
|
||||||
|
|
||||||
def get_active_jid(self):
|
|
||||||
active_child = self.chat_notebook.get_nth_page(\
|
|
||||||
self.chat_notebook.get_current_page())
|
|
||||||
active_jid = ''
|
|
||||||
for room_jid in self.xmls:
|
|
||||||
child = self.xmls[room_jid].get_widget('group_vbox')
|
|
||||||
if child == active_child:
|
|
||||||
active_jid = room_jid
|
|
||||||
break
|
|
||||||
return active_jid
|
|
||||||
|
|
||||||
def set_subject(self, room_jid, subject):
|
def set_subject(self, room_jid, subject):
|
||||||
self.subjects[room_jid] = subject
|
self.subjects[room_jid] = subject
|
||||||
self.xml.get_widget('subject_entry').set_text(subject)
|
self.xml.get_widget('subject_entry').set_text(subject)
|
||||||
|
@ -225,10 +204,6 @@ class Groupchat_window:
|
||||||
subject = self.xml.get_widget('subject_entry').get_text()
|
subject = self.xml.get_widget('subject_entry').get_text()
|
||||||
self.plugin.send('GC_SUBJECT', self.account, (room_jid, subject))
|
self.plugin.send('GC_SUBJECT', self.account, (room_jid, subject))
|
||||||
|
|
||||||
def on_close_button_clicked(self, button):
|
|
||||||
room_jid = self.get_active_jid()
|
|
||||||
self.remove_tab(room_jid)
|
|
||||||
|
|
||||||
def on_message_textview_key_press_event(self, widget, event):
|
def on_message_textview_key_press_event(self, widget, event):
|
||||||
"""When a key is pressed:
|
"""When a key is pressed:
|
||||||
if enter is pressed without the shit key, message (if not empty) is sent
|
if enter is pressed without the shit key, message (if not empty) is sent
|
||||||
|
@ -268,59 +243,6 @@ class Groupchat_window:
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def on_groupchat_window_key_press_event(self, widget, event):
|
|
||||||
st = "1234567890" # humans count from 1, pc from 0 :P
|
|
||||||
room_jid = self.get_active_jid()
|
|
||||||
if event.keyval == gtk.keysyms.Escape: #ESCAPE
|
|
||||||
self.remove_tab(room_jid)
|
|
||||||
elif event.string and event.string in st \
|
|
||||||
and (event.state & gtk.gdk.MOD1_MASK): # alt + 1,2,3 ...
|
|
||||||
self.chat_notebook.set_current_page(st.index(event.string))
|
|
||||||
elif event.keyval == gtk.keysyms.Page_Down: # PAGEDOWN
|
|
||||||
if event.state & gtk.gdk.CONTROL_MASK:
|
|
||||||
current = self.chat_notebook.get_current_page()
|
|
||||||
if current > 0:
|
|
||||||
self.chat_notebook.set_current_page(current-1)
|
|
||||||
# else:
|
|
||||||
# self.chat_notebook.set_current_page(\
|
|
||||||
# self.chat_notebook.get_n_pages()-1)
|
|
||||||
elif event.state & gtk.gdk.SHIFT_MASK:
|
|
||||||
conversation_textview = self.xmls[room_jid].\
|
|
||||||
get_widget('conversation_textview')
|
|
||||||
rect = conversation_textview.get_visible_rect()
|
|
||||||
iter = conversation_textview.get_iter_at_location(rect.x,\
|
|
||||||
rect.y + rect.height)
|
|
||||||
conversation_textview.scroll_to_iter(iter, 0.1, True, 0, 0)
|
|
||||||
elif event.keyval == gtk.keysyms.Page_Up: # PAGEUP
|
|
||||||
if event.state & gtk.gdk.CONTROL_MASK:
|
|
||||||
current = self.chat_notebook.get_current_page()
|
|
||||||
if current < (self.chat_notebook.get_n_pages()-1):
|
|
||||||
self.chat_notebook.set_current_page(current+1)
|
|
||||||
# else:
|
|
||||||
# self.chat_notebook.set_current_page(0)
|
|
||||||
elif event.state & gtk.gdk.SHIFT_MASK:
|
|
||||||
conversation_textview = self.xmls[room_jid].\
|
|
||||||
get_widget('conversation_textview')
|
|
||||||
rect = conversation_textview.get_visible_rect()
|
|
||||||
iter = conversation_textview.get_iter_at_location(rect.x, rect.y)
|
|
||||||
conversation_textview.scroll_to_iter(iter, 0.1, True, 0, 1)
|
|
||||||
elif event.keyval == gtk.keysyms.Tab and \
|
|
||||||
(event.state & gtk.gdk.CONTROL_MASK): # CTRL+TAB
|
|
||||||
current = self.chat_notebook.get_current_page()
|
|
||||||
if current < (self.chat_notebook.get_n_pages()-1):
|
|
||||||
self.chat_notebook.set_current_page(current+1)
|
|
||||||
else:
|
|
||||||
self.chat_notebook.set_current_page(0)
|
|
||||||
|
|
||||||
'''FIXME:
|
|
||||||
NOT GOOD steals focus from Subject entry and I cannot find a way to prevent this
|
|
||||||
|
|
||||||
else: # it's a normal key press make sure message_textview has focus
|
|
||||||
message_textview = self.xmls[room_jid].get_widget('message_textview')
|
|
||||||
if not message_textview.is_focus():
|
|
||||||
message_textview.grab_focus()
|
|
||||||
'''
|
|
||||||
|
|
||||||
def print_conversation(self, text, room_jid, contact = '', tim = None):
|
def print_conversation(self, text, room_jid, contact = '', tim = None):
|
||||||
"""Print a line in the conversation :
|
"""Print a line in the conversation :
|
||||||
if contact is set : it's a message from someone
|
if contact is set : it's a message from someone
|
||||||
|
@ -343,10 +265,7 @@ class Groupchat_window:
|
||||||
if contact == self.nicks[room_jid]:
|
if contact == self.nicks[room_jid]:
|
||||||
tag = 'outgoing'
|
tag = 'outgoing'
|
||||||
else:
|
else:
|
||||||
if self.nicks[room_jid].lower() in text.lower().split():
|
tag = 'incoming'
|
||||||
tag = 'incoming_bold'
|
|
||||||
else:
|
|
||||||
tag = 'incoming'
|
|
||||||
self.last_message_time[room_jid] = time.time()
|
self.last_message_time[room_jid] = time.time()
|
||||||
|
|
||||||
if text.startswith('/me'):
|
if text.startswith('/me'):
|
||||||
|
@ -358,7 +277,12 @@ class Groupchat_window:
|
||||||
tag = 'status'
|
tag = 'status'
|
||||||
ttext = text + '\n'
|
ttext = text + '\n'
|
||||||
|
|
||||||
conversation_buffer.insert_with_tags_by_name(end_iter, ttext, tag)
|
if tag == 'incoming' and self.nicks[room_jid].lower() in\
|
||||||
|
text.lower().split():
|
||||||
|
conversation_buffer.insert_with_tags_by_name(end_iter, ttext, tag,\
|
||||||
|
'bold')
|
||||||
|
else:
|
||||||
|
conversation_buffer.insert_with_tags_by_name(end_iter, ttext, tag)
|
||||||
#TODO: emoticons, url grabber
|
#TODO: emoticons, url grabber
|
||||||
conversation_buffer.insert(end_iter, otext)
|
conversation_buffer.insert(end_iter, otext)
|
||||||
#scroll to the end of the textview
|
#scroll to the end of the textview
|
||||||
|
@ -498,70 +422,31 @@ class Groupchat_window:
|
||||||
menu.show_all()
|
menu.show_all()
|
||||||
menu.reposition()
|
menu.reposition()
|
||||||
|
|
||||||
def on_groupchat_window_focus_in_event(self, widget, event):
|
|
||||||
"""When window get focus"""
|
|
||||||
room_jid = self.get_active_jid()
|
|
||||||
if self.nb_unread[room_jid] > 0:
|
|
||||||
self.nb_unread[room_jid] = 0
|
|
||||||
self.redraw_tab(room_jid)
|
|
||||||
self.show_title()
|
|
||||||
self.plugin.systray.remove_jid(room_jid, self.account)
|
|
||||||
|
|
||||||
def on_chat_notebook_switch_page(self, notebook, page, page_num):
|
|
||||||
new_child = notebook.get_nth_page(page_num)
|
|
||||||
new_jid = ''
|
|
||||||
for room_jid in self.xmls:
|
|
||||||
child = self.xmls[room_jid].get_widget('group_vbox')
|
|
||||||
if child == new_child:
|
|
||||||
new_jid = room_jid
|
|
||||||
break
|
|
||||||
self.xml.get_widget('subject_entry').set_text(self.subjects[new_jid])
|
|
||||||
if self.nb_unread[new_jid] > 0:
|
|
||||||
self.nb_unread[new_jid] = 0
|
|
||||||
self.redraw_tab(new_jid)
|
|
||||||
self.show_title()
|
|
||||||
self.plugin.systray.remove_jid(new_jid, self.account)
|
|
||||||
|
|
||||||
def active_tab(self, room_jid):
|
|
||||||
child = self.xmls[room_jid].get_widget('group_vbox')
|
|
||||||
self.chat_notebook.set_current_page(self.chat_notebook.page_num(child))
|
|
||||||
self.xmls[room_jid].get_widget('message_textview').grab_focus()
|
|
||||||
|
|
||||||
def remove_tab(self, room_jid):
|
def remove_tab(self, room_jid):
|
||||||
if time.time() - self.last_message_time[room_jid] < 2:
|
if time.time() - self.last_message_time[room_jid] < 2:
|
||||||
dialog = Confirmation_dialog(_('You received a message in the room %s in the last two seconds.\nDo you still want to close this tab ?') % \
|
dialog = Confirmation_dialog(_('You received a message in the room %s in the last two seconds.\nDo you still want to close this tab ?') % \
|
||||||
room_jid.split('@')[0])
|
room_jid.split('@')[0])
|
||||||
if dialog.get_response() != gtk.RESPONSE_YES:
|
if dialog.get_response() != gtk.RESPONSE_YES:
|
||||||
return
|
return
|
||||||
if len(self.xmls) == 1:
|
|
||||||
self.window.destroy()
|
chat.remove_tab(self, jid, 'gc')
|
||||||
else:
|
if len(self.xmls) > 0:
|
||||||
self.plugin.send('GC_STATUS', self.account, (self.nicks[room_jid], \
|
self.plugin.send('GC_STATUS', self.account, (self.nicks[room_jid], \
|
||||||
room_jid, 'offline', 'offline'))
|
room_jid, 'offline', 'offline'))
|
||||||
self.chat_notebook.remove_page(self.chat_notebook.get_current_page())
|
|
||||||
del self.plugin.windows[self.account]['gc'][room_jid]
|
|
||||||
del self.nicks[room_jid]
|
del self.nicks[room_jid]
|
||||||
del self.nb_unread[room_jid]
|
|
||||||
del self.last_message_time[room_jid]
|
|
||||||
del self.xmls[room_jid]
|
|
||||||
del self.tagIn[room_jid]
|
|
||||||
del self.tagInBold[room_jid]
|
|
||||||
del self.tagOut[room_jid]
|
|
||||||
del self.tagStatus[room_jid]
|
|
||||||
del self.list_treeview[room_jid]
|
del self.list_treeview[room_jid]
|
||||||
del self.subjects[room_jid]
|
del self.subjects[room_jid]
|
||||||
if len(self.xmls) == 1:
|
|
||||||
self.chat_notebook.set_show_tabs(False)
|
|
||||||
self.show_title()
|
|
||||||
|
|
||||||
def new_group(self, room_jid, nick):
|
def new_group(self, room_jid, nick):
|
||||||
self.nb_unread[room_jid] = 0
|
self.names[room_jid] = room_jid.split('@')[0]
|
||||||
self.last_message_time[room_jid] = 0
|
self.xmls[room_jid] = gtk.glade.XML(GTKGUI_GLADE, 'gc_vbox', APP)
|
||||||
|
self.childs[room_jid] = self.xmls[room_jid].get_widget('gc_vbox')
|
||||||
|
chat.new_tab(self, room_jid)
|
||||||
self.nicks[room_jid] = nick
|
self.nicks[room_jid] = nick
|
||||||
self.subjects[room_jid] = ''
|
self.subjects[room_jid] = ''
|
||||||
self.xmls[room_jid] = gtk.glade.XML(GTKGUI_GLADE, 'group_vbox', APP)
|
|
||||||
self.list_treeview[room_jid] = self.xmls[room_jid].\
|
self.list_treeview[room_jid] = self.xmls[room_jid].\
|
||||||
get_widget('list_treeview')
|
get_widget('list_treeview')
|
||||||
|
print self.list_treeview[room_jid]
|
||||||
|
|
||||||
#status_image, nickname, real_jid
|
#status_image, nickname, real_jid
|
||||||
store = gtk.TreeStore(gtk.Image, str, str)
|
store = gtk.TreeStore(gtk.Image, str, str)
|
||||||
|
@ -583,32 +468,6 @@ class Groupchat_window:
|
||||||
column.set_visible(False)
|
column.set_visible(False)
|
||||||
self.list_treeview[room_jid].set_expander_column(column)
|
self.list_treeview[room_jid].set_expander_column(column)
|
||||||
|
|
||||||
conversation_textview = self.xmls[room_jid].\
|
|
||||||
get_widget('conversation_textview')
|
|
||||||
conversation_buffer = conversation_textview.get_buffer()
|
|
||||||
end_iter = conversation_buffer.get_end_iter()
|
|
||||||
conversation_buffer.create_mark('end', end_iter, 0)
|
|
||||||
self.tagIn[room_jid] = conversation_buffer.create_tag('incoming')
|
|
||||||
# (nk) what is this?
|
|
||||||
self.tagInBold[room_jid] = conversation_buffer.create_tag('incoming_bold')
|
|
||||||
color = self.plugin.config['inmsgcolor']
|
|
||||||
self.tagIn[room_jid].set_property('foreground', color)
|
|
||||||
self.tagInBold[room_jid].set_property('foreground', color)
|
|
||||||
self.tagInBold[room_jid].set_property('weight', 700)
|
|
||||||
self.tagOut[room_jid] = conversation_buffer.create_tag('outgoing')
|
|
||||||
color = self.plugin.config['outmsgcolor']
|
|
||||||
self.tagOut[room_jid].set_property('foreground', color)
|
|
||||||
self.tagStatus[room_jid] = conversation_buffer.create_tag('status')
|
|
||||||
color = self.plugin.config['statusmsgcolor']
|
|
||||||
self.tagStatus[room_jid].set_property('foreground', color)
|
|
||||||
|
|
||||||
self.xmls[room_jid].signal_autoconnect(self)
|
|
||||||
|
|
||||||
self.chat_notebook.append_page(self.xmls[room_jid].\
|
|
||||||
get_widget('group_vbox'))
|
|
||||||
if len(self.xmls) > 1:
|
|
||||||
self.chat_notebook.set_show_tabs(True)
|
|
||||||
|
|
||||||
self.redraw_tab(room_jid)
|
self.redraw_tab(room_jid)
|
||||||
self.show_title()
|
self.show_title()
|
||||||
|
|
||||||
|
@ -664,35 +523,3 @@ class Groupchat_window:
|
||||||
change the icon of the arrow"""
|
change the icon of the arrow"""
|
||||||
model = widget.get_model()
|
model = widget.get_model()
|
||||||
model.set_value(iter, 0, self.plugin.roster.pixbufs['closed'])
|
model.set_value(iter, 0, self.plugin.roster.pixbufs['closed'])
|
||||||
|
|
||||||
def __init__(self, room_jid, nick, plugin, account):
|
|
||||||
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'groupchat_window', APP)
|
|
||||||
self.chat_notebook = self.xml.get_widget('chat_notebook')
|
|
||||||
self.chat_notebook.remove_page(0)
|
|
||||||
self.plugin = plugin
|
|
||||||
self.account = account
|
|
||||||
self.xmls = {}
|
|
||||||
self.tagIn = {}
|
|
||||||
self.tagInBold = {}
|
|
||||||
self.tagOut = {}
|
|
||||||
self.tagStatus = {}
|
|
||||||
self.nicks = {}
|
|
||||||
self.nb_unread = {}
|
|
||||||
self.last_message_time = {}
|
|
||||||
self.list_treeview = {}
|
|
||||||
self.subjects = {}
|
|
||||||
self.window = self.xml.get_widget('groupchat_window')
|
|
||||||
self.new_group(room_jid, nick)
|
|
||||||
self.show_title()
|
|
||||||
self.xml.signal_connect('on_groupchat_window_destroy', \
|
|
||||||
self.on_groupchat_window_destroy)
|
|
||||||
self.xml.signal_connect('on_groupchat_window_delete_event', \
|
|
||||||
self.on_groupchat_window_delete_event)
|
|
||||||
self.xml.signal_connect('on_groupchat_window_focus_in_event', \
|
|
||||||
self.on_groupchat_window_focus_in_event)
|
|
||||||
self.xml.signal_connect('on_groupchat_window_key_press_event', \
|
|
||||||
self.on_groupchat_window_key_press_event)
|
|
||||||
self.xml.signal_connect('on_chat_notebook_switch_page', \
|
|
||||||
self.on_chat_notebook_switch_page)
|
|
||||||
self.xml.signal_connect('on_set_button_clicked', \
|
|
||||||
self.on_set_button_clicked)
|
|
||||||
|
|
|
@ -6971,7 +6971,6 @@ Custom</property>
|
||||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||||
<signal name="focus_in_event" handler="on_groupchat_window_focus_in_event" last_modification_time="Sat, 05 Mar 2005 00:34:51 GMT"/>
|
<signal name="focus_in_event" handler="on_groupchat_window_focus_in_event" last_modification_time="Sat, 05 Mar 2005 00:34:51 GMT"/>
|
||||||
<signal name="key_press_event" handler="on_groupchat_window_key_press_event" last_modification_time="Sat, 05 Mar 2005 10:57:33 GMT"/>
|
|
||||||
<signal name="delete_event" handler="on_groupchat_window_delete_event" last_modification_time="Mon, 07 Mar 2005 11:19:05 GMT"/>
|
<signal name="delete_event" handler="on_groupchat_window_delete_event" last_modification_time="Mon, 07 Mar 2005 11:19:05 GMT"/>
|
||||||
<signal name="destroy" handler="on_groupchat_window_destroy" last_modification_time="Mon, 07 Mar 2005 16:46:37 GMT"/>
|
<signal name="destroy" handler="on_groupchat_window_destroy" last_modification_time="Mon, 07 Mar 2005 16:46:37 GMT"/>
|
||||||
|
|
||||||
|
@ -7062,73 +7061,13 @@ Custom</property>
|
||||||
<property name="scrollable">True</property>
|
<property name="scrollable">True</property>
|
||||||
<property name="enable_popup">False</property>
|
<property name="enable_popup">False</property>
|
||||||
<signal name="switch_page" handler="on_chat_notebook_switch_page" last_modification_time="Sat, 05 Mar 2005 10:57:01 GMT"/>
|
<signal name="switch_page" handler="on_chat_notebook_switch_page" last_modification_time="Sat, 05 Mar 2005 10:57:01 GMT"/>
|
||||||
|
<signal name="key_press_event" handler="on_chat_notebook_key_press_event" last_modification_time="Sat, 12 Mar 2005 21:19:23 GMT"/>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkVBox" id="group_vbox">
|
<widget class="GtkVBox" id="gc_vbox">
|
||||||
<property name="border_width">4</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="homogeneous">False</property>
|
<property name="homogeneous">False</property>
|
||||||
<property name="spacing">4</property>
|
<property name="spacing">0</property>
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkHBox" id="hbox2929">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="homogeneous">False</property>
|
|
||||||
<property name="spacing">4</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkLabel" id="jid_label">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="label" translatable="yes"></property>
|
|
||||||
<property name="use_underline">False</property>
|
|
||||||
<property name="use_markup">False</property>
|
|
||||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
|
||||||
<property name="wrap">False</property>
|
|
||||||
<property name="selectable">False</property>
|
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="yalign">0.5</property>
|
|
||||||
<property name="xpad">0</property>
|
|
||||||
<property name="ypad">0</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkButton" id="close_button">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">True</property>
|
|
||||||
<signal name="clicked" handler="on_close_button_clicked" last_modification_time="Sat, 05 Mar 2005 10:52:53 GMT"/>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkImage" id="image432">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="stock">gtk-close</property>
|
|
||||||
<property name="icon_size">1</property>
|
|
||||||
<property name="xalign">0.5</property>
|
|
||||||
<property name="yalign">0.5</property>
|
|
||||||
<property name="xpad">0</property>
|
|
||||||
<property name="ypad">0</property>
|
|
||||||
</widget>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkVPaned" id="vpaned4">
|
<widget class="GtkVPaned" id="vpaned4">
|
||||||
|
@ -7171,7 +7110,7 @@ Custom</property>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkScrolledWindow" id="scrolledwindow18">
|
<widget class="GtkScrolledWindow" id="conversation_scrolledwindow">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||||
|
@ -8067,7 +8006,6 @@ Custom</property>
|
||||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||||
<signal name="focus_in_event" handler="on_tabbed_chat_window_focus_in_event" last_modification_time="Wed, 02 Mar 2005 17:57:33 GMT"/>
|
<signal name="focus_in_event" handler="on_tabbed_chat_window_focus_in_event" last_modification_time="Wed, 02 Mar 2005 17:57:33 GMT"/>
|
||||||
<signal name="key_press_event" handler="on_tabbed_chat_window_key_press_event" last_modification_time="Wed, 02 Mar 2005 17:59:50 GMT"/>
|
|
||||||
<signal name="delete_event" handler="on_tabbed_chat_window_delete_event" last_modification_time="Mon, 07 Mar 2005 11:06:00 GMT"/>
|
<signal name="delete_event" handler="on_tabbed_chat_window_delete_event" last_modification_time="Mon, 07 Mar 2005 11:06:00 GMT"/>
|
||||||
<signal name="destroy" handler="on_tabbed_chat_window_destroy" last_modification_time="Mon, 07 Mar 2005 16:35:25 GMT"/>
|
<signal name="destroy" handler="on_tabbed_chat_window_destroy" last_modification_time="Mon, 07 Mar 2005 16:35:25 GMT"/>
|
||||||
|
|
||||||
|
@ -8080,9 +8018,10 @@ Custom</property>
|
||||||
<property name="scrollable">False</property>
|
<property name="scrollable">False</property>
|
||||||
<property name="enable_popup">False</property>
|
<property name="enable_popup">False</property>
|
||||||
<signal name="switch_page" handler="on_chat_notebook_switch_page" last_modification_time="Wed, 02 Mar 2005 18:00:21 GMT"/>
|
<signal name="switch_page" handler="on_chat_notebook_switch_page" last_modification_time="Wed, 02 Mar 2005 18:00:21 GMT"/>
|
||||||
|
<signal name="key_press_event" handler="on_chat_notebook_key_press_event" last_modification_time="Sat, 12 Mar 2005 21:18:17 GMT"/>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkVBox" id="tab_vbox">
|
<widget class="GtkVBox" id="chats_vbox">
|
||||||
<property name="border_width">5</property>
|
<property name="border_width">5</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="homogeneous">False</property>
|
<property name="homogeneous">False</property>
|
||||||
|
|
|
@ -51,8 +51,8 @@ class tabbed_chat_window(chat):
|
||||||
self.on_tabbed_chat_window_delete_event)
|
self.on_tabbed_chat_window_delete_event)
|
||||||
self.xml.signal_connect('on_tabbed_chat_window_focus_in_event', \
|
self.xml.signal_connect('on_tabbed_chat_window_focus_in_event', \
|
||||||
self.on_tabbed_chat_window_focus_in_event)
|
self.on_tabbed_chat_window_focus_in_event)
|
||||||
self.xml.signal_connect('on_tabbed_chat_window_key_press_event', \
|
self.xml.signal_connect('on_chat_notebook_key_press_event', \
|
||||||
self.on_tabbed_chat_window_key_press_event)
|
self.on_chat_notebook_key_press_event)
|
||||||
self.xml.signal_connect('on_chat_notebook_switch_page', \
|
self.xml.signal_connect('on_chat_notebook_switch_page', \
|
||||||
self.on_chat_notebook_switch_page)
|
self.on_chat_notebook_switch_page)
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class tabbed_chat_window(chat):
|
||||||
"""close window"""
|
"""close window"""
|
||||||
for jid in self.users:
|
for jid in self.users:
|
||||||
if time.time() - self.last_message_time[jid] < 2: # 2 seconds
|
if time.time() - self.last_message_time[jid] < 2: # 2 seconds
|
||||||
dialog = Confirmation_dialog(_('You received a message from %s in the last two seconds.\nDo you still want to close this window?') % jid)
|
dialog = Confirmation_dialog(_('You received a message from %s in the last two seconds.\nDo you still want to close this window ?') % jid)
|
||||||
if dialog.get_response() != gtk.RESPONSE_YES:
|
if dialog.get_response() != gtk.RESPONSE_YES:
|
||||||
return True #stop the propagation of the event
|
return True #stop the propagation of the event
|
||||||
|
|
||||||
|
@ -94,8 +94,8 @@ class tabbed_chat_window(chat):
|
||||||
def on_tabbed_chat_window_focus_in_event(self, widget, event):
|
def on_tabbed_chat_window_focus_in_event(self, widget, event):
|
||||||
chat.on_chat_window_focus_in_event(self, widget, event)
|
chat.on_chat_window_focus_in_event(self, widget, event)
|
||||||
|
|
||||||
def on_tabbed_chat_window_key_press_event(self, widget, event):
|
def on_chat_notebook_key_press_event(self, widget, event):
|
||||||
chat.on_chat_window_key_press_event(self, widget, event)
|
chat.on_chat_notebook_key_press_event(self, widget, event)
|
||||||
|
|
||||||
def on_clear_button_clicked(self, widget):
|
def on_clear_button_clicked(self, widget):
|
||||||
"""When clear button is pressed :
|
"""When clear button is pressed :
|
||||||
|
@ -124,20 +124,11 @@ class tabbed_chat_window(chat):
|
||||||
|
|
||||||
def new_user(self, user):
|
def new_user(self, user):
|
||||||
self.names[user.jid] = user.name
|
self.names[user.jid] = user.name
|
||||||
|
self.xmls[user.jid] = gtk.glade.XML(GTKGUI_GLADE, 'chats_vbox', APP)
|
||||||
|
self.childs[user.jid] = self.xmls[user.jid].get_widget('chats_vbox')
|
||||||
chat.new_tab(self, user.jid)
|
chat.new_tab(self, user.jid)
|
||||||
self.users[user.jid] = user
|
self.users[user.jid] = user
|
||||||
|
|
||||||
conversation_textview = \
|
|
||||||
self.xmls[user.jid].get_widget('conversation_textview')
|
|
||||||
conversation_buffer = conversation_textview.get_buffer()
|
|
||||||
|
|
||||||
child = self.xmls[user.jid].get_widget('tab_vbox')
|
|
||||||
xm = gtk.glade.XML(GTKGUI_GLADE, 'tab_hbox', APP)
|
|
||||||
tab_hbox = xm.get_widget('tab_hbox')
|
|
||||||
xm.signal_connect('on_close_button_clicked', \
|
|
||||||
self.on_close_button_clicked, user.jid)
|
|
||||||
self.notebook.set_tab_label(child, tab_hbox)
|
|
||||||
|
|
||||||
self.redraw_tab(user.jid)
|
self.redraw_tab(user.jid)
|
||||||
self.draw_widgets(user)
|
self.draw_widgets(user)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue