Daniel Brötzmann pushed to branch newcontrol at gajim / gajim

Commits:

4 changed files:

Changes:

  • gajim/gtk/chat_stack.py
    ... ... @@ -333,7 +333,7 @@ def _update_base_actions(self, contact: ChatContactT) -> None:
    333 333
             client = app.get_client(contact.account)
    
    334 334
             online = app.account_is_connected(contact.account)
    
    335 335
     
    
    336
    -        has_text = self._message_action_box.msg_textview.has_text()
    
    336
    +        has_text = self._message_action_box.msg_textview.has_text
    
    337 337
             app.window.get_action('send-message').set_enabled(
    
    338 338
                 online and has_text)
    
    339 339
     
    

  • gajim/gtk/main.py
    ... ... @@ -498,7 +498,7 @@ def _on_window_motion_notify(self,
    498 498
                 chat_stack = self._chat_page.get_chat_stack()
    
    499 499
                 msg_action_box = chat_stack.get_message_action_box()
    
    500 500
                 client.get_module('Chatstate').set_mouse_activity(
    
    501
    -                control.contact, msg_action_box.msg_textview.has_text())
    
    501
    +                control.contact, msg_action_box.msg_textview.has_text)
    
    502 502
     
    
    503 503
         def _on_window_delete(self,
    
    504 504
                               _widget: Gtk.ApplicationWindow,
    

  • gajim/gtk/message_actions_box.py
    ... ... @@ -282,7 +282,7 @@ def _update_message_input_state(self) -> None:
    282 282
         def _set_chatstate(self, state: bool) -> None:
    
    283 283
             assert self._client is not None
    
    284 284
             if state:
    
    285
    -            if self.msg_textview.has_text():
    
    285
    +            if self.msg_textview.has_text:
    
    286 286
                     self._client.get_module('Chatstate').set_chatstate(
    
    287 287
                         self._contact, Chatstate.PAUSED)
    
    288 288
                 else:
    
    ... ... @@ -513,7 +513,7 @@ def _update_send_file_button_tooltip(self):
    513 513
             self._ui.sendfile_button.set_tooltip_text(tooltip_text)
    
    514 514
     
    
    515 515
         def _on_buffer_changed(self, textbuffer: Gtk.TextBuffer) -> None:
    
    516
    -        has_text = self.msg_textview.has_text()
    
    516
    +        has_text = self.msg_textview.has_text
    
    517 517
             send_message_action = app.window.lookup_action('send-message')
    
    518 518
             assert send_message_action is not None
    
    519 519
             send_message_action.set_enabled(has_text)
    

  • gajim/gtk/message_input.py
    ... ... @@ -77,7 +77,7 @@ def __init__(self) -> None:
    77 77
             self.undo_pressed: bool = False
    
    78 78
     
    
    79 79
             self._contact: Optional[ChatContactT] = None
    
    80
    -        self._drafts: dict[JID, str] = {}
    
    80
    +        self._drafts: dict[tuple[str, JID], str] = {}
    
    81 81
     
    
    82 82
             self._chat_action_processor = ChatActionProcessor(self)
    
    83 83
     
    
    ... ... @@ -95,13 +95,15 @@ def __init__(self) -> None:
    95 95
     
    
    96 96
         def switch_contact(self, contact: ChatContactT) -> None:
    
    97 97
             if self._contact is not None:
    
    98
    -            if self.has_text():
    
    99
    -                self._drafts[self._contact.jid] = self.get_text()
    
    98
    +            account = self._contact.account
    
    99
    +            jid = self._contact.jid
    
    100
    +            if self.has_text:
    
    101
    +                self._drafts[(account, jid)] = self.get_text()
    
    100 102
                 else:
    
    101
    -                self._drafts.pop(self._contact.jid, None)
    
    103
    +                self._drafts.pop((account, jid), None)
    
    102 104
     
    
    103 105
             self.clear()
    
    104
    -        draft = self._drafts.get(contact.jid)
    
    106
    +        draft = self._drafts.get((contact.account, contact.jid))
    
    105 107
             if draft is not None:
    
    106 108
                 self.insert_text(draft)
    
    107 109
     
    
    ... ... @@ -138,7 +140,7 @@ def _on_focus_out(self,
    138 140
             scrolled = self.get_parent()
    
    139 141
             assert scrolled
    
    140 142
             scrolled.get_style_context().remove_class('message-input-focus')
    
    141
    -        if not self.has_text():
    
    143
    +        if not self.has_text:
    
    142 144
                 self.toggle_speller(False)
    
    143 145
             return False
    
    144 146
     
    
    ... ... @@ -188,6 +190,7 @@ def insert_newline(self) -> None:
    188 190
             if buf.get_end_iter().equal(iter_):
    
    189 191
                 GLib.idle_add(scroll_to_end, self.get_parent())
    
    190 192
     
    
    193
    +    @property
    
    191 194
         def has_text(self) -> bool:
    
    192 195
             buf = self.get_buffer()
    
    193 196
             start, end = buf.get_bounds()
    
    ... ... @@ -200,6 +203,9 @@ def get_text(self) -> str:
    200 203
             text = self.get_buffer().get_text(start, end, True)
    
    201 204
             return text
    
    202 205
     
    
    206
    +    def get_draft(self, account: str, jid: JID) -> Optional[str]:
    
    207
    +        return self._drafts.get((account, jid))
    
    208
    +
    
    203 209
         def toggle_speller(self, activate: bool) -> None:
    
    204 210
             if app.is_installed('GSPELL') and app.settings.get('use_speller'):
    
    205 211
                 spell_view = Gspell.TextView.get_from_gtk_text_view(self)