comparison frontends/primitivus/primitivus @ 153:f197b52796ee

Primitivus: begining of management for actionResult
author Goffi <goffi@goffi.org>
date Sat, 31 Jul 2010 00:34:05 +0800
parents c8b231abfe96
children 13888bdb72b6
comparison
equal deleted inserted replaced
152:b1f1955d96b3 153:f197b52796ee
35 from statusbar import StatusBar 35 from statusbar import StatusBar
36 from chat import Chat 36 from chat import Chat
37 from tools.jid import JID""" 37 from tools.jid import JID"""
38 import logging 38 import logging
39 from logging import debug, info, error 39 from logging import debug, info, error
40 #import locale
41 import sys, os 40 import sys, os
42 from tools.jid import JID 41 from tools.jid import JID
43 #from curses import ascii 42 from xmlui import XMLUI
44 #import locale
45 #from signal import signal, SIGWINCH
46 #import fcntl
47 #import struct
48 #import termios
49 #from boxsizer import BoxSizer
50 43
51 44
52 ### logging configuration FIXME: put this elsewhere ### 45 ### logging configuration FIXME: put this elsewhere ###
53 logging.basicConfig(level=logging.CRITICAL, #TODO: configure it to put messages in a log file 46 logging.basicConfig(level=logging.CRITICAL, #TODO: configure it to put messages in a log file
54 format='%(message)s') 47 format='%(message)s')
123 self.loop.set_alarm_in(0,lambda a,b: self.postInit()) 116 self.loop.set_alarm_in(0,lambda a,b: self.postInit())
124 self.loop.run() 117 self.loop.run()
125 118
126 def inputFilter(self, input, raw): 119 def inputFilter(self, input, raw):
127 for i in input: 120 for i in input:
128 if i.__class__==tuple: 121 if isinstance(i,tuple):
129 if i[0] == 'mouse press': 122 if i[0] == 'mouse press':
130 if i[1] == 4: #Mouse wheel up 123 if i[1] == 4: #Mouse wheel up
131 input[input.index(i)] = 'up' 124 input[input.index(i)] = 'up'
132 if i[1] == 5: #Mouse wheel down 125 if i[1] == 5: #Mouse wheel down
133 input[input.index(i)] = 'down' 126 input[input.index(i)] = 'down'
244 QuickApp.newMessage(self, from_jid, msg, type, to_jid, profile) 237 QuickApp.newMessage(self, from_jid, msg, type, to_jid, profile)
245 sender = JID(from_jid) 238 sender = JID(from_jid)
246 if JID(self.contactList.selected).short != sender.short: 239 if JID(self.contactList.selected).short != sender.short:
247 self.contactList.putAlert(sender) 240 self.contactList.putAlert(sender)
248 241
242 def actionResult(self, type, id, data):
243 if not id in self.current_action_ids:
244 debug (_('unknown id, ignoring'))
245 return
246 if type == "SUPPRESS":
247 self.current_action_ids.remove(id)
248 elif type == "XMLUI":
249 self.current_action_ids.remove(id)
250 debug (_("XML user interface received"))
251 misc = {}
252 #FIXME FIXME FIXME: must clean all this crap !
253 title = _('Form')
254 if data['type'] == _('registration'):
255 title = _('Registration')
256 misc['target'] = data['target']
257 misc['action_back'] = self.bridge.gatewayRegister
258 ui = XMLUI(self, title=title, xml_data = data['xml'], misc = misc)
259 assert(len(self.center_part.widget_list)==2)
260 self.center_part.widget_list[1] = ui
261 self.menu_roller.removeMenu(_('Chat menu'))
262 self.contactList.selected = None
263 self.redraw()
264 else:
265 error (_("FIXME FIXME FIXME: type [%s] not implemented") % type)
266 raise NotImplementedError
267
268 ##DIALOGS CALLBACKS##
249 def onJoinRoom(self, button, edit): 269 def onJoinRoom(self, button, edit):
250 self.removePopUp() 270 self.removePopUp()
251 room_jid = JID(edit.get_edit_text()) 271 room_jid = JID(edit.get_edit_text())
252 if room_jid.is_valid(): 272 if room_jid.is_valid():
253 self.bridge.joinMUC(room_jid.domain, room_jid.node, self.profiles[self.profile]['whoami'].node, self.profile) 273 self.bridge.joinMUC(room_jid.domain, room_jid.node, self.profiles[self.profile]['whoami'].node, self.profile)
296 self.showPopUp(custom_widgets.Alert(_("Error"), _("You have not selected any contact to delete !"), ok_cb=self.removePopUp)) 316 self.showPopUp(custom_widgets.Alert(_("Error"), _("You have not selected any contact to delete !"), ok_cb=self.removePopUp))
297 else: 317 else:
298 pop_up_widget = custom_widgets.ConfirmDialog(_("Are you sure you want to delete the contact [%s] ?" % contact), yes_cb=self.onRemoveContact, no_cb=self.removePopUp) 318 pop_up_widget = custom_widgets.ConfirmDialog(_("Are you sure you want to delete the contact [%s] ?" % contact), yes_cb=self.onRemoveContact, no_cb=self.removePopUp)
299 self.showPopUp(pop_up_widget) 319 self.showPopUp(pop_up_widget)
300 320
301
302
303
304 def onAboutRequest(self, menu): 321 def onAboutRequest(self, menu):
305 self.showPopUp(custom_widgets.Alert(_("About"), const_APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp)) 322 self.showPopUp(custom_widgets.Alert(_("About"), const_APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp))
306 323
307 324
308 sat = PrimitivusApp() 325 sat = PrimitivusApp()