Allow for subclasses of Entry to override the base gtk.Entry.
This commit is contained in:
parent
ac23b66059
commit
63c5bd5dbd
@ -49,7 +49,7 @@ class Entry(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
self._round_box.props.border_color = Color.FRAME_BORDER.get_int()
|
self._round_box.props.border_color = Color.FRAME_BORDER.get_int()
|
||||||
self.append(self._round_box, hippo.PACK_EXPAND)
|
self.append(self._round_box, hippo.PACK_EXPAND)
|
||||||
|
|
||||||
self._entry = gtk.Entry()
|
self._entry = self.create_entry()
|
||||||
self._entry.props.has_frame = False
|
self._entry.props.has_frame = False
|
||||||
self._update_colors(focused=False)
|
self._update_colors(focused=False)
|
||||||
self._entry.modify_text(gtk.STATE_SELECTED,
|
self._entry.modify_text(gtk.STATE_SELECTED,
|
||||||
@ -66,6 +66,13 @@ class Entry(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
self._canvas_widget.props.widget = self._entry
|
self._canvas_widget.props.widget = self._entry
|
||||||
self._round_box.append(self._canvas_widget, hippo.PACK_EXPAND)
|
self._round_box.append(self._canvas_widget, hippo.PACK_EXPAND)
|
||||||
|
|
||||||
|
def create_entry():
|
||||||
|
"""
|
||||||
|
Subclasses can override this method in order to provide a different
|
||||||
|
entry widget.
|
||||||
|
"""
|
||||||
|
return gtk.Entry()
|
||||||
|
|
||||||
def add_button(self, icon_name, action_id):
|
def add_button(self, icon_name, action_id):
|
||||||
button = Button(icon_name=icon_name)
|
button = Button(icon_name=icon_name)
|
||||||
|
|
||||||
@ -79,12 +86,10 @@ class Entry(hippo.CanvasBox, hippo.CanvasItem):
|
|||||||
self._buttons[button] = action_id
|
self._buttons[button] = action_id
|
||||||
|
|
||||||
def do_set_property(self, pspec, value):
|
def do_set_property(self, pspec, value):
|
||||||
if pspec.name == 'text':
|
self._entry.set_property(pspec.name, value)
|
||||||
self._entry.set_text(value)
|
|
||||||
|
|
||||||
def do_get_property(self, pspec, value):
|
def do_get_property(self, pspec):
|
||||||
if pspec.name == 'text':
|
return self._entry.get_property(pspec.name)
|
||||||
return self._entry.get_text()
|
|
||||||
|
|
||||||
def _entry_focus_in_event_cb(self, widget, event):
|
def _entry_focus_in_event_cb(self, widget, event):
|
||||||
self._update_colors(focused=True)
|
self._update_colors(focused=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user