Ejemplo n.º 1
0
    def __on_chat_send(self, entry, event_keyval, event_keymod):
        if (event_keyval == gtk.keysyms.Return):
            buffer = entry.get_buffer()
            start, end = buffer.get_bounds()
            msg = buffer.get_text(start, end)
            entry.clear()
            entry.grab_focus()
            if (msg == ''): return False

            color = self.button_color.get_color()
            hex8 = "%.2x%.2x%.2x" % ((color.red / 0x101),
                                     (color.green / 0x101),
                                     (color.blue / 0x101))
            style = papyon.TextFormat.NO_EFFECT
            if self.button_bold.get_active(): style |= papyon.TextFormat.BOLD
            if self.button_italic.get_active():
                style |= papyon.TextFormat.ITALIC
            if self.button_underline.get_active():
                style |= papyon.TextFormat.UNDERLINE
            if self.button_strikethrough.get_active():
                style |= papyon.TextFormat.STRIKETHROUGH
            font_name = self.button_font.get_font_name()
            font_family = pango.FontDescription(font_name).get_family()
            format = papyon.TextFormat(font=font_family,
                                       color=hex8,
                                       style=style)
            strv = StringView()
            strv.appendText(msg)
            self._amsn_conversation.sendMessage(strv, format)

        elif event_keyval == gtk.keysyms.Escape:
            self._parent.destroy()
Ejemplo n.º 2
0
    def annoy_user(self):
        msg = "Let's free the pandas ! (testing papyon)"
        formatting = papyon.TextFormat("Comic Sans MS",
                         papyon.TextFormat.UNDERLINE | papyon.TextFormat.BOLD,
                         'FF0000')
        self._client.send_text_message(papyon.ConversationMessage(msg, formatting))
#         self._client.send_nudge()
#         self._client.send_typing_notification()
        return True
Ejemplo n.º 3
0
def formatting_papy_to_e3(format=papyon.TextFormat(), size_=None):
    font = format.font
    color = e3.base.Color.from_hex('#' + str(format.color))
    bold = format.style & papyon.TextFormat.BOLD == papyon.TextFormat.BOLD
    italic = format.style & papyon.TextFormat.ITALIC == papyon.TextFormat.ITALIC
    underline = format.style & papyon.TextFormat.UNDERLINE == papyon.TextFormat.UNDERLINE
    strike = format.style & papyon.TextFormat.STRIKETHROUGH == papyon.TextFormat.STRIKETHROUGH
    size = size_
    return e3.base.Style(font, color, bold, italic, underline, strike, size)
Ejemplo n.º 4
0
def formatting_e3_to_papy(format=e3.base.Style()):
    font = format.font
    style = 0
    if format.bold: style |= papyon.TextFormat.BOLD
    if format.italic: style |= papyon.TextFormat.ITALIC
    if format.underline: style |= papyon.TextFormat.UNDERLINE
    if format.strike: style |= papyon.TextFormat.STRIKETHROUGH
    color = format.color.to_hex()
    charset = papyon.TextFormat.DEFAULT_CHARSET  # wtf
    family = papyon.TextFormat.FF_DONTCARE  # wtf/2
    pitch = papyon.TextFormat.DEFAULT_PITCH  # wtf/3
    right_alignment = False  # wtf/4

    return papyon.TextFormat(font, style, color, charset, family, pitch, \
        right_alignment)
Ejemplo n.º 5
0
    def __sendMessage(self):
        # TODO: Switch to this when implemented
        """ msg = self.ui.inputWidget.toHtml()
        self.ui.inputWidget.clear()
        strv = StringView()
        strv.appendElementsFromHtml(msg) """

        msg = QtCore.QString.fromUtf8(self.ui.inputWidget.toPlainText())
        self.ui.inputWidget.clear()
        color = self.color
        hex8 = "%.2x%.2x%.2x" % ((color.red()), (color.green()), (color.blue()))
        style = papyon.TextFormat.NO_EFFECT
        info = QtGui.QFontInfo(self.font)
        if info.bold(): style |= papyon.TextFormat.BOLD
        if info.italic():  style |= papyon.TextFormat.ITALIC
        if self.font.underline(): style |= papyon.TextFormat.UNDERLINE
        if self.font.strikeOut(): style |= papyon.TextFormat.STRIKETHROUGH
        font_family = str(info.family())
        format = papyon.TextFormat(font=font_family, color=hex8, style=style)
        strv = StringView()
        strv.append_text(str(msg))
        ## as we send our msg to the conversation:
        self._amsn_conversation.send_message(strv, format)