Emit a signal when editing is done
This commit is contained in:
parent
bf20587edc
commit
846e0c0fff
|
@ -20,6 +20,7 @@
|
||||||
# pylint: disable-msg=W0212
|
# pylint: disable-msg=W0212
|
||||||
""" Editable Label class"""
|
""" Editable Label class"""
|
||||||
import gtk
|
import gtk
|
||||||
|
import gobject
|
||||||
|
|
||||||
class EditableLabel(gtk.EventBox):
|
class EditableLabel(gtk.EventBox):
|
||||||
"""
|
"""
|
||||||
|
@ -33,9 +34,15 @@ class EditableLabel(gtk.EventBox):
|
||||||
_entry = None
|
_entry = None
|
||||||
_entry_handler_id = []
|
_entry_handler_id = []
|
||||||
|
|
||||||
|
__gsignals__ = {
|
||||||
|
'edit-done': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, text = ""):
|
def __init__(self, text = ""):
|
||||||
""" Class initialiser"""
|
""" Class initialiser"""
|
||||||
gtk.EventBox.__init__(self)
|
gtk.EventBox.__init__(self)
|
||||||
|
self.__gobject_init__()
|
||||||
|
|
||||||
self._label = gtk.Label(text)
|
self._label = gtk.Label(text)
|
||||||
self._custom = False
|
self._custom = False
|
||||||
self.set_visible_window (False)
|
self.set_visible_window (False)
|
||||||
|
@ -58,7 +65,7 @@ class EditableLabel(gtk.EventBox):
|
||||||
|
|
||||||
def _on_click_text(self, widget, event):
|
def _on_click_text(self, widget, event):
|
||||||
"""event handling text edition"""
|
"""event handling text edition"""
|
||||||
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 ()
|
||||||
self._entry.set_text (self._label.get_text ())
|
self._entry.set_text (self._label.get_text ())
|
||||||
|
@ -89,6 +96,7 @@ class EditableLabel(gtk.EventBox):
|
||||||
self.add (self._label)
|
self.add (self._label)
|
||||||
self._entry = None
|
self._entry = None
|
||||||
self.show_all ()
|
self.show_all ()
|
||||||
|
self.emit('edit-done')
|
||||||
return True
|
return True
|
||||||
#make pylint happy
|
#make pylint happy
|
||||||
if 1 or widget or event:
|
if 1 or widget or event:
|
||||||
|
@ -119,3 +127,4 @@ class EditableLabel(gtk.EventBox):
|
||||||
if 1 or widget or event:
|
if 1 or widget or event:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
gobject.type_register(EditableLabel)
|
||||||
|
|
Loading…
Reference in New Issue