core, frontends: unify the roster management UIs in sat/stdui/ui_contact_list.py

This commit is contained in:
souliane 2014-04-03 16:10:44 +02:00
commit e91a30729f
2 changed files with 278 additions and 83 deletions

View file

@ -290,9 +290,8 @@ class PrimitivusApp(QuickApp, InputHistory):
menu.addMenu(general, _("Parameters"), self.onParam)
menu.addMenu(general, _("About"), self.onAboutRequest)
menu.addMenu(general, _("Exit"), self.onExitRequest, 'ctrl x')
contact = _("Contact")
menu.addMenu(contact, _("Add contact"), self.onAddContactRequest)
menu.addMenu(contact, _("Remove contact"), self.onRemoveContactRequest)
contact = _("Contacts")
menu.addMenu(contact)
communication = _("Communication")
menu.addMenu(communication, _("Join room"), self.onJoinRoomRequest, 'meta j')
#additionals menus
@ -550,21 +549,6 @@ class PrimitivusApp(QuickApp, InputHistory):
error (message)
self.showPopUp(sat_widgets.Alert(_("Error"), message, ok_cb=self.removePopUp))
def onAddContact(self, button, edit):
self.removePopUp()
jid=JID(edit.get_edit_text())
if jid.is_valid():
self.bridge.addContact(jid.bare, profile_key=self.profile)
else:
message = _("'%s' is an invalid JID !") % jid
error (message)
self.showPopUp(sat_widgets.Alert(_("Error"), message, ok_cb=self.removePopUp))
def onRemoveContact(self, button):
self.removePopUp()
info(_("Unsubscribing %s presence"),self.contact_list.getContact())
self.bridge.delContact(self.contact_list.getContact(), profile_key=self.profile)
#MENU EVENTS#
def onConnectRequest(self, menu):
self.bridge.connect(self.profile)
@ -589,18 +573,6 @@ class PrimitivusApp(QuickApp, InputHistory):
pop_up_widget = sat_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt = 'room@muc_service.server.tld', cancel_cb=self.removePopUp, ok_cb=self.onJoinRoom)
self.showPopUp(pop_up_widget)
def onAddContactRequest(self, menu):
pop_up_widget = sat_widgets.InputDialog(_("Adding a contact"), _("Please enter new contact JID"), default_txt = 'name@server.tld', cancel_cb=self.removePopUp, ok_cb=self.onAddContact)
self.showPopUp(pop_up_widget)
def onRemoveContactRequest(self, menu):
contact = self.contact_list.getContact()
if not contact:
self.showPopUp(sat_widgets.Alert(_("Error"), _("You have not selected any contact to delete !"), ok_cb=self.removePopUp))
else:
pop_up_widget = sat_widgets.ConfirmDialog(_("Are you sure you want to delete the contact [%s] ?" % contact), yes_cb=self.onRemoveContact, no_cb=self.removePopUp)
self.showPopUp(pop_up_widget)
def onAboutRequest(self, menu):
self.showPopUp(sat_widgets.Alert(_("About"), Const.APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp))

View file

@ -37,11 +37,9 @@ idDISCONNECT,\
idEXIT,\
idABOUT,\
idPARAM,\
idADD_CONTACT,\
idREMOVE_CONTACT,\
idSHOW_PROFILE,\
idJOIN_ROOM,\
= range(9)
= range(7)
class ChatList(QuickChatList):
"""This class manage the list of chat windows"""
@ -124,10 +122,6 @@ class MainWindow(wx.Frame, QuickApp):
connectMenu.Append(idABOUT, _("A&bout"), _(" About %s") % Const.APP_NAME)
connectMenu.Append(idEXIT,_("E&xit"),_(" Terminate the program"))
contactMenu = wx.Menu()
contactMenu.Append(idADD_CONTACT, _("&Add contact"),_(" Add a contact to your list"))
contactMenu.Append(idREMOVE_CONTACT, _("&Remove contact"),_(" Remove the selected contact from your list"))
contactMenu.AppendSeparator()
contactMenu.Append(idSHOW_PROFILE, _("&Show profile"), _(" Show contact's profile"))
communicationMenu = wx.Menu()
communicationMenu.Append(idJOIN_ROOM, _("&Join Room"),_(" Join a Multi-User Chat room"))
self.menuBar = wx.MenuBar()
@ -163,6 +157,9 @@ class MainWindow(wx.Frame, QuickApp):
wx.EVT_MENU(self, item_id, event_answer)
# menu items that should be displayed after the automatically added ones
contactMenu.AppendSeparator()
contactMenu.Append(idSHOW_PROFILE, _("&Show profile"), _(" Show contact's profile"))
#events
wx.EVT_MENU(self, idCONNECT, self.onConnectRequest)
@ -170,8 +167,6 @@ class MainWindow(wx.Frame, QuickApp):
wx.EVT_MENU(self, idPARAM, self.onParam)
wx.EVT_MENU(self, idABOUT, self.onAbout)
wx.EVT_MENU(self, idEXIT, self.onExit)
wx.EVT_MENU(self, idADD_CONTACT, self.onAddContact)
wx.EVT_MENU(self, idREMOVE_CONTACT, self.onRemoveContact)
wx.EVT_MENU(self, idSHOW_PROFILE, self.onShowProfile)
wx.EVT_MENU(self, idJOIN_ROOM, self.onJoinRoom)
@ -434,45 +429,6 @@ class MainWindow(wx.Frame, QuickApp):
def onExit(self, e):
self.Close()
def onAddContact(self, e):
debug(_("Add contact request"))
dlg = wx.TextEntryDialog(
self, _('Please enter new contact JID'),
_('Adding a contact'), _('name@server.tld'))
if dlg.ShowModal() == wx.ID_OK:
jid=JID(dlg.GetValue())
if jid.is_valid():
self.bridge.addContact(jid.bare, profile_key=self.profile)
else:
error (_("'%s' is an invalid JID !"), jid)
#TODO: notice the user
dlg.Destroy()
def onRemoveContact(self, e):
debug(_("Remove contact request"))
target = self.contact_list.getSelection()
if not target:
dlg = wx.MessageDialog(self, _("You haven't selected any contact !"),
_('Error'),
wx.OK | wx.ICON_ERROR
)
dlg.ShowModal()
dlg.Destroy()
return
dlg = wx.MessageDialog(self, _("Are you sure you want to delete %s from your roster list ?") % target.bare,
_('Contact suppression'),
wx.YES_NO | wx.ICON_QUESTION
)
if dlg.ShowModal() == wx.ID_YES:
info(_("Unsubscribing %s presence"), target.bare)
self.bridge.delContact(target.bare, profile_key=self.profile)
dlg.Destroy()
def onShowProfile(self, e):
debug(_("Show contact's profile request"))
target = self.contact_list.getSelection()