示例#1
0
class CellRendererPlus(CellRendererFunction):
    '''Nick renderer that parse the MSN+ markup, showing colors, gradients and
    effects'''

    NAME = 'Cell Renderer Plus'
    DESCRIPTION = _('Parse MSN+ markup, showing colors, gradients and effects')
    AUTHOR = 'Mariano Guerra'
    WEBSITE = 'www.emesene.org'

    def __init__(self):
        global plus_or_noplus
        plus_or_noplus = 1
        CellRendererFunction.__init__(self, msnplus_to_list)

extension.implements(CellRendererPlus, 'nick renderer')

gobject.type_register(CellRendererPlus)

class CellRendererNoPlus(CellRendererFunction):
    '''Nick renderer that "strip" MSN+ markup, not showing any effect/color,
    but improving the readability'''

    NAME = 'Cell Renderer No Plus'
    DESCRIPTION = _('Strip MSN+ markup, not showing any effect/color, but improving the readability')
    AUTHOR = 'Mariano Guerra'
    WEBSITE = 'www.emesene.org'


    def __init__(self):
        global plus_or_noplus
示例#2
0
文件: emesene.py 项目: Lagg3r/emesene
# fix for gstreamer --help
argv = sys.argv
sys.argv = [argv[0]]

class SingleInstanceOption(object):
    '''option parser'''

    def option_register(self):
        '''register the options to parse by the command line option parser'''
        option = optparse.Option("-s", "--single",
            action="count", dest="single_instance", default=False,
            help="Allow only one instance of emesene")
        return option

extension.implements('option provider')(SingleInstanceOption)
extension.get_category('option provider').activate(SingleInstanceOption)

class VerboseOption(object):
    '''option parser'''

    def option_register(self):
        '''register the options to parse by the command line option parser'''
        option = optparse.Option("-v", "--verbose",
            action="count", dest="debuglevel", default=0,
            help="Enable debug in console (add another -v to show debug)")
        return option

extension.implements('option provider')(VerboseOption)
extension.get_category('option provider').activate(VerboseOption)
示例#3
0
        'a': ('background', '#%s'),
        'c': ('foreground', '#%s'),
        'b': ('weight', 'bold'),
        'u': ('underline', 'single'),
        'i': ('style', 'italic'),
        's': ('strikethrough', 'true'),
        '$': ('foreground', '#%s'),
        '#': ('weight', 'bold'),
        '@': ('underline', 'single'),
        '&': ('style', 'italic'),
        '\'': ('strikethrough', 'true')
    }
    def FONT_COLOR(self, color):
        return 'foreground=%s' % color

extension.implements('toolkit tags', GTKTags)

def safe_gtk_image_load(path, size=None):
    '''try to return a gtk image from path, if fails, return a broken image'''
    if file_readable(path):
        pixbuf = safe_gtk_pixbuf_load(path, size)
        return gtk.image_new_from_pixbuf(pixbuf)
    else:
        return gtk.image_new_from_stock(gtk.STOCK_MISSING_IMAGE,
            gtk.ICON_SIZE_DIALOG)

def gtk_ico_image_load(path, icosize=None):
    '''try to return a gtk image from path, if fails, return a broken image'''
    if file_readable(path):
        pixbuf = gtk_pixbuf_load(path)
        iconset = gtk.IconSet(pixbuf)
示例#4
0
import gobject

import e3
import gui
import utils
import extension
from debugger import dbg

from gui.base import Plus
import RichBuffer

class GtkCellRenderer(gtk.CellRendererText):
    def __init__(self):
        gtk.CellRendererText.__init__(self)

extension.implements(GtkCellRenderer, 'nick renderer')

class CellRendererFunction(gtk.GenericCellRenderer):
    '''
    CellRenderer that behaves like a label, but apply a function to "markup"
    to show a modified nick. Its a base class, and it is intended to be
    inherited by extensions.
    '''
    __gproperties__ = {
            'markup': (gobject.TYPE_STRING,
                "text",
                "text we'll display (even with plus markup!)",
                '', #default value
                gobject.PARAM_READWRITE),
            'ellipsize': (gobject.TYPE_BOOLEAN,
                "",
示例#5
0
        worker = Worker('emesene2', self, proxy, use_http)
        worker.start()

        #msn password must have 16 chars max.
        password=password[:16]
        #------------------------------------
        self.account = e3.Account(account, password, status, host)

        self.add_action(e3.Action.ACTION_LOGIN, (account, password, status,
            host, port))

    def send_message(self, cid, text, style=None, cedict=None, celist=None):
        '''send a common message'''
        if cedict is None:
            cedict = {}

        if celist is None:
            celist = []

        account = self.account.account
        message = Message(Message.TYPE_MESSAGE, text, account, style)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))

    def request_attention(self, cid):
        '''send a nudge message'''
        account = self.account.account
        message = Message(Message.TYPE_NUDGE, None, account)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))

extension.implements(Session, 'session')
示例#6
0
        account = self.account.account
        message = e3.Message(e3.Message.TYPE_MESSAGE, text, account,
            style)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))

    def send_typing_notification(self, cid):
        '''send typing notification to contact'''
        pass

    def request_attention(self, cid):
        '''request the attention of the contact'''
        account = self.account.account
        message = e3.Message(e3.Message.TYPE_NUDGE,
            '%s requests your attention' % (account, ), account)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))

    def session_has_service(self, service):
        '''returns True if some service is supported, False otherwise'''
        if service in [Session.SERVICE_CONTACT_MANAGING,
                        Session.SERVICE_CONTACT_BLOCK,
                        Session.SERVICE_GROUP_MANAGING,
                        Session.SERVICE_CONTACT_INVITE,
                        Session.SERVICE_CALLS,
                        Session.SERVICE_FILETRANSFER]:
            return False

        return True

extension.implements(Session, 'session')
示例#7
0

class SingleInstanceOption(object):
    '''option parser'''
    def option_register(self):
        '''register the options to parse by the command line option parser'''
        option = optparse.Option("-s",
                                 "--single",
                                 action="count",
                                 dest="single_instance",
                                 default=False,
                                 help="Allow only one instance of emesene")
        return option


extension.implements('option provider')(SingleInstanceOption)
extension.get_category('option provider').activate(SingleInstanceOption)


class VerboseOption(object):
    '''option parser'''
    def option_register(self):
        '''register the options to parse by the command line option parser'''
        option = optparse.Option(
            "-v",
            "--verbose",
            action="count",
            dest="debuglevel",
            default=0,
            help="Enable debug in console (add another -v to show debug)")
        return option
示例#8
0
def msnplus_to_plain_text(txt):
    ''' from a nasty string, returns a nice plain text string without
    bells and whistles, just text '''
    return plus_parser.removeMarkup(txt)


class CellRendererPlus(CellRendererFunction):
    '''Nick renderer that parse the MSN+ markup, showing colors, gradients and
    effects'''
    def __init__(self):
        global plus_or_noplus
        plus_or_noplus = 1
        CellRendererFunction.__init__(self, msnplus_to_list)


extension.implements(CellRendererPlus, 'nick renderer')

gobject.type_register(CellRendererPlus)


class CellRendererNoPlus(CellRendererFunction):
    '''Nick renderer that "strip" MSN+ markup, not showing any effect/color,
    but improving the readability'''
    def __init__(self):
        global plus_or_noplus
        plus_or_noplus = 0
        CellRendererFunction.__init__(self, msnplus_to_list)


extension.implements(CellRendererNoPlus, 'nick renderer')
示例#9
0
文件: emesene.py 项目: Roger/emesene
import interfaces
import gui


class MinimizedOption(object):
    """option parser"""

    def option_register(self):
        """register the options to parse by the command line option parser"""
        option = optparse.Option(
            "-m", "--minimized", action="count", dest="minimized", default=False, help="Minimize emesene at start"
        )
        return option


extension.implements("option provider")(MinimizedOption)
extension.get_category("option provider").activate(MinimizedOption)


class SingleInstanceOption(object):
    """option parser"""

    def option_register(self):
        """register the options to parse by the command line option parser"""
        option = optparse.Option(
            "-s",
            "--single",
            action="count",
            dest="single_instance",
            default=False,
            help="Allow only one instance of emesene",
示例#10
0
                decorated_markup = Plus.msnplus_strip(self.markup)

            layout.set_text(decorated_markup)
        else:
            layout.set_text('')

        return layout

    def _style_set(self, widget, previous_style):
        '''callback to the style-set signal of widget'''
        self._cached_markup = {}
        self._cached_layout = {}
        widget.queue_resize()


extension.implements(CellRendererFunction, 'nick renderer')


class GtkCellRenderer(CellRendererFunction):
    '''Nick renderer that parse the MSN+ markup, showing colors, gradients and
    effects'''
    def __init__(self):
        CellRendererFunction.__init__(self, replace_markup)


extension.implements(GtkCellRenderer, 'nick renderer')


def balance_tag(text, tag):
    '''balance a tag'''
    opens = text.count("<" + tag)
示例#11
0
文件: Session.py 项目: Roger/emesene
        worker = Worker("emesene2", self, proxy, use_http)
        worker.start()

        # msn password must have 16 chars max.
        password = password[:16]
        # ------------------------------------
        self.account = e3.Account(account, password, status, host)

        self.add_action(e3.Action.ACTION_LOGIN, (account, password, status, host, port))

    def send_message(self, cid, text, style=None, cedict=None, celist=None):
        """send a common message"""
        if cedict is None:
            cedict = {}

        if celist is None:
            celist = []

        account = self.account.account
        message = Message(Message.TYPE_MESSAGE, text, account, style)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))

    def request_attention(self, cid):
        """send a nudge message"""
        account = self.account.account
        message = Message(Message.TYPE_NUDGE, None, account)
        self.add_action(e3.Action.ACTION_SEND_MESSAGE, (cid, message))


extension.implements(Session, "session")
示例#12
0

class CellRendererPlus(CellRendererFunction):
    """Nick renderer that parse the MSN+ markup, showing colors, gradients and
    effects"""

    NAME = "Cell Renderer Plus"
    DESCRIPTION = _("Parse MSN+ markup, showing colors, gradients and effects")
    AUTHOR = "Mariano Guerra"
    WEBSITE = "www.emesene.org"

    def __init__(self):
        CellRendererFunction.__init__(self, True)


extension.implements(CellRendererPlus, "nick renderer")


class CellRendererNoPlus(CellRendererFunction):
    """Nick renderer that "strip" MSN+ markup, not showing any effect/color,
    but improving the readability"""

    NAME = "Cell Renderer No Plus"
    DESCRIPTION = _("Strip MSN+ markup, not showing any effect/color, but improving the readability")
    AUTHOR = "Mariano Guerra"
    WEBSITE = "www.emesene.org"

    def __init__(self):
        CellRendererFunction.__init__(self, False)

示例#13
0
    def __init__(self):
        pass

    def option_register(self):
        option = optparse.Option(
            "-v",
            "--verbose",
            action="count",
            dest="debuglevel",
            default=0,
            help="Enable debug in console (add another -v to show debug)",
        )
        return option


extension.implements("option provider")(VerboseOption)
extension.get_category("option provider").activate(VerboseOption)


class Controller(object):
    """class that handle the transition between states of the windows"""

    def __init__(self):
        """class constructor"""
        self.window = None
        self.tray_icon = None
        self.conversations = None
        self.config = e3.common.Config()
        self.config_dir = e3.common.ConfigDir("emesene2")
        self.config_path = self.config_dir.join("config")
        self.config.load(self.config_path)