Ejemplo n.º 1
0
def rounded_corners(corner_size=1, rounded_imgs={}):
    if not isinstance(corner_size, int):
        import util
        corner_size = util.try_this(lambda: int(bool(corner_size)), 1)
    else:
        corner_size = max(0, min(corner_size, 3))

    try:
        return rounded_imgs[corner_size]
    except KeyError:
        pass

    imgs = []

    from gui import skin
    rounded_img = Image.open(
        skin.resourcedir() /
        ('corner' + str(corner_size) + '.gif')).convert('L')

    for name, rotation in CORNERS:
        mask = rounded_img.transpose(
            rotation) if rotation is not None else rounded_img
        imgs.append(mask)

    return rounded_imgs.setdefault(corner_size, imgs)
Ejemplo n.º 2
0
def main():
    from tests.testapp import testapp
    from tests.mock.mockbuddy import MockBuddy
    from path import path

    a = testapp('../../..')

    from gui.imwin.messagearea import MessageArea
    from gui.imwin.styles import get_theme
    from common.logger import history_from_files
    from gui import skin

    f = wx.Frame(None, title = 'Conversation Preview')
    msgarea = MessageArea(f)

    buddy = MockBuddy('digsby01')

    theme = get_theme('GoneDark', 'Steel')
    msgarea.init_content(theme, buddy.alias, buddy, show_history = False)

    msgs = history_from_files([skin.resourcedir() / 'Example Conversation.html'])
    msgarea.replay_messages(msgs, buddy)

    f.Show()
    a.MainLoop()
Ejemplo n.º 3
0
def get_themes():
    p = skin.resourcedir() / CONVO_THEME_DIR
    themes = []
    userdirs = get_user_themes_dirs()

    userthemes = []
    for dir in userdirs:
        userdir = dir.abspath()
        try:
            userthemes.extend(pth.abspath() for pth in (userdir.dirs() if userdir.isdir() else []))
        except Exception, e:
            print_exc()
Ejemplo n.º 4
0
def get_themes():
    p = skin.resourcedir() / CONVO_THEME_DIR
    themes = []
    userdirs = get_user_themes_dirs()

    userthemes = []
    for dir in userdirs:
        userdir = dir.abspath()
        try:
            userthemes.extend(
                pth.abspath()
                for pth in (userdir.dirs() if userdir.isdir() else []))
        except Exception, e:
            print_exc()
Ejemplo n.º 5
0
def list_soundsets():
    import stdpaths
    paths = [
             stdpaths.userdata / 'sounds',
             stdpaths.config / 'sounds',
             skin.resourcedir() / 'sounds',
             ]

    soundsets = []
    for pth in paths:
        for dir in pth.dirs():
            if (dir / DESC_FILENAME).isfile():
                soundsets.append((dir.name, dir))

    return soundsets
Ejemplo n.º 6
0
def list_soundsets():
    import stdpaths
    paths = [
        stdpaths.userdata / 'sounds',
        stdpaths.config / 'sounds',
        skin.resourcedir() / 'sounds',
    ]

    soundsets = []
    for pth in paths:
        for dir in pth.dirs():
            if (dir / DESC_FILENAME).isfile():
                soundsets.append((dir.name, dir))

    return soundsets
Ejemplo n.º 7
0
def test_splitimage():
    f = wx.Frame(None, style = wx.DEFAULT_FRAME_STYLE | wx.FULL_REPAINT_ON_RESIZE)

    s = makeImage(skin.resourcedir() / 'digsbybig.png')#si4(S(source = 'c:\\digsbybig.png', center = {'extend': 'up down'},
        #      x1 = 30, x2 = -30, y1 = 30, y2 = -30))

    def paint(e):
        dc=  wx.AutoBufferedPaintDC(f)
        dc.Brush = wx.BLACK_BRUSH
        dc.DrawRectangleRect(f.ClientRect)
        s.Draw(dc, f.ClientRect)

    f.Bind(wx.EVT_PAINT, paint)
    f.Bind(wx.EVT_ERASE_BACKGROUND, lambda e: None)
    return f
Ejemplo n.º 8
0
def build_example_message_area(parent, theme):
    buddy = MockBuddy('Friend')

    msgarea = MessageArea(parent)
    msgarea.SetMinSize((-1, 150))
    msgarea.init_content(theme, buddy.alias, buddy, show_history=False)

    # load an example conversation from the resource directory.
    bytes = (skin.resourcedir() / EXAMPLE_CONVO_FILENAME).bytes()
    bytes = Template(bytes).safe_substitute({'Me': profile.username})
    msgs = parent._examplehistory = list(common.logger.parse_html(bytes))

    log.info('  %d messages', len(msgs))
    msgarea.replay_messages(msgs, buddy, context=False)

    return msgarea
Ejemplo n.º 9
0
def load_tiny_font():
    global _tinyfont
    if _tinyfont == -1:
        # There was an error loading the pixel font before.
        return None
    elif _tinyfont is None:
        try:
            import locale
            from gui import skin
            _tinyfont = ImageFont.truetype((skin.resourcedir() / 'slkscr.ttf').encode(locale.getpreferredencoding()), 9)
        except Exception:
            print_exc()
            _tinyfont = -1
            return None

    return _tinyfont
Ejemplo n.º 10
0
def build_example_message_area(parent, theme):
    buddy = MockBuddy('Friend')

    msgarea = MessageArea(parent)
    msgarea.SetMinSize((-1, 150))
    msgarea.init_content(theme, buddy.alias, buddy, show_history = False)

    # load an example conversation from the resource directory.
    bytes = (skin.resourcedir() / EXAMPLE_CONVO_FILENAME).bytes()
    bytes = Template(bytes).safe_substitute({'Me': profile.username})
    msgs  = parent._examplehistory = list(common.logger.parse_html(bytes))

    log.info('  %d messages', len(msgs))
    msgarea.replay_messages(msgs, buddy, context = False)

    return msgarea
Ejemplo n.º 11
0
def _actions():

    global _actions_cached
    global _actions_imported

    if _actions_imported:
        return _actions_cached

    from gui import skin
    try:
        actions = importer.yaml_import('actions', loadpath = [skin.resourcedir()])
    except ImportError:
        actions = {}
    finally:
        _actions_imported = True

    add_actions(actions)
    return _actions_cached
Ejemplo n.º 12
0
def get_notification_info(_cache = []):
    try:
        nots = _cache[0]
    except IndexError:
        pass

        from gui import skin
        mod = importer.yaml_import('notificationview', loadpath = [skin.resourcedir()])

        nots = _process_notifications_list(mod.__content__)

        _cache.append(nots)

    # allow plugins to add their own notification topics here.
    import hooks
    hooks.notify('digsby.notifications.get_topics', nots)

    return nots
Ejemplo n.º 13
0
def get_notification_info(_cache=[]):
    try:
        nots = _cache[0]
    except IndexError:
        pass

        from gui import skin
        mod = importer.yaml_import('notificationview',
                                   loadpath=[skin.resourcedir()])

        nots = _process_notifications_list(mod.__content__)

        _cache.append(nots)

    # allow plugins to add their own notification topics here.
    import hooks
    hooks.notify('digsby.notifications.get_topics', nots)

    return nots
Ejemplo n.º 14
0
def test_splitimage():
    f = wx.Frame(None,
                 style=wx.DEFAULT_FRAME_STYLE | wx.FULL_REPAINT_ON_RESIZE)

    s = makeImage(
        skin.resourcedir() / 'digsbybig.png'
    )  #si4(S(source = 'c:\\digsbybig.png', center = {'extend': 'up down'},

    #      x1 = 30, x2 = -30, y1 = 30, y2 = -30))

    def paint(e):
        dc = wx.AutoBufferedPaintDC(f)
        dc.Brush = wx.BLACK_BRUSH
        dc.DrawRectangleRect(f.ClientRect)
        s.Draw(dc, f.ClientRect)

    f.Bind(wx.EVT_PAINT, paint)
    f.Bind(wx.EVT_ERASE_BACKGROUND, lambda e: None)
    return f
Ejemplo n.º 15
0
def _actions():

    global _actions_cached
    global _actions_imported

    if _actions_imported:
        return _actions_cached

    from gui import skin
    try:
        actions = importer.yaml_import('actions',
                                       loadpath=[skin.resourcedir()])
    except ImportError:
        actions = {}
    finally:
        _actions_imported = True

    add_actions(actions)
    return _actions_cached
Ejemplo n.º 16
0
    def initialContents(self,
                        chatName,
                        buddy,
                        header=False,
                        prevent_align_to_bottom=False):
        '''
        Return the initial HTML contents of this message style. Usually
        res/MessageStyles/Template.html, but can be overridden by an individual
        style by a file with the same name in its resource directory.
        '''

        self.options = dict(chatName=chatName)
        template = self.resources / 'Template.html'

        if template.isfile():
            s = template.text('utf-8')
        else:
            baseTemplate = skin.resourcedir(
            ) / 'MessageStyles' / 'Template.html'
            s = baseTemplate.text('utf-8')

        # the default Adium Template.html file includes several string
        # special substitution character sequences
        s = s.replace('%', '%%').replace('%%@', '%s')

        args = (self.base.replace('\\', '/'),
                self.default_css_styles,
                self.css_file.replace('\\', '/'),
                self.applySubstitutions(self.get_header(prevent_align_to_bottom=prevent_align_to_bottom), buddy = buddy),
                self.applySubstitutions(self.footer, buddy = buddy) + \
                    self.init_header_script(header))

        try:
            s = s % args
        except Exception:
            try:
                s = s % (args[:1] + args[2:])
            except Exception:
                print >> sys.stderr, s
                print_exc()

        return s
Ejemplo n.º 17
0
def rounded_corners(corner_size = 1, rounded_imgs = {}):
    if not isinstance(corner_size, int):
        import util
        corner_size = util.try_this(lambda: int(bool(corner_size)), 1)
    else:
        corner_size = max(0, min(corner_size, 3))

    try: return rounded_imgs[corner_size]
    except KeyError: pass

    imgs = []

    from gui import skin
    rounded_img = Image.open(skin.resourcedir() / ('corner' + str(corner_size) + '.gif')).convert('L')

    for name, rotation in CORNERS:
        mask = rounded_img.transpose(rotation) if rotation is not None else rounded_img
        imgs.append(mask)

    return rounded_imgs.setdefault(corner_size, imgs)
Ejemplo n.º 18
0
    def initialContents(self, chatName, buddy, header = False, prevent_align_to_bottom=False):
        '''
        Return the initial HTML contents of this message style. Usually
        res/MessageStyles/Template.html, but can be overridden by an individual
        style by a file with the same name in its resource directory.
        '''

        self.options = dict(chatName = chatName)
        template     = self.resources     / 'Template.html'

        if template.isfile():
            s = template.text('utf-8')
        else:
            baseTemplate = skin.resourcedir() / 'MessageStyles' / 'Template.html'
            s = baseTemplate.text('utf-8')

        # the default Adium Template.html file includes several string
        # special substitution character sequences
        s = s.replace('%', '%%').replace('%%@', '%s')

        args = (self.base.replace('\\', '/'),
                self.default_css_styles,
                self.css_file.replace('\\', '/'),
                self.applySubstitutions(self.get_header(prevent_align_to_bottom=prevent_align_to_bottom), buddy = buddy),
                self.applySubstitutions(self.footer, buddy = buddy) + \
                    self.init_header_script(header))

        try:
            s = s % args
        except Exception:
            try:
                s = s % (args[:1] + args[2:])
            except Exception:
                print >> sys.stderr, s
                print_exc()

        return s
Ejemplo n.º 19
0
        self.ubar.Add(self.b3)

        content.Add(self.ubar,0,wx.EXPAND,0)
        self.SetSizer(content)

    def onButton(self,event):
        print 'clixxored!!!'
        self.ubar.SetAlignment(wx.ALIGN_LEFT if self.ubar.alignment!=wx.ALIGN_LEFT else wx.ALIGN_CENTER)

if __name__ == '__main__':
    from tests.testapp import testapp
    a = testapp()

    from gui.skin import resourcedir
    global resdir
    resdir = resourcedir()

    hit = wx.FindWindowAtPointer
    def onKey(event):
        if hasattr(wx.GetActiveWindow(),'menubar'):
            menubar=wx.GetActiveWindow().menubar
            if menubar.focus != None:
                a.captured=True
                if menubar.DoNaviCode(event.GetKeyCode()):return
            elif event.GetKeyCode()==wx.WXK_ALT:
                if not menubar.navimode: menubar.ToggleNaviMode(True)
                return
        event.Skip()

    def onKeyUp(event):
        if not a.captured and hasattr(wx.GetActiveWindow(),'menubar') and event.GetKeyCode()==wx.WXK_ALT and wx.GetActiveWindow().menubar.focus == None:
Ejemplo n.º 20
0
 def resdir():
     from gui import skin
     return skin.resourcedir()
Ejemplo n.º 21
0
        content.Add(self.ubar, 0, wx.EXPAND, 0)
        self.SetSizer(content)

    def onButton(self, event):
        print 'clixxored!!!'
        self.ubar.SetAlignment(wx.ALIGN_LEFT if self.ubar.alignment != wx.
                               ALIGN_LEFT else wx.ALIGN_CENTER)


if __name__ == '__main__':
    from tests.testapp import testapp
    a = testapp()

    from gui.skin import resourcedir
    global resdir
    resdir = resourcedir()

    hit = wx.FindWindowAtPointer

    def onKey(event):
        if hasattr(wx.GetActiveWindow(), 'menubar'):
            menubar = wx.GetActiveWindow().menubar
            if menubar.focus != None:
                a.captured = True
                if menubar.DoNaviCode(event.GetKeyCode()): return
            elif event.GetKeyCode() == wx.WXK_ALT:
                if not menubar.navimode: menubar.ToggleNaviMode(True)
                return
        event.Skip()

    def onKeyUp(event):
Ejemplo n.º 22
0
def _load_noicon():
    try:
        return skin.get('BuddiesPanel.BuddyIcons.NoIcon').PIL
    except:
        # A fallback.
        return Image.open(skin.resourcedir() / 'AppDefaults' / 'contact.png')
Ejemplo n.º 23
0
 def resdir():
     from gui import skin
     return skin.resourcedir()