Philipp Hörist pushed to branch master at gajim / gajim

Commits:

3 changed files:

Changes:

  • gajim/chat_control.py
    ... ... @@ -1116,12 +1116,14 @@ class ChatControl(ChatControlBase):
    1116 1116
             # if wel're inactive prevent composing (XEP violation)
    
    1117 1117
             if contact.our_chatstate == 'inactive' and state == 'composing':
    
    1118 1118
                 # go active before
    
    1119
    +            app.log('chatstates').info('%-10s - %s', 'active', self.contact.jid)
    
    1119 1120
                 app.nec.push_outgoing_event(MessageOutgoingEvent(None,
    
    1120 1121
                     account=self.account, jid=self.contact.jid, chatstate='active',
    
    1121 1122
                     control=self))
    
    1122 1123
                 contact.our_chatstate = 'active'
    
    1123 1124
                 self.reset_kbd_mouse_timeout_vars()
    
    1124 1125
     
    
    1126
    +        app.log('chatstates').info('%-10s - %s', state, self.contact.jid)
    
    1125 1127
             app.nec.push_outgoing_event(MessageOutgoingEvent(None,
    
    1126 1128
                 account=self.account, jid=self.contact.jid, chatstate=state,
    
    1127 1129
                 control=self))
    

  • gajim/chat_control_base.py
    ... ... @@ -797,18 +797,16 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
    797 797
                 self.possible_paused_timeout_id = None
    
    798 798
                 return False  # stop looping
    
    799 799
     
    
    800
    -        message_buffer = self.msg_textview.get_buffer()
    
    801
    -        if (self.kbd_activity_in_last_5_secs and
    
    802
    -                message_buffer.get_char_count()):
    
    803
    -            # Only composing if the keyboard activity was in text entry
    
    804
    -            self.send_chatstate('composing', self.contact)
    
    805
    -        elif (self.mouse_over_in_last_5_secs and
    
    806
    -              current_state == 'inactive' and
    
    807
    -                jid == self.parent_win.get_active_jid()):
    
    808
    -            self.send_chatstate('active', self.contact)
    
    809
    -        else:
    
    810
    -            if current_state == 'composing':
    
    811
    -                self.send_chatstate('paused', self.contact)  # pause composing
    
    800
    +        if current_state == 'composing':
    
    801
    +            if not self.kbd_activity_in_last_5_secs:
    
    802
    +                if self.msg_textview.has_text():
    
    803
    +                    self.send_chatstate('paused', self.contact)
    
    804
    +                else:
    
    805
    +                    self.send_chatstate('active', self.contact)
    
    806
    +        elif current_state == 'inactive':
    
    807
    +            if (self.mouse_over_in_last_5_secs and
    
    808
    +                    jid == self.parent_win.get_active_jid()):
    
    809
    +                self.send_chatstate('active', self.contact)
    
    812 810
     
    
    813 811
             # assume no activity and let the motion-notify or 'insert-text' make them
    
    814 812
             # True refresh 30 seconds vars too or else it's 30 - 5 = 25 seconds!
    
    ... ... @@ -870,10 +868,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
    870 868
         def _on_message_tv_buffer_changed(self, textbuffer):
    
    871 869
             self.kbd_activity_in_last_5_secs = True
    
    872 870
             self.kbd_activity_in_last_30_secs = True
    
    873
    -        if textbuffer.get_char_count():
    
    874
    -            self.send_chatstate('composing', self.contact)
    
    875
    -        else:
    
    876
    -            self.send_chatstate('active', self.contact)
    
    871
    +        if not self.msg_textview.has_text():
    
    872
    +            return
    
    873
    +        self.send_chatstate('composing', self.contact)
    
    877 874
     
    
    878 875
         def save_message(self, message, msg_type):
    
    879 876
             # save the message, so user can scroll though the list with key up/down
    
    ... ... @@ -1146,8 +1143,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
    1146 1143
                         self.redraw_after_event_removed(jid)
    
    1147 1144
                 # send chatstate inactive to the one we're leaving
    
    1148 1145
                 # and active to the one we visit
    
    1149
    -            message_buffer = self.msg_textview.get_buffer()
    
    1150
    -            if message_buffer.get_char_count():
    
    1146
    +            if self.msg_textview.has_text():
    
    1151 1147
                     self.send_chatstate('paused', self.contact)
    
    1152 1148
                 else:
    
    1153 1149
                     self.send_chatstate('active', self.contact)
    

  • gajim/message_textview.py
    ... ... @@ -100,10 +100,16 @@ class MessageTextView(Gtk.TextView):
    100 100
             buf = self.get_buffer()
    
    101 101
             start, end = buf.get_bounds()
    
    102 102
             text = buf.get_text(start, end, True)
    
    103
    -        return text != self.PLACEHOLDER
    
    103
    +        return text != self.PLACEHOLDER and text != ''
    
    104
    +
    
    105
    +    def is_placeholder(self):
    
    106
    +        buf = self.get_buffer()
    
    107
    +        start, end = buf.get_bounds()
    
    108
    +        text = buf.get_text(start, end, True)
    
    109
    +        return text == self.PLACEHOLDER
    
    104 110
     
    
    105 111
         def _on_focus_in(self, *args):
    
    106
    -        if not self.has_text():
    
    112
    +        if self.is_placeholder():
    
    107 113
                 self.get_buffer().set_text('')
    
    108 114
             self.toggle_speller(True)
    
    109 115