Philipp Hörist pushed to branch master at gajim / gajim
Commits:
97a53a65 by Daniel Brötzmann at 2020-07-07T23:06:31+02:00
Roster: Allow sending messages to multiple groups
- - - - -
f309d2b1 by Daniel Brötzmann at 2020-07-07T23:06:32+02:00
InviteMenu: Create menuitem before checking for Transports group
Otherwise modifying this menuitem later will fail (UnboundLocalError)
- - - - -
1 changed file:
- gajim/roster_window.py
Changes:
=====================================
gajim/roster_window.py
=====================================
@@ -4782,38 +4782,49 @@ class RosterWindow:
menu.show_all()
menu.popup(None, None, None, None, event_button, event.time)
- def make_group_menu(self, event, titer):
+ def make_group_menu(self, event, iters):
"""
Make group's popup menu
"""
model = self.modelfilter
- group = model[titer][Column.JID]
- account = model[titer][Column.ACCOUNT]
+ groups = []
+ accounts = []
+
+ list_ = [] # list of (contact, account) tuples
+ list_online = [] # list of (contact, account) tuples
- list_ = [] # list of (contact, account) tuples
- list_online = [] # list of (contact, account) tuples
+ for titer in iters:
+ groups.append(model[titer][Column.JID])
+ accounts.append(model[titer][Column.ACCOUNT])
+ # Don't show menu if groups of more than one account are selected
+ if accounts[0] != model[titer][Column.ACCOUNT]:
+ return
+ account = accounts[0]
show_bookmarked = True
- group = model[titer][Column.JID]
for jid in app.contacts.get_jid_list(account):
contact = app.contacts.get_contact_with_highest_priority(account,
jid)
- if group in contact.get_shown_groups():
- if contact.show not in ('offline', 'error'):
- list_online.append((contact, account))
- # Check that all contacts support direct NUC invite
- if not contact.supports(Namespace.CONFERENCE):
- show_bookmarked = False
- list_.append((contact, account))
+ for group in groups:
+ if group in contact.get_shown_groups():
+ if contact.show not in ('offline', 'error'):
+ list_online.append((contact, account))
+ # Check that all contacts support direct NUC invite
+ if not contact.supports(Namespace.CONFERENCE):
+ show_bookmarked = False
+ list_.append((contact, account))
menu = Gtk.Menu()
# Make special context menu if group is Groupchats
- if group == _('Group chats'):
- maximize_menuitem = Gtk.MenuItem.new_with_mnemonic(_(
- '_Maximize All'))
- maximize_menuitem.connect('activate',
- self.on_all_groupchat_maximized, list_)
- menu.append(maximize_menuitem)
+ if _('Group chats') in groups:
+ if len(groups) == 1:
+ maximize_menuitem = Gtk.MenuItem.new_with_mnemonic(
+ _('_Maximize All'))
+ maximize_menuitem.connect('activate',
+ self.on_all_groupchat_maximized, list_)
+ menu.append(maximize_menuitem)
+ else:
+ return
else:
# Send Group Message
send_group_message_item = Gtk.MenuItem.new_with_mnemonic(
@@ -4838,10 +4849,9 @@ class RosterWindow:
self.on_send_single_message_menuitem_activate, account, list_)
# Invite to
- if group != _('Transports'):
- invite_menuitem = Gtk.MenuItem.new_with_mnemonic(
- _('In_vite to'))
-
+ invite_menuitem = Gtk.MenuItem.new_with_mnemonic(
+ _('In_vite to'))
+ if _('Transports') not in groups:
gui_menu_builder.build_invite_submenu(invite_menuitem,
list_online, show_bookmarked=show_bookmarked)
menu.append(invite_menuitem)
@@ -4854,7 +4864,14 @@ class RosterWindow:
send_group_message_item.set_sensitive(False)
invite_menuitem.set_sensitive(False)
- if not group in helpers.special_groups:
+ special_group = False
+ for group in groups:
+ if group in helpers.special_groups:
+ special_group = True
+ break
+
+ if not special_group and len(groups) == 1:
+ group = groups[0]
item = Gtk.SeparatorMenuItem.new() # separator
menu.append(item)
@@ -5071,8 +5088,8 @@ class RosterWindow:
for titer in iters[1:]:
if model[titer][Column.TYPE] != type_:
return
- if type_ == 'group' and len(iters) == 1:
- self.make_group_menu(event, iters[0])
+ if type_ == 'group':
+ self.make_group_menu(event, iters)
if type_ == 'groupchat' and len(iters) == 1:
self.make_groupchat_menu(event, iters[0])
elif type_ == 'agent' and len(iters) == 1:
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/7832e433f7852b5cef1ee53747184dae21f2d27d...f309d2b1299145897e58f9214df1af2ec229d29c
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/7832e433f7852b5cef1ee53747184dae21f2d27d...f309d2b1299145897e58f9214df1af2ec229d29c
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits