changeset e8a99916f407 in tryton:5.8
details: https://hg.tryton.org/tryton?cmd=changeset&node=e8a99916f407
description:
        Use changed event to trigger focus out in Selection widget of Dict

        issue10856
        review389101002
        (grafted from 795501d0c8d174bc7c0c4baf4449fae150c33b46)
diffstat:

 tryton/gui/window/view_form/view/form_gtk/dictionary.py |  20 +++++++++++-----
 1 files changed, 13 insertions(+), 7 deletions(-)

diffs (41 lines):

diff -r aefd45038be4 -r e8a99916f407 
tryton/gui/window/view_form/view/form_gtk/dictionary.py
--- a/tryton/gui/window/view_form/view/form_gtk/dictionary.py   Fri Oct 15 
17:13:58 2021 +0200
+++ b/tryton/gui/window/view_form/view/form_gtk/dictionary.py   Tue Oct 19 
00:23:30 2021 +0200
@@ -99,13 +99,11 @@
         # customizing entry
         child = widget.get_child()
         child.props.activates_default = True
-        child.connect('changed', self.parent_widget.send_modified)
+        child.connect('changed', self._changed)
         child.connect('focus-out-event',
             lambda w, e: self.parent_widget._focus_out())
         child.connect('activate',
             lambda w: self.parent_widget._focus_out())
-        widget.connect('notify::active',
-            lambda w, e: self.parent_widget._focus_out())
         widget.connect(
             'scroll-event',
             lambda c, e: c.stop_emission_by_name('scroll-event'))
@@ -156,10 +154,18 @@
             if selection[1] == value:
                 active = i
                 break
-        self.widget.set_active(active)
-        if active == -1:
-            # When setting no item GTK doesn't clear the entry
-            self.widget.get_child().set_text('')
+        child = self.widget.get_child()
+        child.handler_block_by_func(self._changed)
+        try:
+            self.widget.set_active(active)
+            if active == -1:
+                # When setting no item GTK doesn't clear the entry
+                child.set_text('')
+        finally:
+            child.handler_unblock_by_func(self._changed)
+
+    def _changed(self, selection):
+        GLib.idle_add(self.parent_widget._focus_out)
 
     def set_readonly(self, readonly):
         self.widget.set_sensitive(not readonly)

Reply via email to