show transport menu in chat control banner if the chat window is with a transport. Fixes #7520
This commit is contained in:
parent
45e32ab847
commit
b38fac4abe
|
@ -2690,6 +2690,10 @@ class ChatControl(ChatControlBase):
|
|||
tranasports) and file_transfer_menuitem and hide()/show() for
|
||||
add_to_roster_menuitem
|
||||
"""
|
||||
if gajim.jid_is_transport(self.contact.jid):
|
||||
menu = gui_menu_builder.get_transport_menu(self.contact,
|
||||
self.account)
|
||||
else:
|
||||
menu = gui_menu_builder.get_contact_menu(self.contact, self.account,
|
||||
use_multiple_contacts=False, show_start_chat=False,
|
||||
show_encryption=True, control=self,
|
||||
|
|
|
@ -509,3 +509,139 @@ control=None, gc_contact=None, is_anonymous=True):
|
|||
contact_context_menu.connect('selection-done', gtkgui_helpers.destroy_widget)
|
||||
contact_context_menu.show_all()
|
||||
return contact_context_menu
|
||||
|
||||
def get_transport_menu(contact, account):
|
||||
roster = gajim.interface.roster
|
||||
jid = contact.jid
|
||||
|
||||
menu = Gtk.Menu()
|
||||
|
||||
# Send single message
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('Send Single _Message...'))
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_NEW, Gtk.IconSize.MENU)
|
||||
item.set_image(icon)
|
||||
item.connect('activate', roster.on_send_single_message_menuitem_activate,
|
||||
account, contact)
|
||||
menu.append(item)
|
||||
if gajim.account_is_disconnected(account):
|
||||
item.set_sensitive(False)
|
||||
|
||||
blocked = False
|
||||
if helpers.jid_is_blocked(account, jid):
|
||||
blocked = True
|
||||
|
||||
# Send Custom Status
|
||||
send_custom_status_menuitem = Gtk.ImageMenuItem.new_with_mnemonic(
|
||||
_('Send Cus_tom Status'))
|
||||
# add a special img for this menuitem
|
||||
if blocked:
|
||||
send_custom_status_menuitem.set_image(gtkgui_helpers.load_icon(
|
||||
'offline'))
|
||||
send_custom_status_menuitem.set_sensitive(False)
|
||||
else:
|
||||
if account in gajim.interface.status_sent_to_users and \
|
||||
jid in gajim.interface.status_sent_to_users[account]:
|
||||
send_custom_status_menuitem.set_image(gtkgui_helpers.load_icon(
|
||||
gajim.interface.status_sent_to_users[account][jid]))
|
||||
else:
|
||||
icon = Gtk.Imag.new_from_stock(Gtk.STOCK_NETWORK,
|
||||
Gtk.IconSize.MENU)
|
||||
send_custom_status_menuitem.set_image(icon)
|
||||
status_menuitems = Gtk.Menu()
|
||||
send_custom_status_menuitem.set_submenu(status_menuitems)
|
||||
iconset = gajim.config.get('iconset')
|
||||
path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
|
||||
for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'):
|
||||
# icon MUST be different instance for every item
|
||||
state_images = gtkgui_helpers.load_iconset(path)
|
||||
status_menuitem = Gtk.ImageMenuItem(helpers.get_uf_show(s))
|
||||
status_menuitem.connect('activate', roster.on_send_custom_status,
|
||||
[(contact, account)], s)
|
||||
icon = state_images[s]
|
||||
status_menuitem.set_image(icon)
|
||||
status_menuitems.append(status_menuitem)
|
||||
menu.append(send_custom_status_menuitem)
|
||||
if gajim.account_is_disconnected(account):
|
||||
send_custom_status_menuitem.set_sensitive(False)
|
||||
|
||||
item = Gtk.SeparatorMenuItem.new() # separator
|
||||
menu.append(item)
|
||||
|
||||
# Execute Command
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('E_xecute Command...'))
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_EXECUTE, Gtk.IconSize.MENU)
|
||||
item.set_image(icon)
|
||||
menu.append(item)
|
||||
item.connect('activate', roster.on_execute_command, contact, account,
|
||||
contact.resource)
|
||||
if gajim.account_is_disconnected(account):
|
||||
item.set_sensitive(False)
|
||||
|
||||
# Manage Transport submenu
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('_Manage Transport'))
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_PROPERTIES, Gtk.IconSize.MENU)
|
||||
item.set_image(icon)
|
||||
manage_transport_submenu = Gtk.Menu()
|
||||
item.set_submenu(manage_transport_submenu)
|
||||
menu.append(item)
|
||||
|
||||
# Modify Transport
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('_Modify Transport'))
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_PREFERENCES, Gtk.IconSize.MENU)
|
||||
item.set_image(icon)
|
||||
manage_transport_submenu.append(item)
|
||||
item.connect('activate', roster.on_edit_agent, contact, account)
|
||||
if gajim.account_is_disconnected(account):
|
||||
item.set_sensitive(False)
|
||||
|
||||
# Rename
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('_Rename...'))
|
||||
# add a special img for rename menuitem
|
||||
gtkgui_helpers.add_image_to_menuitem(item, 'gajim-kbd_input')
|
||||
manage_transport_submenu.append(item)
|
||||
item.connect('activate', roster.on_rename, 'agent', jid, account)
|
||||
if gajim.account_is_disconnected(account):
|
||||
item.set_sensitive(False)
|
||||
|
||||
item = Gtk.SeparatorMenuItem.new() # separator
|
||||
manage_transport_submenu.append(item)
|
||||
|
||||
# Block
|
||||
if blocked:
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('_Unblock'))
|
||||
item.connect('activate', roster.on_unblock, [(contact, account)])
|
||||
else:
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('_Block'))
|
||||
item.connect('activate', roster.on_block, [(contact, account)])
|
||||
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_STOP, Gtk.IconSize.MENU)
|
||||
item.set_image(icon)
|
||||
manage_transport_submenu.append(item)
|
||||
if gajim.account_is_disconnected(account):
|
||||
item.set_sensitive(False)
|
||||
|
||||
# Remove
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('Remo_ve'))
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_REMOVE, Gtk.IconSize.MENU)
|
||||
item.set_image(icon)
|
||||
manage_transport_submenu.append(item)
|
||||
item.connect('activate', roster.on_remove_agent, [(contact, account)])
|
||||
if gajim.account_is_disconnected(account):
|
||||
item.set_sensitive(False)
|
||||
|
||||
item = Gtk.SeparatorMenuItem.new() # separator
|
||||
menu.append(item)
|
||||
|
||||
# Information
|
||||
information_menuitem = Gtk.ImageMenuItem.new_with_mnemonic(
|
||||
_('_Information'))
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_INFO, Gtk.IconSize.MENU)
|
||||
information_menuitem.set_image(icon)
|
||||
menu.append(information_menuitem)
|
||||
information_menuitem.connect('activate', roster.on_info, contact, account)
|
||||
if gajim.account_is_disconnected(account):
|
||||
information_menuitem.set_sensitive(False)
|
||||
|
||||
menu.connect('selection-done', gtkgui_helpers.destroy_widget)
|
||||
menu.show_all()
|
||||
return menu
|
||||
|
|
|
@ -6021,141 +6021,9 @@ class RosterWindow:
|
|||
path = model.get_path(titer)
|
||||
account = model[titer][C_ACCOUNT]
|
||||
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||
menu = Gtk.Menu()
|
||||
|
||||
# Send single message
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('Send Single Message...'))
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_NEW, Gtk.IconSize.MENU)
|
||||
item.set_image(icon)
|
||||
item.connect('activate',
|
||||
self.on_send_single_message_menuitem_activate, account, contact)
|
||||
menu.append(item)
|
||||
if gajim.account_is_disconnected(account):
|
||||
item.set_sensitive(False)
|
||||
|
||||
blocked = False
|
||||
if helpers.jid_is_blocked(account, jid):
|
||||
blocked = True
|
||||
|
||||
# Send Custom Status
|
||||
send_custom_status_menuitem = Gtk.ImageMenuItem.new_with_mnemonic(
|
||||
_('Send Cus_tom Status'))
|
||||
# add a special img for this menuitem
|
||||
if blocked:
|
||||
send_custom_status_menuitem.set_image(gtkgui_helpers.load_icon(
|
||||
'offline'))
|
||||
send_custom_status_menuitem.set_sensitive(False)
|
||||
else:
|
||||
if account in gajim.interface.status_sent_to_users and \
|
||||
jid in gajim.interface.status_sent_to_users[account]:
|
||||
send_custom_status_menuitem.set_image(gtkgui_helpers.load_icon(
|
||||
gajim.interface.status_sent_to_users[account][jid]))
|
||||
else:
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_NETWORK,
|
||||
Gtk.IconSize.MENU)
|
||||
send_custom_status_menuitem.set_image(icon)
|
||||
status_menuitems = Gtk.Menu()
|
||||
send_custom_status_menuitem.set_submenu(status_menuitems)
|
||||
iconset = gajim.config.get('iconset')
|
||||
path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
|
||||
for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'):
|
||||
# icon MUST be different instance for every item
|
||||
state_images = gtkgui_helpers.load_iconset(path)
|
||||
status_menuitem = Gtk.ImageMenuItem(helpers.get_uf_show(s))
|
||||
status_menuitem.connect('activate', self.on_send_custom_status,
|
||||
[(contact, account)], s)
|
||||
icon = state_images[s]
|
||||
status_menuitem.set_image(icon)
|
||||
status_menuitems.append(status_menuitem)
|
||||
menu.append(send_custom_status_menuitem)
|
||||
if gajim.account_is_disconnected(account):
|
||||
send_custom_status_menuitem.set_sensitive(False)
|
||||
|
||||
item = Gtk.SeparatorMenuItem.new() # separator
|
||||
menu.append(item)
|
||||
|
||||
# Execute Command
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('E_xecute Command...'))
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_EXECUTE, Gtk.IconSize.MENU)
|
||||
item.set_image(icon)
|
||||
menu.append(item)
|
||||
item.connect('activate', self.on_execute_command, contact, account,
|
||||
contact.resource)
|
||||
if gajim.account_is_disconnected(account):
|
||||
item.set_sensitive(False)
|
||||
|
||||
# Manage Transport submenu
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('_Manage Transport'))
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_PROPERTIES,
|
||||
Gtk.IconSize.MENU)
|
||||
item.set_image(icon)
|
||||
manage_transport_submenu = Gtk.Menu()
|
||||
item.set_submenu(manage_transport_submenu)
|
||||
menu.append(item)
|
||||
|
||||
# Modify Transport
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('_Modify Transport'))
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_PREFERENCES,
|
||||
Gtk.IconSize.MENU)
|
||||
item.set_image(icon)
|
||||
manage_transport_submenu.append(item)
|
||||
item.connect('activate', self.on_edit_agent, contact, account)
|
||||
if gajim.account_is_disconnected(account):
|
||||
item.set_sensitive(False)
|
||||
|
||||
# Rename
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('_Rename...'))
|
||||
# add a special img for rename menuitem
|
||||
gtkgui_helpers.add_image_to_menuitem(item, 'gajim-kbd_input')
|
||||
manage_transport_submenu.append(item)
|
||||
item.connect('activate', self.on_rename, 'agent', jid, account)
|
||||
if gajim.account_is_disconnected(account):
|
||||
item.set_sensitive(False)
|
||||
|
||||
item = Gtk.SeparatorMenuItem.new() # separator
|
||||
manage_transport_submenu.append(item)
|
||||
|
||||
# Block
|
||||
if blocked:
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('_Unblock'))
|
||||
item.connect('activate', self.on_unblock, [(contact, account)])
|
||||
else:
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('_Block'))
|
||||
item.connect('activate', self.on_block, [(contact, account)])
|
||||
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_STOP, Gtk.IconSize.MENU)
|
||||
item.set_image(icon)
|
||||
manage_transport_submenu.append(item)
|
||||
if gajim.account_is_disconnected(account):
|
||||
item.set_sensitive(False)
|
||||
|
||||
# Remove
|
||||
item = Gtk.ImageMenuItem.new_with_mnemonic(_('Remo_ve'))
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_REMOVE, Gtk.IconSize.MENU)
|
||||
item.set_image(icon)
|
||||
manage_transport_submenu.append(item)
|
||||
item.connect('activate', self.on_remove_agent, [(contact, account)])
|
||||
if gajim.account_is_disconnected(account):
|
||||
item.set_sensitive(False)
|
||||
|
||||
item = Gtk.SeparatorMenuItem.new() # separator
|
||||
menu.append(item)
|
||||
|
||||
# Information
|
||||
information_menuitem = Gtk.ImageMenuItem.new_with_mnemonic(_(
|
||||
'_Information'))
|
||||
icon = Gtk.Image.new_from_stock(Gtk.STOCK_INFO, Gtk.IconSize.MENU)
|
||||
information_menuitem.set_image(icon)
|
||||
menu.append(information_menuitem)
|
||||
information_menuitem.connect('activate', self.on_info, contact, account)
|
||||
if gajim.account_is_disconnected(account):
|
||||
information_menuitem.set_sensitive(False)
|
||||
|
||||
menu = gui_menu_builder.get_transport_menu(contact, account)
|
||||
event_button = gtkgui_helpers.get_possible_button_event(event)
|
||||
|
||||
menu.attach_to_widget(self.tree, None)
|
||||
menu.connect('selection-done', gtkgui_helpers.destroy_widget)
|
||||
menu.show_all()
|
||||
menu.popup(None, None, None, None, event_button, event.time)
|
||||
|
||||
def make_groupchat_menu(self, event, titer):
|
||||
|
|
Loading…
Reference in New Issue