added action cb mechanism for buttons. Tested with a temporary new user registration button.
This commit is contained in:
parent
bd70d6d7b6
commit
a103e8b41b
6 changed files with 226 additions and 66 deletions
|
|
@ -201,6 +201,9 @@ class JP():
|
|||
#we just accept one file
|
||||
self.loop.quit()
|
||||
|
||||
def actionResult(self, type, id, data):
|
||||
#FIXME
|
||||
info ("FIXME: actionResult not implemented")
|
||||
|
||||
def wait_file(self):
|
||||
"""Wait for a file and write it on local dir"""
|
||||
|
|
|
|||
|
|
@ -40,12 +40,14 @@ class QuickApp():
|
|||
self.bridge.register("paramUpdate", self.paramUpdate)
|
||||
self.bridge.register("contactDeleted", self.contactDeleted)
|
||||
self.bridge.register("askConfirmation", self.askConfirmation, "request")
|
||||
self.bridge.register("actionResult", self.actionResult, "request")
|
||||
|
||||
###now we get the essential params###
|
||||
self.whoami=JID(self.bridge.getParamV("JabberID","Connection"))
|
||||
self.watched=self.bridge.getParamV("Watched", "Misc").split() #TODO: put this in a plugin
|
||||
self.whoami=JID(self.bridge.getParamA("JabberID","Connection"))
|
||||
self.watched=self.bridge.getParamA("Watched", "Misc").split() #TODO: put this in a plugin
|
||||
|
||||
## misc ##
|
||||
self.current_action_ids = set()
|
||||
self.onlineContact = set() #FIXME: temporary
|
||||
|
||||
if self.bridge.isConnected():
|
||||
|
|
@ -156,3 +158,6 @@ class QuickApp():
|
|||
|
||||
def askConfirmation(self, type, id, data):
|
||||
raise NotImplementedError
|
||||
|
||||
def actionResult(self, type, id, data):
|
||||
raise NotImplementedError
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ class DBusBridgeFrontend(BridgeFrontend):
|
|||
def setParam(self, name, value, category):
|
||||
return self.db_comm_iface.setParam(name, value, category)
|
||||
|
||||
def getParamV(self, name, category):
|
||||
return self.db_comm_iface.getParamV(name, category)
|
||||
def getParamA(self, name, category):
|
||||
return self.db_comm_iface.getParamA(name, category)
|
||||
|
||||
def getParams(self):
|
||||
return self.db_comm_iface.getParams()
|
||||
|
|
@ -88,6 +88,9 @@ class DBusBridgeFrontend(BridgeFrontend):
|
|||
def isConnected(self):
|
||||
return self.db_comm_iface.isConnected()
|
||||
|
||||
def launchAction(self, type, data):
|
||||
return self.db_req_iface.launchAction(type, data)
|
||||
|
||||
def confirmationAnswer(self, id, accepted, data):
|
||||
return self.db_req_iface.confirmationAnswer(id, accepted, data)
|
||||
|
||||
|
|
|
|||
|
|
@ -273,6 +273,14 @@ class SortilegeApp(QuickApp):
|
|||
self.editBar.replace_cur()
|
||||
curses.doupdate()
|
||||
|
||||
def askConfirmation(self, type, id, data):
|
||||
#FIXME
|
||||
info ("FIXME: askConfirmation not implemented")
|
||||
|
||||
def actionResult(self, type, id, data):
|
||||
#FIXME
|
||||
info ("FIXME: actionResult not implemented")
|
||||
|
||||
def newMessage(self, from_jid, msg, type, to_jid):
|
||||
QuickApp.newMessage(self, from_jid, msg, type, to_jid)
|
||||
sender=JID(from_jid)
|
||||
|
|
|
|||
|
|
@ -284,11 +284,46 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
answer = wx.ID_NO
|
||||
if answer==wx.ID_NO:
|
||||
self.bridge.confirmationAnswer(id, False, answer_data)
|
||||
|
||||
dlg.Destroy()
|
||||
|
||||
elif type == "YES/NO":
|
||||
debug ("Yes/No confirmation asked")
|
||||
dlg = wx.MessageDialog(self, data["message"],
|
||||
'Confirmation',
|
||||
wx.YES_NO | wx.ICON_QUESTION
|
||||
)
|
||||
answer=dlg.ShowModal()
|
||||
if answer==wx.ID_YES:
|
||||
self.bridge.confirmationAnswer(id, True, {})
|
||||
if answer==wx.ID_NO:
|
||||
self.bridge.confirmationAnswer(id, False, {})
|
||||
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
|
||||
def actionResult(self, type, id, data):
|
||||
debug ("actionResult: type = [%s] id = [%s] data =[%s]" % (type, id, data))
|
||||
if type == "SUPPRESS":
|
||||
self.current_action_ids.remove(id)
|
||||
elif type == "SUCCESS":
|
||||
dlg = wx.MessageDialog(self, data["message"],
|
||||
'Success',
|
||||
wx.OK | wx.ICON_INFORMATION
|
||||
)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
elif type == "ERROR":
|
||||
dlg = wx.MessageDialog(self, data["message"],
|
||||
'Error',
|
||||
wx.OK | wx.ICON_ERROR
|
||||
)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
else:
|
||||
error ("FIXME FIXME FIXME: type [%s] not implemented" % type)
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
|
||||
def progressCB(self, id, title, message):
|
||||
data = self.bridge.getProgress(id)
|
||||
|
|
@ -340,7 +375,7 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
|
||||
def onParam(self, e):
|
||||
debug("Param request")
|
||||
param=Param(self.bridge)
|
||||
param=Param(self)
|
||||
|
||||
def onExit(self, e):
|
||||
self.Close()
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ from logging import debug, info, error
|
|||
|
||||
|
||||
class Param(wx.Frame):
|
||||
def __init__(self, bridge, title="Configuration"):
|
||||
def __init__(self, host, title="Configuration"):
|
||||
super(Param, self).__init__(None, title=title)
|
||||
|
||||
self.bridge = bridge
|
||||
self.host = host
|
||||
|
||||
self.modified={} # dict of modified data (i.e. what we have to save)
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ class Param(wx.Frame):
|
|||
|
||||
self.MakeModal()
|
||||
|
||||
for category in self.bridge.getParamsCategories():
|
||||
for category in self.host.bridge.getParamsCategories():
|
||||
self.addCategory(category)
|
||||
|
||||
self.Show()
|
||||
|
|
@ -55,7 +55,7 @@ class Param(wx.Frame):
|
|||
panel=wx.Panel(self.notebook)
|
||||
panel.sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
cat_dom = minidom.parseString(self.bridge.getParamsForCategory(category))
|
||||
cat_dom = minidom.parseString(self.host.bridge.getParamsForCategory(category))
|
||||
|
||||
for param in cat_dom.documentElement.getElementsByTagName("param"):
|
||||
name = param.getAttribute("name")
|
||||
|
|
@ -96,8 +96,12 @@ class Param(wx.Frame):
|
|||
|
||||
def onButtonClicked(self, event):
|
||||
"""Called when a paramated is modified"""
|
||||
print "Button Clicked (%s/%s)" % event.GetEventObject().param_id#TODO: gof: appeler callback
|
||||
#self.modified[event.GetEventObject().param_id]=event.GetString()
|
||||
print "Button Clicked (%s/%s)" % event.GetEventObject().param_id
|
||||
name, category = event.GetEventObject().param_id
|
||||
data = {"name":name, "category":category}
|
||||
id = self.host.bridge.launchAction("button", data)
|
||||
self.host.current_action_ids.add(id)
|
||||
print "action id:",id
|
||||
event.Skip()
|
||||
|
||||
def onClose(self, event):
|
||||
|
|
@ -105,7 +109,7 @@ class Param(wx.Frame):
|
|||
debug("close")
|
||||
#now we save the modifier params
|
||||
for param in self.modified:
|
||||
self.bridge.setParam(param[0], self.modified[param], param[1])
|
||||
self.host.bridge.setParam(param[0], self.modified[param], param[1])
|
||||
|
||||
self.MakeModal(False)
|
||||
event.Skip()
|
||||
|
|
|
|||
Loading…
Reference in a new issue