From 9d2fb4b95cdf8526bf947bf956714fc526913da7 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 30 Jan 2013 11:27:01 +0000 Subject: [PATCH] Improve button handling of EditableLabel. Closes LP#1092775 --- terminatorlib/editablelabel.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/terminatorlib/editablelabel.py b/terminatorlib/editablelabel.py index f99578ed..50a2666e 100644 --- a/terminatorlib/editablelabel.py +++ b/terminatorlib/editablelabel.py @@ -72,6 +72,8 @@ class EditableLabel(gtk.EventBox): def _on_click_text(self, widget, event): # pylint: disable-msg=W0613 """event handling text edition""" + if event.button != 1: + return False if event.type == gtk.gdk._2BUTTON_PRESS: self.remove (self._label) self._entry = gtk.Entry () @@ -85,6 +87,9 @@ class EditableLabel(gtk.EventBox): sig = self._entry.connect ("key-press-event", self._on_entry_keypress) self._entry_handler_id.append(sig) + sig = self._entry.connect("button-press-event", + self._on_entry_buttonpress) + self._entry_handler_id.append(sig) self._entry.grab_focus () return(True) return(False) @@ -126,6 +131,16 @@ class EditableLabel(gtk.EventBox): if key == 'Escape': self._entry_to_label (None, None) + def _on_entry_buttonpress (self, widget, event): + """handle button events in gtk.Entry.""" + # Block right clicks to avoid a deadlock. + # The correct solution here would be for _entry_to_label to trigger a + # deferred execution handler and for that handler to check if focus is + # in a GtkMenu. The problem being that we are unable to get a context + # menu for the GtkEntry. + if event.button == 3: + return True + def modify_fg(self, state, color): """Set the label foreground""" self._label.modify_fg(state, color)