comparison frontends/src/primitivus/status.py @ 937:255e6953b2c3

primitivus: do not display the presence/status dialog if the profile is not connected
author souliane <souliane@mailoo.org>
date Tue, 25 Mar 2014 17:26:31 +0100
parents 1fe00f0c9a91
children aa15453ec54d
comparison
equal deleted inserted replaced
936:6404df5305e3 937:255e6953b2c3
39 ('weight', 9, self.status), ('weight', 1, status_suffix)]) 39 ('weight', 9, self.status), ('weight', 1, status_suffix)])
40 urwid.connect_signal(self.presence, 'click', self.onPresenceClick) 40 urwid.connect_signal(self.presence, 'click', self.onPresenceClick)
41 urwid.connect_signal(self.status, 'click', self.onStatusClick) 41 urwid.connect_signal(self.status, 'click', self.onStatusClick)
42 42
43 def onPresenceClick(self, sender=None): 43 def onPresenceClick(self, sender=None):
44 if not self.host.bridge.isConnected(self.host.profile):
45 return
44 options = [commonConst.PRESENCE[presence] for presence in commonConst.PRESENCE] 46 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) 47 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'))) 48 decorated = sat_widgets.LabelLine(list_widget, sat_widgets.SurroundedText(_('Set your presence')))
47 self.host.showPopUp(decorated) 49 self.host.showPopUp(decorated)
48 50
49 def onStatusClick(self, sender=None): 51 def onStatusClick(self, sender=None):
52 if not self.host.bridge.isConnected(self.host.profile):
53 return
50 pop_up_widget = sat_widgets.InputDialog(_('Set your status'), _('New status'), default_txt=self.status.get_text(), 54 pop_up_widget = sat_widgets.InputDialog(_('Set your status'), _('New status'), default_txt=self.status.get_text(),
51 cancel_cb=lambda dummy: self.host.removePopUp, ok_cb=self.onChange) 55 cancel_cb=lambda dummy: self.host.removePopUp, ok_cb=self.onChange)
52 self.host.showPopUp(pop_up_widget) 56 self.host.showPopUp(pop_up_widget)
53 57
54 def onChange(self, sender=None, user_data=None): 58 def onChange(self, sender=None, user_data=None):