[roidelapluie] better groupchat support in roster and systray. Better nick support
This commit is contained in:
parent
170e0af3aa
commit
52c6c6cbb7
|
@ -552,6 +552,11 @@ def get_icon_name_to_show(contact, account = None):
|
||||||
contact.jid in gajim.interface.minimized_controls[account] and gajim.interface.\
|
contact.jid in gajim.interface.minimized_controls[account] and gajim.interface.\
|
||||||
minimized_controls[account][contact.jid].get_nb_unread_pm() > 0:
|
minimized_controls[account][contact.jid].get_nb_unread_pm() > 0:
|
||||||
return 'message'
|
return 'message'
|
||||||
|
if account and gajim.gc_connected[account].has_key(contact.jid):
|
||||||
|
if gajim.gc_connected[account][contact.jid]:
|
||||||
|
return 'muc_active'
|
||||||
|
else:
|
||||||
|
return 'muc_inactive'
|
||||||
if contact.jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent
|
if contact.jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent
|
||||||
return contact.show
|
return contact.show
|
||||||
if contact.sub in ('both', 'to'):
|
if contact.sub in ('both', 'to'):
|
||||||
|
|
|
@ -2127,6 +2127,14 @@ class Interface:
|
||||||
jid = gajim.get_jid_without_resource(fjid)
|
jid = gajim.get_jid_without_resource(fjid)
|
||||||
if type_ in ('printed_gc_msg', 'printed_marked_gc_msg', 'gc_msg'):
|
if type_ in ('printed_gc_msg', 'printed_marked_gc_msg', 'gc_msg'):
|
||||||
w = self.msg_win_mgr.get_window(jid, account)
|
w = self.msg_win_mgr.get_window(jid, account)
|
||||||
|
if gajim.interface.minimized_controls.has_key(account) and \
|
||||||
|
gajim.interface.minimized_controls[account].has_key(fjid):
|
||||||
|
ctrl = gajim.interface.minimized_controls[account][fjid]
|
||||||
|
if not w:
|
||||||
|
w = gajim.interface.msg_win_mgr.create_window(ctrl.contact, \
|
||||||
|
ctrl.account, ctrl.type_id)
|
||||||
|
ctrl.parent_win = w
|
||||||
|
w.new_tab(ctrl)
|
||||||
elif type_ in ('printed_chat', 'chat', ''):
|
elif type_ in ('printed_chat', 'chat', ''):
|
||||||
# '' is for log in/out notifications
|
# '' is for log in/out notifications
|
||||||
if self.msg_win_mgr.has_window(fjid, account):
|
if self.msg_win_mgr.has_window(fjid, account):
|
||||||
|
|
|
@ -697,7 +697,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
if self.needs_visual_notification(text):
|
if self.needs_visual_notification(text):
|
||||||
highlight = True
|
highlight = True
|
||||||
if gajim.config.get_per('soundevents', 'muc_message_highlight',
|
if gajim.config.get_per('soundevents', 'muc_message_highlight',
|
||||||
'enabled'):
|
'enabled'):
|
||||||
sound = 'highlight'
|
sound = 'highlight'
|
||||||
|
|
||||||
# Is it a history message? Don't want sound-floods when we join.
|
# Is it a history message? Don't want sound-floods when we join.
|
||||||
|
@ -891,8 +891,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
'reason': reason }
|
'reason': reason }
|
||||||
self.print_conversation(s, 'info', tim = tim)
|
self.print_conversation(s, 'info', tim = tim)
|
||||||
elif statusCode == '303': # Someone changed his or her nick
|
elif statusCode == '303': # Someone changed his or her nick
|
||||||
if nick == self.nick: # We changed our nick
|
if new_nick == self.nick: # We changed our nick
|
||||||
self.nick = new_nick
|
|
||||||
s = _('You are now known as %s') % new_nick
|
s = _('You are now known as %s') % new_nick
|
||||||
else:
|
else:
|
||||||
s = _('%s is now known as %s') % (nick, new_nick)
|
s = _('%s is now known as %s') % (nick, new_nick)
|
||||||
|
@ -902,6 +901,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
# after that, but that doesn't hurt
|
# after that, but that doesn't hurt
|
||||||
self.add_contact_to_roster(new_nick, show, role, affiliation,
|
self.add_contact_to_roster(new_nick, show, role, affiliation,
|
||||||
status, jid)
|
status, jid)
|
||||||
|
if nick in self.attention_list:
|
||||||
|
self.attention_list.remove(nick)
|
||||||
# keep nickname color
|
# keep nickname color
|
||||||
if nick in self.gc_custom_colors:
|
if nick in self.gc_custom_colors:
|
||||||
self.gc_custom_colors[new_nick] = self.gc_custom_colors[nick]
|
self.gc_custom_colors[new_nick] = self.gc_custom_colors[nick]
|
||||||
|
@ -1011,6 +1012,9 @@ class GroupchatControl(ChatControlBase):
|
||||||
# delete ressource
|
# delete ressource
|
||||||
simple_jid = gajim.get_jid_without_resource(jid)
|
simple_jid = gajim.get_jid_without_resource(jid)
|
||||||
nick_jid += ' (%s)' % simple_jid
|
nick_jid += ' (%s)' % simple_jid
|
||||||
|
if show == 'offline':
|
||||||
|
if nick in self.attention_list:
|
||||||
|
self.attention_list.remove(nick)
|
||||||
if show == 'offline' and print_status in ('all', 'in_and_out') and \
|
if show == 'offline' and print_status in ('all', 'in_and_out') and \
|
||||||
statusCode != '307':
|
statusCode != '307':
|
||||||
st = _('%s has left') % nick_jid
|
st = _('%s has left') % nick_jid
|
||||||
|
@ -1127,6 +1131,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
nick = message_array[0]
|
nick = message_array[0]
|
||||||
nick = helpers.parse_resource(nick)
|
nick = helpers.parse_resource(nick)
|
||||||
gajim.connections[self.account].join_gc(nick, self.room_jid, None)
|
gajim.connections[self.account].join_gc(nick, self.room_jid, None)
|
||||||
|
self.nick = nick
|
||||||
self.clear(self.msg_textview)
|
self.clear(self.msg_textview)
|
||||||
else:
|
else:
|
||||||
self.get_command_help(command)
|
self.get_command_help(command)
|
||||||
|
@ -1408,6 +1413,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
nick = instance.input_entry.get_text().decode('utf-8')
|
nick = instance.input_entry.get_text().decode('utf-8')
|
||||||
nick = helpers.parse_resource(nick)
|
nick = helpers.parse_resource(nick)
|
||||||
gajim.connections[self.account].join_gc(nick, self.room_jid, None)
|
gajim.connections[self.account].join_gc(nick, self.room_jid, None)
|
||||||
|
self.nick = nick
|
||||||
instance = dialogs.InputDialog(title, prompt, proposed_nick,
|
instance = dialogs.InputDialog(title, prompt, proposed_nick,
|
||||||
is_modal = False, ok_handler = on_ok)
|
is_modal = False, ok_handler = on_ok)
|
||||||
|
|
||||||
|
|
|
@ -370,7 +370,7 @@ class RosterWindow:
|
||||||
typestr = 'contact'
|
typestr = 'contact'
|
||||||
if group == _('Transports'):
|
if group == _('Transports'):
|
||||||
typestr = 'agent'
|
typestr = 'agent'
|
||||||
if group == _('Groupchats'):
|
if gajim.gc_connected[account].has_key(jid):
|
||||||
typestr = 'groupchat'
|
typestr = 'groupchat'
|
||||||
|
|
||||||
name = contact.get_shown_name()
|
name = contact.get_shown_name()
|
||||||
|
@ -426,12 +426,18 @@ class RosterWindow:
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||||
if contact == None:
|
if contact == None:
|
||||||
contact = gajim.contacts.create_contact(jid = jid, name = jid,
|
contact = gajim.contacts.create_contact(jid = jid, name = jid,
|
||||||
groups = [_('Groupchats')], show = 'muc_active',
|
groups = [_('Groupchats')], show = 'online',
|
||||||
status = status, sub = 'none',
|
status = status, sub = 'none',
|
||||||
resource = resource)
|
resource = resource)
|
||||||
gajim.contacts.add_contact(account, contact)
|
gajim.contacts.add_contact(account, contact)
|
||||||
self.add_contact_to_roster(jid, account)
|
self.add_contact_to_roster(jid, account)
|
||||||
self.draw_group(_('Groupchats'), account)
|
self.draw_group(_('Groupchats'), account)
|
||||||
|
else:
|
||||||
|
contact.show = 'online'
|
||||||
|
self.draw_contact(jid, account)
|
||||||
|
self.add_contact_to_roster(jid, account)
|
||||||
|
for group in contact.groups:
|
||||||
|
self.draw_group(group, account)
|
||||||
return contact
|
return contact
|
||||||
|
|
||||||
def get_self_contact_iter(self, account):
|
def get_self_contact_iter(self, account):
|
||||||
|
@ -645,22 +651,28 @@ class RosterWindow:
|
||||||
status = helpers.reduce_chars_newlines(status, max_lines = 1)
|
status = helpers.reduce_chars_newlines(status, max_lines = 1)
|
||||||
# escape markup entities and make them small italic and fg color
|
# escape markup entities and make them small italic and fg color
|
||||||
color = gtkgui_helpers._get_fade_color(self.tree, selected, focus)
|
color = gtkgui_helpers._get_fade_color(self.tree, selected, focus)
|
||||||
colorstring = "#%04x%04x%04x" % (color.red, color.green, color.blue)
|
colorstring = '#%04x%04x%04x' % (color.red, color.green, color.blue)
|
||||||
name += \
|
name += \
|
||||||
'\n<span size="small" style="italic" foreground="%s">%s</span>' \
|
'\n<span size="small" style="italic" foreground="%s">%s</span>' \
|
||||||
% (colorstring, gobject.markup_escape_text(status))
|
% (colorstring, gobject.markup_escape_text(status))
|
||||||
|
|
||||||
iter = iters[0] # choose the icon with the first iter
|
iter = iters[0] # choose the icon with the first iter
|
||||||
|
|
||||||
|
if gajim.gc_connected[account].has_key(jid):
|
||||||
|
contact.show = 'online'
|
||||||
|
model[iter][C_TYPE] = 'groupchat'
|
||||||
|
|
||||||
icon_name = helpers.get_icon_name_to_show(contact, account)
|
icon_name = helpers.get_icon_name_to_show(contact, account)
|
||||||
# look if another resource has awaiting events
|
# look if another resource has awaiting events
|
||||||
for c in contact_instances:
|
for c in contact_instances:
|
||||||
c_icon_name = helpers.get_icon_name_to_show(c, account)
|
c_icon_name = helpers.get_icon_name_to_show(c, account)
|
||||||
if c_icon_name == 'message':
|
if c_icon_name in ('message', 'muc_active', 'muc_inactive'):
|
||||||
icon_name = c_icon_name
|
icon_name = c_icon_name
|
||||||
break
|
break
|
||||||
path = model.get_path(iter)
|
path = model.get_path(iter)
|
||||||
if model.iter_has_child(iter):
|
if model.iter_has_child(iter):
|
||||||
if not self.tree.row_expanded(path) and icon_name != 'message':
|
if not self.tree.row_expanded(path) and \
|
||||||
|
icon_name not in ('message', 'muc_active', 'muc_inactive'):
|
||||||
child_iter = model.iter_children(iter)
|
child_iter = model.iter_children(iter)
|
||||||
if icon_name in ('error', 'offline'):
|
if icon_name in ('error', 'offline'):
|
||||||
# get the icon from the first child as they are sorted by show
|
# get the icon from the first child as they are sorted by show
|
||||||
|
@ -692,13 +704,6 @@ class RosterWindow:
|
||||||
state_images = self.get_appropriate_state_images(jid,
|
state_images = self.get_appropriate_state_images(jid,
|
||||||
icon_name = icon_name)
|
icon_name = icon_name)
|
||||||
|
|
||||||
if icon_name != 'message' and gajim.gc_connected[account].\
|
|
||||||
has_key(jid):
|
|
||||||
if gajim.gc_connected[account][jid]:
|
|
||||||
icon_name = 'muc_active'
|
|
||||||
else:
|
|
||||||
icon_name = 'muc_inactive'
|
|
||||||
|
|
||||||
img = state_images[icon_name]
|
img = state_images[icon_name]
|
||||||
|
|
||||||
for iter in iters:
|
for iter in iters:
|
||||||
|
@ -754,18 +759,20 @@ class RosterWindow:
|
||||||
if minimize:
|
if minimize:
|
||||||
contact = gajim.contacts.create_contact(jid = room_jid, name = nick)
|
contact = gajim.contacts.create_contact(jid = room_jid, name = nick)
|
||||||
gc_control = GroupchatControl(None, contact, account)
|
gc_control = GroupchatControl(None, contact, account)
|
||||||
|
|
||||||
if not gajim.interface.minimized_controls.has_key(account):
|
if not gajim.interface.minimized_controls.has_key(account):
|
||||||
gajim.interface.minimized_controls[account] = {}
|
gajim.interface.minimized_controls[account] = {}
|
||||||
gajim.interface.minimized_controls[account][room_jid] = gc_control
|
gajim.interface.minimized_controls[account][room_jid] = gc_control
|
||||||
|
|
||||||
self.add_groupchat_to_roster(account, room_jid)
|
|
||||||
gajim.connections[account].join_gc(nick, room_jid, password)
|
gajim.connections[account].join_gc(nick, room_jid, password)
|
||||||
if password:
|
if password:
|
||||||
gajim.gc_passwords[room_jid] = password
|
gajim.gc_passwords[room_jid] = password
|
||||||
|
self.add_groupchat_to_roster(account, room_jid)
|
||||||
return
|
return
|
||||||
if not gajim.interface.msg_win_mgr.has_window(room_jid, account):
|
if not gajim.interface.msg_win_mgr.has_window(room_jid, account):
|
||||||
self.new_room(room_jid, nick, 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)
|
||||||
gc_win = gajim.interface.msg_win_mgr.get_window(room_jid, account)
|
gc_win = gajim.interface.msg_win_mgr.get_window(room_jid, account)
|
||||||
gc_win.set_active_tab(room_jid, account)
|
gc_win.set_active_tab(room_jid, account)
|
||||||
gc_win.window.present()
|
gc_win.window.present()
|
||||||
|
@ -2403,13 +2410,16 @@ class RosterWindow:
|
||||||
|
|
||||||
menu = gtk.Menu()
|
menu = gtk.Menu()
|
||||||
|
|
||||||
maximize_menuitem = gtk.ImageMenuItem(_('_Maximize'))
|
if gajim.interface.minimized_controls.has_key(account) and \
|
||||||
icon = gtk.image_new_from_stock(gtk.STOCK_GOTO_TOP, gtk.ICON_SIZE_MENU)
|
jid in gajim.interface.minimized_controls[account]:
|
||||||
maximize_menuitem.set_image(icon)
|
maximize_menuitem = gtk.ImageMenuItem(_('_Maximize'))
|
||||||
maximize_menuitem.connect('activate', self.on_groupchat_maximized, \
|
icon = gtk.image_new_from_stock(gtk.STOCK_GOTO_TOP, gtk.ICON_SIZE_MENU)
|
||||||
jid, account)
|
maximize_menuitem.set_image(icon)
|
||||||
|
maximize_menuitem.connect('activate', self.on_groupchat_maximized, \
|
||||||
|
jid, account)
|
||||||
|
menu.append(maximize_menuitem)
|
||||||
|
|
||||||
|
|
||||||
menu.append(maximize_menuitem)
|
|
||||||
|
|
||||||
event_button = gtkgui_helpers.get_possible_button_event(event)
|
event_button = gtkgui_helpers.get_possible_button_event(event)
|
||||||
|
|
||||||
|
@ -2437,9 +2447,10 @@ class RosterWindow:
|
||||||
mw.window.present()
|
mw.window.present()
|
||||||
|
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||||
self.remove_contact(contact, account)
|
if contact.groups == [_('Groupchats')]:
|
||||||
gajim.contacts.remove_contact(account, contact)
|
self.remove_contact(contact, account)
|
||||||
self.draw_group(_('Groupchats'), account)
|
gajim.contacts.remove_contact(account, contact)
|
||||||
|
self.draw_group(_('Groupchats'), account)
|
||||||
del gajim.interface.minimized_controls[account][jid]
|
del gajim.interface.minimized_controls[account][jid]
|
||||||
|
|
||||||
def make_group_menu(self, event, iter):
|
def make_group_menu(self, event, iter):
|
||||||
|
@ -4374,6 +4385,10 @@ class RosterWindow:
|
||||||
return 1
|
return 1
|
||||||
if name2 == _('Not in Roster'):
|
if name2 == _('Not in Roster'):
|
||||||
return -1
|
return -1
|
||||||
|
if name1 == _('Groupchats'):
|
||||||
|
return 1
|
||||||
|
if name2 == _('Groupchats'):
|
||||||
|
return -1
|
||||||
account1 = model[iter1][C_ACCOUNT]
|
account1 = model[iter1][C_ACCOUNT]
|
||||||
account2 = model[iter2][C_ACCOUNT]
|
account2 = model[iter2][C_ACCOUNT]
|
||||||
if not account1 or not account2:
|
if not account1 or not account2:
|
||||||
|
|
Loading…
Reference in New Issue