7317: DateEdit statusbar to report invalid dates
Port [6b0b9f] from gramps34 Add/remove an explanatory prompt on the statusbar along with disabling/enabling the "OK" button when the date is invalid.
This commit is contained in:
parent
087a7ecad2
commit
a3c59778f9
@ -130,6 +130,7 @@ class EditDate(ManagedWindow):
|
|||||||
self.top.get_object('title'),
|
self.top.get_object('title'),
|
||||||
_('Date selection'))
|
_('Date selection'))
|
||||||
|
|
||||||
|
self.statusbar = self.top.get_object('statusbar')
|
||||||
self.ok_button = self.top.get_object('ok_button')
|
self.ok_button = self.top.get_object('ok_button')
|
||||||
self.calendar_box = self.top.get_object('calendar_box')
|
self.calendar_box = self.top.get_object('calendar_box')
|
||||||
for name in Date.ui_calendar_names:
|
for name in Date.ui_calendar_names:
|
||||||
@ -245,6 +246,8 @@ class EditDate(ManagedWindow):
|
|||||||
LOG.debug("revalidate: {0} changed, value: {1}".format(
|
LOG.debug("revalidate: {0} changed, value: {1}".format(
|
||||||
obj, the_value))
|
obj, the_value))
|
||||||
d = Date(self.date)
|
d = Date(self.date)
|
||||||
|
if not self.ok_button.get_sensitive():
|
||||||
|
self.statusbar.pop(1)
|
||||||
try:
|
try:
|
||||||
d.set(
|
d.set(
|
||||||
quality=the_quality,
|
quality=the_quality,
|
||||||
@ -259,6 +262,11 @@ class EditDate(ManagedWindow):
|
|||||||
return True
|
return True
|
||||||
except DateError as e:
|
except DateError as e:
|
||||||
self.ok_button.set_sensitive(0)
|
self.ok_button.set_sensitive(0)
|
||||||
|
self.statusbar.push(1,
|
||||||
|
_("Correct the date or switch from `{cur_mode}' to `{text_mode}'"
|
||||||
|
).format(
|
||||||
|
cur_mode = MOD_TEXT[self.type_box.get_active()][1],
|
||||||
|
text_mode = MOD_TEXT[-1][1]))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def build_menu_names(self, obj):
|
def build_menu_names(self, obj):
|
||||||
|
Loading…
Reference in New Issue
Block a user