Preliminary GroupchatControl support
This commit is contained in:
parent
008dfea48b
commit
496199aaef
4 changed files with 57 additions and 34 deletions
|
@ -63,8 +63,8 @@ class ChatControlBase(MessageControl):
|
||||||
def _update_banner_state_image(self):
|
def _update_banner_state_image(self):
|
||||||
pass # Derived types MAY implement this
|
pass # Derived types MAY implement this
|
||||||
|
|
||||||
def __init__(self, parent_win, widget_name, display_name, contact, acct):
|
def __init__(self, type_id, parent_win, widget_name, display_name, contact, acct):
|
||||||
MessageControl.__init__(self, parent_win, widget_name, display_name,
|
MessageControl.__init__(self, type_id, parent_win, widget_name, display_name,
|
||||||
contact, acct);
|
contact, acct);
|
||||||
|
|
||||||
# FIXME: These are hidden from 0.8 on, but IMO all these things need
|
# FIXME: These are hidden from 0.8 on, but IMO all these things need
|
||||||
|
@ -372,9 +372,11 @@ class ChatControlBase(MessageControl):
|
||||||
|
|
||||||
class ChatControl(ChatControlBase):
|
class ChatControl(ChatControlBase):
|
||||||
'''A control for standard 1-1 chat'''
|
'''A control for standard 1-1 chat'''
|
||||||
|
TYPE_ID = 1
|
||||||
|
|
||||||
def __init__(self, parent_win, contact, acct):
|
def __init__(self, parent_win, contact, acct):
|
||||||
ChatControlBase.__init__(self, parent_win, 'chat_child_vbox', _('Chat'),
|
ChatControlBase.__init__(self, self.TYPE_ID, parent_win, 'chat_child_vbox',
|
||||||
contact, acct);
|
_('Chat'), contact, acct);
|
||||||
self.compact_view_always = gajim.config.get('always_compact_view_chat')
|
self.compact_view_always = gajim.config.get('always_compact_view_chat')
|
||||||
self.set_compact_view(self.compact_view_always)
|
self.set_compact_view(self.compact_view_always)
|
||||||
|
|
||||||
|
|
35
src/groupchat_control.py
Normal file
35
src/groupchat_control.py
Normal file
|
@ -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):
|
class MessageControl(gtk.VBox):
|
||||||
'''An abstract base widget that can embed in the gtk.Notebook of a MessageWindow'''
|
'''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)
|
gtk.VBox.__init__(self)
|
||||||
|
|
||||||
|
self.type_id = type_id
|
||||||
self.parent_win = parent_win
|
self.parent_win = parent_win
|
||||||
self.widget_name = widget_name
|
self.widget_name = widget_name
|
||||||
self.display_name = display_name
|
self.display_name = display_name
|
||||||
|
|
|
@ -31,8 +31,6 @@ import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import common.sleepy
|
import common.sleepy
|
||||||
import tabbed_chat_window
|
|
||||||
import groupchat_window
|
|
||||||
import history_window
|
import history_window
|
||||||
import dialogs
|
import dialogs
|
||||||
import vcard
|
import vcard
|
||||||
|
@ -48,6 +46,7 @@ from common import helpers
|
||||||
from common import i18n
|
from common import i18n
|
||||||
from message_window import MessageWindowMgr
|
from message_window import MessageWindowMgr
|
||||||
from chat_control import ChatControl
|
from chat_control import ChatControl
|
||||||
|
from groupchat_control import GroupchatControl
|
||||||
|
|
||||||
_ = i18n._
|
_ = i18n._
|
||||||
APP = i18n.APP
|
APP = i18n.APP
|
||||||
|
@ -1649,28 +1648,16 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
|
||||||
self.make_menu()
|
self.make_menu()
|
||||||
|
|
||||||
def new_chat(self, contact, account):
|
def new_chat(self, contact, account):
|
||||||
# Get target window
|
# Get target window, create a control, and associate it with the window
|
||||||
mw = gajim.interface.msg_win_mgr.get_window(contact, account, None) # FIXME: type arg
|
mw = gajim.interface.msg_win_mgr.get_window(contact, account,
|
||||||
|
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)
|
||||||
|
|
||||||
# REMOVE: eliminate all usage of gajim.interface.instances[account]['chats']
|
# 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):
|
def new_chat_from_jid(self, account, jid):
|
||||||
|
# FIXME
|
||||||
if gajim.contacts[account].has_key(jid):
|
if gajim.contacts[account].has_key(jid):
|
||||||
contact = gajim.get_contact_instance_with_highest_priority(account, jid)
|
contact = gajim.get_contact_instance_with_highest_priority(account, jid)
|
||||||
else:
|
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()
|
gajim.interface.instances[account]['chats'][jid].window.present()
|
||||||
|
|
||||||
def new_room(self, jid, nick, account):
|
def new_room(self, jid, nick, account):
|
||||||
if gajim.config.get('usetabbedchat'):
|
# FIXME: Not contact. Use jid and nick
|
||||||
if not gajim.interface.instances[account]['gc'].has_key('tabbed'):
|
# Get target window, create a control, and associate it with the window
|
||||||
gajim.interface.instances[account]['gc']['tabbed'] = \
|
mw = gajim.interface.msg_win_mgr.get_window(contact, account,
|
||||||
groupchat_window.GroupchatWindow(jid, nick, account)
|
GroupchatControl.TYPE_ID)
|
||||||
else:
|
gc_control = ChatControl(mw, contact, account)
|
||||||
gajim.interface.instances[account]['gc']['tabbed'].new_room(jid, nick)
|
mw.new_tab(gc_control)
|
||||||
gajim.interface.instances[account]['gc'][jid] = \
|
# REMOVE: eliminate all usage of gajim.interface.instances[account]['gc']
|
||||||
gajim.interface.instances[account]['gc']['tabbed']
|
##################################
|
||||||
else:
|
|
||||||
gajim.interface.instances[account]['gc'][jid] = \
|
|
||||||
groupchat_window.GroupchatWindow(jid, nick, account)
|
|
||||||
|
|
||||||
def on_message(self, jid, msg, tim, account, encrypted = False,
|
def on_message(self, jid, msg, tim, account, encrypted = False,
|
||||||
|
# FIXME
|
||||||
msg_type = '', subject = None, resource = ''):
|
msg_type = '', subject = None, resource = ''):
|
||||||
'''when we receive a message'''
|
'''when we receive a message'''
|
||||||
if not gajim.contacts[account].has_key(jid):
|
if not gajim.contacts[account].has_key(jid):
|
||||||
|
|
Loading…
Add table
Reference in a new issue