Mercurial > libervia-backend
comparison frontends/src/primitivus/primitivus @ 776:f89173f44850
frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 03 Jan 2014 21:25:07 +0100 |
parents | eac23b1aad90 |
children | 5642939d254e |
comparison
equal
deleted
inserted
replaced
775:ab66dac17d1f | 776:f89173f44850 |
---|---|
101 """Called when text is entered in the main edit bar""" | 101 """Called when text is entered in the main edit bar""" |
102 if self.mode == 'INSERTION': | 102 if self.mode == 'INSERTION': |
103 contact = self.app.contact_list.getContact() ###Based on the fact that there is currently only one contact selectableat once | 103 contact = self.app.contact_list.getContact() ###Based on the fact that there is currently only one contact selectableat once |
104 if contact: | 104 if contact: |
105 chat = self.app.chat_wins[contact] | 105 chat = self.app.chat_wins[contact] |
106 try: | 106 self.app.sendMessage(contact, |
107 self.app.sendMessage(contact, | |
108 editBar.get_edit_text(), | 107 editBar.get_edit_text(), |
109 mess_type = "groupchat" if chat.type == 'group' else "chat", | 108 mess_type = "groupchat" if chat.type == 'group' else "chat", |
110 profile_key=self.app.profile) | 109 errback=lambda failure: self.app.notify(_("Error while sending message (%s)") % unicode(failure)), |
111 except: # FIXME: bad global catch + sendMessage is now async | 110 profile_key=self.app.profile |
112 self.app.notify(_("Error while sending message")) | 111 ) |
113 editBar.set_edit_text('') | 112 editBar.set_edit_text('') |
114 elif self.mode == 'COMMAND': | 113 elif self.mode == 'COMMAND': |
115 self.commandHandler() | 114 self.commandHandler() |
116 | 115 |
117 def commandHandler(self): | 116 def commandHandler(self): |
344 self.notBar.addPopUp(pop_up_widget) | 343 self.notBar.addPopUp(pop_up_widget) |
345 | 344 |
346 def notify(self, message): | 345 def notify(self, message): |
347 """"Notify message to user via notification bar""" | 346 """"Notify message to user via notification bar""" |
348 self.notBar.addMessage(message) | 347 self.notBar.addMessage(message) |
348 self.redraw() | |
349 | 349 |
350 def addWindow(self, widget): | 350 def addWindow(self, widget): |
351 """Display a window if possible, | 351 """Display a window if possible, |
352 else add it in the notification bar queue | 352 else add it in the notification bar queue |
353 @param widget: BoxWidget""" | 353 @param widget: BoxWidget""" |