Daniel Brötzmann pushed to branch newcontrol at gajim / gajim
Commits: 1627d7ae by wurstsalat at 2022-07-11T13:32:03+02:00 Contacts: Add is_irc property
- - - - - 3d849e73 by wurstsalat at 2022-07-11T13:32:39+02:00 GroupchatControl UI: Remove obsolete destroy page
- - - - - 58aa8db0 by wurstsalat at 2022-07-11T13:36:53+02:00 Move actions from GroupchatControl to ChatStack
- - - - -
9 changed files:
- gajim/common/modules/contacts.py - gajim/data/gui/groupchat_control.ui - gajim/gtk/chat_banner.py - gajim/gtk/chat_stack.py - gajim/gtk/const.py - gajim/gtk/controls/base.py - gajim/gtk/controls/groupchat.py - gajim/gtk/menus.py - gajim/gtk/message_actions_box.py
Changes:
===================================== gajim/common/modules/contacts.py ===================================== @@ -551,6 +551,13 @@ def __init__(self, logger: LogAdapter, jid: JID, account: str) -> None: def is_groupchat(self) -> bool: return True
+ @property + def is_irc(self) -> bool: + disco_info = self.get_disco() + if disco_info is None: + return False + return disco_info.is_irc + def add_resource(self, resource: str) -> GroupchatParticipant: jid = self._jid.new_with(resource=resource) assert isinstance(self._log, LogAdapter)
===================================== gajim/data/gui/groupchat_control.ui ===================================== @@ -921,164 +921,7 @@ </packing> </child> <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="orientation">vertical</property> - <child> - <!-- n-columns=1 n-rows=6 --> - <object class="GtkGrid"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="halign">center</property> - <property name="valign">center</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <property name="row-spacing">6</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="margin-bottom">6</property> - <property name="label" translatable="yes">Destroy This Chat</property> - <property name="ellipsize">end</property> - <property name="single-line-mode">True</property> - <property name="max-width-chars">22</property> - <property name="xalign">0</property> - <style> - <class name="bold16"/> - </style> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">0</property> - </packing> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="homogeneous">True</property> - <child> - <object class="GtkButton"> - <property name="label" translatable="yes">_Cancel</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">True</property> - <property name="halign">start</property> - <property name="valign">start</property> - <property name="use-underline">True</property> - <signal name="clicked" handler="_on_page_cancel_clicked" swapped="no"/> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="destroy_button"> - <property name="label" translatable="yes">_Destroy</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="can-default">True</property> - <property name="receives-default">True</property> - <property name="halign">end</property> - <property name="valign">start</property> - <property name="use-underline">True</property> - <signal name="clicked" handler="_on_destroy_confirm" swapped="no"/> - <style> - <class name="destructive-action"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">5</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="destroy_alternate_entry"> - <property name="width-request">200</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="margin-bottom">6</property> - <property name="activates-default">True</property> - <property name="caps-lock-warning">False</property> - <property name="secondary-icon-tooltip-text" translatable="yes">Insert Emoji</property> - <property name="placeholder-text" translatable="yes">Alternate venue (optional)...</property> - <signal name="notify::text" handler="_on_destroy_alternate_changed" swapped="no"/> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">4</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="destroy_reason_entry"> - <property name="width-request">200</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="margin-bottom">6</property> - <property name="activates-default">True</property> - <property name="caps-lock-warning">False</property> - <property name="secondary-icon-tooltip-text" translatable="yes">Insert Emoji</property> - <property name="placeholder-text" translatable="yes">Reason (optional)...</property> - <property name="show-emoji-icon">True</property> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="halign">start</property> - <property name="label" translatable="yes">Reason for destruction</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="halign">start</property> - <property name="label" translatable="yes">Where participants should go</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">3</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - </object> - <packing> - <property name="name">destroy</property> - <property name="position">8</property> - </packing> + <placeholder/> </child> <child> <object class="GtkBox">
===================================== gajim/gtk/chat_banner.py ===================================== @@ -17,7 +17,6 @@ from typing import Any from typing import Optional
-from gi.repository import Gio from gi.repository import Gtk
import cairo @@ -73,9 +72,6 @@ def __init__(self) -> None: 'hide_groupchat_occupants_list', self._set_toggle_roster_button_icon)
- action = Gio.SimpleAction.new('request-voice', None) - app.window.add_action(action) - self.show_all()
def switch_contact(self, @@ -290,7 +286,7 @@ def _update_account_badge(self) -> None:
def _on_request_voice_clicked(self, _button: Gtk.Button) -> None: self._ui.visitor_popover.popdown() - app.window.activate_action('request-voice', None) + app.window.activate_action('muc-request-voice', None)
def _on_toggle_roster_clicked(self, _button: Gtk.Button) -> None: state = app.settings.get('hide_groupchat_occupants_list')
===================================== gajim/gtk/chat_stack.py ===================================== @@ -28,6 +28,7 @@ from nbxmpp.structs import PresenceProperties
from gajim.common import app, helpers +from gajim.common.events import MucDiscoUpdate from gajim.common.i18n import _ from gajim.common.const import CallType from gajim.common.modules.contacts import BareContact @@ -38,6 +39,7 @@
from .chat_banner import ChatBanner from .control_stack import ControlStack +from .controls.groupchat import GroupchatControl from .message_actions_box import MessageActionsBox from .util import EventHelper, open_window
@@ -92,8 +94,10 @@ def show_chat(self, account: str, jid: JID) -> None: self._update_base_actions(self._current_contact) if isinstance(self._current_contact, GroupchatContact): self._current_contact.multi_connect({ + 'user-joined': self._on_user_joined, 'user-role-changed': self._on_user_role_changed, - 'state-changed': self._on_muc_state_changed + 'user-affiliation-changed': self._on_user_affiliation_changed, + 'state-changed': self._on_muc_state_changed, }) self._update_group_chat_actions(self._current_contact) elif isinstance(self._current_contact, GroupchatParticipant): @@ -109,6 +113,14 @@ def _on_muc_state_changed(self, ) -> None: self._update_group_chat_actions(contact)
+ def _on_user_joined(self, + contact: GroupchatContact, + _signal_name: str, + _user_contact: GroupchatParticipant, + _properties: PresenceProperties + ) -> None: + self._update_group_chat_actions(contact) + def _on_user_role_changed(self, contact: GroupchatContact, _signal_name: str, @@ -117,6 +129,24 @@ def _on_user_role_changed(self, ) -> None: self._update_group_chat_actions(contact)
+ def _on_user_affiliation_changed(self, + contact: GroupchatContact, + _signal_name: str, + _user_contact: GroupchatParticipant, + _properties: PresenceProperties + ) -> None: + self._update_group_chat_actions(contact) + + def _on_muc_disco_update(self, event: MucDiscoUpdate) -> None: + if self._current_contact is None: + return + + if event.jid != self._current_contact.jid: + return + + if isinstance(self._current_contact, GroupchatContact): + self._update_group_chat_actions(self._current_contact) + def _connect_actions(self) -> None: actions = [ 'add-to-roster', @@ -129,7 +159,15 @@ def _connect_actions(self) -> None: 'start-video-call', 'start-voice-call', 'send-message', - 'request-voice', + 'muc-change-nickname', + 'muc-invite', + 'muc-contact-info', + 'muc-execute-command', + 'muc-ban', + 'muc-kick', + 'muc-change-role', + 'muc-change-affiliation', + 'muc-request-voice', ]
stateful_actions = [ @@ -203,9 +241,18 @@ def _update_group_chat_actions(self, contact: GroupchatContact) -> None: assert self_contact is_visitor = self_contact.role.is_visitor
- app.window.get_action('request-voice').set_enabled(is_visitor) + app.window.get_action('muc-change-nickname').set_enabled( + joined and not contact.is_irc) + + app.window.get_action('muc-contact-info').set_enabled(joined) + app.window.get_action('muc-execute-command').set_enabled(joined) + app.window.get_action('muc-ban').set_enabled(joined) + app.window.get_action('muc-kick').set_enabled(joined) + app.window.get_action('muc-change-role').set_enabled(joined) + app.window.get_action('muc-change-affiliation').set_enabled(joined) + app.window.get_action('muc-invite').set_enabled(joined)
- app.window.get_action('show-contact-info').set_enabled(joined) + app.window.get_action('muc-request-voice').set_enabled(is_visitor)
app.window.get_action('quote').set_enabled(joined) app.window.get_action('mention').set_enabled(joined) @@ -224,6 +271,7 @@ def _on_action(self, account = contact.account client = app.get_client(account) jid = contact.jid + current_control = self._control_stack.get_current_control()
if action_name == 'send-message': self._on_send_message() @@ -236,9 +284,8 @@ def _on_action(self,
elif action_name.startswith('send-file'): name = action.get_name() - control = self._control_stack.get_current_control() if 'httpupload' in name: - app.interface.send_httpupload(control) + app.interface.send_httpupload(current_control) return
if 'jingle' in name: @@ -251,7 +298,7 @@ def _on_action(self, return
if method == 'httpupload': - app.interface.send_httpupload(control) + app.interface.send_httpupload(current_control) else: app.interface.instances[ 'file_transfers'].show_file_send_request(account, contact) @@ -266,7 +313,7 @@ def _on_action(self, open_window('AddContact', account=account, jid=jid)
elif action_name == 'clear-chat': - self._control_stack.get_current_control().reset_view() + current_control.reset_view()
elif action_name == 'show-contact-info': if isinstance(contact, GroupchatContact): @@ -274,7 +321,58 @@ def _on_action(self, else: app.window.contact_info(account, str(jid))
- elif action_name == 'request-voice': + elif action_name == 'muc-contact-info': + assert param is not None + nick = param.get_string() + assert isinstance(contact, GroupchatContact) + resource_contact = contact.get_resource(nick) + open_window( + 'ContactInfo', account=account, contact=resource_contact) + + elif action_name == 'muc-invite': + assert isinstance(current_control, GroupchatControl) + current_control.show_inviter() + + elif action_name == 'muc-change-nickname': + assert isinstance(current_control, GroupchatControl) + current_control.show_change_nick() + + elif action_name == 'muc-execute-command': + assert isinstance(current_control, GroupchatControl) + nick = None + if param is not None: + nick = param.get_string() + if nick: + assert isinstance(contact, GroupchatContact) + resource_contact = contact.get_resource(nick) + jid = resource_contact.jid + open_window('AdHocCommands', account=account, jid=jid) + + elif action_name == 'muc-kick': + assert isinstance(current_control, GroupchatControl) + assert param is not None + kick_nick = param.get_string() + current_control.show_kick(kick_nick) + + elif action_name == 'muc-ban': + assert isinstance(current_control, GroupchatControl) + assert param is not None + ban_jid = param.get_string() + current_control.show_ban(ban_jid) + + elif action_name == 'muc-change-role': + assert param is not None + nick, role = param.get_strv() + client.get_module('MUC').set_role(contact.jid, nick, role) + + elif action_name == 'muc-change-affiliation': + assert param is not None + jid, affiliation = param.get_strv() + client.get_module('MUC').set_affiliation( + contact.jid, + {jid: {'affiliation': affiliation}}) + + elif action_name == 'muc-request-voice': client.get_module('MUC').request_voice(contact.jid)
def _on_stateful_action(self, @@ -374,6 +472,8 @@ def clear(self) -> None: self._control_stack.clear()
def process_event(self, event: Any) -> None: + if isinstance(event, MucDiscoUpdate): + self._on_muc_disco_update(event) self._control_stack.process_event(event)
===================================== gajim/gtk/const.py ===================================== @@ -206,6 +206,15 @@ def __str__(self): ('clear-chat', None, False), ('show-contact-info', None, False), ('send-message', None, False), + ('muc-change-nickname', None, False), + ('muc-invite', None, False), + ('muc-contact-info', 's', False), + ('muc-execute-command', 's', False), + ('muc-ban', 's', False), + ('muc-kick', 's', False), + ('muc-change-role', 'as', False), + ('muc-change-affiliation', 'as', False), + ('muc-request-voice', None, False), ]
===================================== gajim/gtk/controls/base.py ===================================== @@ -133,8 +133,7 @@ def __init__(self, widget_name: str, account: str, jid: JID) -> None: self._units = GLib.FormatSizeFlags.DEFAULT
self.xml = get_builder(f'{widget_name}.ui') - # TODO - # self.xml.connect_signals(self) + self.xml.connect_signals(self) self.widget: Gtk.Box = self.xml.get_object(f'{widget_name}_hbox')
# Drag and drop
===================================== gajim/gtk/controls/groupchat.py ===================================== @@ -128,27 +128,16 @@ def __init__(self, account: str, jid: JID) -> None: 'hide_groupchat_occupants_list', self._show_roster) self.roster.connect('row-activated', self._on_roster_row_activated)
- self.add_actions() - GLib.idle_add(self.update_actions) - # Holds CaptchaRequest widget self._captcha_request: Optional[DataFormWidget] = None
self._subject_text = ''
# Groupchat invite - # self.xml.quick_invite_button.set_action_name( - # f'win.invite-{self.control_id}') - self._invite_box = GroupChatInviter(self.room_jid) self.xml.invite_grid.attach(self._invite_box, 0, 0, 1, 1) self._invite_box.connect('listbox-changed', self._on_invite_ready)
- app.settings.connect_signal('gc_print_join_left_default', - self.update_actions) - app.settings.connect_signal('gc_print_status_default', - self.update_actions) - self._set_control_inactive()
# Stack @@ -212,60 +201,6 @@ def _on_client_state_changed(self, def disco_info(self): return app.storage.cache.get_last_disco_info(self.contact.jid)
- def add_actions(self) -> None: - actions = [ - ('change-nickname-', None, self._on_change_nick), - ('destroy-', None, self._on_destroy_room), - ('invite-', None, self._on_invite), - ('contact-information-', 's', self._on_contact_information), - ('execute-command-', 's', self._on_execute_command), - ('ban-', 's', self._on_ban), - ('kick-', 's', self._on_kick), - ('change-role-', 'as', self._on_change_role), - ('change-affiliation-', 'as', self._on_change_affiliation), - ] - - for action in actions: - action_name, variant, func = action - if variant is not None: - variant = GLib.VariantType.new(variant) - act = Gio.SimpleAction.new(action_name + self.control_id, variant) - act.connect("activate", func) - app.window.add_action(act) - - def update_actions(self, *args: Any) -> None: - joined = self.contact.is_joined - - self._get_action('change-nickname-').set_enabled( - joined and not self.is_irc()) - - self._get_action('execute-command-').set_enabled(joined) - - self._get_action('contact-information-').set_enabled(joined) - - self._get_action('ban-').set_enabled(joined) - - self._get_action('kick-').set_enabled(joined) - - self._get_action('invite-').set_enabled(joined) - - def remove_actions(self) -> None: - actions = [ - 'change-nickname-', - 'destroy-', - 'configure-', - 'invite-', - 'contact-information-', - 'execute-command-', - 'ban-', - 'kick-', - 'change-role-', - 'change-affiliation-', - ] - - for action in actions: - app.window.remove_action(f'{action}{self.control_id}') - def is_irc(self) -> bool: if self.disco_info is None: return False @@ -277,20 +212,15 @@ def _show_page(self, name: str) -> None: transition = Gtk.StackTransitionType.SLIDE_UP active_control = app.window.get_active_control() if active_control == self: - self.msg_textview.grab_focus() + pass + #self.msg_textview.grab_focus() self.xml.stack.set_visible_child_full(name, transition)
def _get_current_page(self) -> str: return self.xml.stack.get_visible_child_name()
- def _on_muc_disco_update(self, _event: events.MucDiscoUpdate) -> None: - self.update_actions() - # Actions - def _on_invite(self, - _action: Gio.SimpleAction, - _param: Optional[GLib.Variant] - ) -> None: + def show_inviter(self) -> None: self._invite_box.load_contacts() self._show_page('invite')
@@ -314,98 +244,24 @@ def invite(self, invited_jid: JID) -> None: self.add_info_message( _('%s has been invited to this group chat') % invited_contact.name)
- def _on_destroy_room(self, _button: Gtk.Button) -> None: - self.xml.destroy_reason_entry.grab_focus() - self.xml.destroy_button.grab_default() - self._show_page('destroy') - - def _on_destroy_alternate_changed(self, - entry: Gtk.Entry, - _param: Any - ) -> None: - jid = entry.get_text() - if jid: - try: - jid = helpers.validate_jid(jid) - except Exception: - icon = 'dialog-warning-symbolic' - text = _('Invalid XMPP Address') - self.xml.destroy_alternate_entry.set_icon_from_icon_name( - Gtk.EntryIconPosition.SECONDARY, icon) - self.xml.destroy_alternate_entry.set_icon_tooltip_text( - Gtk.EntryIconPosition.SECONDARY, text) - self.xml.destroy_button.set_sensitive(False) - return - self.xml.destroy_alternate_entry.set_icon_from_icon_name( - Gtk.EntryIconPosition.SECONDARY, None) - self.xml.destroy_button.set_sensitive(True) - - def _on_destroy_confirm(self, _button: Gtk.Button) -> None: - reason = self.xml.destroy_reason_entry.get_text() - jid = self.xml.destroy_alternate_entry.get_text() - self._client.get_module('MUC').destroy(self.room_jid, reason, jid) - self._show_page('groupchat') - - def _on_execute_command(self, - _action: Gio.SimpleAction, - param: GLib.Variant - ) -> None: - jid = self.room_jid - nick = param.get_string() - if nick: - jid += '/' + nick - open_window('AdHocCommands', account=self.account, jid=jid) - - def _on_contact_information(self, - _action: Gio.SimpleAction, - param: GLib.Variant - ) -> None: - nick = param.get_string() - contact = self.contact.get_resource(nick) - open_window('ContactInfo', account=self.account, contact=contact) - - def _on_kick(self, - _action: Gio.SimpleAction, - param: GLib.Variant - ) -> None: - nick = param.get_string() - self._kick_nick = nick - text = _('Kick %s') % nick + def show_kick(self, kick_nick: str) -> None: + self._kick_nick = kick_nick + text = _('Kick %s') % kick_nick self.xml.kick_label.set_text(text) self.xml.kick_label.set_tooltip_text(text) self.xml.kick_reason_entry.grab_focus() self.xml.kick_participant_button.grab_default() self._show_page('kick')
- def _on_ban(self, - _action: Gio.SimpleAction, - param: GLib.Variant - ) -> None: - jid = param.get_string() - self._ban_jid = jid - text = _('Ban %s') % jid + def show_ban(self, ban_jid: str) -> None: + self._ban_jid = ban_jid + text = _('Ban %s') % ban_jid self.xml.ban_label.set_text(text) self.xml.ban_label.set_tooltip_text(text) self.xml.ban_reason_entry.grab_focus() self.xml.ban_participant_button.grab_default() self._show_page('ban')
- def _on_change_role(self, - _action: Gio.SimpleAction, - param: GLib.Variant - ) -> None: - nick, role = param.get_strv() - self._client.get_module('MUC').set_role(self.room_jid, nick, role) - - def _on_change_affiliation(self, - _action: Gio.SimpleAction, - param: GLib.Variant - ) -> None: - jid, affiliation = param.get_strv() - self._client.get_module('MUC').set_affiliation( - self.room_jid, - {jid: {'affiliation': affiliation}}) - def _show_roster(self, show_roster: bool, *args: Any) -> None: transition = Gtk.RevealerTransitionType.SLIDE_RIGHT if show_roster: @@ -613,16 +469,12 @@ def _set_control_active(self) -> None: self.roster.initial_draw() self.conversation_view.update_avatars()
- self.update_actions() - def _set_control_inactive(self) -> None: self.roster.enable_sort(False) self.roster.clear()
self._client.get_module('Chatstate').remove_delay_timeout(self.contact)
- self.update_actions() - def rejoin(self) -> None: self._client.get_module('MUC').join(self.room_jid)
@@ -657,9 +509,6 @@ def _on_user_joined(self, _('The server has assigned or modified your nickname in this ' 'group chat'))
- # Update Actions - self.update_actions() - def _on_room_config_finished(self, _contact: GroupchatContact, _signal_name: str @@ -735,7 +584,6 @@ def _on_user_affiliation_changed(self, reason=reason)
self.add_info_message(message) - self.update_actions()
def _on_user_role_changed(self, _contact: GroupchatContact, @@ -765,7 +613,6 @@ def _on_user_role_changed(self, reason=reason)
self.add_info_message(message) - self.update_actions()
def _on_room_kicked(self, _contact: GroupchatContact, @@ -968,8 +815,6 @@ def shutdown(self, reason: Optional[str] = None) -> None: self.roster.destroy() self.roster = None
- self.remove_actions() - super(GroupchatControl, self).shutdown() app.check_finalize(self)
@@ -1006,6 +851,7 @@ def delegate_action(self, action: str) -> int: return res
if action == 'change-nickname': + # TODO control_action = f'{action}-{self.control_id}' app.window.lookup_action(control_action).activate() return Gdk.EVENT_STOP @@ -1046,8 +892,6 @@ def focus(self) -> None: self._captcha_request.focus_first_entry() elif page_name == 'invite': self._invite_box.focus_search_entry() - elif page_name == 'destroy': - self.xml.destroy_reason_entry.grab_focus_without_selecting()
def _on_kick_participant_clicked(self, _button: Gtk.Button) -> None: reason = self.xml.kick_reason_entry.get_text() @@ -1077,10 +921,7 @@ def _on_page_change(self, stack: Gtk.Stack, _param: Any) -> None: elif page_name == 'error': self.xml.close_button.grab_default()
- def _on_change_nick(self, - _action: Gio.SimpleAction, - _param: Optional[GLib.Variant] - ) -> None: + def show_change_nick(self) -> None: if self._get_current_page() != 'groupchat': return self.xml.nickname_entry.set_text(self.contact.nickname)
===================================== gajim/gtk/menus.py ===================================== @@ -117,9 +117,9 @@ def get_send_file_submenu() -> GajimMenu: def get_groupchat_menu(contact: GroupchatContact) -> GajimMenu: menuitems: MenuItemListT = [ (_('Details'), 'win.show-contact-info', None), - (_('Change Nickname…'), 'win.change-nickname', None), - (_('Request Voice'), 'win.request-voice', None), - (_('Execute Command…'), 'win.execute-command', '""'), + (_('Change Nickname…'), 'win.muc-change-nickname', None), + (_('Request Voice'), 'win.muc-request-voice', None), + (_('Execute Command…'), 'win.muc-execute-command', '""'), (_('Search…'), 'win.search-history', None) ]
@@ -452,13 +452,12 @@ def get_workspace_params(current_workspace_id: str, yield name, params
-def get_groupchat_admin_menu(control_id: str, - self_contact: types.GroupchatParticipant, +def get_groupchat_admin_menu(self_contact: types.GroupchatParticipant, contact: types.GroupchatParticipant) -> GajimMenu:
menu = GajimMenu()
- action = f'win.change-affiliation-{control_id}' + action = 'win.muc-change-affiliation'
if is_affiliation_change_allowed(self_contact, contact, 'owner'): value = f'["{contact.real_jid}", "owner"]' @@ -478,7 +477,7 @@ def get_groupchat_admin_menu(control_id: str,
if is_affiliation_change_allowed(self_contact, contact, 'outcast'): value = f'"{contact.real_jid}"' - menu.add_item(_('Ban…'), f'win.ban-{control_id}', value) + menu.add_item(_('Ban…'), 'win.muc-ban', value)
if not menu.get_n_items(): menu.add_item(_('Not Available'), 'dummy', None) @@ -486,8 +485,7 @@ def get_groupchat_admin_menu(control_id: str, return menu
-def get_groupchat_mod_menu(control_id: str, - self_contact: types.GroupchatParticipant, +def get_groupchat_mod_menu(self_contact: types.GroupchatParticipant, contact: types.GroupchatParticipant ) -> GajimMenu:
@@ -495,9 +493,9 @@ def get_groupchat_mod_menu(control_id: str,
if is_role_change_allowed(self_contact, contact): value = f'"{contact.name}"' - menu.add_item(_('Kick…'), f'win.kick-{control_id}', value) + menu.add_item(_('Kick…'), 'win.muc-kick', value)
- action = f'win.change-role-{control_id}' + action = 'win.muc-change-role'
if is_role_change_allowed(self_contact, contact): if contact.role.is_visitor: @@ -514,7 +512,6 @@ def get_groupchat_mod_menu(control_id: str,
def get_groupchat_roster_menu(account: str, - control_id: str, self_contact: types.GroupchatParticipant, contact: types.GroupchatParticipant ) -> GajimMenu: @@ -522,8 +519,8 @@ def get_groupchat_roster_menu(account: str, value = f'"{contact.name}"'
general_items: MenuItemListT = [ - (_('Details'), f'win.contact-information-{control_id}', value), - (_('Execute Command…'), f'win.execute-command-{control_id}', value), + (_('Details'), 'win.muc-contact-info', value), + (_('Execute Command…'), 'win.muc-execute-command', value), ]
real_contact = contact.get_real_contact() @@ -532,8 +529,8 @@ def get_groupchat_roster_menu(account: str, action = f'app.{account}-add-contact' general_items.insert(1, (_('Add to Contact List…'), action, value))
- mod_menu = get_groupchat_mod_menu(control_id, self_contact, contact) - admin_menu = get_groupchat_admin_menu(control_id, self_contact, contact) + mod_menu = get_groupchat_mod_menu(self_contact, contact) + admin_menu = get_groupchat_admin_menu(self_contact, contact)
menu = GajimMenu.from_list(general_items) menu.append_section(_('Moderation'), mod_menu)
===================================== gajim/gtk/message_actions_box.py ===================================== @@ -101,6 +101,8 @@ def __init__(self) -> None: self._ui.formattings_button.set_menu_model(get_format_menu()) self._ui.encryption_menu_button.set_menu_model(get_encryption_menu())
+ self._ui.quick_invite_button.set_action_name('win.muc-invite') + self._init_emoticon_popover() # TODO init spellchecker uses a contact on callback, contact might # be None
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/40f863f18c83c0f62cbb08941b8c1d75...