Exemple #1
0
    def append(self, text, cedict, cepath, scroll=True):
        """append formatted text to the widget"""
        if self.config.b_show_emoticons:
            text = MarkupParser.replace_emotes(text, cedict, cepath)

        # Parse links
        text = MarkupParser.urlify(text)

        TextBox.append(self, text, scroll)
Exemple #2
0
    def _prepare_markup(self, markup, is_plus=True):
        if is_plus:
            text = Plus.msnplus_parse(markup)
        else:
            text = Plus.msnplus_strip(markup)

        text = MarkupParser.replace_markup(text)
        text_list = MarkupParser.replace_emoticons(text)
        return text_list
Exemple #3
0
    def append(self, text, cedict, scroll=True):
        '''append formatted text to the widget'''
        if self.config.b_show_emoticons:
            text = MarkupParser.replace_emotes(text, cedict)

        #Parse links
        text = MarkupParser.urlify(text)

        TextBox.append(self, text, scroll)
Exemple #4
0
    def _prepare_markup(self, markup, is_plus=True):
        if is_plus:
            text = Plus.msnplus_parse(markup)
        else:
            text = Plus.msnplus_strip(markup)

        text = MarkupParser.replace_markup(text)
        text_list = MarkupParser.replace_emoticons(text)
        return text_list
Exemple #5
0
    def send_message(self, formatter, contact, message, cedict, cepath, is_first):
        '''add a message to the widget'''
        is_raw, consecutive, outgoing, first, last = \
            formatter.format(contact, message.type)

        if is_raw:
            middle = MarkupParser.escape(message.body)
        else:
            middle = MarkupParser.escape(message.body)
            middle = e3.common.add_style_to_message(middle, message.style, False)

        all_ = first + middle + last
        self.append(all_, cedict, cepath, self.config.b_allow_auto_scroll)
Exemple #6
0
    def send_message(self, formatter, contact, text, cedict, style, is_first):
        """add a message to the widget"""
        nick = contact.display_name

        is_raw, consecutive, outgoing, first, last = formatter.format(contact)

        if is_raw:
            middle = MarkupParser.escape(text)
        else:
            middle = MarkupParser.escape(text)
            middle = e3.common.add_style_to_message(middle, style, False)

        all_ = first + middle + last
        self.append(all_, cedict, self.config.b_allow_auto_scroll)
Exemple #7
0
    def send_message(self, formatter, contact, text, cedict, style, is_first):
        '''add a message to the widget'''
        nick = contact.display_name

        is_raw, consecutive, outgoing, first, last = \
            formatter.format(contact)

        if is_raw:
            middle = MarkupParser.escape(text)
        else:
            middle = MarkupParser.escape(text)
            middle = e3.common.add_style_to_message(middle, style, False)

        all_ = first + middle + last
        self.append(all_, cedict, self.config.b_allow_auto_scroll)
Exemple #8
0
    def send_message(self, formatter, contact, text, cedict, cepath, style, is_first, type_=None):
        """add a message to the widget"""
        is_raw, consecutive, outgoing, first, last = formatter.format(contact, type_)

        if type_ == e3.Message.TYPE_NUDGE:
            middle = ""
        else:
            if is_raw:
                middle = MarkupParser.escape(text)
            else:
                middle = MarkupParser.escape(text)
                middle = e3.common.add_style_to_message(middle, style, False)

        all_ = first + middle + last
        self.append(all_, cedict, self.config.b_allow_auto_scroll)
Exemple #9
0
    def send_message(self, formatter, contact, message, cedict, cepath, is_first):
        '''add a message to the widget'''
        is_raw, consecutive, outgoing, first, last = \
            formatter.format(contact, message.type)

        if message.type == e3.Message.TYPE_NUDGE:
            middle = ''
        else:
            if is_raw:
                middle = MarkupParser.escape(message.body)
            else:
                middle = MarkupParser.escape(message.body)
                middle = e3.common.add_style_to_message(middle, message.style, False)

        all_ = first + middle + last
        self.append(all_, cedict, self.config.b_allow_auto_scroll)
Exemple #10
0
 def append_text(self, text):
     """
     adds text at the end of the actual text
     """
     self.text = self.text + "\n" + text
     self.messageLabel.set_text(self.markup2 % (self.FColor, MarkupParser.escape(self.text)))
     self.messageLabel.set_use_markup(True)
     self.messageLabel.show()
    def _build_display_role(self, index, is_group=False):
        '''Build a string to be used as item's display role'''
        model = index.model()
        data_role = model.data(index, Role.DataRole).toPyObject()

        if is_group:
            display_role = self.contact_list.format_group(data_role)
        else:
            display_role = self.contact_list.format_nick(data_role)

        text = self.plus_text_parse(display_role) if not is_group else display_role
        text = MarkupParser.replace_markup(text)
        if not is_group:
            text_list = MarkupParser.replace_emoticons(text)
            return text_list

        return [text]
Exemple #12
0
def parse_emotes(text, include_table_tags=True):
    '''Parses emotes in text string, returning a html string laid out
    using a table, to vertically align emotes correctly'''
    text = MarkupParser.replace_emotes(text)
    parser = MyHTMLParser(include_table_tags)
    parser.feed(text)
    text2 = parser.get_data()
    return text2
Exemple #13
0
def parse_emotes(text, include_table_tags=True):
    '''Parses emotes in text string, returning a html string laid out
    using a table, to vertically align emotes correctly'''
    text = MarkupParser.replace_emotes(text)
    parser = MyHTMLParser(include_table_tags)
    parser.feed(text)
    text2 = parser.get_data()
    return text2
Exemple #14
0
 def append_text(self, text):
     '''
     adds text at the end of the actual text
     '''
     self.text = self.text + "\n" + text
     self.messageLabel.set_text(self.markup2 % (self.FColor,
                                MarkupParser.escape(self.text)))
     self.messageLabel.set_use_markup(True)
     self.messageLabel.show()
Exemple #15
0
    def receive_message(self, formatter, contact, message, cedict, cepath, is_first):
        '''add a message to the widget'''
        is_raw, consecutive, outgoing, first, last = formatter.format(contact)

        middle = MarkupParser.escape(message.body)
        if not is_raw:
            middle = e3.common.add_style_to_message(message.body, message.style)

        self.append(first + middle + last, cedict, self.config.b_allow_auto_scroll)
    def _build_display_role(self, index, is_group=False):
        '''Build a string to be used as item's display role'''
        model = index.model()
        data_role = model.data(index, Role.DataRole).toPyObject()

        if is_group:
            display_role = self.contact_list.format_group(data_role)
        else:
            display_role = self.contact_list.format_nick(data_role)

        text = self.plus_text_parse(
            display_role) if not is_group else display_role
        text = MarkupParser.replace_markup(text)
        if not is_group:
            text_list = MarkupParser.replace_emoticons(text)
            return text_list

        return [text]
Exemple #17
0
    def receive_message(self, formatter, contact, message, cedict, is_first):
        '''add a message to the widget'''
        is_raw, consecutive, outgoing, first, last = formatter.format(contact)

        middle = MarkupParser.escape(message.body)
        if not is_raw:
            middle = e3.common.add_style_to_message(message.body, message.style)

        self.append(first + middle + last, cedict, self.config.b_allow_auto_scroll)
Exemple #18
0
    def _set_extension_info(self, ext):
        """fill the information about the ext"""
        name = self.get_attr_or_default(ext, 'NAME', '?')
        description = self.get_attr_or_default(ext, 'DESCRIPTION', '?')
        author = self.get_attr_or_default(ext, 'AUTHOR', '?')
        website = self.get_attr_or_default(ext, 'WEBSITE', '?')

        self.name_info.set_text(name)
        self.description_info.set_text(description)
        self.author_info.set_text(author)
        self.website_info.set_markup(MarkupParser.urlify(website))
Exemple #19
0
    def _set_extension_info(self, ext):
        """fill the information about the ext"""
        name = self.get_attr_or_default(ext, 'NAME', '?')
        description = self.get_attr_or_default(ext, 'DESCRIPTION', '?')
        author = self.get_attr_or_default(ext, 'AUTHOR', '?')
        website = self.get_attr_or_default(ext, 'WEBSITE', '?')

        self.name_info.set_text(name)
        self.description_info.set_text(description)
        self.author_info.set_text(author)
        self.website_info.set_markup(MarkupParser.urlify(website))
Exemple #20
0
    def append(self, text, cedict=None, scroll=True):
        '''append formatted text to the widget'''
        if not self.loaded:
            self._texts.append(text)
            return

        if not self.config or self.config.b_show_emoticons:
            text = MarkupParser.parse_emotes(text, cedict)

        text = text.replace('\r\n', '<br/>').replace('\n', '<br/>')
        text = self.parse_url(text)
        text = text.replace('"', '\\"')
        self._textbox.execute_script('add_message("%s");' % (text,))

        if scroll:
            self.scroll_to_end()
    def __init__(self, title, text, picture_path, callback, tooltip):

        gtk.Window.__init__(self, type=gtk.WINDOW_POPUP)

        # constants
        self.FColor = "white"
        max_width = 300
        self.callback = callback

        # window attributes
        self.set_border_width(10)

        # labels
        self._title = title #nick
        markup1 = '<span foreground="%s" weight="ultrabold">%s</span>'
        titleLabel = gtk.Label(markup1 % (self.FColor, \
                               MarkupParser.escape(self._title)))
        titleLabel.set_use_markup(True)
        titleLabel.set_justify(gtk.JUSTIFY_CENTER)
        titleLabel.set_ellipsize(pango.ELLIPSIZE_END)

        self.text = text #status, message, etc...
        self.markup2 = '<span foreground="%s">%s</span>'
        self.messageLabel = gtk.Label(self.markup2 % (self.FColor,
                                      MarkupParser.escape(self.text)))
        self.messageLabel.set_use_markup(True)
        self.messageLabel.set_justify(gtk.JUSTIFY_CENTER)
        self.messageLabel.set_ellipsize(pango.ELLIPSIZE_END)

        Avatar = extension.get_default('avatar')

        # image
        avatarImage = Avatar(cell_dimension=48)
        if picture_path:
            picture_path = picture_path[7:]
        avatarImage.set_from_file(picture_path)

        # boxes
        hbox = gtk.HBox() # main box
        self.messageVbox = gtk.VBox() # title + message
        lbox = gtk.HBox() # avatar + title/message
        lbox.set_spacing(10)

        lboxEventBox = gtk.EventBox() # detects mouse events
        lboxEventBox.set_visible_window(False)
        lboxEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        lboxEventBox.connect("button_press_event", self.onClick)
        lboxEventBox.add(lbox)
        self.connect("button_press_event", self.onClick)

        if tooltip is not None:
            lboxEventBox.set_tooltip_text(tooltip)

        # pack everything
        self.messageVbox.pack_start(titleLabel, False, False)
        self.messageVbox.pack_start(self.messageLabel, True, True)
        lbox.pack_start(avatarImage, False, False)
        lbox.pack_start(self.messageVbox, True, True)
        hbox.pack_start(lboxEventBox, True, True)

        self.add(hbox)

        # change background color
        self.set_app_paintable(True)
        self.realize()
        if hasattr(self, 'window'):
            BColor = gtk.gdk.Color(0, 0, 0)
            self.window.set_background(BColor)
        else:
            ABColor = gtk.gdk.RGBA(0,0,0,0)
            state = self.get_state_flags()
            self.override_background_color(state, ABColor)

        # A bit of transparency to be less intrusive
        self.set_opacity(0.85)

        self.timerId = None
        self.set_default_size(max_width,-1)
        self.connect("size-allocate", self.relocate)
        self.show_all()
Exemple #22
0
    def __init__(self, title, text, picture_path, callback, tooltip):

        gtk.Window.__init__(self, type=gtk.WINDOW_POPUP)

        # constants
        self.FColor = "white"
        max_width = 300
        self.callback = callback

        # window attributes
        self.set_border_width(10)

        # labels
        self._title = title #nick
        markup1 = '<span foreground="%s" weight="ultrabold">%s</span>'
        titleLabel = gtk.Label(markup1 % (self.FColor, \
                               MarkupParser.escape(self._title)))
        titleLabel.set_use_markup(True)
        titleLabel.set_justify(gtk.JUSTIFY_CENTER)
        titleLabel.set_ellipsize(pango.ELLIPSIZE_END)

        self.text = text #status, message, etc...
        self.markup2 = '<span foreground="%s">%s</span>'
        self.messageLabel = gtk.Label(self.markup2 % (self.FColor,
                                      MarkupParser.escape(self.text)))
        self.messageLabel.set_use_markup(True)
        self.messageLabel.set_justify(gtk.JUSTIFY_CENTER)
        self.messageLabel.set_ellipsize(pango.ELLIPSIZE_END)

        Avatar = extension.get_default('avatar')

        # image
        avatarImage = Avatar(cell_dimension=48)
        if picture_path:
            picture_path = picture_path[7:]
        avatarImage.set_from_file(picture_path)

        # boxes
        hbox = gtk.HBox() # main box
        self.messageVbox = gtk.VBox() # title + message
        lbox = gtk.HBox() # avatar + title/message
        lbox.set_spacing(10)

        lboxEventBox = gtk.EventBox() # detects mouse events
        lboxEventBox.set_visible_window(False)
        lboxEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        lboxEventBox.connect("button_press_event", self.onClick)
        lboxEventBox.add(lbox)
        self.connect("button_press_event", self.onClick)

        if tooltip is not None:
            lboxEventBox.set_tooltip_text(tooltip)

        # pack everything
        self.messageVbox.pack_start(titleLabel, False, False)
        self.messageVbox.pack_start(self.messageLabel, True, True)
        lbox.pack_start(avatarImage, False, False)
        lbox.pack_start(self.messageVbox, True, True)
        hbox.pack_start(lboxEventBox, True, True)

        self.add(hbox)

        # change background color
        self.set_app_paintable(True)
        self.realize()
        if hasattr(self, 'window'):
            BColor = gtk.gdk.Color(0, 0, 0)
            self.window.set_background(BColor)
        else:
            ABColor = gtk.gdk.RGBA(0,0,0,0)
            state = self.get_state_flags()
            self.override_background_color(state, ABColor)

        # A bit of transparency to be less intrusive
        self.set_opacity(0.85)

        self.timerId = None
        self.set_default_size(max_width,-1)
        self.connect("size-allocate", self.relocate)
        self.show_all()
Exemple #23
0
    def append(self, text, cedict,scroll=True):
        '''append formatted text to the widget'''
        if self.config.b_show_emoticons:
            text = MarkupParser.parse_emotes(text, cedict)

        TextBox.append(self, text, scroll)
Exemple #24
0
    def __init__(self, title, text, picturePath, callback):

        gtk.Window.__init__(self, type=gtk.WINDOW_POPUP)

        # constants
        self.FColor = "white"
        BColor = gtk.gdk.Color()
        avatar_size = 48;
        max_width = 300;
        self.callback = callback

        # window attributes
        self.set_border_width(10)

        # labels
        self._title = title #nick
        markup1 = '<span foreground="%s" weight="ultrabold">%s</span>'
        titleLabel = gtk.Label(markup1 % (self.FColor, \
                               MarkupParser.escape(self._title)))
        titleLabel.set_use_markup(True)
        titleLabel.set_justify(gtk.JUSTIFY_CENTER)
        titleLabel.set_ellipsize(pango.ELLIPSIZE_END)

        self.text = text #status, message, etc...
        self.markup2 = '<span foreground="%s">%s</span>'
        self.messageLabel = gtk.Label(self.markup2 % (self.FColor, \
                                      MarkupParser.escape(self.text)))
        self.messageLabel.set_use_markup(True)
        self.messageLabel.set_justify(gtk.JUSTIFY_CENTER)
        self.messageLabel.set_ellipsize(pango.ELLIPSIZE_END)

        # image
        avatarImage = gtk.Image()
        try:
            userPixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                                  picturePath[7:], avatar_size, avatar_size)
        except:
            userPixbuf = utils.safe_gtk_pixbuf_load(gui.theme.user,
                                                 (avatar_size, avatar_size))
        avatarImage.set_from_pixbuf(userPixbuf)

        # boxes
        hbox = gtk.HBox() # main box
        self.messageVbox = gtk.VBox() # title + message
        lbox = gtk.HBox() # avatar + title/message
        lbox.set_spacing(10)

        lboxEventBox = gtk.EventBox() # detects mouse events
        lboxEventBox.set_visible_window(False)
        lboxEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        lboxEventBox.connect("button_press_event", self.onClick)
        lboxEventBox.add(lbox)
        self.connect("button_press_event", self.onClick)

        # pack everything
        self.messageVbox.pack_start(titleLabel, False, False)
        self.messageVbox.pack_start(self.messageLabel, True, True)
        lbox.pack_start(avatarImage, False, False)
        lbox.pack_start(self.messageVbox, True, True)
        hbox.pack_start(lboxEventBox, True, True)

        self.add(hbox)

        # change background color
        self.set_app_paintable(True)
        self.realize()
        self.window.set_background(BColor)

        # A bit of transparency to be less intrusive
        self.set_opacity(0.85)

        self.timerId = None
        self.set_default_size(max_width,-1)
        self.connect("size-allocate", self.relocate)
        self.show_all()
Exemple #25
0
def msnplus_to_list(text):
    '''parse text and return a list of strings and gtk.gdk.Pixbufs'''
    text = plus_text_parse(text)
    text = MarkupParser.replace_markup(text)
    text_list = MarkupParser.replace_emoticons(text)
    return text_list
Exemple #26
0
    def __init__(self, title, text, picture_path, callback, tooltip):

        gtk.Window.__init__(self, type=gtk.WINDOW_POPUP)

        # constants
        self.FColor = "white"
        BColor = gtk.gdk.Color()
        avatar_size = 48
        max_width = 300
        self.callback = callback

        # window attributes
        self.set_border_width(10)

        # labels
        self._title = title  #nick
        markup1 = '<span foreground="%s" weight="ultrabold">%s</span>'
        titleLabel = gtk.Label(markup1 % (self.FColor, \
                               MarkupParser.escape(self._title)))
        titleLabel.set_use_markup(True)
        titleLabel.set_justify(gtk.JUSTIFY_CENTER)
        titleLabel.set_ellipsize(pango.ELLIPSIZE_END)

        self.text = text  #status, message, etc...
        self.markup2 = '<span foreground="%s">%s</span>'
        self.messageLabel = gtk.Label(
            self.markup2 % (self.FColor, MarkupParser.escape(self.text)))
        self.messageLabel.set_use_markup(True)
        self.messageLabel.set_justify(gtk.JUSTIFY_CENTER)
        self.messageLabel.set_ellipsize(pango.ELLIPSIZE_END)

        # image
        avatarImage = gtk.Image()
        try:
            userPixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                picture_path[7:], avatar_size, avatar_size)
        except:
            userPixbuf = utils.safe_gtk_pixbuf_load(gui.theme.image_theme.user,
                                                    (avatar_size, avatar_size))
        avatarImage.set_from_pixbuf(userPixbuf)

        # boxes
        hbox = gtk.HBox()  # main box
        self.messageVbox = gtk.VBox()  # title + message
        lbox = gtk.HBox()  # avatar + title/message
        lbox.set_spacing(10)

        lboxEventBox = gtk.EventBox()  # detects mouse events
        lboxEventBox.set_visible_window(False)
        lboxEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        lboxEventBox.connect("button_press_event", self.onClick)
        lboxEventBox.add(lbox)
        self.connect("button_press_event", self.onClick)

        if tooltip is not None:
            lboxEventBox.set_tooltip_text(tooltip)

        # pack everything
        self.messageVbox.pack_start(titleLabel, False, False)
        self.messageVbox.pack_start(self.messageLabel, True, True)
        lbox.pack_start(avatarImage, False, False)
        lbox.pack_start(self.messageVbox, True, True)
        hbox.pack_start(lboxEventBox, True, True)

        self.add(hbox)

        # change background color
        self.set_app_paintable(True)
        self.realize()
        self.window.set_background(BColor)

        # A bit of transparency to be less intrusive
        self.set_opacity(0.85)

        self.timerId = None
        self.set_default_size(max_width, -1)
        self.connect("size-allocate", self.relocate)
        self.show_all()