check birthday date format when editing profile window. Fixes #5692
This commit is contained in:
parent
ed28b14b82
commit
f8ab01b418
2 changed files with 15 additions and 0 deletions
|
@ -432,6 +432,7 @@
|
||||||
<object class="GtkEntry" id="BDAY_entry">
|
<object class="GtkEntry" id="BDAY_entry">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
|
<signal name="focus_out_event" handler="on_BDAY_entry_focus_out_event"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">3</property>
|
<property name="left_attach">3</property>
|
||||||
|
|
|
@ -203,6 +203,20 @@ class ProfileWindow:
|
||||||
elif event.button == 1: # left click
|
elif event.button == 1: # left click
|
||||||
self.on_set_avatar_button_clicked(widget)
|
self.on_set_avatar_button_clicked(widget)
|
||||||
|
|
||||||
|
def on_BDAY_entry_focus_out_event(self, widget, event):
|
||||||
|
txt = widget.get_text()
|
||||||
|
if not txt:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
time.strptime(txt, '%Y-%m-%d')
|
||||||
|
except ValueError:
|
||||||
|
if not widget.is_focus():
|
||||||
|
pritext = _('Wrong date format')
|
||||||
|
dialogs.ErrorDialog(pritext, _('Format of the date must be '
|
||||||
|
'YYYY-MM-DD'))
|
||||||
|
gobject.idle_add(lambda: widget.grab_focus())
|
||||||
|
return True
|
||||||
|
|
||||||
def set_value(self, entry_name, value):
|
def set_value(self, entry_name, value):
|
||||||
try:
|
try:
|
||||||
self.xml.get_object(entry_name).set_text(value)
|
self.xml.get_object(entry_name).set_text(value)
|
||||||
|
|
Loading…
Add table
Reference in a new issue