ability to call ad hoc commands on groupchats and groupchats occupants.

Fixes #8819
This commit is contained in:
Yann Leboulanger 2017-12-22 12:21:57 +01:00
parent ed0e2dd82b
commit c3369f0304
4 changed files with 39 additions and 2 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkAccelGroup" id="accelgroup1"/>
@ -125,6 +125,14 @@
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="execute_command_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Execute command</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="block_menuitem">
<property name="visible">True</property>

View File

@ -46,6 +46,7 @@ from gajim import config
from gajim import vcard
from gajim import cell_renderer_image
from gajim import dataforms_widget
from gajim import adhoc_commands
from gajim.common.const import AvatarSize
from gajim.common.caps_cache import muc_caps_cache
import nbxmpp
@ -514,6 +515,7 @@ class GroupchatControl(ChatControlBase):
('configure-', self._on_configure_room),
('bookmark-', self._on_bookmark_room),
('request-voice-', self._on_request_voice),
('execute-command-', self._on_execute_command),
]
for action in actions:
@ -582,6 +584,10 @@ class GroupchatControl(ChatControlBase):
win.lookup_action('change-nick-' + self.control_id).set_enabled(
online)
# Execute command
win.lookup_action('execute-command-' + self.control_id).set_enabled(
online)
# Actions
def _on_change_subject(self, action, param):
@ -679,6 +685,12 @@ class GroupchatControl(ChatControlBase):
app.config.set_per('rooms', self.contact.jid,
'notify_on_all_messages', param.get_boolean())
def _on_execute_command(self, action, param):
"""
Execute AdHoc commands on the current room
"""
adhoc_commands.CommandWindow(self.account, self.room_jid)
def show_roster(self):
new_state = not self.hpaned.get_child2().is_visible()
image = self.hide_roster_button.get_image()
@ -2560,6 +2572,10 @@ class GroupchatControl(ChatControlBase):
id_ = item.connect('activate', self.on_add_to_roster, jid)
self.handlers[id_] = item
item = xml.get_object('execute_command_menuitem')
id_ = item.connect('activate', self._on_execute_command_occupant, nick)
self.handlers[id_] = item
item = xml.get_object('block_menuitem')
item2 = xml.get_object('unblock_menuitem')
if not app.connections[self.account].privacy_rules_supported:
@ -2608,6 +2624,10 @@ class GroupchatControl(ChatControlBase):
return ctrl
def _on_execute_command_occupant(self, widget, nick):
jid = self.room_jid + '/' + nick
adhoc_commands.CommandWindow(self.account, jid)
def on_row_activated(self, widget, path):
"""
When an iter is activated (dubblick or single click if gnome is set this

View File

@ -642,6 +642,7 @@ def get_groupchat_menu(control_id):
('win.request-voice-', _('Request Voice')),
('win.notify-on-message-', _('Notify on all messages')),
('win.minimize-', _('Minimize on close')),
('win.execute-command-', _('Execute command')),
('win.browse-history-', _('History')),
('win.disconnect-', _('Disconnect')),
]

View File

@ -5389,8 +5389,16 @@ class RosterWindow:
item = Gtk.SeparatorMenuItem.new() # separator
menu.append(item)
adhoc_menuitem = Gtk.MenuItem.new_with_mnemonic(_('Execute command'))
adhoc_menuitem.connect('activate', self.on_execute_command, contact,
account)
menu.append(adhoc_menuitem)
item = Gtk.SeparatorMenuItem.new() # separator
menu.append(item)
history_menuitem = Gtk.MenuItem.new_with_mnemonic(_('_History'))
history_menuitem .connect('activate', self.on_history, contact, account)
history_menuitem.connect('activate', self.on_history, contact, account)
menu.append(history_menuitem)
event_button = gtkgui_helpers.get_possible_button_event(event)