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
2 changed files with 214 additions and 12 deletions

View file

@ -109,6 +109,18 @@ class DBusBridgeFrontend(BridgeFrontend):
def confirmationAnswer(self, id, accepted, data):
return self.db_req_iface.confirmationAnswer(id, accepted, data)
def getProgress(self, id):
return self.db_req_iface.getProgress(id)
def getMenus(self):
return self.db_req_iface.getMenus()
def getMenuHelp(self, category, name, type="NORMAL"):
return self.db_req_iface.getMenuHelp(category, name, type)
def callMenu(self, category, name, type="NORMAL", profile_key='@DEFAULT@'):
return self.db_req_iface.callMenu(category, name, type, profile_key)
#methods from plugins
def getRoomJoined(self, profile_key='@DEFAULT@'):
return self.db_comm_iface.getRoomJoined(profile_key)
@ -151,8 +163,7 @@ class DBusBridgeFrontend(BridgeFrontend):
def gatewayRegister(self, action, target, data):
if data == None:
data = [('', '')] #XXX: we have to this awful hack because python dbus need to guess the signature
data = [('', '')] #XXX: we have to do this awful hack because python dbus need to guess the signature
return self.db_req_iface.gatewayRegister(action, target, data)
def getProgress(self, id):
return self.db_req_iface.getProgress(id)

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)