comparison frontends/src/primitivus/status.py @ 1354:14fc88275e65 frontends_multi_profiles

frontends (primitivus): fixes setting the presence and status (for now all the profiles share the same info)
author souliane <souliane@mailoo.org>
date Fri, 06 Mar 2015 15:24:45 +0100
parents 89dc29afe01c
children 069ad98b360d
comparison
equal deleted inserted replaced
1353:361b0fe72961 1354:14fc88275e65
37 ('weight', 9, self.status), ('weight', 1, status_suffix)]) 37 ('weight', 9, self.status), ('weight', 1, status_suffix)])
38 urwid.connect_signal(self.presence, 'click', self.onPresenceClick) 38 urwid.connect_signal(self.presence, 'click', self.onPresenceClick)
39 urwid.connect_signal(self.status, 'click', self.onStatusClick) 39 urwid.connect_signal(self.status, 'click', self.onStatusClick)
40 40
41 def onPresenceClick(self, sender=None): 41 def onPresenceClick(self, sender=None):
42 if not self.host.bridge.isConnected(self.host.profile): 42 if not self.host.bridge.isConnected(self.host.current_profile): # FIXME: manage multi-profiles
43 return 43 return
44 options = [commonConst.PRESENCE[presence] for presence in commonConst.PRESENCE] 44 options = [commonConst.PRESENCE[presence] for presence in commonConst.PRESENCE]
45 list_widget = sat_widgets.GenericList(options=options, option_type=sat_widgets.ClickableText, on_click=self.onChange) 45 list_widget = sat_widgets.GenericList(options=options, option_type=sat_widgets.ClickableText, on_click=self.onChange)
46 decorated = sat_widgets.LabelLine(list_widget, sat_widgets.SurroundedText(_('Set your presence'))) 46 decorated = sat_widgets.LabelLine(list_widget, sat_widgets.SurroundedText(_('Set your presence')))
47 self.host.showPopUp(decorated) 47 self.host.showPopUp(decorated)
48 48
49 def onStatusClick(self, sender=None): 49 def onStatusClick(self, sender=None):
50 if not self.host.bridge.isConnected(self.host.profile): 50 if not self.host.bridge.isConnected(self.host.current_profile): # FIXME: manage multi-profiles
51 return 51 return
52 pop_up_widget = sat_widgets.InputDialog(_('Set your status'), _('New status'), default_txt=self.status.get_text(), 52 pop_up_widget = sat_widgets.InputDialog(_('Set your status'), _('New status'), default_txt=self.status.get_text(),
53 cancel_cb=self.host.removePopUp, ok_cb=self.onChange) 53 cancel_cb=self.host.removePopUp, ok_cb=self.onChange)
54 self.host.showPopUp(pop_up_widget) 54 self.host.showPopUp(pop_up_widget)
55 55
59 if isinstance(user_data, sat_widgets.ClickableText): 59 if isinstance(user_data, sat_widgets.ClickableText):
60 new = ([key for key in commonConst.PRESENCE if commonConst.PRESENCE[key] == new_value][0], previous[1]) 60 new = ([key for key in commonConst.PRESENCE if commonConst.PRESENCE[key] == new_value][0], previous[1])
61 elif isinstance(user_data, sat_widgets.AdvancedEdit): 61 elif isinstance(user_data, sat_widgets.AdvancedEdit):
62 new = (previous[0], new_value[0]) 62 new = (previous[0], new_value[0])
63 if new != previous: 63 if new != previous:
64 self.host.bridge.setPresence(show=new[0], statuses={'default': new[1]}, profile_key=self.host.profile) #FIXME: manage multilingual statuses 64 for profile in self.host.profiles: # FIXME: for now all the profiles share the same status
65 self.host.bridge.setPresence(show=new[0], statuses={'default': new[1]}, profile_key=profile) # FIXME: manage multilingual statuses
65 self.setPresenceStatus(new[0], new[1]) 66 self.setPresenceStatus(new[0], new[1])
66 self.host.removePopUp() 67 self.host.removePopUp()
67 68
68 def setPresenceStatus(self, show, status): 69 def setPresenceStatus(self, show, status):
69 show_icon, show_attr = Const.PRESENCE.get(show) 70 show_icon, show_attr = Const.PRESENCE.get(show)