home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from __future__ import with_statement
- import wx
- import os
- import sys
- from gui.pref.prefcontrols import *
- from gui.pref.iconeditor import IconEditor
- from gui.uberwidgets.formattedinput import FormattedInput
- from common import profile
- from config import platformName
- from gui.pref.prefstrings import general_profile as _
-
- def save_profile(new_profile):
- profile.set_profile_blob(new_profile)
-
-
- def get_promote():
- return profile.prefs['profile.promote']
-
-
- def get_shortcut(pth):
- import comtypes.client as client
- shell = client.CreateObject('WScript.Shell')
- scut = client.dynamic.Dispatch(shell.CreateShortcut(pth))
- return scut
-
-
- def on_startup_change(new):
- if platformName == 'mac':
- import loginitems
- import sys
- appdir = os.path.abspath(os.path.join(sys.argv[0], '..', '..', '..'))
- if new and not loginitems.hasitem(appdir):
- loginitems.additem(appdir)
- elif not new and loginitems.hasitem(appdir):
- loginitems.removeitem('Digsby')
-
- return None
-
- path = path
- import path
- shortcuts = startup_shortcuts()
- if new and not shortcuts:
- import sys
- import locale
- GetStartupDir = GetStartupDir
- import gui.toolbox
- exe = sys.executable.decode('locale')
- pth = path(GetStartupDir()) / 'digsby.lnk'
- scut = get_shortcut(pth)
- scut.TargetPath = exe.encode('filesys')
- scut.WorkingDirectory = unicode(path(exe).parent).encode('filesys')
- scut.Save()
- elif shortcuts and not new:
- for scut in shortcuts:
-
- try:
- scut.remove()
- continue
- except Exception:
- e = None
- log.info('Error removing shortcut %r: %r', scut, e)
- continue
- continue
-
-
-
-
-
-
- def startup_shortcuts():
- if 'wxMSW' in wx.PlatformInfo:
- GetStartupDir = GetStartupDir
- import gui.toolbox
- startup = unicode(GetStartupDir())
- shortcuts = digsby_shortcuts(startup)
- return shortcuts
- else:
- return False
-
-
- def digsby_shortcuts(dir):
- path = path
- import path
- import sys
- import locale
- res = []
- if 'wxMSW' not in wx.PlatformInfo:
- return res
-
- dir = path(dir)
- exe = path(sys.executable.decode('locale')).basename().encode('filesys')
- if not dir.exists():
- print 'warning, no startup dir', dir
- return []
-
- for lnk in dir.walk('*.lnk'):
- scut = get_shortcut(lnk)
- if exe == path(scut.TargetPath).basename():
- res.append(lnk)
- continue
-
- return res
-
- from gui.uberwidgets.PrefPanel import PrefPanel, PrefCollection
-
- def panel(panel, sizer, addgroup, exithooks):
- startup = wx.CheckBox(panel, label = _('&Launch Digsby when this computer starts'))
-
- try:
- startupval = bool(startup_shortcuts())
- except Exception:
- startupval = False
- startup.Disable()
-
- startup.Value = startupval
- startup.Bind((wx.EVT_CHECKBOX,), (lambda e: on_startup_change(startup.Value)))
- grp1 = PrefPanel(panel, PrefCollection(startup, Check('login.reconnect.attempt', _('&If connection to IM service is lost, automatically attempt to reconnect')), layout = VSizer(), itemoptions = (0, wx.BOTTOM | wx.TOP, 3)), _('General Options'))
- (p, input, chk) = build_profile_panel(panel)
-
- panel.get_profile = lambda : input.Value
-
- panel.get_promote = lambda : chk.Value
- (exithooks,) += (lambda : save_profile(panel.get_profile()))
- profile_grp = PrefPanel(panel, p, _('Profile (AIM Only)'))
- ico = build_buddy_icon_panel(panel, 'bicon')
- buddy_icon_grp = PrefPanel(panel, ico, _('Buddy Icon'))
- innersz = wx.BoxSizer(wx.HORIZONTAL)
- innersz.Add(profile_grp, 1, wx.EXPAND)
- innersz.Add(buddy_icon_grp, 0, wx.LEFT, 6)
- lang_choices = [
- ('en', 'English')]
- langchoice = Choice('locale', lang_choices)(panel)
- lang_grp = PrefPanel(panel, langchoice, _('Language'))
- sizer.AddMany([
- (grp1, 0, wx.EXPAND | wx.ALL, 3),
- (innersz, 0, wx.EXPAND | wx.ALL, 3),
- (lang_grp, 0, wx.EXPAND | wx.ALL, 3)])
- sizer.AddStretchSpacer()
- wx.CallAfter(input.SetValue, profile.profile)
- panel.Layout()
- return panel
-
-
- class BitmapPanel(wx.Panel):
-
- def __init__(self, *a, **k):
- wx.Panel.__init__(self, *a, **k)
- self.Bind(wx.EVT_PAINT, self.OnPaint)
- self._icon = None
-
- icon = property((lambda self: self._icon), (lambda self, i: (setattr(self, '_icon', i), self.Refresh())))
-
- def OnPaint(self, e):
- e.Skip()
- icon = self.icon
- dc = wx.PaintDC(self)
- if icon is not None:
- (w, h) = self.Size
- icopos = (w / 2 - icon.Width / 2, h / 2 - icon.Height / 2)
- dc.DrawBitmap(icon, *icopos)
- dc.Brush = wx.TRANSPARENT_BRUSH
- dc.Pen = wx.Pen(wx.Color(213, 213, 213))
- dc.DrawRectangleRect(wx.RectPS(icopos, (icon.Width, icon.Height)))
-
-
-
-
- def build_buddy_icon_panel(parent, prefix):
- p = wx.Panel(parent)
- icon_panel = BitmapPanel(p, size = (128, 128))
- picon = profile.get_icon_bitmap()
- if picon is not None:
- icon_panel.icon = picon.ResizedSmaller(128)
- else:
- icon_panel.icon = None
- button = wx.Button(p, -1, _('Change'))
- if platformName == 'mac':
- button.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
- icon_button_flags = (0, wx.ALIGN_CENTER_HORIZONTAL | wx.TOP | wx.BOTTOM, 4)
- else:
- icon_button_flags = (0, wx.EXPAND | wx.TOP, 5)
-
- def changeicon(e):
- if IconEditor.RaiseExisting():
- return None
-
- if not profile.get_icon_bytes():
- pass
- ie = IconEditor(p, '')
-
- def onOK():
- if ie.ImageChanged:
- log.info('iconeditor.ImageChanged = True')
- import hub
- h = hub.get_instance()
- bytes = ie.Bytes
- h.set_buddy_icon_file(bytes)
- icon_panel.icon = profile.get_icon_bitmap()
-
-
- ie.Prompt(onOK)
-
- button.Bind(wx.EVT_BUTTON, changeicon)
- sz.Add(icon_panel)
- sz.Add(button, *icon_button_flags)
- return p
-
-
- def build_profile_panel(parent):
- p = wx.Panel(parent)
- input = FormattedInput(p, outlined = True, autosize = False, aimprofile = True)
- chk = Check('profile.promote', _('&Promote digsby!'))(p)
- chk.Value = get_promote()
- if platformName == 'mac':
- checkbox = chk
- chk = wx.BoxSizer(wx.HORIZONTAL)
- chk.Add(checkbox)
- chk.AddStretchSpacer(1)
- chk.Add(input.CreateFontButton(p))
- chk.AddSpacer(4)
- chk_sizer_flags = (0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
- else:
- chk_sizer_flags = (0, wx.TOP, 3)
- s = p.Sizer = VSizer()
- s.Add(input, 1, wx.EXPAND)
- s.Add(chk, *chk_sizer_flags)
- return (p, input, chk)
-
-
- def build_name_panel(parent):
- s = wx.BoxSizer(wx.VERTICAL)
- txt = Text(parent, 'profile.name')
- s.Add(txt)
- return s
-
-