def __init__(self, message = None, status = None, editable = None, **kws): StatusMessage.__init__(self, title = u'Promote Digsby!', status ='available' if status is None else status, message = None, editable = False, edit_toggle = kws.get('edit_toggle', self.edit_toggle))
def __init__(self, message=None, status=None, editable=None, **kws): StatusMessage.__init__( self, title=u'Promote Digsby!', status='available' if status is None else status, message=None, editable=False, edit_toggle=kws.get('edit_toggle', self.edit_toggle))
def __init__(self, message = None, status = None, editable = None, **kws): #log.info('NowPlayingStatus.__init__(message = %r, editable = %s, kws = %r)', message, editable, kws) # store extra formatting for protocols which want specific information self.format_args = kws.get('format_args', None) self.format_string = kws.get('format_string', None) self.app = kws.get('app', None) self._use_notes_symbol = kws.get('_use_notes_symbol', True) self._a_href = kws.get('_a_href', False) StatusMessage.__init__(self, title = _('Listening To...'), status ='available' if status is None else status, message = None, editable = False, edit_toggle = kws.get('edit_toggle', self.edit_toggle))
def change_state(self, state, change_text=False): if not isinstance(state, basestring): raise TypeError('change_state takes a string got a %s' % type(state)) self.status_state = state if change_text: self.ChangeValue(self.status_state, state.title()) else: self.Default = state.title() edit_toggle = getattr(profile.status, 'edit_toggle', True) if getattr(profile.status, 'edit_toggle', True): # update the icon self.SetButtonIcon(StatusMessage.icon_for(self.status_state)) self.cancel_timer() self.timer.StartOneShot(self.set_delay) # select all text in the textfield disp = self.display disp.TypeField() wx.CallAfter(disp.txtfld.SetSelection, -1, -1) else: self.setandshow( profile.status.copy(status=self.status_state, editable=None, edit_toggle=None))
def on_status_button(self, button): ''' Invoked when the user clicks the state button to the left of the dropdown. ''' # toggle the control's status state isavail = StatusMessage.is_available_state(self.status_state) # do we need to change the shown text? needs_change = self._shown_status in StatusMessage.SpecialStatuses or not self._shown_status.editable self.oldValue = None self.change_state(state='Away' if isavail else 'Available', )
def on_status_button(self, button): ''' Invoked when the user clicks the state button to the left of the dropdown. ''' # toggle the control's status state isavail = StatusMessage.is_available_state(self.status_state) # do we need to change the shown text? needs_change = self._shown_status in StatusMessage.SpecialStatuses or not self._shown_status.editable self.oldValue = None self.change_state(state = 'Away' if isavail else 'Available',)
def show_status(self, status, force=False): 'Displays the specified status message.' if not force and status is getattr(self, '_shown_status', None): return # make the text area not editable for statuses like "Invisble" and # "Offline", which have the "editable" attribute set to False self.Editable = status.editable self.display.empty_text = getattr(status, 'hint', '') self.ChangeValue(status.message) # change text self.SetButtonIcon(StatusMessage.icon_for(status)) # change icon self.status_state = status.status # store the state self._shown_status = status
def show_extended_status_menu(self): from gui.status import get_state_choices m = SimpleMenu(self, skinkey = skin.get('%s.MenuSkin'%self.skinkey)) for status in get_state_choices(): statusname, statuslabel = status def onclick(item, state=statusname): self.change_state(state)#, change_text = self.status_state == self.GetValue()) m.AppendItem(SimpleMenuItem([StatusMessage.icon_for(statusname), statuslabel], method = onclick)) if m.GetCount() > 0: m.Display(self.cbutton)
def UpdateSkin(self): key = 'statuspanel' if not skin.get(key, False) or skin.get(key + '.mode', '') == 'native': s = lambda k, d: None else: s = lambda k, default: skin.get('%s.%s' % (key, k), default) comboskinkey = s('comboboxskin', None) self.cbuttonskin = cbskinkey = s('statusbuttonskin', None) self.SetSkinKey(comboskinkey) UberCombo.UpdateSkin(self) if hasattr(self, 'cbutton'): self.cbutton.SetSkinKey(cbskinkey, True) self.SetButtonIcon(StatusMessage.icon_for(self.status_state)) if hasattr(self, 'menu') and self.menu: self.on_status_messages_changed()
def show_extended_status_menu(self): from gui.status import get_state_choices m = SimpleMenu(self, skinkey=skin.get('%s.MenuSkin' % self.skinkey)) for status in get_state_choices(): statusname, statuslabel = status def onclick(item, state=statusname): self.change_state( state ) #, change_text = self.status_state == self.GetValue()) m.AppendItem( SimpleMenuItem( [StatusMessage.icon_for(statusname), statuslabel], method=onclick)) if m.GetCount() > 0: m.Display(self.cbutton)
def UpdateSkin(self): key = 'statuspanel' if not skin.get(key, False) or skin.get(key+ '.mode','') == 'native': s = lambda k,d: None else: s = lambda k, default: skin.get('%s.%s' % (key, k), default) comboskinkey = s('comboboxskin',None) self.cbuttonskin = cbskinkey = s('statusbuttonskin',None) self.SetSkinKey(comboskinkey) UberCombo.UpdateSkin(self) if hasattr(self, 'cbutton'): self.cbutton.SetSkinKey(cbskinkey, True) self.SetButtonIcon(StatusMessage.icon_for(self.status_state)) if hasattr(self,'menu') and self.menu: self.on_status_messages_changed()
def on_text_lose_focus(self, new_msg): if self.searching: return self.on_search_timer() # Cancel the status button timer if it's running. self.cancel_timer() if getattr(self, 'skipenter', False): wx.CallAfter(lambda: setattr(self, 'skipenter', False)) else: # don't set status if we lost focus because the user is clicking # on the state button if wx.GetMouseState().LeftDown() and wx.FindWindowAtPoint( wx.GetMousePosition()) is self.cbutton: return profile_status = self.get_profile_status() if new_msg == '': self.display.empty_text = profile_status.hint if new_msg != profile_status.message or self.status_state != profile_status.status: # entering a new text value clears all exceptions newmsg = StatusMessage(new_msg, self.status_state, new_msg) self.set_profile_status(newmsg)
def change_state(self, state, change_text = False): if not isinstance(state, basestring): raise TypeError('change_state takes a string got a %s' % type(state)) self.status_state = state if change_text: self.ChangeValue(self.status_state, state.title()) else: self.Default = state.title() edit_toggle = getattr(profile.status, 'edit_toggle', True) if getattr(profile.status, 'edit_toggle', True): # update the icon self.SetButtonIcon(StatusMessage.icon_for(self.status_state)) self.cancel_timer() self.timer.StartOneShot(self.set_delay) # select all text in the textfield disp = self.display disp.TypeField() wx.CallAfter(disp.txtfld.SetSelection, -1, -1) else: self.setandshow(profile.status.copy(status = self.status_state, editable = None, edit_toggle = None))
def StatusMessageFromInfo(self): "Builds a StatusMessage object from this dialog's fields." return StatusMessage(**self.info())
def add_status_menu_item(menu, statusmsg): return menu.Append(statusmsg.title, bitmap = StatusMessage.icon_for(statusmsg), callback = status_setter(statusmsg))
def add_status_menu_item(menu, statusmsg): return menu.Append(statusmsg.title, bitmap=StatusMessage.icon_for(statusmsg), callback=status_setter(statusmsg))