All code from chat.py and tabbed_chat.py has been merged into the new framework. Lot's of testing to follow and then onto groupchat *in the same window*, w00t!

This commit is contained in:
Travis Shirk 2006-01-03 04:44:56 +00:00
parent 5f093a06b5
commit deba09827c
6 changed files with 54 additions and 27 deletions

View file

@ -276,6 +276,15 @@ class ChatControlBase(MessageControl):
# Clear msg input # Clear msg input
message_buffer = self.msg_textview.get_buffer() message_buffer = self.msg_textview.get_buffer()
message_buffer.set_text('') # clear message buffer (and tv of course) message_buffer.set_text('') # clear message buffer (and tv of course)
# FIXME GC ONLY
# if contact is None:
# # contact was from pm in MUC, and left the room, or we left the room
# room, nick = gajim.get_room_and_nick_from_fjid(jid)
# dialogs.ErrorDialog(_('Sending private message failed'),
# #in second %s code replaces with nickname
# _('You are no longer in room "%s" or "%s" has left.') % \
# (room, nick)).get_response()
#
def save_sent_message(self, message): def save_sent_message(self, message):
#save the message, so user can scroll though the list with key up/down #save the message, so user can scroll though the list with key up/down
@ -310,15 +319,18 @@ class ChatControlBase(MessageControl):
if kind == 'incoming_queue': if kind == 'incoming_queue':
gajim.last_message_time[self.account][jid] = time.time() gajim.last_message_time[self.account][jid] = time.time()
urgent = True urgent = True
if (jid != self.parent_win.get_active_jid() or \ if (not self.parent_win.get_active_jid() or\
not self.parent_win.is_active() or not end) and\ jid != self.parent_win.get_active_jid() or \
kind in ('incoming', 'incoming_queue'): not self.parent_win.is_active() or not end) and\
kind in ('incoming', 'incoming_queue'):
self.nb_unread += 1 self.nb_unread += 1
if gajim.interface.systray_enabled and\ if gajim.interface.systray_enabled and\
gajim.config.get('trayicon_notification_on_new_messages'): gajim.config.get('trayicon_notification_on_new_messages'):
gajim.interface.systray.add_jid(jid, self.account, self.type_id) gajim.interface.systray.add_jid(jid, self.account, self.type_id)
self.parent_win.redraw_tab(self.contact) # FIXME: This is one hairy race condition
self.show_title(urgent) if self.parent_win.get_active_control():
self.parent_win.redraw_tab(self.contact)
self.parent_win.show_title(urgent)
def toggle_emoticons(self): def toggle_emoticons(self):
'''hide show emoticons_button and make sure emoticons_menu is always there '''hide show emoticons_button and make sure emoticons_menu is always there
@ -434,12 +446,12 @@ class ChatControlBase(MessageControl):
#we are at the end #we are at the end
if self.nb_unread > 0: if self.nb_unread > 0:
self.nb_unread = 0 + self.get_specific_unread() self.nb_unread = 0 + self.get_specific_unread()
self.parent_win.redraw_tab(jid) self.parent_win.redraw_tab(self.contact)
self.parent_win.show_title() self.parent_win.show_title()
if gajim.interface.systray_enabled: if gajim.interface.systray_enabled:
gajim.interface.systray.remove_jid(jid, gajim.interface.systray.remove_jid(jid,
self.account, self.account,
self.type) self.type_id)
self.msg_textview.grab_focus() self.msg_textview.grab_focus()
def bring_scroll_to_end(self, textview, diff_y = 0): def bring_scroll_to_end(self, textview, diff_y = 0):
@ -599,9 +611,6 @@ class ChatControl(ChatControlBase):
# restore previous conversation # restore previous conversation
self.restore_conversation() self.restore_conversation()
if gajim.awaiting_events[self.account].has_key(self.contact.jid):
self.read_queue()
def _on_avatar_eventbox_enter_notify_event(self, widget, event): def _on_avatar_eventbox_enter_notify_event(self, widget, event):
'''we enter the eventbox area so we under conditions add a timeout '''we enter the eventbox area so we under conditions add a timeout
to show a bigger avatar after 0.5 sec''' to show a bigger avatar after 0.5 sec'''
@ -1014,10 +1023,6 @@ class ChatControl(ChatControlBase):
widget.set_no_show_all(False) widget.set_no_show_all(False)
widget.show_all() widget.show_all()
def on_compact_view_menuitem_activate(self, widget):
isactive = widget.get_active()
self.set_compact_view(isactive)
def send_chatstate(self, state, contact = None): def send_chatstate(self, state, contact = None):
''' sends OUR chatstate as STANDLONE chat state message (eg. no body) ''' sends OUR chatstate as STANDLONE chat state message (eg. no body)
to contact only if new chatstate is different from the previous one to contact only if new chatstate is different from the previous one
@ -1353,3 +1358,17 @@ class ChatControl(ChatControlBase):
cursor = gtk.gdk.Cursor(gtk.gdk.LEFT_PTR) cursor = gtk.gdk.Cursor(gtk.gdk.LEFT_PTR)
self.bigger_avatar_window.window.set_cursor(cursor) self.bigger_avatar_window.window.set_cursor(cursor)
def _on_compact_view_menuitem_activate(self, widget):
isactive = widget.get_active()
self.set_compact_view(isactive)
def _on_send_file_menuitem_activate(self, widget):
gajim.interface.instances['file_transfers'].show_file_send_request(
self.account, self.contact)
def _on_add_to_roster_menuitem_activate(self, widget):
dialogs.AddNewContactWindow(self.account, self.contact.jid)
def _on_contact_information_menuitem_clicked(self, widget):
gajim.interface.roster.on_info(widget, self.contact, self.account)

View file

@ -648,10 +648,10 @@ class Interface:
win = None win = None
ctl = None ctl = None
if gajim.interface.msg_win_mgr.has_window(jid): if gajim.interface.msg_win_mgr.has_window(jid):
win = gajim.interface.msg_type.get_window(jid) win = gajim.interface.msg_win_mgr.get_window(jid)
ctl = win.get_control(jid) ctl = win.get_control(jid)
elif resource and gajim.interface.msg_win_mgr.has_window(jid + '/' + resource): elif resource and gajim.interface.msg_win_mgr.has_window(jid + '/' + resource):
win = gajim.interface.msg_type.get_window(jid + '/' + resource) win = gajim.interface.msg_win_mgr.get_window(jid + '/' + resource)
ctl = win.get_control(jid + '/' + resource) ctl = win.get_control(jid + '/' + resource)
if win: if win:
ctl.show_avatar() ctl.show_avatar()

View file

@ -16218,7 +16218,7 @@ Banner</property>
<property name="tooltip" translatable="yes">Click to see past conversations with this contact</property> <property name="tooltip" translatable="yes">Click to see past conversations with this contact</property>
<property name="label" translatable="yes">_History</property> <property name="label" translatable="yes">_History</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<signal name="activate" handler="on_history_menuitem_clicked" last_modification_time="Thu, 04 Aug 2005 13:53:23 GMT"/> <signal name="activate" handler="_on_history_menuitem_clicked" last_modification_time="Tue, 03 Jan 2006 04:27:11 GMT"/>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1241"> <widget class="GtkImage" id="image1241">
@ -16239,7 +16239,7 @@ Banner</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="label">gtk-dialog-info</property> <property name="label">gtk-dialog-info</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
<signal name="activate" handler="on_contact_information_menuitem_clicked" last_modification_time="Tue, 20 Sep 2005 18:08:14 GMT"/> <signal name="activate" handler="_on_contact_information_menuitem_clicked" last_modification_time="Tue, 03 Jan 2006 04:27:04 GMT"/>
</widget> </widget>
</child> </child>
@ -16248,7 +16248,7 @@ Banner</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Send _File</property> <property name="label" translatable="yes">Send _File</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<signal name="activate" handler="on_send_file_menuitem_activate" last_modification_time="Wed, 03 Aug 2005 15:21:47 GMT"/> <signal name="activate" handler="_on_send_file_menuitem_activate" last_modification_time="Tue, 03 Jan 2006 04:26:55 GMT"/>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1242"> <widget class="GtkImage" id="image1242">
@ -16270,7 +16270,7 @@ Banner</property>
<property name="label" translatable="yes">Toggle Open_PGP Encryption</property> <property name="label" translatable="yes">Toggle Open_PGP Encryption</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="active">False</property> <property name="active">False</property>
<signal name="activate" handler="on_toggle_gpg_menuitem_activate" last_modification_time="Thu, 30 Jun 2005 10:43:11 GMT"/> <signal name="activate" handler="_on_toggle_gpg_menuitem_activate" last_modification_time="Tue, 03 Jan 2006 04:26:46 GMT"/>
</widget> </widget>
</child> </child>
@ -16280,7 +16280,7 @@ Banner</property>
<property name="label" translatable="yes">_Compact View Alt+C</property> <property name="label" translatable="yes">_Compact View Alt+C</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="active">False</property> <property name="active">False</property>
<signal name="activate" handler="on_compact_view_menuitem_activate" last_modification_time="Thu, 30 Jun 2005 13:07:17 GMT"/> <signal name="activate" handler="_on_compact_view_menuitem_activate" last_modification_time="Tue, 03 Jan 2006 04:26:30 GMT"/>
</widget> </widget>
</child> </child>
@ -16289,7 +16289,7 @@ Banner</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Add to Roster</property> <property name="label" translatable="yes">_Add to Roster</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<signal name="activate" handler="on_add_to_roster_menuitem_activate" last_modification_time="Thu, 21 Jul 2005 22:46:10 GMT"/> <signal name="activate" handler="_on_add_to_roster_menuitem_activate" last_modification_time="Tue, 03 Jan 2006 04:26:37 GMT"/>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image1243"> <widget class="GtkImage" id="image1243">

View file

@ -107,7 +107,7 @@ class MessageControl:
def load_var(self, jid, var): def load_var(self, jid, var):
pass # Derived classes SHOULD implement this pass # Derived classes SHOULD implement this
def get_specific_unread(self, jid): def get_specific_unread(self):
return 0 return 0
def send_message(self, message, keyID = '', type = 'chat', chatstate = None): def send_message(self, message, keyID = '', type = 'chat', chatstate = None):

View file

@ -214,7 +214,7 @@ class MessageWindow:
ctl = self.get_active_control() ctl = self.get_active_control()
if len(self._controls) > 1: # if more than one tab in the same window if len(self._controls) > 1: # if more than one tab in the same window
add = ctl.display_name add = ctl.display_name
elif len(self._controls) == 1: # just one tab else:
add = ctl.contact.name add = ctl.contact.name
# FIXME: This is for GC only # FIXME: This is for GC only
# elif self.widget_name == 'groupchat_window': # elif self.widget_name == 'groupchat_window':
@ -264,7 +264,6 @@ class MessageWindow:
self.show_title() self.show_title()
def redraw_tab(self, contact, chatstate = None): def redraw_tab(self, contact, chatstate = None):
print self._controls
ctl = self._controls[contact.jid] ctl = self._controls[contact.jid]
ctl.update_state() ctl.update_state()
@ -317,9 +316,15 @@ class MessageWindow:
active_widget = notebook.get_nth_page(notebook.get_current_page()) active_widget = notebook.get_nth_page(notebook.get_current_page())
return self._widget_to_control(active_widget) return self._widget_to_control(active_widget)
def get_active_contact(self): def get_active_contact(self):
return self.get_active_control().contact ctl = self.get_active_control()
if ctl:
return ctl.contact
return None
def get_active_jid(self): def get_active_jid(self):
return self.get_active_contact().jid contact = self.get_active_contact()
if contact:
return contact.jid
return None
def is_active(self): def is_active(self):
return self.window.is_active() return self.window.is_active()

View file

@ -1672,6 +1672,9 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
ChatControl.TYPE_ID) ChatControl.TYPE_ID)
chat_control = ChatControl(mw, contact, account) chat_control = ChatControl(mw, contact, account)
mw.new_tab(chat_control) mw.new_tab(chat_control)
if gajim.awaiting_events[account].has_key(contact.jid):
# We call this here to avoid race conditions with widget validation
chat_control.read_queue()
def new_chat_from_jid(self, account, jid): def new_chat_from_jid(self, account, jid):
contact = gajim.contacts.get_contact_with_highest_priority(account, jid) contact = gajim.contacts.get_contact_with_highest_priority(account, jid)