Mercurial > libervia-backend
comparison frontends/src/primitivus/status.py @ 1367:f71a0fc26886
merged branch frontends_multi_profiles
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 18 Mar 2015 10:52:28 +0100 |
parents | 14fc88275e65 |
children | 069ad98b360d |
comparison
equal
deleted
inserted
replaced
1295:1e3b1f9ad6e2 | 1367:f71a0fc26886 |
---|---|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 import urwid | 21 import urwid |
22 from urwid_satext import sat_widgets | 22 from urwid_satext import sat_widgets |
23 from sat_frontends.constants import Const as commonConst | 23 from sat_frontends.quick_frontend.constants import Const as commonConst |
24 from sat_frontends.primitivus.constants import Const | 24 from sat_frontends.primitivus.constants import Const |
25 | 25 |
26 | 26 |
27 class StatusBar(urwid.Columns): | 27 class StatusBar(urwid.Columns): |
28 | 28 |
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) |