Mercurial > libervia-backend
comparison frontends/src/wix/main_window.py @ 987:3a96920c07b7
core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 03 Apr 2014 16:10:44 +0200 |
parents | 01342bfe9f41 |
children | 5a6354ff468c |
comparison
equal
deleted
inserted
replaced
986:224cafc67324 | 987:3a96920c07b7 |
---|---|
35 idCONNECT,\ | 35 idCONNECT,\ |
36 idDISCONNECT,\ | 36 idDISCONNECT,\ |
37 idEXIT,\ | 37 idEXIT,\ |
38 idABOUT,\ | 38 idABOUT,\ |
39 idPARAM,\ | 39 idPARAM,\ |
40 idADD_CONTACT,\ | |
41 idREMOVE_CONTACT,\ | |
42 idSHOW_PROFILE,\ | 40 idSHOW_PROFILE,\ |
43 idJOIN_ROOM,\ | 41 idJOIN_ROOM,\ |
44 = range(9) | 42 = range(7) |
45 | 43 |
46 class ChatList(QuickChatList): | 44 class ChatList(QuickChatList): |
47 """This class manage the list of chat windows""" | 45 """This class manage the list of chat windows""" |
48 | 46 |
49 def createChat(self, target): | 47 def createChat(self, target): |
122 connectMenu.Append(idPARAM,_("&Parameters"),_(" Configure the program")) | 120 connectMenu.Append(idPARAM,_("&Parameters"),_(" Configure the program")) |
123 connectMenu.AppendSeparator() | 121 connectMenu.AppendSeparator() |
124 connectMenu.Append(idABOUT, _("A&bout"), _(" About %s") % Const.APP_NAME) | 122 connectMenu.Append(idABOUT, _("A&bout"), _(" About %s") % Const.APP_NAME) |
125 connectMenu.Append(idEXIT,_("E&xit"),_(" Terminate the program")) | 123 connectMenu.Append(idEXIT,_("E&xit"),_(" Terminate the program")) |
126 contactMenu = wx.Menu() | 124 contactMenu = wx.Menu() |
127 contactMenu.Append(idADD_CONTACT, _("&Add contact"),_(" Add a contact to your list")) | |
128 contactMenu.Append(idREMOVE_CONTACT, _("&Remove contact"),_(" Remove the selected contact from your list")) | |
129 contactMenu.AppendSeparator() | |
130 contactMenu.Append(idSHOW_PROFILE, _("&Show profile"), _(" Show contact's profile")) | |
131 communicationMenu = wx.Menu() | 125 communicationMenu = wx.Menu() |
132 communicationMenu.Append(idJOIN_ROOM, _("&Join Room"),_(" Join a Multi-User Chat room")) | 126 communicationMenu.Append(idJOIN_ROOM, _("&Join Room"),_(" Join a Multi-User Chat room")) |
133 self.menuBar = wx.MenuBar() | 127 self.menuBar = wx.MenuBar() |
134 self.menuBar.Append(connectMenu,_("&General")) | 128 self.menuBar.Append(connectMenu,_("&General")) |
135 self.menuBar.Append(contactMenu,_("&Contacts")) | 129 self.menuBar.Append(contactMenu,_("&Contacts")) |
161 def event_answer(e, id_=id_): | 155 def event_answer(e, id_=id_): |
162 self.launchAction(id_, None, profile_key = self.profile) | 156 self.launchAction(id_, None, profile_key = self.profile) |
163 | 157 |
164 wx.EVT_MENU(self, item_id, event_answer) | 158 wx.EVT_MENU(self, item_id, event_answer) |
165 | 159 |
160 # menu items that should be displayed after the automatically added ones | |
161 contactMenu.AppendSeparator() | |
162 contactMenu.Append(idSHOW_PROFILE, _("&Show profile"), _(" Show contact's profile")) | |
166 | 163 |
167 #events | 164 #events |
168 wx.EVT_MENU(self, idCONNECT, self.onConnectRequest) | 165 wx.EVT_MENU(self, idCONNECT, self.onConnectRequest) |
169 wx.EVT_MENU(self, idDISCONNECT, self.onDisconnectRequest) | 166 wx.EVT_MENU(self, idDISCONNECT, self.onDisconnectRequest) |
170 wx.EVT_MENU(self, idPARAM, self.onParam) | 167 wx.EVT_MENU(self, idPARAM, self.onParam) |
171 wx.EVT_MENU(self, idABOUT, self.onAbout) | 168 wx.EVT_MENU(self, idABOUT, self.onAbout) |
172 wx.EVT_MENU(self, idEXIT, self.onExit) | 169 wx.EVT_MENU(self, idEXIT, self.onExit) |
173 wx.EVT_MENU(self, idADD_CONTACT, self.onAddContact) | |
174 wx.EVT_MENU(self, idREMOVE_CONTACT, self.onRemoveContact) | |
175 wx.EVT_MENU(self, idSHOW_PROFILE, self.onShowProfile) | 170 wx.EVT_MENU(self, idSHOW_PROFILE, self.onShowProfile) |
176 wx.EVT_MENU(self, idJOIN_ROOM, self.onJoinRoom) | 171 wx.EVT_MENU(self, idJOIN_ROOM, self.onJoinRoom) |
177 | 172 |
178 def newMessage(self, from_jid, to_jid, msg, _type, extra, profile): | 173 def newMessage(self, from_jid, to_jid, msg, _type, extra, profile): |
179 QuickApp.newMessage(self, from_jid, to_jid, msg, _type, extra, profile) | 174 QuickApp.newMessage(self, from_jid, to_jid, msg, _type, extra, profile) |
432 wx.AboutBox(about) | 427 wx.AboutBox(about) |
433 | 428 |
434 def onExit(self, e): | 429 def onExit(self, e): |
435 self.Close() | 430 self.Close() |
436 | 431 |
437 def onAddContact(self, e): | |
438 debug(_("Add contact request")) | |
439 dlg = wx.TextEntryDialog( | |
440 self, _('Please enter new contact JID'), | |
441 _('Adding a contact'), _('name@server.tld')) | |
442 | |
443 if dlg.ShowModal() == wx.ID_OK: | |
444 jid=JID(dlg.GetValue()) | |
445 if jid.is_valid(): | |
446 self.bridge.addContact(jid.bare, profile_key=self.profile) | |
447 else: | |
448 error (_("'%s' is an invalid JID !"), jid) | |
449 #TODO: notice the user | |
450 | |
451 dlg.Destroy() | |
452 | |
453 def onRemoveContact(self, e): | |
454 debug(_("Remove contact request")) | |
455 target = self.contact_list.getSelection() | |
456 if not target: | |
457 dlg = wx.MessageDialog(self, _("You haven't selected any contact !"), | |
458 _('Error'), | |
459 wx.OK | wx.ICON_ERROR | |
460 ) | |
461 dlg.ShowModal() | |
462 dlg.Destroy() | |
463 return | |
464 | |
465 dlg = wx.MessageDialog(self, _("Are you sure you want to delete %s from your roster list ?") % target.bare, | |
466 _('Contact suppression'), | |
467 wx.YES_NO | wx.ICON_QUESTION | |
468 ) | |
469 | |
470 if dlg.ShowModal() == wx.ID_YES: | |
471 info(_("Unsubscribing %s presence"), target.bare) | |
472 self.bridge.delContact(target.bare, profile_key=self.profile) | |
473 | |
474 dlg.Destroy() | |
475 | |
476 def onShowProfile(self, e): | 432 def onShowProfile(self, e): |
477 debug(_("Show contact's profile request")) | 433 debug(_("Show contact's profile request")) |
478 target = self.contact_list.getSelection() | 434 target = self.contact_list.getSelection() |
479 if not target: | 435 if not target: |
480 dlg = wx.MessageDialog(self, _("You haven't selected any contact !"), | 436 dlg = wx.MessageDialog(self, _("You haven't selected any contact !"), |