Primitivus: present contacts in groups chat can now be clicked
- updated GenericList/List signals to manage change/click fix in urwid-satext
- a click on a nick in a group chat create a private conversation with her, and select this conversation
/!\ history in backend doesn't manage correctly yet the private conversations /!\
This commit is contained in:
parent
8ad8ca1933
commit
d5fac19b9e
3 changed files with 24 additions and 6 deletions
|
|
@ -24,7 +24,7 @@ from urwid_satext import sat_widgets
|
|||
from urwid_satext.files_management import FileDialog
|
||||
from sat_frontends.quick_frontend.quick_chat import QuickChat
|
||||
from sat_frontends.primitivus.card_game import CardGame
|
||||
from sat_frontends.quick_frontend.quick_utils import unescapePrivate
|
||||
from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate
|
||||
import time
|
||||
from sat.tools.jid import JID
|
||||
|
||||
|
|
@ -155,9 +155,23 @@ class Chat(urwid.WidgetWrap, QuickChat):
|
|||
main_widget = self.pile
|
||||
self._w = main_widget
|
||||
|
||||
def _presentClicked(self, list_wid, clicked_wid):
|
||||
assert(self.type == 'group')
|
||||
nick = clicked_wid.getValue()
|
||||
if nick == self.getUserNick():
|
||||
#We ignore click on our own nick
|
||||
return
|
||||
#we have a click on a nick, we add the private conversation to the contact_list
|
||||
full_jid = JID("%s/%s" % (self.target.short, nick))
|
||||
new_jid = escapePrivate(full_jid)
|
||||
if new_jid not in self.host.contact_list:
|
||||
self.host.contact_list.add(new_jid)
|
||||
|
||||
#now we select the new window
|
||||
self.host.contact_list.setFocus(full_jid, True)
|
||||
|
||||
def __buildPresentList(self):
|
||||
self.present_wid = sat_widgets.GenericList([],option_type = sat_widgets.ClickableText)
|
||||
self.present_wid = sat_widgets.GenericList([],option_type = sat_widgets.ClickableText, on_click=self._presentClicked)
|
||||
return self.present_wid
|
||||
|
||||
def __appendPresentPanel(self):
|
||||
|
|
|
|||
|
|
@ -73,13 +73,17 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
return True
|
||||
return False
|
||||
|
||||
def setFocus(self, name):
|
||||
"""give focus to the first group or contact with the given name"""
|
||||
def setFocus(self, name, select=False):
|
||||
"""give focus to the first group or contact wich contain the given name
|
||||
@param name: name to check
|
||||
@param select: if True, the contact/group is also clicked"""
|
||||
idx = 0
|
||||
for widget in self.frame.body.body:
|
||||
try:
|
||||
if widget.getValue() == name:
|
||||
if name in widget.getValue():
|
||||
self.frame.body.set_focus(idx)
|
||||
if select:
|
||||
self.__contactClicked(widget, True)
|
||||
return
|
||||
except AttributeError:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class ProfileManager(urwid.WidgetWrap):
|
|||
self.login_wid = AdvancedEdit(_('Login:'),align='center')
|
||||
self.pass_wid = Password(_('Password:'),align='center')
|
||||
|
||||
self.list_profile = List(profiles, style=['single'], align='center', on_click=self.onProfileChange)
|
||||
self.list_profile = List(profiles, style=['single'], align='center', on_change=self.onProfileChange)
|
||||
|
||||
#new & delete buttons
|
||||
buttons = [urwid.Button(_("New"), self.onNewProfile),
|
||||
|
|
|
|||
Loading…
Reference in a new issue