changeset 77187055d3c7 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=77187055d3c7
description:
        Populate contextual menu synchronously

        Recent version of GTK does not support anymore filling the contextual 
menu
        asynchronously.

        issue8286
        review265361002
diffstat:

 tryton/common/popup_menu.py                           |  11 +++++------
 tryton/gui/window/view_form/view/form_gtk/many2one.py |   6 +++---
 tryton/gui/window/view_form/view/list.py              |  14 ++++++--------
 3 files changed, 14 insertions(+), 17 deletions(-)

diffs (80 lines):

diff -r 79db10570325 -r 77187055d3c7 tryton/common/popup_menu.py
--- a/tryton/common/popup_menu.py       Thu May 02 12:54:19 2019 +0200
+++ b/tryton/common/popup_menu.py       Fri May 03 09:12:03 2019 +0200
@@ -94,11 +94,11 @@
     action_menu.append(note_item)
     note_item.connect('activate', note)
 
-    def set_toolbar(toolbar):
-        try:
-            toolbar = toolbar()
-        except RPCException:
-            return
+    try:
+        toolbar = RPCExecute('model', model, 'view_toolbar_get')
+    except RPCException:
+        pass
+    else:
         for atype, icon, label, flavor in (
                 ('action', 'tryton-launch', _('Actions...'), None),
                 ('relate', 'tryton-link', _('Relate...'), None),
@@ -125,5 +125,4 @@
                     action['email_print'] = True
                 item.connect('activate', activate, action, atype)
             menu.show_all()
-    RPCExecute('model', model, 'view_toolbar_get', callback=set_toolbar)
     menu.show_all()
diff -r 79db10570325 -r 77187055d3c7 
tryton/gui/window/view_form/view/form_gtk/many2one.py
--- a/tryton/gui/window/view_form/view/form_gtk/many2one.py     Thu May 02 
12:54:19 2019 +0200
+++ b/tryton/gui/window/view_form/view/form_gtk/many2one.py     Fri May 03 
09:12:03 2019 +0200
@@ -318,9 +318,9 @@
     def _populate_popup(self, widget, menu):
         value = self.field.get(self.record)
         if self.has_target(value):
-            # Delay filling of popup as it can take time
-            GLib.idle_add(populate, menu, self.get_model(),
-                self.id_from_value(value), '', self.field)
+            populate(
+                menu, self.get_model(), self.id_from_value(value),
+                '', self.field)
         return True
 
     def _set_completion(self):
diff -r 79db10570325 -r 77187055d3c7 tryton/gui/window/view_form/view/list.py
--- a/tryton/gui/window/view_form/view/list.py  Thu May 02 12:54:19 2019 +0200
+++ b/tryton/gui/window/view_form/view/list.py  Fri May 03 09:12:03 2019 +0200
@@ -823,11 +823,6 @@
                 paste_item = Gtk.MenuItem(label=_('Paste'))
                 paste_item.connect('activate', lambda x: self.on_paste())
                 menu.append(paste_item)
-            menu.show_all()
-            if hasattr(menu, 'popup_at_pointer'):
-                menu.popup_at_pointer(event)
-            else:
-                menu.popup(None, None, None, event.button, event.time)
 
             def pop(menu, group, record):
                 # Don't activate actions if parent is modified
@@ -858,7 +853,6 @@
                     populate(
                         menu, model, record_id, title=label, field=field,
                         context=context)
-                menu.show_all()
 
             selection = treeview.get_selection()
             if selection.count_selected_rows() == 1:
@@ -868,8 +862,12 @@
                 elif selection.get_mode() == Gtk.SelectionMode.MULTIPLE:
                     model = selection.get_selected_rows()[0]
                 record = model.get_value(model.get_iter(path), 0)
-                # Delay filling of popup as it can take time
-                GLib.idle_add(pop, menu, group, record)
+                pop(menu, group, record)
+            menu.show_all()
+            if hasattr(menu, 'popup_at_pointer'):
+                menu.popup_at_pointer(event)
+            else:
+                menu.popup(None, None, None, event.button, event.time)
             return True  # Don't change the selection
         elif event.button == 2:
             with Window(allow_similar=True):

Reply via email to