From 91b8091d5d6d212994204aa66cabf26ffeb85e11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 30 Jan 2019 09:33:51 +0100 Subject: [PATCH] Connect dict widgets to the right activate callback On activate of Entry and on toggle CheckButton, the parent must be activate. The toggled handler must also be blocked when activate the CheckButton by code to avoid unnecessary callbacks. issue7987 review49701002 --- tryton/gui/window/view_form/view/form_gtk/checkbox.py | 6 +++++- .../gui/window/view_form/view/form_gtk/dictionary.py | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tryton/gui/window/view_form/view/form_gtk/checkbox.py b/tryton/gui/window/view_form/view/form_gtk/checkbox.py index 925b4d8e86..78bba3399d 100644 --- a/tryton/gui/window/view_form/view/form_gtk/checkbox.py +++ b/tryton/gui/window/view_form/view/form_gtk/checkbox.py @@ -28,4 +28,8 @@ class CheckBox(Widget): if not self.field: self.widget.set_active(False) return False - self.widget.set_active(bool(self.field.get(self.record))) + self.widget.handler_block_by_func(self.sig_activate) + try: + self.widget.set_active(bool(self.field.get(self.record))) + finally: + self.widget.handler_unblock_by_func(self.sig_activate) diff --git a/tryton/gui/window/view_form/view/form_gtk/dictionary.py b/tryton/gui/window/view_form/view/form_gtk/dictionary.py index 5419139a11..a45f985e54 100644 --- a/tryton/gui/window/view_form/view/form_gtk/dictionary.py +++ b/tryton/gui/window/view_form/view/form_gtk/dictionary.py @@ -41,6 +41,8 @@ class DictEntry(object): widget.connect('key-press-event', self.parent_widget.send_modified) widget.connect('focus-out-event', lambda w, e: self.parent_widget._focus_out()) + widget.props.activates_default = True + widget.connect('activate', self.parent_widget.sig_activate) return widget def modified(self, value): @@ -61,7 +63,7 @@ class DictBooleanEntry(DictEntry): def create_widget(self): widget = gtk.CheckButton() - widget.connect('toggled', self.parent_widget.send_modified) + widget.connect('toggled', self.parent_widget.sig_activate) widget.connect('focus-out-event', lambda w, e: self.parent_widget._focus_out()) return widget @@ -70,7 +72,12 @@ class DictBooleanEntry(DictEntry): return self.widget.props.active def set_value(self, value): - self.widget.props.active = bool(value) + self.widget.handler_block_by_func(self.parent_widget.sig_activate) + try: + self.widget.props.active = bool(value) + finally: + self.widget.handler_unblock_by_func( + self.parent_widget.sig_activate) def set_readonly(self, readonly): self.widget.set_sensitive(not readonly)