core, frontends: callMenu is now async and don't use callback_id anymore
This commit is contained in:
parent
5723ee2ef2
commit
71c1def32a
1 changed files with 93 additions and 56 deletions
|
|
@ -281,8 +281,15 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
except AttributeError:
|
||||
return input
|
||||
|
||||
def _dynamicMenuCb(self, xmlui):
|
||||
misc = {}
|
||||
ui = XMLUI(self, xml_data = xmlui)
|
||||
ui.show('popup')
|
||||
|
||||
def __buildMenuRoller(self):
|
||||
def _dynamicMenuEb(self, failure):
|
||||
self.showDialog(_(u"Error while calling menu"), type="error")
|
||||
|
||||
def _buildMenuRoller(self):
|
||||
menu = sat_widgets.Menu(self.loop)
|
||||
general = _("General")
|
||||
menu.addMenu(general, _("Connect"), self.onConnectRequest)
|
||||
|
|
@ -301,29 +308,28 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
#FIXME: do this in a more generic way (in quickapp)
|
||||
add_menus = self.bridge.getMenus()
|
||||
def add_menu_cb(menu):
|
||||
category, item = menu
|
||||
id = self.bridge.callMenu(category, item, "NORMAL", self.profile)
|
||||
self.current_action_ids.add(id)
|
||||
category, name = menu
|
||||
self.bridge.asyncCallMenu(category, name, Const.MENU_NORMAL, self.profile, callback=self._dynamicMenuCb, errback=self._dynamicMenuEb)
|
||||
for new_menu in add_menus:
|
||||
category,item,type = new_menu
|
||||
assert(type=="NORMAL") #TODO: manage other types
|
||||
menu.addMenu(unicode(category), unicode(item), add_menu_cb)
|
||||
type_, category, name = new_menu
|
||||
assert(type_=="NORMAL") #TODO: manage other types
|
||||
menu.addMenu(unicode(category), unicode(name), add_menu_cb)
|
||||
|
||||
menu_roller = sat_widgets.MenuRoller([(_('Main menu'),menu)])
|
||||
return menu_roller
|
||||
|
||||
def __buildMainWidget(self):
|
||||
def _buildMainWidget(self):
|
||||
self.contact_list = ContactList(self, on_click=self.contactSelected, on_change=lambda w: self.redraw())
|
||||
#self.center_part = urwid.Columns([('weight',2,self.contact_list),('weight',8,Chat('',self))])
|
||||
self.center_part = urwid.Columns([('weight', 2, self.contact_list), ('weight', 8, urwid.Filler(urwid.Text('')))])
|
||||
|
||||
self.editBar = EditBar(self)
|
||||
self.menu_roller = self.__buildMenuRoller()
|
||||
self.menu_roller = self._buildMenuRoller()
|
||||
self.main_widget = sat_widgets.FocusFrame(self.center_part, header=self.menu_roller, footer=self.editBar, focus_part='footer')
|
||||
return self.main_widget
|
||||
|
||||
def plug_profile(self, profile_key='@DEFAULT@'):
|
||||
self.loop.widget = self.__buildMainWidget()
|
||||
self.loop.widget = self._buildMainWidget()
|
||||
self.redraw()
|
||||
QuickApp.plug_profile(self, profile_key)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue