diff frontends/src/wix/main_window.py @ 755:e3ad48a2aab2

core, frontends: callMenu is now async and don't use callback_id anymore
author Goffi <goffi@goffi.org>
date Tue, 24 Dec 2013 15:18:31 +0100
parents 378af36155c2
children 93bd868b8fb6
line wrap: on
line diff
--- a/frontends/src/wix/main_window.py	Tue Dec 24 01:31:18 2013 +0100
+++ b/frontends/src/wix/main_window.py	Tue Dec 24 15:18:31 2013 +0100
@@ -115,6 +115,17 @@
             self.menuBar.EnableTop(i, True)
         super(MainWindow, self).plug_profile(profile_key)
 
+    def _dynamicMenuCb(self, xmlui):
+        XMLUI(self, xml_data = xmlui)
+
+    def _dynamicMenuEb(self, failure):
+        dlg = wx.MessageDialog(self, _(u"Error while calling menu"),
+                               _('Error'),
+                               wx.OK | wx.ICON_ERROR
+                              )
+        dlg.ShowModal()
+        dlg.Destroy()
+
     def createMenus(self):
         info(_("Creating menus"))
         connectMenu = wx.Menu()
@@ -142,8 +153,8 @@
         #FIXME: do this in a more generic way (in quickapp)
         add_menus = self.bridge.getMenus()
         for menu in add_menus:
-            category,item,type = menu
-            assert(type=="NORMAL") #TODO: manage other types
+            type_,category,name = menu
+            assert(type_=="NORMAL") #TODO: manage other types
             menu_idx = self.menuBar.FindMenu(category)
             current_menu = None
             if menu_idx == wx.NOT_FOUND:
@@ -154,12 +165,11 @@
                 current_menu = self.menuBar.GetMenu(menu_idx)
             assert(current_menu != None)
             item_id = wx.NewId()
-            help_string = self.bridge.getMenuHelp(category, item, type)
-            current_menu.Append(item_id, item, help = help_string)
+            help_string = self.bridge.getMenuHelp(category, name, type_)
+            current_menu.Append(item_id, name, help = help_string)
             #now we register the event
             def event_answer(e):
-                id = self.bridge.callMenu(category, item, type, self.profile)
-                self.current_action_ids.add(id)
+                self.bridge.asyncCallMenu(category, name, Const.MENU_NORMAL, self.profile, callback=self._dynamicMenuCb, errback=self._dynamicMenuEb)
             wx.EVT_MENU(self, item_id, event_answer)