From 3b576e29d2ceda0d70f36878fe92d27823cc049d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 29 Sep 2018 20:38:03 +0200 Subject: [PATCH] Toggle window hide on time popup-show This prevent the search window to be hidden when the time drop down is opened. issue7747 review56411002 --- .../window/view_form/view/screen_container.py | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tryton/gui/window/view_form/view/screen_container.py b/tryton/gui/window/view_form/view/screen_container.py index bdd4bba322..06daf90b3a 100644 --- a/tryton/gui/window/view_form/view/screen_container.py +++ b/tryton/gui/window/view_form/view/screen_container.py @@ -47,9 +47,21 @@ class Dates(gtk.HBox): elif to: return '<=%s' % quote(to) + @property + def _widgets(self): + return [self.from_, self.to] + def connect_activate(self, callback): - self.from_.connect('activate', callback) - self.to.connect('activate', callback) + for widget in self._widgets: + if isinstance(widget, Date): + widget.connect('activate', callback) + elif isinstance(widget, Time): + widget.get_child().connect('activate', callback) + + def connect_combo(self, callback): + for widget in self._widgets: + if isinstance(widget, Time): + widget.connect('notify::popup-shown', callback) def set_values(self, from_, to): self.from_.props.value = from_ @@ -66,10 +78,6 @@ class Times(Dates): if value: return datetime.time.strftime(value, widget.props.format) - def connect_activate(self, callback): - for widget in self.from_.get_children() + self.to.get_children(): - widget.connect('activate', callback) - class DateTimes(Dates): @@ -86,12 +94,9 @@ class DateTimes(Dates): return common.datetime_strftime(value, widget.props.date_format + ' ' + widget.props.time_format) - def connect_activate(self, callback): - for widget in self.from_.get_children() + self.to.get_children(): - if isinstance(widget, Date): - widget.connect('activate', callback) - elif isinstance(widget, Time): - widget.get_child().connect('activate', callback) + @property + def _widgets(self): + return self.from_.get_children() + self.to.get_children() class Selection(gtk.ScrolledWindow): @@ -590,6 +595,7 @@ class ScreenContainer(object): elif field['type'] == 'datetime': entry = DateTimes(date_format, time_format) entry.connect_activate(lambda *a: search()) + entry.connect_combo(toggle_window_hide) else: entry = gtk.Entry() entry.connect('activate', lambda *a: search())