home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from __future__ import with_statement
- from wx import PyDeadObjectError
-
- try:
- _
- except:
- import gettext
- gettext.install('Digsby')
-
- import wx
- from gui.uberwidgets.uberbook.tabmanager import TabWindowManager
- from gui.uberwidgets.uberbook.UberBook import NoteBook
- from common import setpref, pref, profile, bind, prefprop
- from util import oset, traceguard
- from gui.uberwidgets.UberEvents import EVT_TAB_NOTIFIED
- from gui.toolbox import saveWindowPos, preLoadWindowPos, snap_pref
- from gui.native import memory_event
- IMFRAME_MINSIZE = (320, 220)
- CLOSETABS_TITLE = _('Close IM Window')
- CHECKBOX_TEXT = _('Warn me when I attempt to close multiple conversations')
- CLOSETABS_MSG = _('You are about to close %d conversations. Are you sure you want to continue?')
- CLOSE_BUTTON_TEXT = _('Close &tabs')
- WARN_PREF = 'messaging.tabs.warn_on_close'
-
- class CloseTabsDialog(wx.Dialog):
-
- def WarnMe(self):
- return self.panel.warn_cb.Value
-
- WarnMe = property(WarnMe)
-
- def __init__(self, parent, num_tabs, warn_value = True):
- wx.Dialog.__init__(self, parent, title = CLOSETABS_TITLE)
- self.panel = CloseTabsPanel(self, num_tabs, warn_value)
- self.Sizer = wx.BoxSizer(wx.VERTICAL)
- self.Sizer.Add(self.panel, 1, wx.EXPAND)
- self.Fit()
-
-
-
- class CloseTabsPanel(wx.Panel):
-
- def __init__(self, parent, num_tabs, warnme_value = True):
- wx.Panel.__init__(self, parent)
- self.Bind(wx.EVT_PAINT, self.OnPaint)
- self.warn_cb = warn_cb = wx.CheckBox(self, -1, CHECKBOX_TEXT)
- warn_cb.SetValue(warnme_value)
- msgsizer = wx.BoxSizer(wx.VERTICAL)
- self.close_msg = wx.StaticText(self, -1, CLOSETABS_MSG % num_tabs)
- msgsizer.Add(self.close_msg, 0, wx.EXPAND | wx.SOUTH, 8)
- msgsizer.Add(warn_cb, 0, wx.EXPAND)
- h = wx.BoxSizer(wx.HORIZONTAL)
- self.bitmap = wx.ArtProvider.GetBitmap(wx.ART_QUESTION)
- self.bitmap.SetMaskColour(wx.BLACK)
- h.Add((self.bitmap.Width, self.bitmap.Height), 0, wx.EXPAND | wx.ALL, 9)
- h.Add(msgsizer, 0, wx.EXPAND | wx.ALL, 12)
- close_button = wx.Button(self, wx.ID_OK, CLOSE_BUTTON_TEXT)
- close_button.SetDefault()
- close_button.SetFocus()
- cancel_button = wx.Button(self, wx.ID_CANCEL, _('&Cancel'))
- buttonsizer = wx.BoxSizer(wx.HORIZONTAL)
- buttonsizer.AddStretchSpacer(1)
- buttonsizer.Add(close_button, 0, wx.RIGHT, 6)
- buttonsizer.Add(cancel_button)
- buttonsizer.AddStretchSpacer(1)
- s = self.Sizer = wx.BoxSizer(wx.VERTICAL)
- s.Add(h, 0, wx.EXPAND | wx.ALL)
- s.Add(buttonsizer, 0, wx.EXPAND | wx.BOTTOM, 12)
-
-
- def OnPaint(self, e):
- dc = wx.PaintDC(self)
- pos = self.close_msg.Position
- dc.DrawBitmap(self.bitmap, pos.x - self.bitmap.Width - 10, pos.y, True)
-
-
- from gui.native.toplevel import FlashOnce, Flash
-
- class TitleBarTimer(wx.Timer):
- shouldFlash = prefprop('conversation_window.notify_flash')
-
- def __init__(self, win, tabs):
- wx.Timer.__init__(self)
- self.win = win
- self.tabs = tabs
- self.index = 0
-
-
- def Start(self):
- self.title = self.win.Title
- wx.Timer.Start(self, 2000)
-
-
- def Notify(self):
- win = self.win
- tabs = self.tabs
- if wx.IsDestroyed(win):
- self.Stop()
- return None
-
- if not win.IsActive() and len(tabs):
- tabNum = len(tabs)
- if self.index >= tabNum:
- None(win.SetTitle if tabNum > 1 else _('(New IM)'))
- self.index = 0
- else:
- tab = tabs[self.index]
- if not wx.IsDestroyed(tab):
- win.SetTitle(tab.label1)
- self.index += 1
- else:
- tabs.remove(tab)
- if self.shouldFlash:
- FlashOnce(win)
-
- else:
- self.Stop()
-
-
- def Stop(self):
- wx.Timer.Stop(self)
- self.win.SetTitle(self.title)
- self.index = 0
-
-
-
- class TabFrame(wx.Frame):
-
- def __init__(self, parent, pos = wx.DefaultPosition, **kwargs):
- wx.Frame.__init__(self, parent, pos = pos, **kwargs)
- self.winman = ImFrame.WinMan()
- self.tabman = ImFrame.TabMan()
- self.notebook = NoteBook(self, self, self.tabman, skinkey = 'Tabs')
- self.mergetimer = None
- self.notifiedtabs = oset()
- self.titletimer = TitleBarTimer(self, self.notifiedtabs)
- Bind = self.Bind
- Bind(wx.EVT_MOVE, self.OnMove)
- Bind(wx.EVT_SIZE, self.OnSize)
- Bind(EVT_TAB_NOTIFIED, self.OnTabNotify)
- sz = self.Sizer = wx.BoxSizer(wx.VERTICAL)
- sz.Add(self.notebook, 1, wx.EXPAND)
-
-
- def GetTabCount(self):
- return self.notebook.GetTabCount()
-
-
- def TabMan():
- return ImFrame.WinMan().TabManager
-
- TabMan = staticmethod(TabMan)
-
- def WinMan():
-
- try:
- return ImFrame._winmanager
- except AttributeError:
- ImFrame._winmanager = TabWindowManager((lambda pos, size = None: ImFrame(pos = pos, size = size)))
-
- def explodeAllWindows():
- for win in (lambda .0: for w in .0:
- if isinstance(w, ImFrame):
- wcontinue)(wx.GetTopLevelWindows()):
- win.notebook.Explode()
-
-
- profile.prefs.link(('messaging.tabs.enabled',), (lambda val: None if not val else None), callnow = False, obj = ImFrame._winmanager)
- return ImFrame._winmanager
-
-
- WinMan = staticmethod(WinMan)
-
- def AddTab(self, ctrl, focus = None):
- return self.notebook.Add(ctrl, focus = focus)
-
- cycleTitle = prefprop('conversation_window.cycle_unread_ims')
- shouldFlash = prefprop('conversation_window.notify_flash')
-
- def OnTabNotify(self, event):
- tab = event.tab
- if tab.notified:
- self.notifiedtabs.add(tab)
- elif tab in self.notifiedtabs:
- self.notifiedtabs.remove(tab)
- return None
- else:
- return None
- if not self.cycleTitle:
- if self.shouldFlash:
- Flash(self)
-
- return None
-
- if len(self.notifiedtabs) and not self.IsActive():
- if not self.titletimer.IsRunning():
- self.titletimer.Start()
-
- elif self.titletimer.IsRunning():
- self.titletimer.Stop()
-
-
-
- def OnMove(self, event):
- event.Skip(True)
- if pref('messaging.tabs.enabled', True):
- mt = self.mergetimer
- if mt is None:
- self.mergetimer = wx.CallLater(10, self.notebook.StartWindowDrag)
- else:
- mt.Start(10)
-
- event.Skip(True)
-
-
- def OnSize(self, event):
- mt = self.mergetimer
- if mt is not None:
- mt.Stop()
-
- event.Skip(True)
-
-
-
- class ImFrame(TabFrame):
- WindowName = u'IM Window'
-
- def __init__(self, pos = None, size = None, startMinimized = False, posId = ''):
- (wininfo, placement) = preLoadWindowPos(ImFrame.WindowName, uniqueId = posId, defaultPos = wx.Point(200, 200), defaultSize = wx.Size(410, 300))
- wininfo['style'] |= wx.DEFAULT_FRAME_STYLE
- setPos = pos is not None
- setSize = size is not None
- if setPos or setSize:
- wininfo['style'] &= ~(wx.MAXIMIZE)
-
- if startMinimized:
- wininfo['style'] |= wx.ICONIZE
-
- TabFrame.__init__(self, parent = None, name = ImFrame.WindowName, **wininfo)
- if placement is not None:
- if not setPos:
- pass
- if not setSize:
- print 'im window placement', placement
- traceguard.__enter__()
-
- try:
- SetWindowPlacement = SetWindowPlacement
- import gui.toolbox
- SetWindowPlacement(self, placement)
- print self.Rect
- finally:
- pass
-
-
- if setPos:
- self.Position = pos
-
- if setSize:
- self.Size = size
-
- self.Bind(wx.EVT_ERASE_BACKGROUND, (lambda e: pass))
- self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
- self.posId = posId
- self.EnsureInScreen()
- if pos is not None:
- wx.CallAfter(self.EnsureNotStacked)
-
- profile.prefs.link('conversation_window.always_on_top', self.on_always_on_top)
- snap_pref(self)
- self.SetMinSize(IMFRAME_MINSIZE)
- self.iconizecallbacks = set()
- Bind = self.Bind
- Bind(wx.EVT_CLOSE, self.OnClose)
- Bind(wx.EVT_ACTIVATE, self.OnActivate)
- Bind(wx.EVT_ICONIZE, self.OnIconize)
- memory_event()
-
-
- def OnIconize(self, event):
- event.Skip()
- for callback in set(self.iconizecallbacks):
-
- try:
- callback()
- continue
- except PyDeadObjectError:
- self.iconizecallbacks.remove(callback)
- continue
-
-
-
-
-
- def AnyNotified(self):
- return any((lambda .0: for iwin in .0:
- iwin.Tab.notified)(self))
-
- AnyNotified = property(AnyNotified)
-
- def OnActivate(self, e):
- e.Skip()
- if e.GetActive():
- tab = self.notebook.ActiveTab
- if tab is not None:
- tab.SetNotify(False)
- tab.page.Content.FocusTextCtrl()
-
-
- if self.titletimer.IsRunning():
- self.titletimer.Stop()
-
-
-
- def __iter__(self):
- return iter((lambda .0: for p in .0:
- p.Content)(self.notebook.Pages()))
-
-
- def __getitem__(self, n):
- return self.notebook.Pages()[n].Content
-
-
- def CloseTabIfNotLast(self):
- if self.notebook.GetTabCount() > 1:
- self.notebook.ActiveTab.CloseTab()
-
-
- CloseTabIfNotLast = bind('ImFrame.Tabs.CloseIfNotLast')(CloseTabIfNotLast)
-
- def CloseActiveTab(self):
- self.notebook.ActiveTab.CloseTab()
-
- CloseActiveTab = bind('ImFrame.Tabs.CloseActive')(CloseActiveTab)
-
- def NextTab(self):
- self.notebook.NextTab()
-
- NextTab = bind('ImFrame.Tabs.NextTab')(NextTab)
-
- def PrevTab(self):
- self.notebook.PrevTab()
-
- PrevTab = bind('ImFrame.Tabs.PrevTab')(PrevTab)
-
- def IncreaseTextSize(self):
- self.ActiveMessageArea.IncreaseTextSize()
-
- IncreaseTextSize = bind('ImFrame.ChatWindow.IncreaseTextSize')(IncreaseTextSize)
-
- def DescreaseTextSize(self):
- self.ActiveMessageArea.DecreaseTextSize()
-
- DescreaseTextSize = bind('ImFrame.ChatWindow.DecreaseTextSize')(DescreaseTextSize)
-
- def ResetTextSize(self):
- self.ActiveMessageArea.ResetTextSize()
-
- ResetTextSize = bind('ImFrame.ChatWindow.ResetTextSize')(ResetTextSize)
-
- def ActiveMessageArea(self):
- return self.notebook.ActiveTab.page.Content.message_area
-
- ActiveMessageArea = property(ActiveMessageArea)
-
- def IsTabDragging(self):
- notebook = self.winman.wdt.notebook
- return None if notebook else False
-
-
- def OnClose(self, e):
- tabcount = self.GetTabCount()
- if e.CanVeto() and tabcount > 1 and pref(WARN_PREF, True):
-
- try:
- diag = _[2]
- diag.CenterOnParent()
- res = diag.ShowModal()
- if not diag.WarnMe:
- setpref(WARN_PREF, False)
-
- if res == wx.ID_CANCEL:
- return e.Veto()
- finally:
- pass
-
-
- self.Hide()
- saveWindowPos(self, uniqueId = self.posId)
- for page in self.notebook.Pages():
- page.Children[0].on_close()
-
- self.tabman.UnRegister(self.notebook)
- self.mergetimer = None
- memory_event()
- self.Destroy()
-
-
- def __repr__(self):
- return '<%s %s>' % (self.__class__.__name__, id(self))
-
-
- def UpdateSkin(self):
- wx.CallAfter(self.Layout)
-
-
- def on_always_on_top(self, val):
- self.OnTop = val
-
-
- from gui.input import add_class_context
- add_class_context(_('IM Windows'), 'ImFrame', cls = ImFrame)
-