Fix some bugs with minimized groupchats.
This commit is contained in:
parent
babd1ee042
commit
6338f63f03
|
@ -569,7 +569,6 @@ class ChatControlBase(MessageControl):
|
|||
full_jid != self.parent_win.get_active_jid() or \
|
||||
not self.parent_win.is_active() or not end)) or \
|
||||
(gc_message and \
|
||||
gajim.interface.minimized_controls.has_key(self.account) and \
|
||||
jid in gajim.interface.minimized_controls[self.account])) and \
|
||||
kind in ('incoming', 'incoming_queue'):
|
||||
# we want to have save this message in events list
|
||||
|
@ -683,8 +682,6 @@ class ChatControlBase(MessageControl):
|
|||
control.unparent()
|
||||
ctrl.parent_win = None
|
||||
|
||||
if not gajim.interface.minimized_controls.has_key(self.account):
|
||||
gajim.interface.minimized_controls[self.account] = {}
|
||||
gajim.interface.minimized_controls[self.account][self.contact.jid] = ctrl
|
||||
|
||||
del win._controls[self.account][self.contact.jid]
|
||||
|
@ -825,8 +822,7 @@ class ChatControlBase(MessageControl):
|
|||
room_jid, nick = gajim.get_room_and_nick_from_fjid(jid)
|
||||
groupchat_control = gajim.interface.msg_win_mgr.get_control(
|
||||
room_jid, self.account)
|
||||
if gajim.interface.minimized_controls.has_key(self.account) and \
|
||||
room_jid in gajim.interface.minimized_controls[self.account]:
|
||||
if room_jid in gajim.interface.minimized_controls[self.account]:
|
||||
groupchat_control = \
|
||||
gajim.interface.minimized_controls[self.account][room_jid]
|
||||
contact = \
|
||||
|
|
35
src/gajim.py
35
src/gajim.py
|
@ -396,6 +396,9 @@ class Interface:
|
|||
prompt = data[2]
|
||||
proposed_nick = data[3]
|
||||
gc_control = self.msg_win_mgr.get_control(room_jid, account)
|
||||
if not gc_control and \
|
||||
room_jid in self.minimized_controls[account]:
|
||||
gc_control = self.minimized_controls[account][room_jid]
|
||||
if gc_control: # user may close the window before we are here
|
||||
gc_control.show_change_nick_input_dialog(title, prompt, proposed_nick)
|
||||
|
||||
|
@ -479,7 +482,8 @@ class Interface:
|
|||
model[self.roster.status_message_menuitem_iter][3] = True
|
||||
|
||||
# Inform all controls for this account of the connection state change
|
||||
for ctrl in self.msg_win_mgr.get_controls():
|
||||
for ctrl in self.msg_win_mgr.get_controls() + \
|
||||
self.minimized_controls[account].values():
|
||||
if ctrl.account == account:
|
||||
if status == 'offline' or (status == 'invisible' and \
|
||||
gajim.connections[account].is_zeroconf):
|
||||
|
@ -488,6 +492,7 @@ class Interface:
|
|||
# Other code rejoins all GCs, so we don't do it here
|
||||
if not ctrl.type_id == message_control.TYPE_GC:
|
||||
ctrl.got_connected()
|
||||
if ctrl.parent_win:
|
||||
ctrl.parent_win.redraw_tab(ctrl)
|
||||
|
||||
self.roster.on_status_changed(account, status)
|
||||
|
@ -687,7 +692,6 @@ class Interface:
|
|||
|
||||
groupchat_control = self.msg_win_mgr.get_control(jid, account)
|
||||
if not groupchat_control and \
|
||||
self.minimized_controls.has_key(account) and \
|
||||
jid in self.minimized_controls[account]:
|
||||
groupchat_control = self.minimized_controls[account][jid]
|
||||
pm = False
|
||||
|
@ -798,6 +802,9 @@ class Interface:
|
|||
jids = full_jid_with_resource.split('/', 1)
|
||||
jid = jids[0]
|
||||
gc_control = self.msg_win_mgr.get_control(jid, account)
|
||||
if not gc_control and \
|
||||
jid in self.minimized_controls[account]:
|
||||
gc_control = self.minimized_controls[account][jid]
|
||||
if gc_control and gc_control.type_id != message_control.TYPE_GC:
|
||||
gc_control = None
|
||||
if gc_control:
|
||||
|
@ -821,7 +828,7 @@ class Interface:
|
|||
return
|
||||
|
||||
gc_control.print_conversation('Error %s: %s' % (array[1], array[2]))
|
||||
if gc_control.parent_win.get_active_jid() == jid:
|
||||
if gc_control.parent_win and gc_control.parent_win.get_active_jid() == jid:
|
||||
gc_control.set_subject(gc_control.subject)
|
||||
return
|
||||
|
||||
|
@ -1021,6 +1028,9 @@ class Interface:
|
|||
|
||||
# Show avatar in roster or gc_roster
|
||||
gc_ctrl = self.msg_win_mgr.get_control(jid, account)
|
||||
if not gc_ctrl and \
|
||||
jid in self.minimized_controls[account]:
|
||||
gc_ctrl = self.minimized_controls[account][jid]
|
||||
if gc_ctrl and gc_ctrl.type_id == message_control.TYPE_GC:
|
||||
gc_ctrl.draw_avatar(resource)
|
||||
else:
|
||||
|
@ -1076,7 +1086,6 @@ class Interface:
|
|||
# PrivateChatControl
|
||||
control = self.msg_win_mgr.get_control(room_jid, account)
|
||||
if not control and \
|
||||
self.minimized_controls.has_key(account) and \
|
||||
room_jid in self.minimized_controls[account]:
|
||||
control = self.minimized_controls[account][room_jid]
|
||||
|
||||
|
@ -1085,7 +1094,10 @@ class Interface:
|
|||
if control:
|
||||
control.chg_contact_status(nick, show, status, array[4], array[5],
|
||||
array[6], array[7], array[8], array[9], array[10], array[11])
|
||||
if control and not control.parent_win:
|
||||
|
||||
contact = gajim.contacts.\
|
||||
get_contact_with_highest_priority(account, room_jid)
|
||||
if contact:
|
||||
self.roster.draw_contact(room_jid, account)
|
||||
|
||||
ctrl = self.msg_win_mgr.get_control(fjid, account)
|
||||
|
@ -1114,7 +1126,6 @@ class Interface:
|
|||
|
||||
gc_control = self.msg_win_mgr.get_control(room_jid, account)
|
||||
if not gc_control and \
|
||||
self.minimized_controls.has_key(account) and \
|
||||
room_jid in self.minimized_controls[account]:
|
||||
gc_control = self.minimized_controls[account][room_jid]
|
||||
|
||||
|
@ -1149,7 +1160,6 @@ class Interface:
|
|||
gc_control = self.msg_win_mgr.get_control(jid, account)
|
||||
|
||||
if not gc_control and \
|
||||
self.minimized_controls.has_key(account) and \
|
||||
jid in self.minimized_controls[account]:
|
||||
gc_control = self.minimized_controls[account][jid]
|
||||
|
||||
|
@ -1615,7 +1625,8 @@ class Interface:
|
|||
if self.instances[account].has_key('profile'):
|
||||
win = self.instances[account]['profile']
|
||||
win.vcard_published()
|
||||
for gc_control in self.msg_win_mgr.get_controls(message_control.TYPE_GC):
|
||||
for gc_control in self.msg_win_mgr.get_controls(message_control.TYPE_GC) + \
|
||||
self.minimized_controls[account].values():
|
||||
if gc_control.account == account:
|
||||
show = gajim.SHOW_LIST[gajim.connections[account].connected]
|
||||
status = gajim.connections[account].status
|
||||
|
@ -1643,7 +1654,8 @@ class Interface:
|
|||
if gajim.connections[account].connected == invisible_show:
|
||||
return
|
||||
# join already open groupchats
|
||||
for gc_control in self.msg_win_mgr.get_controls(message_control.TYPE_GC):
|
||||
for gc_control in self.msg_win_mgr.get_controls(message_control.TYPE_GC) + \
|
||||
self.minimized_controls[account].values():
|
||||
if account != gc_control.account:
|
||||
continue
|
||||
room_jid = gc_control.room_jid
|
||||
|
@ -2127,8 +2139,7 @@ class Interface:
|
|||
jid = gajim.get_jid_without_resource(fjid)
|
||||
if type_ in ('printed_gc_msg', 'printed_marked_gc_msg', 'gc_msg'):
|
||||
w = self.msg_win_mgr.get_window(jid, account)
|
||||
if self.minimized_controls.has_key(account) and \
|
||||
self.minimized_controls[account].has_key(jid):
|
||||
if self.minimized_controls[account].has_key(jid):
|
||||
if not w:
|
||||
ctrl = self.minimized_controls[account][jid]
|
||||
w = self.msg_win_mgr.create_window(ctrl.contact, \
|
||||
|
@ -2308,6 +2319,8 @@ class Interface:
|
|||
for a in gajim.connections:
|
||||
self.instances[a] = {'infos': {}, 'disco': {}, 'gc_config': {},
|
||||
'search': {}}
|
||||
if not a in self.minimized_controls:
|
||||
self.minimized_controls[a] = {}
|
||||
gajim.contacts.add_account(a)
|
||||
gajim.groups[a] = {}
|
||||
gajim.gc_connected[a] = {}
|
||||
|
|
|
@ -100,8 +100,7 @@ class PrivateChatControl(ChatControl):
|
|||
def __init__(self, parent_win, gc_contact, contact, account):
|
||||
room_jid = contact.jid.split('/')[0]
|
||||
room_ctrl = gajim.interface.msg_win_mgr.get_control(room_jid, account)
|
||||
if gajim.interface.minimized_controls.has_key(account) and \
|
||||
gajim.interface.minimized_controls[account].has_key(room_jid):
|
||||
if gajim.interface.minimized_controls[account].has_key(room_jid):
|
||||
room_ctrl = gajim.interface.minimized_controls[account][room_jid]
|
||||
self.room_name = room_ctrl.name
|
||||
self.gc_contact = gc_contact
|
||||
|
@ -788,6 +787,7 @@ class GroupchatControl(ChatControlBase):
|
|||
gc_contact.show = 'offline'
|
||||
gc_contact.status = ''
|
||||
ctrl.update_ui()
|
||||
if ctrl.parent_win:
|
||||
ctrl.parent_win.redraw_tab(ctrl)
|
||||
gajim.contacts.remove_gc_contact(self.account, gc_contact)
|
||||
gajim.gc_connected[self.account][self.room_jid] = False
|
||||
|
@ -1455,10 +1455,6 @@ class GroupchatControl(ChatControlBase):
|
|||
del self.handlers[i]
|
||||
# Remove unread events from systray
|
||||
gajim.events.remove_events(self.account, self.room_jid)
|
||||
contact = gajim.contacts.get_contact_with_highest_priority(self.account, \
|
||||
self.room_jid)
|
||||
if contact:
|
||||
gajim.interface.roster.remove_contact(contact, self.account)
|
||||
|
||||
def allow_shutdown(self, method):
|
||||
'''If check_selection is True, '''
|
||||
|
|
|
@ -588,8 +588,7 @@ class RosterWindow:
|
|||
name = gobject.markup_escape_text(contact.get_shown_name())
|
||||
|
||||
# gets number of unread gc marked messages
|
||||
if gajim.interface.minimized_controls.has_key(account) and \
|
||||
jid in gajim.interface.minimized_controls[account]:
|
||||
if jid in gajim.interface.minimized_controls[account]:
|
||||
nb_unread = len(gajim.events.get_events(account, jid,
|
||||
['printed_marked_gc_msg']))
|
||||
nb_unread += \
|
||||
|
@ -748,38 +747,37 @@ class RosterWindow:
|
|||
win.set_active_tab(room_jid, account)
|
||||
dialogs.ErrorDialog(_('You are already in group chat %s') % room_jid)
|
||||
return
|
||||
if gajim.interface.minimized_controls.has_key(account) and \
|
||||
room_jid in gajim.interface.minimized_controls[account]:
|
||||
self.on_groupchat_maximized(None, room_jid, account)
|
||||
return
|
||||
minimized_control_exists = False
|
||||
if room_jid in gajim.interface.minimized_controls[account]:
|
||||
minimized_control_exists = True
|
||||
invisible_show = gajim.SHOW_LIST.index('invisible')
|
||||
if gajim.connections[account].connected == invisible_show:
|
||||
dialogs.ErrorDialog(
|
||||
_('You cannot join a group chat while you are invisible'))
|
||||
return
|
||||
if minimize:
|
||||
if minimize and not minimized_control_exists:
|
||||
contact = gajim.contacts.create_contact(jid = room_jid, name = nick)
|
||||
gc_control = GroupchatControl(None, contact, account)
|
||||
if not gajim.interface.minimized_controls.has_key(account):
|
||||
gajim.interface.minimized_controls[account] = {}
|
||||
gajim.interface.minimized_controls[account][room_jid] = gc_control
|
||||
gajim.connections[account].join_gc(nick, room_jid, password)
|
||||
if password:
|
||||
gajim.gc_passwords[room_jid] = password
|
||||
self.add_groupchat_to_roster(account, room_jid)
|
||||
return
|
||||
if not gajim.interface.msg_win_mgr.has_window(room_jid, account):
|
||||
if not minimized_control_exists and \
|
||||
not gajim.interface.msg_win_mgr.has_window(room_jid, account):
|
||||
self.new_room(room_jid, nick, account)
|
||||
contact = gajim.contacts.get_contact_with_highest_priority(account, \
|
||||
room_jid)
|
||||
if contact:
|
||||
self.add_groupchat_to_roster(account, room_jid)
|
||||
if not minimized_control_exists:
|
||||
gc_win = gajim.interface.msg_win_mgr.get_window(room_jid, account)
|
||||
gc_win.set_active_tab(room_jid, account)
|
||||
gc_win.window.present()
|
||||
gajim.connections[account].join_gc(nick, room_jid, password)
|
||||
if password:
|
||||
gajim.gc_passwords[room_jid] = password
|
||||
contact = gajim.contacts.get_contact_with_highest_priority(account, \
|
||||
room_jid)
|
||||
if contact or minimized_control_exists:
|
||||
self.add_groupchat_to_roster(account, room_jid)
|
||||
|
||||
def on_actions_menuitem_activate(self, widget):
|
||||
self.make_menu()
|
||||
|
@ -2456,8 +2454,7 @@ class RosterWindow:
|
|||
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||
menu = gtk.Menu()
|
||||
|
||||
if gajim.interface.minimized_controls.has_key(account) and \
|
||||
jid in gajim.interface.minimized_controls[account]:
|
||||
if jid in gajim.interface.minimized_controls[account]:
|
||||
maximize_menuitem = gtk.ImageMenuItem(_('_Maximize'))
|
||||
icon = gtk.image_new_from_stock(gtk.STOCK_GOTO_TOP, gtk.ICON_SIZE_MENU)
|
||||
maximize_menuitem.set_image(icon)
|
||||
|
@ -2487,8 +2484,6 @@ class RosterWindow:
|
|||
|
||||
def on_groupchat_maximized(self, widget, jid, account):
|
||||
'''When a groupchat is maximised'''
|
||||
if not gajim.interface.minimized_controls.has_key(account):
|
||||
return
|
||||
if not gajim.interface.minimized_controls[account].has_key(jid):
|
||||
return
|
||||
|
||||
|
@ -2502,13 +2497,15 @@ class RosterWindow:
|
|||
mw.new_tab(ctrl)
|
||||
mw.set_active_tab(jid, account)
|
||||
mw.window.present()
|
||||
del gajim.interface.minimized_controls[account][jid]
|
||||
|
||||
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||
if not contact:
|
||||
return
|
||||
if contact.groups == [_('Groupchats')]:
|
||||
self.remove_contact(contact, account)
|
||||
gajim.contacts.remove_contact(account, contact)
|
||||
self.draw_group(_('Groupchats'), account)
|
||||
del gajim.interface.minimized_controls[account][jid]
|
||||
|
||||
def make_group_menu(self, event, iter):
|
||||
'''Make group's popup menu'''
|
||||
|
@ -3312,8 +3309,6 @@ class RosterWindow:
|
|||
gajim.interface.status_sent_to_users[account] = {}
|
||||
if gajim.interface.status_sent_to_groups.has_key(account):
|
||||
gajim.interface.status_sent_to_groups[account] = {}
|
||||
if not gajim.interface.minimized_controls.has_key(account):
|
||||
gajim.interface.minimized_controls[account] = {}
|
||||
for gc_control in gajim.interface.msg_win_mgr.get_controls(
|
||||
message_control.TYPE_GC) + \
|
||||
gajim.interface.minimized_controls[account].values():
|
||||
|
@ -4067,8 +4062,7 @@ class RosterWindow:
|
|||
self.tree.collapse_row(path)
|
||||
else:
|
||||
self.tree.expand_row(path, False)
|
||||
elif gajim.interface.minimized_controls.has_key(account) and \
|
||||
gajim.interface.minimized_controls[account].has_key(jid):
|
||||
elif jid in gajim.interface.minimized_controls[account]:
|
||||
self.on_groupchat_maximized(None, jid, account)
|
||||
else:
|
||||
first_ev = gajim.events.get_first_event(account, jid)
|
||||
|
|
Loading…
Reference in New Issue