Preliminary GroupchatControl support
This commit is contained in:
parent
008dfea48b
commit
496199aaef
|
@ -63,8 +63,8 @@ class ChatControlBase(MessageControl):
|
|||
def _update_banner_state_image(self):
|
||||
pass # Derived types MAY implement this
|
||||
|
||||
def __init__(self, parent_win, widget_name, display_name, contact, acct):
|
||||
MessageControl.__init__(self, parent_win, widget_name, display_name,
|
||||
def __init__(self, type_id, parent_win, widget_name, display_name, contact, acct):
|
||||
MessageControl.__init__(self, type_id, parent_win, widget_name, display_name,
|
||||
contact, acct);
|
||||
|
||||
# FIXME: These are hidden from 0.8 on, but IMO all these things need
|
||||
|
@ -372,9 +372,11 @@ class ChatControlBase(MessageControl):
|
|||
|
||||
class ChatControl(ChatControlBase):
|
||||
'''A control for standard 1-1 chat'''
|
||||
TYPE_ID = 1
|
||||
|
||||
def __init__(self, parent_win, contact, acct):
|
||||
ChatControlBase.__init__(self, parent_win, 'chat_child_vbox', _('Chat'),
|
||||
contact, acct);
|
||||
ChatControlBase.__init__(self, self.TYPE_ID, parent_win, 'chat_child_vbox',
|
||||
_('Chat'), contact, acct);
|
||||
self.compact_view_always = gajim.config.get('always_compact_view_chat')
|
||||
self.set_compact_view(self.compact_view_always)
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
## groupchat_control.py
|
||||
##
|
||||
## Copyright (C) 2005-2006 Travis Shirk <travis@pobox.com>
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published
|
||||
## by the Free Software Foundation; version 2 only.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
|
||||
import gtk
|
||||
import gtk.glade
|
||||
import pango
|
||||
import gobject
|
||||
import gtkgui_helpers
|
||||
|
||||
from common import gajim
|
||||
from chat_control import ChatControlBase
|
||||
from conversation_textview import ConversationTextview
|
||||
from message_textview import MessageTextView
|
||||
|
||||
class GroupchatControl(ChatControlBase):
|
||||
TYPE_ID = 2
|
||||
|
||||
def __init__(self, parent_win, contact, acct):
|
||||
ChatControlBase.__init__(self, self.TYPE_ID, parent_win,
|
||||
'muc_child_vbox', _('Group Chat'), contact, acct);
|
||||
self.compact_view_always = gajim.config.get('always_compact_view_gc')
|
||||
# muc attention states (when we are mentioned in a muc)
|
||||
# if the room jid is in the list, the room has mentioned us
|
||||
self.muc_attentions = []
|
|
@ -342,9 +342,10 @@ class MessageWindowMgr:
|
|||
class MessageControl(gtk.VBox):
|
||||
'''An abstract base widget that can embed in the gtk.Notebook of a MessageWindow'''
|
||||
|
||||
def __init__(self, parent_win, widget_name, display_name, contact, account):
|
||||
def __init__(self, type_id, parent_win, widget_name, display_name, contact, account):
|
||||
gtk.VBox.__init__(self)
|
||||
|
||||
self.type_id = type_id
|
||||
self.parent_win = parent_win
|
||||
self.widget_name = widget_name
|
||||
self.display_name = display_name
|
||||
|
|
|
@ -31,8 +31,6 @@ import os
|
|||
import time
|
||||
|
||||
import common.sleepy
|
||||
import tabbed_chat_window
|
||||
import groupchat_window
|
||||
import history_window
|
||||
import dialogs
|
||||
import vcard
|
||||
|
@ -48,6 +46,7 @@ from common import helpers
|
|||
from common import i18n
|
||||
from message_window import MessageWindowMgr
|
||||
from chat_control import ChatControl
|
||||
from groupchat_control import GroupchatControl
|
||||
|
||||
_ = i18n._
|
||||
APP = i18n.APP
|
||||
|
@ -1649,28 +1648,16 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
|
|||
self.make_menu()
|
||||
|
||||
def new_chat(self, contact, account):
|
||||
# Get target window
|
||||
mw = gajim.interface.msg_win_mgr.get_window(contact, account, None) # FIXME: type arg
|
||||
# Get target window, create a control, and associate it with the window
|
||||
mw = gajim.interface.msg_win_mgr.get_window(contact, account,
|
||||
ChatControl.TYPE_ID)
|
||||
chat_control = ChatControl(mw, contact, account)
|
||||
mw.new_tab(chat_control)
|
||||
|
||||
# REMOVE: eliminate all usage of gajim.interface.instances[account]['chats']
|
||||
##################################
|
||||
# chats = gajim.interface.instances[account]['chats']
|
||||
# if gajim.config.get('usetabbedchat'):
|
||||
# if not chats.has_key('tabbed'):
|
||||
# chats['tabbed'] = tabbed_chat_window.TabbedChatWindow(contact,
|
||||
# account)
|
||||
# else:
|
||||
# chats['tabbed'].new_tab(contact)
|
||||
#
|
||||
# chats[contact.jid] = chats['tabbed']
|
||||
# else:
|
||||
# chats[contact.jid] = tabbed_chat_window.TabbedChatWindow(contact,
|
||||
# account)
|
||||
#######################
|
||||
|
||||
def new_chat_from_jid(self, account, jid):
|
||||
# FIXME
|
||||
if gajim.contacts[account].has_key(jid):
|
||||
contact = gajim.get_contact_instance_with_highest_priority(account, jid)
|
||||
else:
|
||||
|
@ -1691,19 +1678,17 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
|
|||
gajim.interface.instances[account]['chats'][jid].window.present()
|
||||
|
||||
def new_room(self, jid, nick, account):
|
||||
if gajim.config.get('usetabbedchat'):
|
||||
if not gajim.interface.instances[account]['gc'].has_key('tabbed'):
|
||||
gajim.interface.instances[account]['gc']['tabbed'] = \
|
||||
groupchat_window.GroupchatWindow(jid, nick, account)
|
||||
else:
|
||||
gajim.interface.instances[account]['gc']['tabbed'].new_room(jid, nick)
|
||||
gajim.interface.instances[account]['gc'][jid] = \
|
||||
gajim.interface.instances[account]['gc']['tabbed']
|
||||
else:
|
||||
gajim.interface.instances[account]['gc'][jid] = \
|
||||
groupchat_window.GroupchatWindow(jid, nick, account)
|
||||
# FIXME: Not contact. Use jid and nick
|
||||
# Get target window, create a control, and associate it with the window
|
||||
mw = gajim.interface.msg_win_mgr.get_window(contact, account,
|
||||
GroupchatControl.TYPE_ID)
|
||||
gc_control = ChatControl(mw, contact, account)
|
||||
mw.new_tab(gc_control)
|
||||
# REMOVE: eliminate all usage of gajim.interface.instances[account]['gc']
|
||||
##################################
|
||||
|
||||
def on_message(self, jid, msg, tim, account, encrypted = False,
|
||||
# FIXME
|
||||
msg_type = '', subject = None, resource = ''):
|
||||
'''when we receive a message'''
|
||||
if not gajim.contacts[account].has_key(jid):
|
||||
|
|
Loading…
Reference in New Issue