Daniel Brötzmann pushed to branch newcontrol at gajim / gajim
Commits: 5c450b09 by wurstsalat at 2022-07-20T19:22:32+02:00 GroupchatState: Connect to contact
- - - - - e5703480 by wurstsalat at 2022-07-20T19:25:36+02:00 ChatFunctionPage: Set input visibility for password
- - - - - b00603be by wurstsalat at 2022-07-20T19:25:50+02:00 GroupchatState: Fix indentation
- - - - -
3 changed files:
- gajim/gtk/chat_function_page.py - gajim/gtk/controls/groupchat.py - gajim/gtk/groupchat_state.py
Changes:
===================================== gajim/gtk/chat_function_page.py ===================================== @@ -354,6 +354,7 @@ def __init__(self, heading_label.set_text(_('Password Required')) sub_label.set_text(_('Enter a password to join this chat')) self._entry.set_input_purpose(Gtk.InputPurpose.PASSWORD) + self._entry.set_visibility(False)
self.connect('destroy', self._on_destroy) self.show_all()
===================================== gajim/gtk/controls/groupchat.py ===================================== @@ -38,7 +38,6 @@
from gi.repository import Gtk from gi.repository import Gdk -from gi.repository import GLib
from gajim.common import app from gajim.common import events @@ -93,11 +92,7 @@ def __init__(self, account: str, jid: JID) -> None: self.correcting: bool = False self.last_sent_msg: Optional[str] = None
- self._groupchat_state = GroupchatState() - self._groupchat_state.connect('join-clicked', - self._on_groupchat_state_join_clicked) - self._groupchat_state.connect('abort-clicked', - self._on_groupchat_state_abort_clicked) + self._groupchat_state = GroupchatState(self.contact) self.xml.conv_view_overlay.add_overlay(self._groupchat_state)
self.roster = GroupchatRoster(self.account, self.room_jid, self) @@ -141,12 +136,8 @@ def _on_muc_state_changed(self, _contact: GroupchatContact, _signal_name: str ) -> None: - if self.contact.is_joining: - self._groupchat_state.set_joining() - if self.contact.is_joined: self._set_control_active() - self._groupchat_state.set_joined()
elif self.contact.is_not_joined: self._set_control_inactive() @@ -686,13 +677,3 @@ def _on_drag_data_received(self, if target_type == TARGET_TYPE_URI_LIST: # File drag and drop (handled in chat_control_base) self.drag_data_file_transfer(selection) - - def _on_groupchat_state_abort_clicked(self, _button: Gtk.Button) -> None: - app.window.activate_action( - 'remove-chat', - GLib.Variant('as', [self.account, str(self.room_jid)])) - - def _on_groupchat_state_join_clicked(self, - _groupchat_state: GroupchatState - ) -> None: - self._client.get_module('MUC').join(self.room_jid)
===================================== gajim/gtk/groupchat_state.py ===================================== @@ -12,53 +12,64 @@ # 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 gi.repository import GLib from gi.repository import Gtk -from gi.repository import GObject + +from gajim.common import app +from gajim.common.modules.contacts import GroupchatContact
from gajim.gui.builder import get_builder
class GroupchatState(Gtk.Box): - - __gsignals__ = { - 'join-clicked': ( - GObject.SignalFlags.RUN_FIRST, - None, - ()), - 'abort-clicked': ( - GObject.SignalFlags.RUN_FIRST, - None, - ()), - } - - def __init__(self): + def __init__(self, contact: GroupchatContact) -> None: Gtk.Box.__init__(self) - self.set_halign(Gtk.Align.CENTER) self.set_valign(Gtk.Align.END)
+ self._contact = contact + self._contact.connect('state-changed', self._on_muc_state_changed) + self._ui = get_builder('groupchat_state.ui') self._ui.connect_signals(self) self.add(self._ui.groupchat_state) self.show_all()
- def set_joining(self): + def _on_muc_state_changed(self, + contact: GroupchatContact, + _signal_name: str + ) -> None: + if contact.is_joining: + self._set_joining() + + if contact.is_joined: + self._set_joined() + + if contact.is_not_joined: + self._set_not_joined() + + def _set_joining(self) -> None: self._ui.groupchat_state.set_visible_child_name('joining')
- def set_joined(self): + def _set_joined(self) -> None: self.hide() self.set_no_show_all(True)
- def set_not_joined(self): + def _set_not_joined(self) -> None: self._ui.groupchat_state.set_visible_child_name('not-joining') self.show()
- def set_fetching(self): + def set_fetching(self) -> None: self._ui.groupchat_state.set_visible_child_name('fetching')
def _on_join_clicked(self, _button: Gtk.Button) -> None: - self.emit('join-clicked') + client = app.get_client(self._contact.account) + client.get_module('MUC').join(self._contact.jid)
def _on_abort_clicked(self, _button: Gtk.Button) -> None: - self.emit('abort-clicked') + app.window.activate_action( + 'remove-chat', + GLib.Variant( + 'as', [self._contact.account, str(self._contact.jid)]))
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/9ed653f5bdc4c37b47349ce06ad18112...