def __init__(self, win, autohide=False, enabled=True): self.Animate = True self.autohidden = False self.AutoHide = False self.docked = False self.docking = False self.LinkedWindows = [] self.manualMove = False self.motiontrigger = False self.pixelsdragged = 0 self.ShouldShowInTaskbar = lambda: True self.timer = wx.PyTimer(self.OnTimer) self.spookyGhostWindow = None self.win = win self.win.Bind(wx.EVT_ACTIVATE, self.OnActivateWin) self.win.Bind(wx.EVT_MOVE, self.OnMoving) self.lastrect = None self.SetAutoHide(autohide) self.OnDock = Delegate() self.OnHide = Delegate() publisher = Publisher() publisher.subscribe(self.OnActivateApp, 'app.activestate.changed')
def __init__(self, parent, text, on_click=None, should_be_active=None, align='right'): self._on_click = Delegate() if on_click: self._on_click += on_click ClearLink.__init__(self, parent, -1, text, on_click, style=wx.NO_BORDER | getattr(wx, 'HL_ALIGN_%s' % align.upper())) linkfont = skin.get('filetransfers.fonts.link', default_font) self.SetFont(linkfont) self._is_active = Delegate(collect_values=True) if should_be_active: self._is_active += should_be_active
def __init__(self, jabber): self.jabber = jabber self.on_incoming_node = Delegate() self.on_outgoing_node = Delegate() jabber.add_observer(self.state_changed, 'state') self.state_changed(jabber)
def __init__(self, parent): SimplePanel.__init__(self, parent) self.OnEditEmail = Delegate() self.OnSendEmail = Delegate() self.gui_constructed = False self.UpdateSkin() self.construct_gui()
def __init__(self, updatefreq=None, *a, **k): StateMixin.__init__(self, *a, **k) if updatefreq is not None: try: updatefreq = int(updatefreq) except ValueError: pass else: if updatefreq < 1: updatefreq = 60 self.updatefreq = max(updatefreq, 15) self.on_connect = Delegate() self.on_disable = Delegate()
def retrieved_blob(self, stanza): ''' The answer from server_retrieve. Sends blob to the profile, either from the (in memory, pre-loaded) cache, or from the response from the server. If the local copy was newer, this initiates a profile.save for the blob, after sending it to the profile. ''' ns = stanza.get_query_ns() info('retrieved blob w/ ns:"%r"', ns) blob = ns_to_obj[ns](stanza.get_query()) name = ns_to_name[ns] calls = Delegate() if blob.update_needed is True: assert blob._data is None info('%s: server-side older, sending our copy', name) calls.append(lambda: self.profile.save(name, force=True)) if blob._data is None: info('%s: server-side matched cache', name) blob._data = self.from_cache.pop(name) #default? else: info('%s: server-side newer', name) self.blob_cache(blob) useful_data = blob.data old_loading = self.loading self.waiting_blobs.discard(name) self.profile.update_blob(name, useful_data) self.notify('loading', old_loading, self.loading) calls()
def __init__(self, frame): frame.Bind(wx.EVT_MENU, self._oncommandevent) self.frame = frame self.cbs = defaultdict( lambda: Delegate(ignore_exceptions=wx.PyDeadObjectError)) self.idcbs = {}
def __init__(self, timer_secs, time_mode, trigger_mode, current_time_func=time): assert isinstance(timer_secs, int) assert trigger_mode in allowed_trigger_modes assert time_mode in allowed_time_modes self.has_focus = False self.timer_secs = timer_secs self.time_mode = time_mode self.trigger_mode = trigger_mode self.scenario_identifier = '%s_%s_%s' % (timer_secs, time_mode, trigger_mode) assert hasattr(current_time_func, '__call__') self._get_time = current_time_func self._reset_time( start=False) # the last UNIX time we showed an ad ( = now). self.on_reload = Delegate() if self.trigger_mode == 'focus': self.wx_timer = wx.PyTimer(self._on_wxtimer) self.wx_timer.StartRepeating(1000)
def __init__(self, username, password): self.username = username self.password = password self.recent_timeline = [] self.self_tweet = None self.trends = {} self.feeds = [] self.feeds_by_name = {} self.unread_counts = [] e = self.events = Storage( (name, Delegate()) for name in self.event_names) e.following += self.on_following e.trends += self.on_trends e.on_unread_counts += self.on_unread_counts e.recent_timeline += self.on_recent_timeline e.self_tweet += self.on_self_tweet e.on_feeds += self.on_feeds e.on_change_view += self.on_change_view e.on_view += self.on_view_changed def render_tweets(tweets, render_context): return htmlize_tweets(self, tweets) self.social_feed = SocialFeed('twitter_' + self.username, 'twitter_' + self.username, self.get_tweet_feed, render_tweets, lambda: self.account.set_infobox_dirty)
def conversation_reconnected(self): try: d = self._conversation_reconnected except AttributeError: from util.primitives.funcs import Delegate d = self._conversation_reconnected = Delegate() return d
def __init__(self, tocombo, fromcombo): BInfoControl.__init__(self, tocombo, fromcombo, 'email', email_menu_content) self._obs_link = None self.setup_from_accts() self.OnEmailAccountChanged = Delegate()
def new_done(func=None): done = Delegate() if func is not None: done += func done += set_order done += self.save_server_info return done
def __init__(self, parent, label='', id=None, onshow=None, windowless=None): if not isinstance(parent, wx.WindowClass): raise TypeError('UMenu parent must be a wx.Window') wx.Menu.__init__(self, label) InstanceTracker.track(self) if not isinstance(id, (int, type(None))): raise TypeError self._parentmenu = self._childmenu = None self.Id = wx.NewId() if id is None else id self._window = ref(parent) self.OnDismiss = Delegate() self.cbs = {} #self.Bind(wx.EVT_MENU, lambda e: menuEventHandler(self.InvokingWindow).ProcessEvent(e)) if onshow is not None: self.Handler.AddShowCallback(self.Id, lambda menu=ref(self): onshow(menu())) if wxMSW: self.Handler.hwndMap[self.HMenu] = self self.Windowless = windowless self.UpdateSkin()
def __init__(self, webview): self.id_count = 0 self.callbacks = {} # TODO: expire timeouts self.webview = webview self.webview.Bind(wx.webview.EVT_WEBVIEW_RECEIVED_TITLE, self.on_before_load) self.specifiers = {} self.on_call = Delegate()
def __init__(self, win, autohide = False, enabled = True): self.win = win self._side = None#ABE_LEFT self.DockMargin = 30 self.ShouldShowInTaskbar = lambda: True #must be set by window self.ShouldAlwaysStayOnTop = None self.RevealDurationMs = 300 self.Animate = True self.autohidden = self.docking = self.docked = False self._enabled = enabled self._autohide = autohide self.bypassSizeEvents = False self.bypassMoveEvents = False self.reReserveTimer = None Bind = win.Bind BindWin32 = win.BindWin32 Bind(wx.EVT_MOVING, self.OnMoving) Bind(wx.EVT_CLOSE, self.OnClose) Bind(wx.EVT_ACTIVATE, self.OnActivate) Bind(wx.EVT_DISPLAY_CHANGED, self.OnDisplayChanged) Bind(wx.EVT_SHOW, self.OnShow) BindWin32(WM_WINDOWPOSCHANGING, self.OnWindowPosChanging) BindWin32(WM_EXITSIZEMOVE, self.OnExitSizeMove) BindWin32(WM_SIZING, self.OnSizing) BindWin32(WM_NCHITTEST, self.OnNCHitTest) BindWin32(WM_SYSCOMMAND, self.OnSysCommand) self.appbar_cb_id = WM_USER + 100 BindWin32(self.appbar_cb_id, self.AppBarCallback) self.firstShow = True self.wasDocked = False self.oldSize = None self.motiontrigger = False self.timer = PyTimer(self.OnTimer) self.OnDock = Delegate() self.OnHide = Delegate() self.LinkedWindows = []
def __init__(self, imwin, capsbar, tocombo, fromcombo, onselection=None): self.imwin = imwin self.capsbar = capsbar self.tocombo = tocombo self.fromcombo = fromcombo self.contact = None self.blist = profile.blist self.register_observers() self.OnSelection = Delegate() self.OnSwitchContact = Delegate() self.msgarea = None self.ischat = False
def __init__(self, parent, initialContents='', contentPath='file:///c:/', url=None, simple_events=False, external_links=True, **opts): super(WebKitWindow, self).__init__(parent, size=wx.Size(200, 200), **opts) self._jsqueue_enabled = True self.jsqueue = [] self.js_to_stderr = False self.ExternalLinks = external_links self.OnNav = Delegate() # Called for NavigateComplete2 events self.OnDoc = Delegate() # Called for DocumentComplete events self.OnTitleChanged = Delegate() Bind = self.Bind Bind(wx.EVT_CONTEXT_MENU, self.__OnContextMenu) Bind(webview.EVT_WEBVIEW_LOAD, self.OnStateChanged) Bind(webview.EVT_WEBVIEW_BEFORE_LOAD, self.OnBeforeLoad) Bind(webview.EVT_WEBVIEW_RECEIVED_TITLE, self.OnTitleChanged) from gui.browser.webkit import setup_webview_logging setup_webview_logging(self, 'webview') self.urltriggers = defaultdict(list) if initialContents and url is not None: raise ValueError( "please specify initialContents or url, but not both") # some APIs call LoadUrl self.LoadUrl = self.LoadURL if url is not None: self.LoadURL(url) else: self.SetPageSource(initialContents, 'file:///') self.BlockWebKitMenu = True
def connection_closed(self, socket=None): if self.state == self.Statuses.OFFLINE: log.info('socket closed normally') reason = self.Reasons.NONE else: log.info('socket closed unexpectedly (-> CONN_LOST)') reason = self.Reasons.CONN_LOST self.Disconnect(reason) self.on_connect = Delegate()
def __init__(self, subject): self.profile = subject self.existing_sps = {} self.order = None self.on_order_changed = Delegate() self.lock = threading.RLock() self.rebuild_count = 0 self.accounts_to_rebuild = None self.new = set()
def watch_status(self, buddy, callback): assert callable(callback) bid = key(buddy) try: watchers = self.watchers[bid] except KeyError: watchers = self.watchers.setdefault(bid, Delegate()) watchers += callback
def __init__(self, source, time_secs): self.source = source self.request_callbacks = Delegate() self.requesting = False self.ads = None self.ad_index = -1 self.append_short_links = SHORTEN_AD_URLS
def __init__(self, username, password, follow_ids): self.follow_ids = follow_ids self.httpmaster = asynchttp.HttpMaster() uris = ['stream.twitter.com', 'twitter.com'] realm = 'Firehose' self.httpmaster.add_password(realm, uris, username, password) self.post_data = 'follow=' + ','.join(str(i) for i in follow_ids) self.on_tweet = Delegate()
def __init__(self, tocombo, fromcombo, info_attr, content_cb): self.tocombo, self.fromcombo = tocombo, fromcombo self._editing = False assert isinstance(info_attr, str) self.info_attr = info_attr self.OnLoseFocus = Delegate() e = self.to_editor = ComboListEditor(tocombo, self.OnLoseFocus) e.SetContentCallback(content_cb) self.blist = profile.blist
def __init__(self, parent, key): wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL | wx.FULL_REPAINT_ON_RESIZE) self.SetSkinKey(key, True) Bind = self.Bind Bind(wx.EVT_ERASE_BACKGROUND, lambda e: None) Bind(wx.EVT_PAINT, self.OnPaint) self.ChildPaints = Delegate()
def __init__(self, profile): Observable.__init__(self) self.accounts_loaded = False self.profile = profile self.connected_accounts = ObservableList() self.reconnect_timers = {} # holds "cancel" objects from Popups self.cancellers = {} self.profile.add_observer(self.on_state_change, 'state') self.profile.add_observer(self.on_offline_change, 'offline_reason') self.profile.add_observer(self.profile_state_changed, 'state') import wx wx.GetApp().OnBuddyListShown.append(lambda *a, **k: Timer(.25, threaded(self.release_accounts), *a, **k).start()) self._hash = sentinel self.got_accounts = False self.acct_calls = Delegate() self.delay_accounts = True self.acct_delay_lock = RLock() self._all_acct_hash = {} self.last_server_order = None self._all_accounts = Storage() for type_ in ('im', 'em', 'so'): s = Storage(accounts = ObservableList(), old = []) setattr(self._all_accounts, type_, s) # when the order of accounts changes, or accounts are added or deleted, # calls profile.accounts_changed('im', list) s.accounts.add_observer(getattr(self, type_ + '_accounts_changed')) self.accounts = self._all_accounts.im.accounts self.emailaccounts = self._all_accounts.em.accounts self.socialaccounts = self._all_accounts.so.accounts self.buddywatcher = BuddyWatcher() import services.service_provider as sp container = sp.ServiceProviderContainer(self.profile) container.on_order_changed += self._set_order
def __init__(self, parent, skinkey='MenuBar'): wx.MenuBar.__init__(self) self.toptitles = {} self.skinkey = skinkey self.accelremoves = Delegate() self.panel = SkinnedPanel( parent, 'MenuBar', ) self.panel.UpdateSkin = self.UpdateSkin self.panel.Hide() self.UpdateSkin()
def __init__(self, parent, account = None, protocol_name = None): "Please do not call directly. See classmethods create_new and edit_account." # Editing an existing account if account is not None: self.new = False assert protocol_name is None protocolinfo = account.protocol_info() self.protocol_name = account.protocol title = '%s - %s Settings' % (account.name, protocolinfo.name) # Creating a new account if account is None: self.new = True protocolinfo = protocols[protocol_name] self.protocol_name = protocol_name title = '%s Account' % protocolinfo.name # What to call the username (screenname, username, Jabber ID, etc.) self.screenname_name = protocolinfo.username_desc wx.Dialog.__init__(self, parent, title=title, size=(400,300)) self.account = account if account is not None else emptystringer(getattr(protocolinfo, 'defaults', None)) self.new = account is None self.protocolinfo = protocolinfo # Set the account type icon from gui import skin self.SetFrameIcon(skin.get('serviceicons.%s' % self.protocol_name)) self.formtype = getattr(protocolinfo, 'form', 'default') self.info_callbacks = Delegate() if self.new: self._allaccts = [acctid(a.protocol, a.name) for a in profile.account_manager] self.construct(account is None) self.layout() # enable or disable the save button as necessary. self.check_warnings() self.Fit() # focus the first enabled text control. for c in self.Children: if isinstance(c, TextCtrl) and c.IsEnabled() and c.IsEditable(): if c is get(self, 'password', None): c.SetSelection(-1, -1) # only makes sense to select all on a password field :) wx.CallAfter(c.SetFocus) break
def AddActionCallback(self, actionname, callback): 'Associates a callable with an action.' actionname = actionname.lower() if isinstance(callback, basestring): callback = LazyStringImport(callback) if not actionname in self.handlers: self.handlers[actionname] = Delegate([callback]) else: self.handlers[actionname] += callback self.resolve_actions()
def __init__(self, parent, initial_tab=default_selected_tab): wx.Frame.__init__(self, parent, title=_('Digsby Preferences'), size=self.default_size, style=prefs_dialog_style, name='Preferences Window') self.loaded_panels = {} self.SetMinSize(self.default_size) metrics.event('Prefs Dialog Opened') self.create_gui() self.bind_events() self.layout_gui() self.exithooks = Delegate() with traceguard: from gui import skin self.SetFrameIcon(skin.get('AppDefaults.TaskbarIcon')) if not wxMac: self.BackgroundColour = wx.WHITE self.Bind(wx.EVT_ERASE_BACKGROUND, lambda e: None) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.Bind(wx.EVT_PAINT, self.OnPaint) # Fake a first selection self.tabs.SetSelection(initial_tab) self.on_tab_selected(initial_tab) self.tabnames = names = [ module_name for module_name, nice_name in tabnames ] self.Bind(wx.EVT_CLOSE, self.on_close) self._loaded = 0 # Obey the windows.sticky prreference snap_pref(self) profile.prefs.add_observer(self.incoming_network_prefs) from gui.uberwidgets.keycatcher import KeyCatcher k = self._keycatcher = KeyCatcher(self) k.OnDown('ctrl+w', self.Close) k.OnDown('escape', self.Close)
def __init__(self, root=None, collapsed=None): self.root = root or [] self.collapsed = set(collapsed) if collapsed is not None else set() self.flattened_list = [] self.listeners = [] self.depths = {} self.filters = [] self.donotexpand = [] self._expandable_cache = {} self.update_list() self.expansion_state_changed = Delegate() # access this object (specifically, the flattened_list member) as a list ListMixin.__init__(self, 'flattened_list')