Daniel Brötzmann pushed to branch newcontrol at gajim / gajim
Commits:
4e88fb41 by wurstsalat at 2022-07-12T13:47:09+02:00
MessageInput: Use JID for draft dict key
- - - - -
45624f6d by wurstsalat at 2022-07-12T13:47:39+02:00
Cleanup
- - - - -
4 changed files:
- gajim/gtk/chat_stack.py
- gajim/gtk/controls/base.py
- gajim/gtk/message_actions_box.py
- gajim/gtk/message_input.py
Changes:
=====================================
gajim/gtk/chat_stack.py
=====================================
@@ -397,7 +397,10 @@ def _on_send_message(self) -> None:
control = self._control_stack.get_current_control()
action = app.window.lookup_action('set-encryption')
- encryption = action.get_state().get_string()
+ assert action is not None
+ state = action.get_state()
+ assert state is not None
+ encryption = state.get_string()
if encryption:
self.sendmessage = True
=====================================
gajim/gtk/controls/base.py
=====================================
@@ -217,9 +217,6 @@ def __init__(self, widget_name: str, account: str, jid:
JID) -> None:
def _connect_contact_signals(self) -> None:
raise NotImplementedError
- def _get_action(self, name: str) -> Gio.SimpleAction:
- return app.window.lookup_action(f'{name}{self.control_id}')
-
def process_event(self, event: events.ApplicationEvent) -> None:
if event.account != self.account:
return
=====================================
gajim/gtk/message_actions_box.py
=====================================
@@ -309,9 +309,10 @@ def _set_encryption_details(self, state: str) -> None:
if state:
app.plugin_manager.extension_point(
- 'encryption_state' + state, self, encryption_state)
+ f'encryption_state{state}', self, encryption_state)
visible, enc_type, authenticated = encryption_state.values()
+ assert isinstance(visible, bool)
if authenticated:
authenticated_string = _('and authenticated')
@@ -333,7 +334,7 @@ def _on_encryption_details_clicked(self, _button:
Gtk.Button) -> None:
contact = self.get_current_contact()
encryption = contact.settings.get('encryption')
app.plugin_manager.extension_point(
- 'encryption_dialog' + encryption, contact)
+ f'encryption_dialog{encryption}', contact)
def _set_settings_menu(self, contact: ChatContactT) -> None:
if isinstance(contact, GroupchatContact):
@@ -481,13 +482,16 @@ def _update_send_file_button_tooltip(self):
def _on_buffer_changed(self, textbuffer: Gtk.TextBuffer) -> None:
has_text = self.msg_textview.has_text()
- app.window.lookup_action('send-message').set_enabled(has_text)
+ send_message_action = app.window.lookup_action('send-message')
+ assert send_message_action is not None
+ send_message_action.set_enabled(has_text)
encryption_enabled, encryption_name = self._get_encryption_state()
if has_text and encryption_enabled:
app.plugin_manager.extension_point('typing' + encryption_name,
self)
+ assert self._contact
client = app.get_client(self._contact.account)
client.get_module('Chatstate').set_keyboard_activity(self._contact)
if not has_text:
=====================================
gajim/gtk/message_input.py
=====================================
@@ -30,6 +30,8 @@
from gi.repository import GLib
from gi.repository import Pango
+from nbxmpp.protocol import JID
+
from gajim.common import app
from gajim.common.i18n import _
from gajim.common.styling import process
@@ -75,7 +77,7 @@ def __init__(self) -> None:
self.undo_pressed: bool = False
self._contact: Optional[ChatContactT] = None
- self._drafts: dict[str, str] = {}
+ self._drafts: dict[JID, str] = {}
self._chat_action_processor = ChatActionProcessor(self)
@@ -94,12 +96,12 @@ def __init__(self) -> None:
def switch_contact(self, contact: ChatContactT) -> None:
if self._contact is not None:
if self.has_text():
- self._drafts[str(self._contact.jid)] = self.get_text()
+ self._drafts[self._contact.jid] = self.get_text()
else:
- self._drafts.pop(str(self._contact.jid), None)
+ self._drafts.pop(self._contact.jid, None)
self.clear()
- draft = self._drafts.get(str(contact.jid))
+ draft = self._drafts.get(contact.jid)
if draft is not None:
self.insert_text(draft)
@@ -345,7 +347,6 @@ def _on_populate_popup(self,
_textview: MessageInputTextView,
menu: Gtk.Widget
) -> None:
-
assert isinstance(menu, Gtk.Menu)
item = Gtk.MenuItem.new_with_mnemonic(_('_Undo'))
menu.prepend(item)
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/f8ef2624bbac60ee41752ae8c889a129c6e0512e...45624f6daa49954a2fea1d49fede40e97cde7377
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/f8ef2624bbac60ee41752ae8c889a129c6e0512e...45624f6daa49954a2fea1d49fede40e97cde7377
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits