Commit 3967d117 authored by Yann Leboulanger's avatar Yann Leboulanger

groupchat window is now also a subclass of chat class

parent c1a07578
......@@ -37,8 +37,6 @@ gtk.glade.textdomain(APP)
GTKGUI_GLADE='plugins/gtkgui/gtkgui.glade'
#the child of the tab must be called tab_vbox
class chat:
"""Class for tabbed chat window"""
def __init__(self, plugin, account, widget_name):
......@@ -56,6 +54,7 @@ class chat:
self.last_message_time = {}
self.print_time_timeout_id = {}
self.names = {} # what is printed in the tab : user.name for example
self.childs = {}
self.window = self.xml.get_widget(widget_name)
def update_tags(self):
......@@ -102,7 +101,7 @@ class chat:
start = "[" + str(self.nb_unread[jid]) + "] "
elif self.nb_unread[jid] == 1:
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.set_text(start + self.names[jid])
......@@ -120,8 +119,7 @@ class chat:
self.notebook.get_current_page())
active_jid = ''
for jid in self.xmls:
child = self.xmls[jid].get_widget('tab_vbox')
if child == active_child:
if self.childs[jid] == active_child:
active_jid = jid
break
return active_jid
......@@ -152,8 +150,7 @@ class chat:
new_child = notebook.get_nth_page(page_num)
new_jid = ''
for jid in self.xmls:
child = self.xmls[jid].get_widget('tab_vbox')
if child == new_child:
if self.childs[jid] == new_child:
new_jid = jid
break
conversation_textview = self.xmls[new_jid].\
......@@ -171,9 +168,8 @@ class chat:
self.plugin.systray.remove_jid(new_jid, self.account)
def active_tab(self, jid):
child = self.xmls[jid].get_widget('tab_vbox')
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'
if len(self.xmls) == 1:
......@@ -182,9 +178,8 @@ class chat:
if self.print_time_timeout_id.has_key(jid):
gobject.source_remove(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.page_num(child))
self.notebook.page_num(self.childs[jid]))
del self.plugin.windows[self.account][kind][jid]
del self.nb_unread[jid]
del self.last_message_time[jid]
......@@ -199,7 +194,6 @@ class chat:
def new_tab(self, jid):
self.nb_unread[jid] = 0
self.last_message_time[jid] = 0
self.xmls[jid] = gtk.glade.XML(GTKGUI_GLADE, 'tab_vbox', APP)
conversation_textview = \
self.xmls[jid].get_widget('conversation_textview')
......@@ -246,14 +240,20 @@ class chat:
conversation_scrolledwindow.get_vadjustment().connect('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)
if len(self.xmls) > 1:
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()
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
jid = self.get_active_jid()
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
# in order to let ctrl+c do its work
pass
#FIXME: will not work with gc
else: # it's a normal key press make sure message_textview has focus
message_textview = self.xmls[jid].get_widget('message_textview')
if not message_textview.is_focus():
......
This diff is collapsed.
......@@ -6971,7 +6971,6 @@ Custom</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</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="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="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="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="key_press_event" handler="on_chat_notebook_key_press_event" last_modification_time="Sat, 12 Mar 2005 21:19:23 GMT"/>
<child>
<widget class="GtkVBox" id="group_vbox">
<property name="border_width">4</property>
<widget class="GtkVBox" id="gc_vbox">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">4</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>
<property name="spacing">0</property>
<child>
<widget class="GtkVPaned" id="vpaned4">
......@@ -7171,7 +7110,7 @@ Custom</property>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow18">
<widget class="GtkScrolledWindow" id="conversation_scrolledwindow">
<property name="visible">True</property>
<property name="hscrollbar_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="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="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="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="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="key_press_event" handler="on_chat_notebook_key_press_event" last_modification_time="Sat, 12 Mar 2005 21:18:17 GMT"/>
<child>
<widget class="GtkVBox" id="tab_vbox">
<widget class="GtkVBox" id="chats_vbox">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
......
......@@ -51,8 +51,8 @@ class tabbed_chat_window(chat):
self.on_tabbed_chat_window_delete_event)
self.xml.signal_connect('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.on_tabbed_chat_window_key_press_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)
......@@ -83,7 +83,7 @@ class tabbed_chat_window(chat):
"""close window"""
for jid in self.users:
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:
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):
chat.on_chat_window_focus_in_event(self, widget, event)
def on_tabbed_chat_window_key_press_event(self, widget, event):
chat.on_chat_window_key_press_event(self, widget, event)
def on_chat_notebook_key_press_event(self, widget, event):
chat.on_chat_notebook_key_press_event(self, widget, event)
def on_clear_button_clicked(self, widget):
"""When clear button is pressed :
......@@ -124,20 +124,11 @@ class tabbed_chat_window(chat):
def new_user(self, user):
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)
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.draw_widgets(user)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment