Improve button handling of EditableLabel. Closes LP#1092775
This commit is contained in:
parent
abf0dbfd8c
commit
9d2fb4b95c
|
@ -72,6 +72,8 @@ class EditableLabel(gtk.EventBox):
|
||||||
def _on_click_text(self, widget, event):
|
def _on_click_text(self, widget, event):
|
||||||
# pylint: disable-msg=W0613
|
# pylint: disable-msg=W0613
|
||||||
"""event handling text edition"""
|
"""event handling text edition"""
|
||||||
|
if event.button != 1:
|
||||||
|
return False
|
||||||
if event.type == gtk.gdk._2BUTTON_PRESS:
|
if event.type == gtk.gdk._2BUTTON_PRESS:
|
||||||
self.remove (self._label)
|
self.remove (self._label)
|
||||||
self._entry = gtk.Entry ()
|
self._entry = gtk.Entry ()
|
||||||
|
@ -85,6 +87,9 @@ class EditableLabel(gtk.EventBox):
|
||||||
sig = self._entry.connect ("key-press-event",
|
sig = self._entry.connect ("key-press-event",
|
||||||
self._on_entry_keypress)
|
self._on_entry_keypress)
|
||||||
self._entry_handler_id.append(sig)
|
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 ()
|
self._entry.grab_focus ()
|
||||||
return(True)
|
return(True)
|
||||||
return(False)
|
return(False)
|
||||||
|
@ -126,6 +131,16 @@ class EditableLabel(gtk.EventBox):
|
||||||
if key == 'Escape':
|
if key == 'Escape':
|
||||||
self._entry_to_label (None, None)
|
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):
|
def modify_fg(self, state, color):
|
||||||
"""Set the label foreground"""
|
"""Set the label foreground"""
|
||||||
self._label.modify_fg(state, color)
|
self._label.modify_fg(state, color)
|
||||||
|
|
Loading…
Reference in New Issue