parent
							
								
									958e1390fd
								
							
						
					
					
						commit
						cd65b591dc
					
				
					 1 changed files with 5 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -95,13 +95,9 @@ class MessageTextView(Gtk.TextView):
 | 
			
		|||
 | 
			
		||||
        self.connect('paste-clipboard', self._paste_clipboard)
 | 
			
		||||
        self.connect_after('paste-clipboard', self._after_paste_clipboard)
 | 
			
		||||
        self.connect('focus-in-event', self._on_focus_in)
 | 
			
		||||
        self.connect('grab-focus', self._on_grab_focus)
 | 
			
		||||
        self.connect('focus-out-event', self._on_focus_out)
 | 
			
		||||
 | 
			
		||||
        start = buffer_.get_bounds()[0]
 | 
			
		||||
        buffer_.insert_with_tags(
 | 
			
		||||
            start, self.PLACEHOLDER, self.placeholder_tag)
 | 
			
		||||
 | 
			
		||||
    def _on_buffer_changed(self, *args):
 | 
			
		||||
        text = self.get_text()
 | 
			
		||||
        # Because of inserting and removing PLACEHOLDER text
 | 
			
		||||
| 
						 | 
				
			
			@ -133,11 +129,14 @@ class MessageTextView(Gtk.TextView):
 | 
			
		|||
        text = buf.get_text(start, end, True)
 | 
			
		||||
        return text == self.PLACEHOLDER
 | 
			
		||||
 | 
			
		||||
    def _on_focus_in(self, *args):
 | 
			
		||||
    def remove_placeholder(self):
 | 
			
		||||
        if self.is_placeholder():
 | 
			
		||||
            self.get_buffer().set_text('')
 | 
			
		||||
        self.toggle_speller(True)
 | 
			
		||||
 | 
			
		||||
    def _on_grab_focus(self, *args):
 | 
			
		||||
        self.remove_placeholder()
 | 
			
		||||
 | 
			
		||||
    def _on_focus_out(self, *args):
 | 
			
		||||
        buf = self.get_buffer()
 | 
			
		||||
        start, end = buf.get_bounds()
 | 
			
		||||
| 
						 | 
				
			
			@ -152,9 +151,6 @@ class MessageTextView(Gtk.TextView):
 | 
			
		|||
            spell_view = Gspell.TextView.get_from_gtk_text_view(self)
 | 
			
		||||
            spell_view.set_inline_spell_checking(activate)
 | 
			
		||||
 | 
			
		||||
    def remove_placeholder(self):
 | 
			
		||||
        self._on_focus_in()
 | 
			
		||||
 | 
			
		||||
    @staticmethod
 | 
			
		||||
    def _paste_clipboard(textview):
 | 
			
		||||
        if textview.is_placeholder():
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue