Daniel Brötzmann pushed to branch newcontrol at gajim / gajim
Commits: 32cdc9d1 by wurstsalat at 2022-07-13T13:41:19+02:00 Add ChatFunctionPage
- - - - -
5 changed files:
- gajim/data/gui/groupchat_control.ui - + gajim/gtk/chat_function_page.py - gajim/gtk/chat_stack.py - gajim/gtk/controls/groupchat.py - pyrightconfig.json
Changes:
===================================== gajim/data/gui/groupchat_control.ui ===================================== @@ -112,114 +112,6 @@ <property name="name">groupchat</property> </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=3 --> - <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">12</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes">Enter Nickname</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="GtkEntry" id="nickname_entry"> - <property name="width-request">200</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="activates-default">True</property> - <property name="caps-lock-warning">False</property> - <property name="show-emoji-icon">True</property> - <signal name="notify::text" handler="_on_nickname_text_changed" swapped="no"/> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">1</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="nickname_change_button"> - <property name="label" translatable="yes">Ch_ange</property> - <property name="visible">True</property> - <property name="sensitive">False</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_nickname_change_clicked" swapped="no"/> - <style> - <class name="suggested-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">2</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">nickname</property> - <property name="position">1</property> - </packing> - </child> <child> <object class="GtkBox"> <property name="visible">True</property> @@ -325,7 +217,7 @@ </object> <packing> <property name="name">password</property> - <property name="position">2</property> + <property name="position">1</property> </packing> </child> <child> @@ -417,7 +309,7 @@ </object> <packing> <property name="name">captcha</property> - <property name="position">3</property> + <property name="position">2</property> </packing> </child> <child> @@ -556,7 +448,7 @@ </object> <packing> <property name="name">error</property> - <property name="position">4</property> + <property name="position">3</property> </packing> </child> <child> @@ -663,344 +555,14 @@ </object> <packing> <property name="name">captcha-error</property> - <property name="position">5</property> - </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=4 --> - <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" id="kick_label"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="margin-bottom">6</property> - <property name="label" translatable="yes">Kick Participant</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="kick_participant_button"> - <property name="label" translatable="yes">_Kick</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_kick_participant_clicked" 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">3</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="kick_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="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 (optional)</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">1</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">kick</property> - <property name="position">6</property> - </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=4 --> - <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" id="ban_label"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="margin-bottom">6</property> - <property name="label" translatable="yes">Ban Participant</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="ban_participant_button"> - <property name="label" translatable="yes">_Ban</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_ban_participant_clicked" 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">3</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="ban_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="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 (optional)</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">1</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">ban</property> - <property name="position">7</property> + <property name="position">4</property> </packing> </child> <child> <placeholder/> </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=2 --> - <object class="GtkGrid" id="invite_grid"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="halign">center</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <property name="border-width">18</property> - <property name="row-spacing">6</property> - <property name="column-spacing">12</property> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="margin-top">6</property> - <property name="spacing">12</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="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="invite_button"> - <property name="label" translatable="yes">_Invite</property> - <property name="visible">True</property> - <property name="sensitive">False</property> - <property name="can-focus">True</property> - <property name="receives-default">True</property> - <property name="use-underline">True</property> - <signal name="clicked" handler="_on_invite_clicked" swapped="no"/> - <style> - <class name="suggested-action"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack-type">end</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">1</property> - </packing> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="name">invite</property> - <property name="position">9</property> - </packing> + <placeholder/> </child> </object> <packing>
===================================== gajim/gtk/chat_function_page.py ===================================== @@ -0,0 +1,270 @@ +# This file is part of Gajim. +# +# Gajim is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; version 3 only. +# +# Gajim is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Gajim. If not, see http://www.gnu.org/licenses/. + +from __future__ import annotations + +from typing import Optional + +from gi.repository import Gdk +from gi.repository import GObject +from gi.repository import Gtk +from gi.repository import Pango + +from nbxmpp.protocol import InvalidJid +from nbxmpp.protocol import JID +from nbxmpp.protocol import validate_resourcepart + +from gajim.common import app +from gajim.common.client import Client +from gajim.common.i18n import _ +from gajim.common.modules.contacts import GroupchatContact +from gajim.common.types import ChatContactT + +from .groupchat_inviter import GroupChatInviter + + +class ChatFunctionPage(Gtk.Box): + + __gsignals__ = { + 'finish': (GObject.SignalFlags.RUN_LAST, None, ()), + 'message': (GObject.SignalFlags.RUN_LAST, None, (str,)), + } + + def __init__(self) -> None: + Gtk.Box.__init__(self, + orientation=Gtk.Orientation.VERTICAL, + spacing=18) + self.set_halign(Gtk.Align.CENTER) + self.set_valign(Gtk.Align.CENTER) + self.get_style_context().add_class('padding-18') + + self._client: Optional[Client] = None + self._contact: Optional[ChatContactT] = None + self._mode: Optional[str] = None + + self._widget: Optional[Gtk.Widget] = None + + self._heading = Gtk.Label() + self._heading.set_max_width_chars(30) + self._heading.set_ellipsize(Pango.EllipsizeMode.END) + self._heading.get_style_context().add_class('large-header') + self.add(self._heading) + + self._content_box = Gtk.Box() + self.add(self._content_box) + + cancel_button = Gtk.Button(label=_('Cancel')) + cancel_button.connect('clicked', self._on_cancel_clicked) + + self._confirm_button = Gtk.Button() + self._confirm_button.set_can_default(True) + self._confirm_button.connect('clicked', self._on_confirm_clicked) + + button_box = Gtk.Box() + button_box.pack_start(cancel_button, False, True, 0) + button_box.pack_end(self._confirm_button, False, True, 0) + + self.add(button_box) + self.connect('key-press-event', self._on_key_press) + + def _on_key_press(self, _widget: Gtk.Widget, event: Gdk.EventKey) -> None: + if event.keyval == Gdk.KEY_Escape: + self.emit('finish') + + def _clear(self) -> None: + for child in self._content_box.get_children(): + child.destroy() + + def set_mode(self, + contact: ChatContactT, + mode: str, + data: Optional[str] = None + ) -> None: + self._clear() + self._confirm_button.get_style_context().remove_class( + 'destructive-action') + self._confirm_button.get_style_context().remove_class( + 'suggested-action') + self._confirm_button.set_sensitive(False) + self._confirm_button.grab_default() + + self._contact = contact + self._heading.set_text(self._contact.name) + self._client = app.get_client(contact.account) + self._mode = mode + self._data = data + + if self._widget is not None: + self._widget.destroy() + + if mode == 'invite': + self._confirm_button.set_label(_('Invite')) + self._confirm_button.get_style_context().add_class( + 'suggested-action') + self._widget = GroupChatInviter(str(contact.jid)) + self._widget.connect('listbox-changed', self._on_ready) + self._widget.load_contacts() + + elif mode == 'change-nickname': + self._confirm_button.set_label(_('Change')) + self._confirm_button.get_style_context().add_class( + 'suggested-action') + self._widget = InputWidget(self._contact, mode) + self._widget.connect('changed', self._on_ready) + + elif mode == 'kick': + self._confirm_button.set_label(_('Kick')) + self._confirm_button.set_sensitive(True) + self._confirm_button.get_style_context().add_class( + 'destructive-action') + self._widget = InputWidget(self._contact, mode, data) + + elif mode == 'ban': + self._confirm_button.set_label(_('Ban')) + self._confirm_button.set_sensitive(True) + self._confirm_button.get_style_context().add_class( + 'destructive-action') + self._widget = InputWidget(self._contact, mode, data) + + assert self._widget is not None + self._content_box.add(self._widget) + if isinstance(self._widget, InputWidget): + self._widget.focus() + + def _on_ready(self, + _widget: Gtk.Widget, + state: bool + ) -> None: + self._confirm_button.set_sensitive(state) + + def _on_confirm_clicked(self, _button: Gtk.Button) -> None: + if self._mode == 'invite': + assert isinstance(self._widget, GroupChatInviter) + invitees = self._widget.get_invitees() + for jid in invitees: + self._invite(JID.from_string(jid)) + + elif self._mode == 'change-nickname': + assert isinstance(self._widget, InputWidget) + nickname = self._widget.get_text() + assert self._client is not None + assert self._contact is not None + self._client.get_module('MUC').change_nick( + self._contact.jid, nickname) + + elif self._mode == 'kick': + assert isinstance(self._widget, InputWidget) + reason = self._widget.get_text() + assert self._client is not None + assert self._contact is not None + self._client.get_module('MUC').set_role( + self._contact.jid, self._data, 'none', reason) + + elif self._mode == 'ban': + assert isinstance(self._widget, InputWidget) + reason = self._widget.get_text() + assert self._client is not None + assert self._contact is not None + self._client.get_module('MUC').set_affiliation( + self._contact.jid, + {self._data: {'affiliation': 'outcast', 'reason': reason}}) + + self.emit('finish') + + def _on_cancel_clicked(self, _button: Gtk.Button) -> None: + self.emit('finish') + + def _invite(self, invited_jid: JID) -> None: + assert self._contact is not None + client = app.get_client(self._contact.account) + client.get_module('MUC').invite( + self._contact.jid, invited_jid) + invited_contact = client.get_module('Contacts').get_contact( + invited_jid) + self.emit( + 'message', + _('%s has been invited to this group chat') % invited_contact.name) + + +class InputWidget(Gtk.Box): + + __gsignals__ = { + 'changed': (GObject.SignalFlags.RUN_LAST, None, (bool,)), + } + + def __init__(self, + contact: ChatContactT, + mode: str, + data: Optional[str] = None + ) -> None: + Gtk.Box.__init__(self, + orientation=Gtk.Orientation.VERTICAL, + spacing=12) + self._contact = contact + self._mode = mode + + heading_label = Gtk.Label() + heading_label.set_xalign(0) + heading_label.get_style_context().add_class('bold16') + self.add(heading_label) + + sub_label = Gtk.Label() + sub_label.set_xalign(0) + sub_label.get_style_context().add_class('dim-label') + self.add(sub_label) + + self._entry = Gtk.Entry() + self._entry.set_activates_default(True) + self._entry.set_size_request(300, -1) + self._entry.connect('changed', self._on_entry_changed) + self.add(self._entry) + + if mode == 'change-nickname': + heading_label.set_text(_('Change Nickname')) + sub_label.set_text(_('Enter your new nickname')) + assert isinstance(self._contact, GroupchatContact) + self._entry.set_text(self._contact.nickname or '') + elif mode == 'kick': + heading_label.set_text(_('Kick %s') % data) + sub_label.set_text(_('Reason (optional)')) + elif mode == 'ban': + heading_label.set_text(_('Ban %s') % data) + sub_label.set_text(_('Reason (optional)')) + self.connect('destroy', self._on_destroy) + self.show_all() + + def _on_destroy(self, _widget: InputWidget) -> None: + app.check_finalize(self) + + def _on_entry_changed(self, entry: Gtk.Entry) -> None: + text = entry.get_text() + + if self._mode == 'change-nickname': + assert isinstance(self._contact, GroupchatContact) + if not text or text == self._contact.nickname: + self.emit('changed', False) + return + try: + validate_resourcepart(text) + except InvalidJid: + self.emit('changed', False) + return + + self.emit('changed', bool(text)) + + def focus(self) -> None: + self._entry.grab_focus() + + def get_text(self) -> str: + return self._entry.get_text()
===================================== gajim/gtk/chat_stack.py ===================================== @@ -38,6 +38,7 @@ from gajim.common.types import ChatContactT
from .chat_banner import ChatBanner +from .chat_function_page import ChatFunctionPage from .control_stack import ControlStack from .controls.groupchat import GroupchatControl from .message_actions_box import MessageActionsBox @@ -56,6 +57,11 @@ def __init__(self):
self.add_named(ChatPlaceholderBox(), 'empty')
+ self._chat_function_page = ChatFunctionPage() + self._chat_function_page.connect('finish', self._on_function_finished) + self._chat_function_page.connect('message', self._on_function_message) + self.add_named(self._chat_function_page, 'function') + self._chat_banner = ChatBanner() self._control_stack = ControlStack() self._message_action_box = MessageActionsBox() @@ -70,6 +76,7 @@ def __init__(self): self._current_contact: Optional[ChatContactT] = None
self.add_named(box, 'controls') + self._connect_actions() self.show_all()
@@ -105,6 +112,7 @@ def show_chat(self, account: str, jid: JID) -> None: else: self._update_chat_actions(self._current_contact)
+ self.set_transition_type(Gtk.StackTransitionType.NONE) self.set_visible_child_name('controls')
def _on_muc_state_changed(self, @@ -322,12 +330,10 @@ def _on_action(self, 'ContactInfo', account=account, contact=resource_contact)
elif action_name == 'muc-invite': - assert isinstance(current_control, GroupchatControl) - current_control.show_inviter() + self._show_chat_function_page('invite')
elif action_name == 'muc-change-nickname': - assert isinstance(current_control, GroupchatControl) - current_control.show_change_nick() + self._show_chat_function_page('change-nickname')
elif action_name == 'muc-execute-command': assert isinstance(current_control, GroupchatControl) @@ -344,13 +350,13 @@ def _on_action(self, assert isinstance(current_control, GroupchatControl) assert param is not None kick_nick = param.get_string() - current_control.show_kick(kick_nick) + self._show_chat_function_page('kick', data=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) + self._show_chat_function_page('ban', data=ban_jid)
elif action_name == 'muc-change-role': assert param is not None @@ -382,6 +388,28 @@ def _on_stateful_action(self, action.set_state(param) contact.settings.set('send_marker', param.get_boolean())
+ def _show_chat_function_page(self, + function: str, + data: Optional[str] = None + ) -> None: + assert self._current_contact is not None + self._chat_function_page.set_mode( + self._current_contact, function, data) + self.set_transition_type(Gtk.StackTransitionType.SLIDE_UP_DOWN) + self.set_visible_child_name('function') + + def _on_function_finished(self, _function_page: ChatFunctionPage) -> None: + self.set_visible_child_name('controls') + self.set_transition_type(Gtk.StackTransitionType.NONE) + + def _on_function_message(self, + _function_page: ChatFunctionPage, + message: str + ) -> None: + control = self._control_stack.get_current_control() + assert control is not None + control.add_info_message(message) + def _on_send_message(self) -> None: self._message_action_box.msg_textview.replace_emojis() message = self._message_action_box.msg_textview.get_text()
===================================== gajim/gtk/controls/groupchat.py ===================================== @@ -30,8 +30,6 @@ import logging
from nbxmpp import JID -from nbxmpp.protocol import InvalidJid -from nbxmpp.protocol import validate_resourcepart from nbxmpp.const import StatusCode from nbxmpp.errors import StanzaError from nbxmpp.modules.security_labels import Displaymarking @@ -63,7 +61,6 @@ from gajim.gui.dialogs import DialogButton from gajim.gui.dialogs import ConfirmationDialog from gajim.gui.dataform import DataFormWidget -from gajim.gui.groupchat_inviter import GroupChatInviter from gajim.gui.groupchat_roster import GroupchatRoster from gajim.gui.groupchat_state import GroupchatState from gajim.gui.util import open_window @@ -89,12 +86,6 @@ def __init__(self, account: str, jid: JID) -> None:
self.room_jid = str(self.contact.jid)
- # Stores nickname we want to kick - self._kick_nick: Optional[str] = None - - # Stores nickname we want to ban - self._ban_jid: Optional[str] = None - # Last sent message text self.last_sent_txt: str = ''
@@ -126,11 +117,6 @@ def __init__(self, account: str, jid: JID) -> None:
self._subject_text = ''
- # Groupchat invite - 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) - self._set_control_inactive()
# Stack @@ -199,23 +185,8 @@ def _get_current_page(self) -> str: return self.xml.stack.get_visible_child_name()
# Actions - def show_inviter(self) -> None: - self._invite_box.load_contacts() - self._show_page('invite') - - def _on_invite_ready(self, - _listbox: GroupChatInviter, - invitable: bool - ) -> None: - self.xml.invite_button.set_sensitive(invitable) - - def _on_invite_clicked(self, _button: Gtk.Button) -> None: - invitees = self._invite_box.get_invitees() - for jid in invitees: - self.invite(JID.from_string(jid)) - self._show_page('groupchat') - def invite(self, invited_jid: JID) -> None: + # TODO: Remove, used by command system self._client.get_module('MUC').invite( self.contact.jid, invited_jid) invited_contact = self._client.get_module('Contacts').get_contact( @@ -223,24 +194,6 @@ def invite(self, invited_jid: JID) -> None: self.add_info_message( _('%s has been invited to this group chat') % invited_contact.name)
- 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 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 _show_roster(self, show_roster: bool, *args: Any) -> None: transition = Gtk.RevealerTransitionType.SLIDE_RIGHT if show_roster: @@ -863,25 +816,8 @@ def focus(self) -> None: pass elif page_name == 'password': self.xml.password_entry.grab_focus_without_selecting() - elif page_name == 'nickname': - self.xml.nickname_entry.grab_focus_without_selecting() elif page_name == 'captcha': self._captcha_request.focus_first_entry() - elif page_name == 'invite': - self._invite_box.focus_search_entry() - - def _on_kick_participant_clicked(self, _button: Gtk.Button) -> None: - reason = self.xml.kick_reason_entry.get_text() - self._client.get_module('MUC').set_role( - self.room_jid, self._kick_nick, 'none', reason) - self._show_page('groupchat') - - def _on_ban_participant_clicked(self, _button: Gtk.Button) -> None: - reason = self.xml.ban_reason_entry.get_text() - self._client.get_module('MUC').set_affiliation( - self.room_jid, - {self._ban_jid: {'affiliation': 'outcast', 'reason': reason}}) - self._show_page('groupchat')
def _on_page_change(self, stack: Gtk.Stack, _param: Any) -> None: page_name = stack.get_visible_child_name() @@ -898,31 +834,6 @@ def _on_page_change(self, stack: Gtk.Stack, _param: Any) -> None: elif page_name == 'error': self.xml.close_button.grab_default()
- def show_change_nick(self) -> None: - if self._get_current_page() != 'groupchat': - return - self.xml.nickname_entry.set_text(self.contact.nickname) - self.xml.nickname_entry.grab_focus() - self.xml.nickname_change_button.grab_default() - self._show_page('nickname') - - def _on_nickname_text_changed(self, entry: Gtk.Entry, _param: Any) -> None: - text = entry.get_text() - if not text or text == self.contact.nickname: - self.xml.nickname_change_button.set_sensitive(False) - else: - try: - validate_resourcepart(text) - except InvalidJid: - self.xml.nickname_change_button.set_sensitive(False) - else: - self.xml.nickname_change_button.set_sensitive(True) - - def _on_nickname_change_clicked(self, _button: Gtk.Button) -> None: - new_nick = self.xml.nickname_entry.get_text() - self._client.get_module('MUC').change_nick(self.room_jid, new_nick) - self._show_page('groupchat') - def _on_password_set_clicked(self, _button: Gtk.Button) -> None: password = self.xml.password_entry.get_text() self._client.get_module('MUC').set_password(self.room_jid, password) @@ -1000,9 +911,6 @@ def _on_retry_join_clicked(self, _button: Gtk.Button) -> None: self._client.get_module('MUC').join(self.room_jid) self._show_page('groupchat')
- def _on_page_cancel_clicked(self, _button: Gtk.Button) -> None: - self._show_page('groupchat') - def _on_page_close_clicked(self, *args: Any) -> None: self._close_control()
===================================== pyrightconfig.json ===================================== @@ -59,6 +59,7 @@ "gajim/gtk/change_password.py", "gajim/gtk/chat_action_processor.py", "gajim/gtk/chat_filter.py", + "gajim/gtk/chat_function_page.py", "gajim/gtk/chat_list_stack.py", "gajim/gtk/chat_list.py", "gajim/gtk/chat_page.py",
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/32cdc9d142b1c0a99dff7fa46030e8d7e...