Couchsurfing plugin: first draft

SàT core: adding additionnal menu method
bridge: new methods getMenus, getMenuHelp and callMenu
wix: new menu are added on startup
CS plugin: login on CS
This commit is contained in:
Goffi 2010-06-19 17:15:30 +08:00
commit f9bbbed6a0

View file

@ -76,9 +76,6 @@ class MainWindow(wx.Frame, QuickApp):
self.chat_wins=ChatList(self)
self.CreateStatusBar()
self.createMenus()
for i in range(self.menuBar.GetMenuCount()):
self.menuBar.EnableTop(i, False)
#ToolBar
self.tools=self.CreateToolBar()
@ -105,6 +102,11 @@ class MainWindow(wx.Frame, QuickApp):
QuickApp.__init__(self)
#self.plug_profile() #gof:
#menus
self.createMenus()
for i in range(self.menuBar.GetMenuCount()):
self.menuBar.EnableTop(i, False)
#profile panel
self.profile_pan = ProfileManager(self)
#self.profile_pan.Hide() #gof:
@ -149,6 +151,31 @@ class MainWindow(wx.Frame, QuickApp):
self.menuBar.Append(communicationMenu,_("&Communication"))
self.SetMenuBar(self.menuBar)
#additionals menus
#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
menu_idx = self.menuBar.FindMenu(category)
current_menu = None
if menu_idx == wx.NOT_FOUND:
#the menu is new, we create it
current_menu = wx.Menu()
self.menuBar.Append(current_menu, category)
else:
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)
#now we register the event
def event_answer(e):
id = self.bridge.callMenu(category, item, type)
self.current_action_ids.add(id)
wx.EVT_MENU(self, item_id, event_answer)
#events
wx.EVT_MENU(self, idCONNECT, self.onConnectRequest)
wx.EVT_MENU(self, idDISCONNECT, self.onDisconnectRequest)